HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_Camera.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: OBJ library (C++)
7  *
8  * COMMENTS: Camera object definition (base class for lights too)
9  *
10  */
11 
12 #ifndef __OBJ_Camera_h__
13 #define __OBJ_Camera_h__
14 
15 #include "OBJ_API.h"
16 #include "OBJ_Node.h"
17 
18 #include <UT/UT_String.h>
19 
21 {
23 };
24 
25 // Projections for cameras
27 {
32 };
33 
34 
36 {
37 public:
38  OBJ_CameraParms() { setDefaults(); }
39  void setDefaults();
40  float focal; // Focal length
41  float aperture; // Aperture
42  float aspect; // Aspect ratio
43  float focus; // Focus distance
44  float fstop; // F-Stop;
45  float curvature; // Lens curvature
46  int xres, yres; // Resolution for camera
47  float cropx[2]; // Min max for cropping in x
48  float cropy[2]; // Min max for cropping in y
49  float winx[2]; // Sub-windowing in X
50  float winy[2]; // Sub-windowing in Y
51  float mynear, myfar; // Near/Far clipping planes
52  float shutterTime; // Shutter time for the camera
54  float orthoZoom; // Orthographic zoom
55 };
56 
57 
58 
59 
60 class OBJ_API OBJ_Camera : public OBJ_Node
61 {
62 public:
63  OBJ_Camera(OP_Network *, const char *, OP_Operator *);
64  ~OBJ_Camera() override;
65 
66  /// Get the IPR camera - This may create a camera object
67  static OBJ_Camera *getIPRCamera(bool *created=nullptr);
68 
69  static PRM_Template *getObsolete();
70  static OP_Node *myConstructor(OP_Network *net,
71  const char *name, OP_Operator *entry);
72 
73  void getCameraParms(OBJ_CameraParms &parms,
74  fpreal t);
75 
76  void addInterestOnCameraParms(OP_Node *node);
77  void addInterestOnCameraParms(DEP_MicroNode *depnode);
78 
79  OBJ_OBJECT_TYPE getObjectType() const override;
80 
82  std::ostream &os) override;
83 
84  static PRM_Template *getTemplateList(OBJ_ParmsStyle style);
85 
86 
87  OBJ_Camera *castToOBJCamera() override { return this; }
88  virtual OBJ_Camera *getControllingCamera(fpreal now);
89 
90 protected:
91  // Used to get pointer to indirection indices for each object type
92  int *getIndirect() const override
93  { return camIndirect; }
94 
95  OP_ERROR cookMyObj(OP_Context &ctx) override;
96 
100  PRM_ParmNameMap &nmap) override;
104  const CH_ChannelList &channels
105  ) override;
106 
107 public: // Public so that other people can get this info
108  /// Get the camera's projection matrix. For example, if you have a point
109  /// @c P in world-space, to get it's NDC space: @code
110  /// UT_Matrix4D worldToCamera, projection;
111  /// cam.getInverseObjectToWorldTransform(context, worldToCamera);
112  /// cam.getProjectionMatrix(context, projection);
113  /// UT_Vector3 P_object = P * worldToCamera;
114  /// UT_Vector3 P_ndc = P_object * projection;
115  /// @endcode
116  void getProjectionMatrix(const OP_Context &context,
118 
119  // Take the winroll into account correctly
120  void getWinParms(fpreal &winx, fpreal &winy,
121  fpreal &sizex, fpreal &sizey,
122  fpreal &winroll, fpreal now);
123 
124  // All projection methods are virtual to allow for blending of camera view.
125  virtual int PROJECTION(fpreal t);
126  virtual int REMOVESCALE(fpreal t);
127  virtual fpreal ORTHOW(fpreal t);
128  virtual int RESX(fpreal);
129  virtual int RESY(fpreal);
130  virtual fpreal ASPECT(fpreal t);
131  virtual fpreal FOCAL(fpreal t);
132  virtual fpreal APERTURE(fpreal t);
133  virtual fpreal SHUTTER(fpreal t);
134  virtual fpreal getNEAR(fpreal t);
135  virtual fpreal getFAR(fpreal t);
136  virtual fpreal CURVATURE(fpreal t);
137  virtual fpreal FSTOP(fpreal t);
138  virtual fpreal FOCUS(fpreal t);
139  virtual fpreal CROPL(fpreal t);
140  virtual fpreal CROPR(fpreal t);
141  virtual fpreal CROPB(fpreal t);
142  virtual fpreal CROPT(fpreal t);
143  virtual fpreal WINPX(fpreal t);
144  virtual fpreal WINPY(fpreal t);
145  virtual fpreal WINX(fpreal t);
146  virtual fpreal WINY(fpreal t);
147  virtual fpreal WINSIZEX(fpreal t);
148  virtual fpreal WINSIZEY(fpreal t);
149  virtual fpreal WINROLL(fpreal t);
150 
151  int ROTOSOURCE(fpreal now);
152  void ROTOFILE(UT_String &str, fpreal t);
153  void ROTOFILE_RAW(UT_String &str, fpreal t);
154  int ROTO_OVERRIDE(fpreal now);
155  int ROTO_RESX(fpreal t);
156  int ROTO_RESY(fpreal t);
157  void COPPATH(UT_String &str, fpreal t);
158  int TRACKWINCHANS(fpreal t);
159  fpreal COPFRAME(fpreal t);
160  void COPFRAME_RAW(UT_String &str, fpreal t);
161  void COLOR_PLANE(UT_String &str, fpreal t);
162  int ALPHA_PLANE(fpreal);
163 
164  fpreal CLEAR(fpreal t);
165  int FOG(fpreal t);
166  fpreal FOGDENSITY(fpreal t);
167  fpreal FOGNEAR(fpreal t);
168  fpreal FOGFAR(fpreal t);
169  fpreal FOGCOLOR(fpreal t, int i);
170  fpreal FOGALPHA(fpreal t);
171 
172  void VIEWCOMMENT(UT_String &str, fpreal t);
173  virtual fpreal MASKASPECT(fpreal t);
174  virtual fpreal MASKOPACITY(fpreal t);
175  virtual void MASKOVERLAY(UT_String &str, fpreal t);
176 
177 protected:
178  // This method should be called when evaluating "spare" parameters which
179  // influence the cook. Currently used by winroll.
180  fpreal cookDependentFloat(const char *name, fpreal now,
181  int vi, fpreal defval);
182  int cookDependentInt(const char *name, fpreal now,
183  int vi, int defval);
184 
185 private:
186  static int *camIndirect;
187 };
188 
189 #endif
GT_API const UT_StringHolder selection
OBJ_ParmsStyle
Definition: OBJ_Node.h:208
OBJ_ProjectionType projection
Definition: OBJ_Camera.h:53
int * getIndirect() const override
Definition: OBJ_Camera.h:92
virtual int collectPropertiesFromParms(PI_EditScriptedParms &editparms, UT_StringArray &names, PRM_ParmNameMap &nmap)
OBJ_ProjectionType
Definition: OBJ_Camera.h:26
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual OBJ_OBJECT_TYPE getObjectType() const =0
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble GLdouble t
Definition: glew.h:1403
virtual void saveDialogScriptExtraInfo(std::ostream &os)
OBJ_Camera * castToOBJCamera() override
Definition: OBJ_Camera.h:87
virtual int collectPropertiesFromChannels(PI_EditScriptedParms &editparms, UT_BitArray &selection, const CH_ChannelList &channels)
virtual OP_ERROR cookMyObj(OP_Context &context)
GLuint const GLuint * names
Definition: glew.h:2695
float shutterTime
Definition: OBJ_Camera.h:52
GLuint GLenum matrix
Definition: glew.h:15055
fpreal64 fpreal
Definition: SYS_Types.h:277
static PRM_Template * getObsolete()
#define OBJ_API
Definition: OBJ_API.h:10
OBJ_OBJECT_TYPE
Definition: OBJ_Node.h:74
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
OBJ_CamIndex
Definition: OBJ_Camera.h:20