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  virtual ~OBJ_Blend();
72 
73  static OP_Node *myConstructor(OP_Network *net,
74  const char *name,
75  OP_Operator *entry);
76 
77  static PRM_Template *getObsolete();
78  virtual bool updateParmsFlags();
79  virtual const char *inputLabel(unsigned idx) const;
80 
81  virtual OBJ_OBJECT_TYPE getObjectType() const;
82 
83  static PRM_Template *getTemplateList();
84 
85  virtual OBJ_Blend *castToOBJBlend() { return this; }
86  virtual void resolveObsoleteParms(PRM_ParmList *obsolete_parms);
87 
88  // DO NOT CHANGE THE NUMBERS IN THIS ENUM!
89  enum {
90  BLEND_BLEND = 0,
91  BLEND_SEQUENCE = 1,
92  BLEND_CONSTRAIN = 2
93  };
94 
95  int BLENDTYPE()
96  { INT_OBJ_PARM("blendtype", I_BLENDTYPE, 0, 0); }
97  void setBLENDTYPE( int parent_type )
98  { setInt("blendtype", getIndirect()[I_BLENDTYPE], 0, 0,
99  parent_type); }
100 
101  const char *getSequenceName()
102  { return BLENDTYPE() == BLEND_SEQUENCE?"sequence_seq":"sequence_con"; }
104  { return BLENDTYPE() == BLEND_SEQUENCE?I_SEQUENCE1 : I_SEQUENCE2; }
105 
107  { FLOAT_OBJ_PARM(getSequenceName(), getSequenceIndex(), 0, t); }
108  void setSEQUENCE(fpreal t, fpreal seq)
109  { setFloat(getSequenceName(),
110  getIndirect()[getSequenceIndex()], 0, t, seq); }
111  void keySEQUENCE(fpreal t);
112  void keySEQUENCE(fpreal t, const char *expr,
113  CH_ExprLanguage language);
114 
116  {
117  switch(i)
118  {
119  case 0:
120  FLOAT_OBJ_PARM("blendw1", I_BLENDW1, 0, t);
121  case 1:
122  FLOAT_OBJ_PARM("blendw2", I_BLENDW2, 0, t);
123  case 2:
124  FLOAT_OBJ_PARM("blendw3", I_BLENDW3, 0, t);
125  case 3:
126  FLOAT_OBJ_PARM("blendw4", I_BLENDW4, 0, t);
127  }
128  return 0;
129  }
130 
131  void setIGNORESCALES(int ignore)
132  { setInt("ignorescales", getIndirect()[I_IGNORESCALES],
133  0, 0.0f, ignore); }
134 
135  virtual OP_ERROR cookMyObj(OP_Context &context);
136  virtual OP_ERROR lockInput(unsigned idx, OP_Context &context);
137  virtual void unlockInput(unsigned idx);
138  virtual OP_ERROR lockInputs(OP_Context &context);
139  virtual void unlockInputs();
140 
141 protected:
142  // Used to get pointer to indirection indices for each object type
143  virtual int *getIndirect() const
144  { return blendIndirect; }
145 
146  virtual int isObjectRenderable(fpreal t) const;
147 
148  virtual int applyInputDependentTransform(
149  OP_Context &context, UT_DMatrix4 &mat);
150 
151 private:
152 
153  int simpleInputIndex(OP_Context &context);
154 
155  int getBlendTransform(UT_DMatrix4 &pmat, OP_Context &context);
156  int getSequenceTransform(UT_DMatrix4 &pmat, OP_Context &context);
157  int getConstrainTransform(UT_DMatrix4 &pmat, OP_Context &context);
158 
159  int calcConstrainTransform(UT_DMatrix4 &pmat, OP_Context &context,
160  int force_cook);
161 
162  void orientAxes(UT_DMatrix4 &pmat, const UT_Vector3R *p);
163 
164  bool USERESTANGLES(fpreal t) const
165  { INT_OBJ_PARM("userestangles", I_USERESTANGLES, 0, t); }
166  int SHORTROT()
167  { INT_OBJ_PARM("shortrot", I_SHORTROT, 0, 0); }
168  int SHORTROTBLEND()
169  { INT_OBJ_PARM("shortrotblend", I_SHORTROTBLEND, 0, 0); }
170  int IGNORESCALES()
171  { INT_OBJ_PARM("ignorescales", I_IGNORESCALES, 0, 0); }
172  fpreal RESET(fpreal t)
173  { FLOAT_OBJ_PARM("reset", I_RESET, 0, t); }
174 
175  int BLENDM(int i)
176  {
177  switch(i)
178  {
179  case 0:
180  INT_OBJ_PARM("blendm1", I_BLENDM1, 0, 0);
181  case 1:
182  INT_OBJ_PARM("blendm2", I_BLENDM2, 0, 0);
183  case 2:
184  INT_OBJ_PARM("blendm3", I_BLENDM3, 0, 0);
185  case 3:
186  INT_OBJ_PARM("blendm4", I_BLENDM4, 0, 0);
187  }
188  return 0;
189  }
190 
191  UT_QuaternionR BLENDREST(int i, fpreal t) const
192  {
193  UT_ASSERT_P(i >= 0 && i < 4);
194  const char * const blendrest[4]
195  = { "blendrest1", "blendrest2",
196  "blendrest3", "blendrest4" };
197  const char * const blendrestord[4]
198  = { "blendrestord1", "blendrestord2",
199  "blendrestord3", "blendrestord4" };
200  const int indirects[4]
203 
205  int xyz;
206 
207  int *pi = &getIndirect()[indirects[i]];
208  evalFloats(blendrest[i], pi + 0, rot.data(), t);
209  xyz = evalInt(blendrestord[i], pi + 1, 0, t);
210 
211  rot.degToRad();
212  return UT_QuaternionR(
213  rot,
215  OP_Node::getRotOrder(xyz)));
216  }
217 
218  fpreal NOFFSET(fpreal t)
219  { FLOAT_OBJ_PARM("noffset", I_NOFFSET, 0, t); }
220 
221  int AXES_ORIENT()
222  { INT_OBJ_PARM("axesorient", I_AXESORIENT, 0, 0); }
223 
224  static int *blendIndirect;
225 
226  int mySimpleInputIndex;
227 
228  UT_DMatrix4 myConstrainAdjustment;
229  UT_DMatrix4 myLastConstrainMat;
230  UT_DMatrix4 myLastParent[MAX_BLEND_PARENTS];
231  UT_DMatrix4 myCurrentParent[MAX_BLEND_PARENTS];
232  int myConstrainIndex;
233 
234  fpreal myLastFrame;
235  int myFirstConstrain;
236 
237 };
238 
239 #undef FLOAT_OBJ_PARM
240 #undef STR_OBJ_PARM
241 #undef INT_OBJ_PARM
242 
243 #endif
SYS_FORCE_INLINE constexpr const T * data() const noexcept
void setSEQUENCE(fpreal t, fpreal seq)
Definition: OBJ_Blend.h:108
#define MAX_BLEND_PARENTS
Definition: OBJ_Blend.h:20
fpreal BLENDW(int i, fpreal t)
Definition: OBJ_Blend.h:115
CH_ExprLanguage
UT_QuaternionT< fpreal > UT_QuaternionR
int getSequenceIndex()
Definition: OBJ_Blend.h:103
GA_API const UT_StringHolder rot
virtual int applyInputDependentTransform(OP_Context &context, UT_DMatrix4 &mat)
void setBLENDTYPE(int parent_type)
Definition: OBJ_Blend.h:97
virtual void resolveObsoleteParms(PRM_ParmList *obsolete_parms)
UT_ErrorSeverity
Definition: UT_Error.h:25
png_uint_32 i
Definition: png.h:2877
void degToRad()
conversion between degrees and radians
static PRM_Template * getTemplateList(OBJ_ParmsStyle style)
virtual OBJ_Blend * castToOBJBlend()
Definition: OBJ_Blend.h:85
int BLENDTYPE()
Definition: OBJ_Blend.h:95
virtual void unlockInput(unsigned idx)
virtual OP_ERROR lockInput(unsigned idx, OP_Context &context)
GLfloat f
Definition: glcorearb.h:1925
static PRM_Template * getObsolete()
const char * getSequenceName()
Definition: OBJ_Blend.h:101
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:125
void evalFloats(int pi, fpreal64 *v, fpreal t) const
virtual void unlockInputs(void)
virtual OP_ERROR cookMyObj(OP_Context &context)
virtual int * getIndirect() const
Definition: OBJ_Geometry.h:106
GLuint const GLchar * name
Definition: glcorearb.h:785
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.
virtual int * getIndirect() const
Definition: OBJ_Blend.h:143
#define FLOAT_OBJ_PARM(name, idx, vi, t)
Definition: OBJ_Blend.h:58
double fpreal
Definition: SYS_Types.h:270
Quaternion class.
Definition: UT_Quaternion.h:51
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)
void setInt(int parmi, int vectori, fpreal t, exint value)
void setIGNORESCALES(int ignore)
Definition: OBJ_Blend.h:131
fpreal SEQUENCE(fpreal t)
Definition: OBJ_Blend.h:106
exint evalInt(int pi, int vi, fpreal t) const
#define INT_OBJ_PARM(name, idx, vi, t)
Definition: OBJ_Blend.h:60
virtual OBJ_OBJECT_TYPE getObjectType() const
#define OBJ_API
Definition: OBJ_API.h:10
virtual bool updateParmsFlags() override
virtual OP_ERROR lockInputs(OP_Context &context)
OBJ_OBJECT_TYPE
Definition: OBJ_Node.h:71