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  virtual ~OBJ_Camera();
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  virtual OBJ_OBJECT_TYPE getObjectType() const;
80 
81  virtual void saveDialogScriptExtraInfo(std::ostream &os);
82 
83  static PRM_Template *getTemplateList(OBJ_ParmsStyle style);
84 
85 
86  virtual OBJ_Camera *castToOBJCamera() { return this; }
87  virtual OBJ_Camera *getControllingCamera(fpreal now);
88 
89 protected:
90  // Used to get pointer to indirection indices for each object type
91  virtual int *getIndirect() const
92  { return camIndirect; }
93 
94  virtual OP_ERROR cookMyObj(OP_Context &ctx);
95 
98  PRM_ParmNameMap &nmap);
101  const CH_ChannelList &channels);
102 
103 public: // Public so that other people can get this info
104  /// Get the camera's projection matrix. For example, if you have a point
105  /// @c P in world-space, to get it's NDC space: @code
106  /// UT_Matrix4D worldToCamera, projection;
107  /// cam.getInverseObjectToWorldTransform(context, worldToCamera);
108  /// cam.getProjectionMatrix(context, projection);
109  /// UT_Vector3 P_object = P * worldToCamera;
110  /// UT_Vector3 P_ndc = P_object * projection;
111  /// @endcode
112  void getProjectionMatrix(const OP_Context &context,
114 
115  // Take the winroll into account correctly
116  void getWinParms(fpreal &winx, fpreal &winy,
117  fpreal &sizex, fpreal &sizey,
118  fpreal &winroll, fpreal now);
119 
120  // All projection methods are virtual to allow for blending of camera view.
121  virtual int PROJECTION(fpreal t);
122  virtual int REMOVESCALE(fpreal t);
123  virtual fpreal ORTHOW(fpreal t);
124  virtual int RESX(fpreal);
125  virtual int RESY(fpreal);
126  virtual fpreal ASPECT(fpreal t);
127  virtual fpreal FOCAL(fpreal t);
128  virtual fpreal APERTURE(fpreal t);
129  virtual fpreal SHUTTER(fpreal t);
130  virtual fpreal getNEAR(fpreal t);
131  virtual fpreal getFAR(fpreal t);
132  virtual fpreal CURVATURE(fpreal t);
133  virtual fpreal FSTOP(fpreal t);
134  virtual fpreal FOCUS(fpreal t);
135  virtual fpreal CROPL(fpreal t);
136  virtual fpreal CROPR(fpreal t);
137  virtual fpreal CROPB(fpreal t);
138  virtual fpreal CROPT(fpreal t);
139  virtual fpreal WINPX(fpreal t);
140  virtual fpreal WINPY(fpreal t);
141  virtual fpreal WINX(fpreal t);
142  virtual fpreal WINY(fpreal t);
143  virtual fpreal WINSIZEX(fpreal t);
144  virtual fpreal WINSIZEY(fpreal t);
145  virtual fpreal WINROLL(fpreal t);
146 
147  int ROTOSOURCE(fpreal now);
148  void ROTOFILE(UT_String &str, fpreal t);
149  void ROTOFILE_RAW(UT_String &str, fpreal t);
150  int ROTO_OVERRIDE(fpreal now);
151  int ROTO_RESX(fpreal t);
152  int ROTO_RESY(fpreal t);
153  void COPPATH(UT_String &str, fpreal t);
154  int TRACKWINCHANS(fpreal t);
155  fpreal COPFRAME(fpreal t);
156  void COPFRAME_RAW(UT_String &str, fpreal t);
157  void COLOR_PLANE(UT_String &str, fpreal t);
158  int ALPHA_PLANE(fpreal);
159 
160  fpreal CLEAR(fpreal t);
161  int FOG(fpreal t);
162  fpreal FOGDENSITY(fpreal t);
163  fpreal FOGNEAR(fpreal t);
164  fpreal FOGFAR(fpreal t);
165  fpreal FOGCOLOR(fpreal t, int i);
166  fpreal FOGALPHA(fpreal t);
167 
168  void VIEWCOMMENT(UT_String &str, fpreal t);
169  virtual fpreal MASKASPECT(fpreal t);
170  virtual fpreal MASKOPACITY(fpreal t);
171  virtual void MASKOVERLAY(UT_String &str, fpreal t);
172 
173 protected:
174  // This method should be called when evaluating "spare" parameters which
175  // influence the cook. Currently used by winroll.
176  fpreal cookDependentFloat(const char *name, fpreal now,
177  int vi, fpreal defval);
178  int cookDependentInt(const char *name, fpreal now,
179  int vi, int defval);
180 
181 private:
182  static int *camIndirect;
183 };
184 
185 #endif
GT_API const UT_StringHolder selection
OBJ_ParmsStyle
Definition: OBJ_Node.h:208
GLuint const GLchar * name
Definition: glew.h:1814
OBJ_ProjectionType projection
Definition: OBJ_Camera.h:53
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
virtual void saveDialogScriptExtraInfo(std::ostream &os)
virtual int collectPropertiesFromChannels(PI_EditScriptedParms &editparms, UT_BitArray &selection, const CH_ChannelList &channels)
GLuint const GLuint * names
Definition: glew.h:2690
virtual OP_ERROR cookMyObj(OP_Context &context)
float shutterTime
Definition: OBJ_Camera.h:52
double fpreal
Definition: SYS_Types.h:276
virtual OBJ_Camera * castToOBJCamera()
Definition: OBJ_Camera.h:86
static PRM_Template * getObsolete()
#define OBJ_API
Definition: OBJ_API.h:10
virtual int * getIndirect() const
Definition: OBJ_Camera.h:91
GLdouble GLdouble t
Definition: glew.h:1398
GLuint GLenum matrix
Definition: glew.h:14742
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