All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_usdcamera.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
28 #ifndef _GUSD_OBJ_USDCAMERA_H_
29 #define _GUSD_OBJ_USDCAMERA_H_
30 
31 #include <OBJ/OBJ_Camera.h>
32 #include <OP/OP_ParmCache.h>
33 #include <UT/UT_RWLock.h>
34 
36 
37 #include <pxr/pxr.h>
38 #include "pxr/usd/usdGeom/camera.h"
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
60 class GusdOBJ_usdcamera : public OBJ_Camera
61 {
62 public:
63 
64  enum
65  {
66  VAR_SCREENASPECT,
67  VAR_YRES,
68  VAR_PROJECTION,
69  VAR_FOCAL,
70  VAR_HAPERTURE,
71  VAR_VAPERTURE,
72  VAR_NEAR,
73  VAR_FAR,
74  VAR_FOCUS,
75  VAR_FSTOP,
76  VAR_HAPERTUREOFFSET,
77 
78  // for backwards compatibility with old stereo attributes {
79  VAR_ISSTEREO,
80  VAR_CONVERGENCEDISTANCE,
81  VAR_INTEROCULARDISTANCE,
82  VAR_LEFTEYEBIAS,
83  // }
84 
85  NUM_VARS,
86  };
87 
88  static OP_TemplatePair* GetTemplates();
89  static OP_VariablePair* GetVariables();
90 
91  static OP_Node* creator(OP_Network* net, const char* name,
92  OP_Operator* op);
93 
95  virtual bool runCreateScript() override;
96 
99  virtual bool evalVariableValue(fpreal& val,
100  int idx, int thread) override;
101  virtual bool evalVariableValue(UT_String& val,
102  int idx, int thread) override
103  {
104  return OP_Network::evalVariableValue(
105  val, idx, thread);
106  }
107 
108 protected:
109  GusdOBJ_usdcamera(OP_Network* net, const char* name, OP_Operator* op);
110 
111  virtual ~GusdOBJ_usdcamera() {}
112 
113  virtual int applyInputIndependentTransform(OP_Context& ctx,
114  UT_DMatrix4& mx) override;
115 
116  virtual bool updateParmsFlags() override;
117 
118  virtual void loadStart() override;
119  virtual void loadFinished() override;
120 
121  virtual OP_ERROR cookMyObj(OP_Context& ctx) override;
122 
123 private:
124  OP_ERROR _Cook(OP_Context& ctx);
125 
126  UsdGeomCamera _LoadCamera(fpreal t, int thread);
127 
128  bool _EvalCamVariable(fpreal& val, int idx, int thread);
129 
130 private:
131  UT_ErrorManager _errors;
132  UsdGeomCamera _cam;
133 
134  int _frameIdx;
136  UT_RWLock _lock;
137  bool _isLoading;
138 
143  GusdOP_ParmChangeMicroNode _camParmsMicroNode;
144 
145 public:
146  static void Register(OP_OperatorTable* table);
147 };
148 
149 PXR_NAMESPACE_CLOSE_SCOPE
150 
151 
152 #endif /* _GUSD_OBJ_USDCAMERA_H_ */
virtual bool runCreateScript() override
Overridden to modify defaults of scripted properties.
Micro node for tracking changes to a set of parameters.
virtual bool evalVariableValue(fpreal &val, int idx, int thread) override
Evaluate the float value of a variable.
USD camera object node.
Definition: OBJ_usdcamera.h:60
Transformable camera.
Definition: camera.h:89