HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_Blend.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_Blend.h (Custom Library, C++)
7  *
8  * COMMENTS: An object which combines multiple parents as a single
9  * parent transform
10  */
11 
12 #ifndef __OBJ_Blend__
13 #define __OBJ_Blend__
14 
15 #include "OBJ_API.h"
16 #include "OBJ_Geometry.h"
17 #include <UT/UT_Quaternion.h>
18 #include <UT/UT_XformOrder.h>
19 
20 #define MAX_BLEND_PARENTS 4
21 
23 {
25 
46 
50 
53 
54  I_N_PXFORM_INDICES // should always be last in the list
55 };
56 
57 
58 #define FLOAT_OBJ_PARM(name, idx, vi, t) \
59  return evalFloat(name, &getIndirect()[idx], vi, t);
60 #define INT_OBJ_PARM(name, idx, vi, t) \
61  return evalInt(name, &getIndirect()[idx], vi, t);
62 #define STR_OBJ_PARM(name, idx, vi, t) \
63  evalString(str, name, &getIndirect()[idx], vi, t);
64 
66 {
67 public:
68  OBJ_Blend(OP_Network *net,
69  const char *name,
70  OP_Operator *op);
71  ~OBJ_Blend() override;
72 
73  static OP_Node *myConstructor(OP_Network *net,
74  const char *name,
75  OP_Operator *entry);
76 
77  static PRM_Template *getObsolete();
78  bool updateParmsFlags() override;
79  const char *inputLabel(unsigned idx) const override;
80 
81  OBJ_OBJECT_TYPE getObjectType() const override;
82 
83  static PRM_Template *getTemplateList();
84 
85  OBJ_Blend *castToOBJBlend() override { return this; }
87  PRM_ParmList *obsolete_parms) override;
88 
89  // DO NOT CHANGE THE NUMBERS IN THIS ENUM!
90  enum {
91  BLEND_BLEND = 0,
92  BLEND_SEQUENCE = 1,
93  BLEND_CONSTRAIN = 2
94  };
95 
96  int BLENDTYPE()
97  { INT_OBJ_PARM("blendtype", I_BLENDTYPE, 0, 0); }
98  void setBLENDTYPE( int parent_type )
99  { setInt("blendtype", getIndirect()[I_BLENDTYPE], 0, 0,
100  parent_type); }
101 
102  const char *getSequenceName()
103  { return BLENDTYPE() == BLEND_SEQUENCE?"sequence_seq":"sequence_con"; }
105  { return BLENDTYPE() == BLEND_SEQUENCE?I_SEQUENCE1 : I_SEQUENCE2; }
106 
108  { FLOAT_OBJ_PARM(getSequenceName(), getSequenceIndex(), 0, t); }
110  { setFloat(getSequenceName(),
111  getIndirect()[getSequenceIndex()], 0, t, seq); }
112  void keySEQUENCE(fpreal t);
113  void keySEQUENCE(fpreal t, const char *expr,
114  CH_ExprLanguage language);
115 
117  {
118  switch(i)
119  {
120  case 0:
121  FLOAT_OBJ_PARM("blendw1", I_BLENDW1, 0, t);
122  case 1:
123  FLOAT_OBJ_PARM("blendw2", I_BLENDW2, 0, t);
124  case 2:
125  FLOAT_OBJ_PARM("blendw3", I_BLENDW3, 0, t);
126  case 3:
127  FLOAT_OBJ_PARM("blendw4", I_BLENDW4, 0, t);
128  }
129  return 0;
130  }
131 
132  void setIGNORESCALES(int ignore)
133  { setInt("ignorescales", getIndirect()[I_IGNORESCALES],
134  0, 0.0f, ignore); }
135 
137  OP_ERROR lockInput(unsigned idx, OP_Context &context) override;
138  void unlockInput(unsigned idx) override;
140  void unlockInputs() override;
141 
142 protected:
143  // Used to get pointer to indirection indices for each object type
144  int *getIndirect() const override
145  { return blendIndirect; }
146 
147  int isObjectRenderable(fpreal t) const override;
148 
150  OP_Context &context, UT_DMatrix4 &mat) override;
151 
152 private:
153 
154  int simpleInputIndex(OP_Context &context);
155 
156  bool getBlendTransform(UT_DMatrix4 &pmat, OP_Context &context);
157  bool getSequenceTransform(UT_DMatrix4 &pmat, OP_Context &context);
158  bool getConstrainTransform(UT_DMatrix4 &pmat, OP_Context &context);
159 
160  bool calcConstrainTransform(UT_DMatrix4 &pmat, OP_Context &context,
161  int force_cook);
162 
163  void orientAxes(UT_DMatrix4 &pmat, const UT_Vector3R *p);
164 
165  bool USERESTANGLES(fpreal t) const
166  { INT_OBJ_PARM("userestangles", I_USERESTANGLES, 0, t); }
167  int SHORTROT()
168  { INT_OBJ_PARM("shortrot", I_SHORTROT, 0, 0); }
169  int SHORTROTBLEND()
170  { INT_OBJ_PARM("shortrotblend", I_SHORTROTBLEND, 0, 0); }
171  int IGNORESCALES()
172  { INT_OBJ_PARM("ignorescales", I_IGNORESCALES, 0, 0); }
173  fpreal RESET(fpreal t)
174  { FLOAT_OBJ_PARM("reset", I_RESET, 0, t); }
175 
176  int BLENDM(int i)
177  {
178  switch(i)
179  {
180  case 0:
181  INT_OBJ_PARM("blendm1", I_BLENDM1, 0, 0);
182  case 1:
183  INT_OBJ_PARM("blendm2", I_BLENDM2, 0, 0);
184  case 2:
185  INT_OBJ_PARM("blendm3", I_BLENDM3, 0, 0);
186  case 3:
187  INT_OBJ_PARM("blendm4", I_BLENDM4, 0, 0);
188  }
189  return 0;
190  }
191 
192  UT_QuaternionR BLENDREST(int i, fpreal t) const
193  {
194  UT_ASSERT_P(i >= 0 && i < 4);
195  const char * const blendrest[4]
196  = { "blendrest1", "blendrest2",
197  "blendrest3", "blendrest4" };
198  const char * const blendrestord[4]
199  = { "blendrestord1", "blendrestord2",
200  "blendrestord3", "blendrestord4" };
201  const int indirects[4]
204 
206  int xyz;
207 
208  int *pi = &getIndirect()[indirects[i]];
209  evalFloats(blendrest[i], pi + 0, rot.data(), t);
210  xyz = evalInt(blendrestord[i], pi + 1, 0, t);
211 
212  rot.degToRad();
213  return UT_QuaternionR(
214  rot,
216  OP_Node::getRotOrder(xyz)));
217  }
218 
219  fpreal NOFFSET(fpreal t)
220  { FLOAT_OBJ_PARM("noffset", I_NOFFSET, 0, t); }
221 
222  int AXES_ORIENT()
223  { INT_OBJ_PARM("axesorient", I_AXESORIENT, 0, 0); }
224 
225  static int *blendIndirect;
226 
227  int mySimpleInputIndex;
228 
229  UT_DMatrix4 myConstrainAdjustment;
230  UT_DMatrix4 myLastConstrainMat;
231  UT_DMatrix4 myLastParent[MAX_BLEND_PARENTS];
232  UT_DMatrix4 myCurrentParent[MAX_BLEND_PARENTS];
233  int myConstrainIndex;
234 
235  fpreal myLastFrame;
236  int myFirstConstrain;
237 
238 };
239 
240 #undef FLOAT_OBJ_PARM
241 #undef STR_OBJ_PARM
242 #undef INT_OBJ_PARM
243 
244 #endif
SYS_FORCE_INLINE constexpr const T * data() const noexcept
GLuint const GLchar * name
Definition: glew.h:1814
void setSEQUENCE(fpreal t, fpreal seq)
Definition: OBJ_Blend.h:109
#define MAX_BLEND_PARENTS
Definition: OBJ_Blend.h:20
fpreal BLENDW(int i, fpreal t)
Definition: OBJ_Blend.h:116
CH_ExprLanguage
UT_QuaternionT< fpreal > UT_QuaternionR
int getSequenceIndex()
Definition: OBJ_Blend.h:104
OBJ_OBJECT_TYPE getObjectType() const override
int * getIndirect() const override
Definition: OBJ_Geometry.h:112
GA_API const UT_StringHolder rot
virtual int applyInputDependentTransform(OP_Context &context, UT_DMatrix4 &mat)
void setBLENDTYPE(int parent_type)
Definition: OBJ_Blend.h:98
UT_ErrorSeverity
Definition: UT_Error.h:25
int * getIndirect() const override
Definition: OBJ_Blend.h:144
void resolveObsoleteParms(PRM_ParmList *obsolete_parms) override
void degToRad()
conversion between degrees and radians
static PRM_Template * getTemplateList(OBJ_ParmsStyle style)
int BLENDTYPE()
Definition: OBJ_Blend.h:96
virtual void unlockInput(unsigned idx)
virtual OP_ERROR lockInput(unsigned idx, OP_Context &context)
static PRM_Template * getObsolete()
const char * getSequenceName()
Definition: OBJ_Blend.h:102
GLclampf f
Definition: glew.h:3499
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:134
void evalFloats(int pi, fpreal64 *v, fpreal t) const
virtual OP_ERROR cookMyObj(OP_Context &context)
virtual void unlockInputs()
static OP_Node * myConstructor(OP_Network *net, const char *name, OP_Operator *entry)
static UT_XformOrder::xyzOrder getRotOrder(int xyz)
Translate a XYZ parameter menu index into the UT_XformOrder type.
#define FLOAT_OBJ_PARM(name, idx, vi, t)
Definition: OBJ_Blend.h:58
GLfloat GLfloat p
Definition: glew.h:16321
Quaternion class.
Definition: UT_Quaternion.h:51
OBJ_Blend * castToOBJBlend() override
Definition: OBJ_Blend.h:85
OBJ_BlendIndex
Definition: OBJ_Blend.h:22
virtual int isObjectRenderable(fpreal t) const
void setFloat(int parmi, int vectori, fpreal t, fpreal value, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING)
fpreal64 fpreal
Definition: SYS_Types.h:277
void setInt(int parmi, int vectori, fpreal t, exint value)
void setIGNORESCALES(int ignore)
Definition: OBJ_Blend.h:132
fpreal SEQUENCE(fpreal t)
Definition: OBJ_Blend.h:107
bool updateParmsFlags() override
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: Math.h:108
exint evalInt(int pi, int vi, fpreal t) const
#define INT_OBJ_PARM(name, idx, vi, t)
Definition: OBJ_Blend.h:60
#define OBJ_API
Definition: OBJ_API.h:10
GLdouble GLdouble t
Definition: glew.h:1398
virtual OP_ERROR lockInputs(OP_Context &context)
OBJ_OBJECT_TYPE
Definition: OBJ_Node.h:74