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