HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimCamera.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GEO_PrimCamera.h ( GEO Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GEO_PrimCamera__
12 #define __GEO_PrimCamera__
13 
14 #include "GEO_API.h"
15 #include "GEO_Primitive.h"
16 
17 #include <UT/UT_BoundingRect.h>
18 #include <UT/UT_CameraParms.h>
19 #include <GA/GA_Types.h>
20 #include <GA/GA_Detail.h>
21 
23 {
24 protected:
25  /// NOTE: The constructor should only be called from subclass
26  /// constructors.
28 
29  /// NOTE: The destructor should only be called from subclass
30  /// destructors.
31  ~GEO_PrimCamera() override {}
32 
33 public:
34 
35  // necessary overrides
36  bool isDegenerate() const override;
37  bool getBBox(UT_BoundingBox *bbox) const override;
39  const GA_Attribute *P) const override;
41  const GA_Attribute *P) const override;
42  void reverse() override;
43 
44  UT_Vector3D computeNormalD() const override;
45  UT_Vector3 computeNormal() const override;
46 
47  int detachPoints(GA_PointGroup &grp) override;
48  GA_DereferenceStatus dereferencePoint(GA_Offset point,
49  bool dry_run=false) override;
50  GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q,
51  bool dry_run=false) override;
52 
53  const GA_PrimitiveJSON *getJSON() const override;
54 
55  bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &hlist,
56  fpreal u, fpreal v,
57  uint du, uint dv) const override;
58 
59  int evaluatePointV4(UT_Vector4 &pos, float u, float v = 0,unsigned du = 0,
60  unsigned dv = 0) const override;
61 
62  /// The fast point offset accessor
65  { return GEO_Primitive::getPointOffset(0); }
66 
67  /// The fast point index accessor
70  { return GEO_Primitive::getPointIndex(0); }
71 
72  /// The fast vertex offset accessor
75  { return GEO_Primitive::getVertexOffset(0); }
76 
77  /// The fast vertex index accessor
80  { return GEO_Primitive::getVertexIndex(0); }
81 
84  { GEO_Primitive::setPointOffset(0, ptoff); }
85 
88  {
89  setPointOffset(pt);
90  }
91  /// This method assigns a preallocated vertex to the camera, optionally
92  /// creating the topological link between the primitive and new vertex.
93  void assignVertex(GA_Offset new_vtx, bool update_topology);
94 
95 
96  UT_Vector3 baryCenter() const override;
97 
98  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
99  void copyPrimitive(const GEO_Primitive *src) override;
100  void copySubclassData(const GA_Primitive *source) override;
101 
102  void stashed(bool beingstashed,
103  GA_Offset offset = GA_INVALID_OFFSET) override;
104 
105  /// builds a new camera. Reuses offset if valid
106  static GEO_PrimCamera *build(GA_Detail *gdp,
107  GA_Offset exisiting_ptoff = GA_INVALID_OFFSET);
108 
109  // // make sure transforming cameras updates the right attributes
110 
111  void transform(const UT_Matrix4 &xform) override;
112 
113  void getTransform4(UT_Matrix4D &mat) const;
114  void setTransform4(const UT_Matrix4D &mat);
115 
116  void getLocalTransform(UT_Matrix3D &matrix) const override;
117  void setLocalTransform(const UT_Matrix3D &matrix) override;
118 
119 
120  // specific to GEO_PrimCamera
121 
122  const UT_CameraParms &getParms() const { return mySettings; }
123  const UT_Matrix3D &getTransform() const { return myXform; }
124 
126 
127  const UT_OptionsHolder getParmsOptions() const;
128 
129  fpreal getAperture() const { return mySettings.aperture; }
130  fpreal getPixelAspect() const { return mySettings.pixelaspect; }
131  fpreal getFocal() const { return mySettings.focal; }
132  fpreal getFocusDistance() const { return mySettings.focusdistance; }
133  fpreal getImagingDistance() const { return mySettings.imagingdistance; }
134  fpreal getFstop() const { return mySettings.fstop; }
135  fpreal getOrthoZoom() const { return mySettings.orthozoom; }
136  fpreal getGuideScale() const { return mySettings.guidescale; }
137 
138  /// Shutter
139  fpreal getShutterOpen() const { return mySettings.shutteropen; }
140  fpreal getShutterClose() const { return mySettings.shutterclose; }
141  void getShutter(fpreal &sopen, fpreal &sclose) const
142  {
143  sopen = mySettings.shutteropen;
144  sclose = mySettings.shutterclose;
145  }
146 
148  {
149  return UT_Vector2T<fpreal>(mySettings.shutteropen,
150  mySettings.shutterclose );
151  }
152 
153  /// Projection
154  OBJ_ProjectionType getProjection() const { return mySettings.projection; }
155  const char *getProjectionToken() const;
156  bool isOrthographic() const { return mySettings.isOrthographic(); }
157 
158  /// Resolution
160  {
161  return UT_Vector2T<exint>(mySettings.resx, mySettings.resy);
162  }
163 
164  void getResolution(exint &rx, exint &ry) const
165  {
166  rx = mySettings.resx;
167  ry = mySettings.resy;
168  }
169 
171  {
172  return mySettings.resx;
173  }
174 
176  {
177  return mySettings.resy;
178  }
179  /// Crop
181  {
182  return UT_Vector4T<fpreal>(mySettings.cropx[0], mySettings.cropx[1],
183  mySettings.cropy[0], mySettings.cropy[1]);
184  }
185 
187  {
188  return UT_Vector2T<fpreal>(mySettings.cropx[0], mySettings.cropy[0]);
189  }
190 
191  void getCropMin(fpreal &xmin, fpreal &ymin) const
192  {
193  xmin = mySettings.cropx[0];
194  ymin = mySettings.cropy[0];
195  }
196 
198  {
199  return UT_Vector2T<fpreal>(mySettings.cropx[1], mySettings.cropy[1]);
200  }
201 
202  void getCropMax(fpreal &xmax, fpreal &ymax) const
203  {
204  xmax = mySettings.cropx[1];
205  ymax = mySettings.cropy[1];
206  }
207 
209  {
210  cropmin.x() = mySettings.cropx[0];
211  cropmin.y() = mySettings.cropy[0];
212  cropmax.x() = mySettings.cropx[1];
213  cropmax.y() = mySettings.cropy[1];
214  }
215 
216  /// Window
218  {
219  return UT_Vector4T<fpreal>(mySettings.winx[0], mySettings.winx[1],
220  mySettings.winy[0], mySettings.winy[1]);
221  }
222 
224  {
225  return UT_Vector2T<fpreal>(mySettings.winx[0], mySettings.winy[0]);
226  }
227 
228  void getWindowMin(fpreal &xmin, fpreal &ymin) const
229  {
230  xmin = mySettings.winx[0];
231  ymin = mySettings.winy[0];
232  }
233 
235  {
236  return UT_Vector2T<fpreal>(mySettings.winx[1], mySettings.winy[1]);
237  }
238 
239  void getWindowMax(fpreal &xmax, fpreal &ymax) const
240  {
241  xmax = mySettings.winx[1];
242  ymax = mySettings.winy[1];
243  }
244 
246  {
247  winmin.x() = mySettings.winx[0];
248  winmin.y() = mySettings.winy[0];
249  winmax.x() = mySettings.winx[1];
250  winmax.y() = mySettings.winy[1];
251  }
252 
253  /// Clipping Planes
255  {
256  return UT_Vector2T<fpreal>(mySettings.clipnear, mySettings.clipfar);
257  }
258 
260  {
261  n = mySettings.clipnear;
262  f = mySettings.clipfar;
263  }
264 
265  fpreal getNearClippingPlane() const { return mySettings.clipnear; }
266  fpreal getFarClippingPlane() const { return mySettings.clipfar; }
267 
268  /// Metadata
269  const UT_OptionsHolder &getMetadata() const { return mySettings.metadata; }
270 
271  void setParms(const UT_CameraParms &parms);
272  void setParms(const UT_OptionsHolder &parms);
273 
274  void setTransform(const UT_Matrix3D &xform) { myXform = xform; }
275 
276  void setPosition(const UT_Vector3D &pos)
277  { GEO_Primitive::setPos3(0, pos); }
278 
279  void setMetadata(const UT_OptionsHolder &opts) { mySettings.metadata = opts; }
280 
281  void setAperture(const fpreal value) { mySettings.aperture = value; }
282  void setPixelAspect(const fpreal value) { mySettings.pixelaspect = value; }
283  void setFocal(const fpreal value) { mySettings.focal = value; }
284  void setFocusDistance(const fpreal value) { mySettings.focusdistance = value; }
285  void setImagingDistance(const fpreal value) { mySettings.imagingdistance = value; }
286  void setFstop(const fpreal value) { mySettings.fstop = value; }
287  void setOrthoZoom(const fpreal value) { mySettings.orthozoom = value; }
288  void setGuideScale(const fpreal value) { mySettings.guidescale = value; }
289 
291  {
292  mySettings.resx = resolution.x();
293  mySettings.resy = resolution.y();
294  }
295 
296  void setResolution(const exint rx, const exint ry)
297  {
298  mySettings.resx = rx;
299  mySettings.resy = ry;
300  }
301 
302  void setResolutionX(const exint rx)
303  {
304  mySettings.resx = rx;
305  }
306 
307  void setResolutionY(const exint ry)
308  {
309  mySettings.resy = ry;
310  }
311 
312  void setShutter(const UT_Vector2T<fpreal> &stime)
313  {
314  mySettings.shutteropen = stime.x();
315  mySettings.shutterclose = stime.y();
316  }
317 
318  void setShutter(const fpreal sopen, const fpreal sclose)
319  {
320  mySettings.shutteropen = sopen;
321  mySettings.shutterclose = sclose;
322  }
323 
324  void setShutterOpen(const fpreal sopen)
325  {
326  mySettings.shutteropen = sopen;
327  }
328 
329  void setShutterClose(const fpreal sclose)
330  {
331  mySettings.shutterclose = sclose;
332  }
333 
335  {
336  mySettings.clipnear = planes.x();
337  mySettings.clipfar = planes.y();
338  }
339  void setClippingPlanes(const fpreal n, const fpreal f)
340  {
341  mySettings.clipnear = n;
342  mySettings.clipfar = f;
343  }
345  {
346  mySettings.clipnear = n;
347  }
349  {
350  mySettings.clipfar = f;
351  }
352 
353  void setProjection(const OBJ_ProjectionType projection)
354  {
355  mySettings.projection = projection;
356  }
357 
358  void setCropMin(const fpreal xmin, const fpreal ymin)
359  {
360  mySettings.cropx[0] = xmin;
361  mySettings.cropy[0] = ymin;
362  }
363 
364  void setCropMin(const UT_Vector2T<fpreal> &xymin)
365  {
366  mySettings.cropx[0] = xymin.x();
367  mySettings.cropy[0] = xymin.y();
368  }
369 
370  void setCropMax(const fpreal xmax, const fpreal ymax)
371  {
372  mySettings.cropx[1] = xmax;
373  mySettings.cropy[1] = ymax;
374  }
375 
376  void setCropMax(const UT_Vector2T<fpreal> &xymax)
377  {
378  mySettings.cropx[1] = xymax.x();
379  mySettings.cropy[1] = xymax.y();
380  }
381 
382  void setWindowMin(const fpreal xmin, const fpreal ymin)
383  {
384  mySettings.winx[0] = xmin;
385  mySettings.winy[0] = ymin;
386  }
387 
389  {
390  mySettings.winx[0] = xymin.x();
391  mySettings.winy[0] = xymin.y();
392  }
393 
394  void setWindowMax(const fpreal xmax, const fpreal ymax)
395  {
396  mySettings.winx[1] = xmax;
397  mySettings.winy[1] = ymax;
398  }
399 
401  {
402  mySettings.winx[1] = xymax.x();
403  mySettings.winy[1] = xymax.y();
404  }
405 
406 protected:
407  /// Register intrinsic attributes
408  GA_DECLARE_INTRINSICS(override)
409 
410  static GA_PrimitiveFamilyMask buildFamilyMask(){ return GA_FAMILY_NONE; }
411 
412 private:
413 
414  UT_Matrix3D myXform;
415  UT_CameraParms mySettings;
416 
417 };
418 
419 
420 #endif
void setImagingDistance(const fpreal value)
void setShutter(const UT_Vector2T< fpreal > &stime)
~GEO_PrimCamera() override
Definition of a geometry attribute.
Definition: GA_Attribute.h:203
void setShutter(const fpreal sopen, const fpreal sclose)
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
Definition: GA_Primitive.h:258
void setShutterOpen(const fpreal sopen)
void setCropMin(const fpreal xmin, const fpreal ymin)
virtual UT_Vector3 baryCenter() const
virtual void copyPrimitive(const GEO_Primitive *src)=0
void setGuideScale(const fpreal value)
void setFstop(const fpreal value)
void setCropMax(const UT_Vector2T< fpreal > &xymax)
const UT_CameraParms & getParms() const
fpreal getPixelAspect() const
void setWindowMax(const fpreal xmax, const fpreal ymax)
void setResolutionX(const exint rx)
SYS_FORCE_INLINE GA_Index getVertexIndex(GA_Size primvertexnum) const
Definition: GA_Primitive.h:250
virtual UT_Vector3D computeNormalD() const =0
void setCropMin(const UT_Vector2T< fpreal > &xymin)
const GLdouble * v
Definition: glcorearb.h:837
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:512
GLsizei const GLfloat * value
Definition: glcorearb.h:824
const UT_Vector4T< fpreal > getCrop() const
Crop.
bool enlargeBoundingBox(UT_BoundingRect &b, const GA_Attribute *p) const override
SYS_FORCE_INLINE GA_Index getPointIndex() const
The fast point index accessor.
const UT_Vector2T< fpreal > getCropMax() const
void setPosition(const UT_Vector3D &pos)
void getClippingPlanes(fpreal &n, fpreal &f) const
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
Definition: GA_Primitive.h:264
void getWindowMin(fpreal &xmin, fpreal &ymin) const
int64 exint
Definition: SYS_Types.h:125
void getCropMax(fpreal &xmax, fpreal &ymax) const
fpreal getNearClippingPlane() const
void getWindow(UT_Vector2T< fpreal > &winmin, UT_Vector2T< fpreal > &winmax)
const UT_Vector2T< fpreal > getShutter() const
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
void reverse() override=0
Reverse the order of vertices.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
Definition: GA_Primitive.h:80
void setPixelAspect(const fpreal value)
Abstract base class for a range membership query object.
const UT_OptionsHolder & getMetadata() const
Metadata.
UT_Vector3D getPosition() const
void setFocal(const fpreal value)
fpreal getImagingDistance() const
GA_PrimitiveFamilyMask
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:694
virtual bool isDegenerate() const =0
Is the primitive degenerate.
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:426
GA_Size GA_Offset
Definition: GA_Types.h:653
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Definition: GA_Primitive.h:278
GLdouble n
Definition: glcorearb.h:2008
const UT_Vector2T< fpreal > getCropMin() const
GLfloat f
Definition: glcorearb.h:1926
virtual void setLocalTransform(const UT_Matrix3D &matrix)
Set the local transform. The default implementation does nothing.
void getWindowMax(fpreal &xmax, fpreal &ymax) const
GLintptr offset
Definition: glcorearb.h:665
void setOrthoZoom(const fpreal value)
void getCrop(UT_Vector2T< fpreal > &cropmin, UT_Vector2T< fpreal > &cropmax)
void setResolutionY(const exint ry)
void setCropMax(const fpreal xmax, const fpreal ymax)
const UT_Vector2T< fpreal > getWindowMax() const
OBJ_ProjectionType getProjection() const
Projection.
void setClippingPlanes(const UT_Vector2T< fpreal > &planes)
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
virtual const GA_PrimitiveJSON * getJSON() const =0
void setMetadata(const UT_OptionsHolder &opts)
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
SYS_FORCE_INLINE GA_Offset getVertexOffset() const
The fast vertex offset accessor.
Provide a JSON interface to a primitive.
OBJ_ProjectionType
fpreal getFocusDistance() const
#define GEO_API
Definition: GEO_API.h:14
A handle to simplify manipulation of multiple attributes.
fpreal getFarClippingPlane() const
exint getResolutionX() const
SYS_FORCE_INLINE GA_Offset getPointOffset() const
The fast point offset accessor.
HUSD_API const char * resolution()
SYS_FORCE_INLINE void setPointOffset(GA_Offset ptoff)
fpreal getShutterOpen() const
Shutter.
bool isOrthographic() const
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:647
void getResolution(exint &rx, exint &ry) const
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
exint getResolutionY() const
SYS_FORCE_INLINE GA_Index getVertexIndex() const
The fast vertex index accessor.
fpreal getOrthoZoom() const
SYS_FORCE_INLINE GA_Index getPointIndex(GA_Size i) const
Definition: GA_Primitive.h:272
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3 &pos) const
Definition: GA_Primitive.h:290
fpreal getFstop() const
void setAperture(const fpreal value)
void setNearClippingPlane(const fpreal n)
void setClippingPlanes(const fpreal n, const fpreal f)
void setResolution(const UT_Vector2T< exint > &resolution)
fpreal getFocal() const
virtual void transform(const UT_Matrix4 &)
virtual void getLocalTransform(UT_Matrix3D &matrix) const
fpreal getAperture() const
SYS_FORCE_INLINE void setVertexPoint(GA_Offset pt)
void setWindowMin(const fpreal xmin, const fpreal ymin)
GA_API const UT_StringHolder parms
virtual int detachPoints(GA_PointGroup &grp)=0
void getCropMin(fpreal &xmin, fpreal &ymin) const
void setWindowMax(const UT_Vector2T< fpreal > &xymax)
fpreal64 fpreal
Definition: SYS_Types.h:283
virtual bool getBBox(UT_BoundingBox *bbox) const =0
void setFarClippingPlane(const fpreal f)
const UT_Vector4T< fpreal > getWindow() const
Window.
fpreal getGuideScale() const
const UT_Vector2T< fpreal > getWindowMin() const
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
Definition: GA_Primitive.h:244
GU_API void xform(CE_Context &context, bool recompile, int npts, const cl::Buffer &outPos, const cl::Buffer &inPos, const cl::Buffer &surfacexform, const cl::Buffer *grp=nullptr)
const UT_Matrix3D & getTransform() const
virtual bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0) const =0
Container class for all geometry.
Definition: GA_Detail.h:105
void setResolution(const exint rx, const exint ry)
fpreal getShutterClose() const
const UT_Vector2T< exint > getResolution() const
Resolution.
void getShutter(fpreal &sopen, fpreal &sclose) const
void setShutterClose(const fpreal sclose)
void setTransform(const UT_Matrix3D &xform)
unsigned int uint
Definition: SYS_Types.h:45
void setFocusDistance(const fpreal value)
const UT_Vector2T< fpreal > getClippingPlanes() const
Clipping Planes.
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:428
void setWindowMin(const UT_Vector2T< fpreal > &xymin)
void setProjection(const OBJ_ProjectionType projection)
GLenum src
Definition: glcorearb.h:1793