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 #include <UT/UT_String.h>
18 #include <UT/UT_CameraParms.h>
19 
21 {
23 };
24 
25 
26 class OBJ_API OBJ_Camera : public OBJ_Node
27 {
28 public:
29  OBJ_Camera(OP_Network *, const char *, OP_Operator *);
30  ~OBJ_Camera() override;
31 
32  /// Get the IPR camera - This may create a camera object
33  static OBJ_Camera *getIPRCamera(bool *created=nullptr);
34 
35  static PRM_Template *getObsolete();
36  static OP_Node *myConstructor(OP_Network *net,
37  const char *name, OP_Operator *entry);
38 
39  void getCameraParms(UT_CameraParms &parms,
40  fpreal t);
41 
42  void addInterestOnCameraParms(OP_Node *node);
43  void addInterestOnCameraParms(DEP_MicroNode *depnode);
44 
45  OBJ_OBJECT_TYPE getObjectType() const override;
46 
48  std::ostream &os) override;
49 
50  static PRM_Template *getTemplateList(OBJ_ParmsStyle style);
51 
52 
53  OBJ_Camera *castToOBJCamera() override { return this; }
54  virtual OBJ_Camera *getControllingCamera(fpreal now);
55 
56 protected:
57  // Used to get pointer to indirection indices for each object type
58  int *getIndirect() const override
59  { return camIndirect; }
60 
61  OP_ERROR cookMyObj(OP_Context &ctx) override;
62 
65  UT_StringArray &names,
66  PRM_ParmNameMap &nmap) override;
71  ) override;
72 
73 public: // Public so that other people can get this info
74  /// Get the camera's projection matrix. For example, if you have a point
75  /// @c P in world-space, to get it's NDC space: @code
76  /// UT_Matrix4D worldToCamera, projection;
77  /// cam.getInverseObjectToWorldTransform(context, worldToCamera);
78  /// cam.getProjectionMatrix(context, projection);
79  /// UT_Vector3 P_object = P * worldToCamera;
80  /// UT_Vector3 P_ndc = P_object * projection;
81  /// @endcode
82  void getProjectionMatrix(const OP_Context &context,
83  UT_Matrix4D &matrix);
84 
85  // Take the winroll into account correctly
86  void getWinParms(fpreal &winx, fpreal &winy,
87  fpreal &sizex, fpreal &sizey,
88  fpreal &winroll, fpreal now);
89 
90  // All projection methods are virtual to allow for blending of camera view.
91  virtual int PROJECTION(fpreal t);
92  virtual int REMOVESCALE(fpreal t);
93  virtual fpreal ORTHOW(fpreal t);
94  virtual int RESX(fpreal);
95  virtual int RESY(fpreal);
96  virtual fpreal ASPECT(fpreal t);
97  virtual fpreal FOCAL(fpreal t);
98  virtual fpreal APERTURE(fpreal t);
99  virtual fpreal SHUTTER(fpreal t);
100  virtual fpreal getNEAR(fpreal t);
101  virtual fpreal getFAR(fpreal t);
102  virtual fpreal CURVATURE(fpreal t);
103  virtual fpreal FSTOP(fpreal t);
104  virtual fpreal FOCUS(fpreal t);
105  virtual fpreal CROPL(fpreal t);
106  virtual fpreal CROPR(fpreal t);
107  virtual fpreal CROPB(fpreal t);
108  virtual fpreal CROPT(fpreal t);
109  virtual fpreal WINPX(fpreal t);
110  virtual fpreal WINPY(fpreal t);
111  virtual fpreal WINX(fpreal t);
112  virtual fpreal WINY(fpreal t);
113  virtual fpreal WINSIZEX(fpreal t);
114  virtual fpreal WINSIZEY(fpreal t);
115  virtual fpreal WINROLL(fpreal t);
116 
117  int ROTOSOURCE(fpreal now);
118  void ROTOFILE(UT_String &str, fpreal t);
119  void ROTOFILE_RAW(UT_String &str, fpreal t);
120  int ROTO_OVERRIDE(fpreal now);
121  int ROTO_RESX(fpreal t);
122  int ROTO_RESY(fpreal t);
123  void COPPATH(UT_String &str, fpreal t);
124  int TRACKWINCHANS(fpreal t);
125  fpreal COPFRAME(fpreal t);
126  void COPFRAME_RAW(UT_String &str, fpreal t);
127  void COLOR_PLANE(UT_String &str, fpreal t);
128  int ALPHA_PLANE(fpreal);
129 
130  fpreal CLEAR(fpreal t);
131  int FOG(fpreal t);
132  fpreal FOGDENSITY(fpreal t);
133  fpreal FOGNEAR(fpreal t);
134  fpreal FOGFAR(fpreal t);
135  fpreal FOGCOLOR(fpreal t, int i);
136  fpreal FOGALPHA(fpreal t);
137 
138  void VIEWCOMMENT(UT_String &str, fpreal t);
139  virtual fpreal MASKASPECT(fpreal t);
140  virtual fpreal MASKOPACITY(fpreal t);
141  virtual void MASKOVERLAY(UT_String &str, fpreal t);
142 
143 protected:
144  // This method should be called when evaluating "spare" parameters which
145  // influence the cook. Currently used by winroll.
146  fpreal cookDependentFloat(const char *name, fpreal now,
147  int vi, fpreal defval);
148  int cookDependentInt(const char *name, fpreal now,
149  int vi, int defval);
150 
151 private:
152  static int *camIndirect;
153 };
154 
155 #endif
GT_API const UT_StringHolder selection
OBJ_ParmsStyle
Definition: OBJ_Node.h:207
int * getIndirect() const override
Definition: OBJ_Camera.h:58
virtual int collectPropertiesFromParms(PI_EditScriptedParms &editparms, UT_StringArray &names, PRM_ParmNameMap &nmap)
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual OBJ_OBJECT_TYPE getObjectType() const =0
virtual void saveDialogScriptExtraInfo(std::ostream &os)
OBJ_Camera * castToOBJCamera() override
Definition: OBJ_Camera.h:53
virtual int collectPropertiesFromChannels(PI_EditScriptedParms &editparms, UT_BitArray &selection, const CH_ChannelList &channels)
virtual OP_ERROR cookMyObj(OP_Context &context)
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
GA_API const UT_StringHolder parms
fpreal64 fpreal
Definition: SYS_Types.h:283
static PRM_Template * getObsolete()
#define OBJ_API
Definition: OBJ_API.h:10
OBJ_OBJECT_TYPE
Definition: OBJ_Node.h:73
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