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