00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __POP_GenVar_h__
00015 #define __POP_GenVar_h__
00016
00017 #include "POP_API.h"
00018 #include "POP_Node.h"
00019
00020
00021
00022
00023
00024 class POP_API POP_GenVar : public POP_Node
00025 {
00026 public:
00027
00028 static CH_LocalVariable myVariables[];
00029 static OP_VariablePair myVariablePair;
00030
00031 static OP_TemplatePair myTemplatePair;
00032
00033 protected:
00034 POP_GenVar (OP_Network* net, const char* name,
00035 OP_Operator* entry);
00036 virtual ~POP_GenVar (void);
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 void birthFromPoints (int doVar, POP_ContextData* data,
00104 GU_Detail* gdp, GB_PointGroup* group,
00105 UT_Matrix4* xform, UT_Matrix3* xformv,
00106 POP_AttribMap* map,
00107 GB_AttributeElem* inherit,
00108 GB_AttributeElem* split,
00109 POP_IntFunc originIndex, int originUse,
00110 float* born, GEO_PrimParticle* part,
00111 GB_PointGroup* birthGroup,
00112 POP_FloatFunc lifetime,
00113 POP_FloatFunc probability,
00114 POP_BirthAttribFunc birthAttrib,
00115 int doRandom,
00116 POP_JitterFunc jitter = 0,
00117 int maxAttempts=100);
00118
00119 void birthFromPointVelocity (int doVar, POP_ContextData *data,
00120 GU_Detail *gdp, GB_PointGroup *group,
00121 UT_Matrix4 *xform, UT_Matrix3 *xformv,
00122 POP_AttribMap *map,
00123 GB_AttributeElem *inherit,
00124 GB_AttributeElem *split,
00125 POP_IntFunc originIndex, int originUse,
00126 float *born, GEO_PrimParticle *part,
00127 GB_PointGroup *birthGroup,
00128 POP_FloatFunc lifetime,
00129 POP_BirthAttribFunc birthAttrib,
00130 UT_Vector3 birthVelocity,
00131 UT_Vector3 birthAcceleration,
00132 fpreal velocityScale,
00133 fpreal particleSpacing);
00134
00135 void birthFromPrimitives (int doVar, POP_ContextData* data,
00136 GU_Detail* gdp, GB_PrimitiveGroup* group,
00137 UT_Matrix4* xform, UT_Matrix3* xformv,
00138 POP_AttribMap* map,
00139 GB_AttributeElem* inherit,
00140 GB_AttributeElem* split,
00141 POP_IntFunc originIndex, int originUse,
00142 float* born, GEO_PrimParticle* part,
00143 GB_PointGroup* birthGroup,
00144 POP_FloatFunc lifetime,
00145 POP_FloatFunc probability,
00146 POP_BirthAttribFunc birthAttrib,
00147 int whereFrom, int checkTrim,
00148 POP_JitterFunc jitter = 0,
00149 int doRandom = 0, int maxAttempts = 100);
00150
00151 void birthFromMetaPrim (int doVar, POP_ContextData* data,
00152 GU_Detail* gdp, GB_PrimitiveGroup* group,
00153 UT_Matrix4* xform, UT_Matrix3* xformv,
00154 POP_AttribMap* map,
00155 GB_AttributeElem* inherit,
00156 GB_AttributeElem* split,
00157 POP_IntFunc originIndex, int originUse,
00158 float* born, GEO_PrimParticle* part,
00159 GB_PointGroup* birthGroup,
00160 POP_FloatFunc lifetime,
00161 POP_BirthAttribFunc birthAttrib,
00162 float threshold, float densityMin,
00163 int useDensityProb,
00164 POP_JitterFunc jitter = 0,
00165 int maxAttempts = 100);
00166
00167 void birthFromDetail (int doVar, POP_ContextData* data,
00168 GU_Detail* gdp,
00169 UT_Matrix4* xform, UT_Matrix3* xformv,
00170 POP_AttribMap* map,
00171 GB_AttributeElem* inherit,
00172 GB_AttributeElem* split,
00173 POP_IntFunc originIndex, int originUse,
00174 float* born, GEO_PrimParticle* part,
00175 GB_PointGroup* birthGroup,
00176 POP_FloatFunc lifetime,
00177 POP_BirthAttribFunc birthAttrib,
00178 GU_RayIntersect* intersector,
00179 POP_JitterFunc jitter = 0,
00180 int maxAttempts = 100);
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 void birthNonUniformlyFromRandomPrimitives (int doVar,
00201 POP_ContextData* data,
00202 GU_Detail* gdp, GB_PrimitiveGroup* group,
00203 UT_Matrix4* xform, UT_Matrix3* xformv,
00204 POP_AttribMap* map,
00205 GB_AttributeElem* inherit,
00206 GB_AttributeElem* split,
00207 POP_IntFunc originIndex, int originUse,
00208 float* born, GEO_PrimParticle* part,
00209 GB_PointGroup* birthGroup,
00210 POP_FloatFunc lifetime,
00211 POP_FloatFunc probability,
00212 POP_BirthAttribFunc birthAttrib,
00213 int whereFrom, int checkTrim,
00214 POP_JitterFunc jitter,
00215 const UT_String &distribAttrib,
00216 int maxAttempts);
00217
00218
00219
00220
00221
00222 void buildVectorTransform (UT_Matrix3& xformv,
00223 const UT_Matrix4& xform);
00224
00225 virtual float getVariableValue (int index, int thread);
00226
00227 void setupVars (POP_ContextData* data,
00228 GU_Detail* gdp,
00229 const GB_Group* source = 0);
00230
00231
00232
00233
00234
00235 bool hasSourceAttributeVars() const;
00236 void refreshSourceAttributeVars(GU_Detail *gdp);
00237
00238 virtual int isVarDependent (GU_Detail* gdp, POP_FParam param,
00239 float t, int thread);
00240 virtual int isVarDependent (GU_Detail* gdp, POP_IParam param,
00241 float t, int thread);
00242 virtual int isVarDependent (GU_Detail* gdp, POP_SParam param,
00243 float t, int thread);
00244 virtual int isVarDependent (GU_Detail* gdp, EV_EXPRESSION* expr,
00245 int thread);
00246
00247 virtual void allowVar (int val) { myAllowGeneratorVar = val; };
00248 int isAllowVar() const { return myAllowGeneratorVar; }
00249
00250 int isVarTest() const { return myVarTest; }
00251 void setVarDependent(int val) { myVarDependent = val; }
00252
00253 UT_Vector4* mySourcePos;
00254 GB_AttributeData* mySourceAtt;
00255 int mySourceIter;
00256 float mySourceU;
00257 float mySourceV;
00258 const GB_Element* mySourceElem;
00259 UT_Vector3* mySourceNml;
00260
00261 fpreal getLastEmissionTime(const GEO_Detail *gdp) const;
00262 void getLastEmissionAttrName(UT_String &name) const;
00263 void setLastEmissionTime(GEO_Detail *gdp, fpreal time) const;
00264
00265 #if !defined(HDK_RELAXED_GB)
00266 private:
00267 #endif
00268 void birthFromPoints (int doVar, POP_ContextData* data,
00269 GU_Detail* gdp, GB_PointGroup* group,
00270 UT_Matrix4* xform, UT_Matrix3* xformv,
00271 POP_AttribMap* map,
00272 GB_AttributeData* inherit,
00273 GB_AttributeData* split,
00274 POP_IntFunc originIndex, int originUse,
00275 float* born, GEO_PrimParticle* part,
00276 GB_PointGroup* birthGroup,
00277 POP_FloatFunc lifetime,
00278 POP_FloatFunc probability,
00279 POP_BirthAttribFunc birthAttrib,
00280 int doRandom,
00281 POP_JitterFunc jitter = 0,
00282 int maxAttempts=100);
00283
00284 void birthFromPointVelocity (int doVar, POP_ContextData *data,
00285 GU_Detail *gdp, GB_PointGroup *group,
00286 UT_Matrix4 *xform, UT_Matrix3 *xformv,
00287 POP_AttribMap *map,
00288 GB_AttributeData *inherit,
00289 GB_AttributeData *split,
00290 POP_IntFunc originIndex, int originUse,
00291 float *born, GEO_PrimParticle *part,
00292 GB_PointGroup *birthGroup,
00293 POP_FloatFunc lifetime,
00294 POP_BirthAttribFunc birthAttrib,
00295 UT_Vector3 birthVelocity,
00296 UT_Vector3 birthAcceleration,
00297 fpreal velocityScale,
00298 fpreal particleSpacing);
00299
00300 void birthFromPrimitives (int doVar, POP_ContextData* data,
00301 GU_Detail* gdp, GB_PrimitiveGroup* group,
00302 UT_Matrix4* xform, UT_Matrix3* xformv,
00303 POP_AttribMap* map,
00304 GB_AttributeData* inherit,
00305 GB_AttributeData* split,
00306 POP_IntFunc originIndex, int originUse,
00307 float* born, GEO_PrimParticle* part,
00308 GB_PointGroup* birthGroup,
00309 POP_FloatFunc lifetime,
00310 POP_FloatFunc probability,
00311 POP_BirthAttribFunc birthAttrib,
00312 int whereFrom, int checkTrim,
00313 POP_JitterFunc jitter = 0,
00314 int doRandom = 0, int maxAttempts = 100);
00315
00316 void birthFromMetaPrim (int doVar, POP_ContextData* data,
00317 GU_Detail* gdp, GB_PrimitiveGroup* group,
00318 UT_Matrix4* xform, UT_Matrix3* xformv,
00319 POP_AttribMap* map,
00320 GB_AttributeData* inherit,
00321 GB_AttributeData* split,
00322 POP_IntFunc originIndex, int originUse,
00323 float* born, GEO_PrimParticle* part,
00324 GB_PointGroup* birthGroup,
00325 POP_FloatFunc lifetime,
00326 POP_BirthAttribFunc birthAttrib,
00327 float threshold, float densityMin,
00328 int useDensityProb,
00329 POP_JitterFunc jitter = 0,
00330 int maxAttempts = 100);
00331
00332 void birthFromDetail (int doVar, POP_ContextData* data,
00333 GU_Detail* gdp,
00334 UT_Matrix4* xform, UT_Matrix3* xformv,
00335 POP_AttribMap* map,
00336 GB_AttributeData* inherit,
00337 GB_AttributeData* split,
00338 POP_IntFunc originIndex, int originUse,
00339 float* born, GEO_PrimParticle* part,
00340 GB_PointGroup* birthGroup,
00341 POP_FloatFunc lifetime,
00342 POP_BirthAttribFunc birthAttrib,
00343 GU_RayIntersect* intersector,
00344 POP_JitterFunc jitter = 0,
00345 int maxAttempts = 100);
00346
00347 void birthNonUniformlyFromRandomPrimitives (int doVar,
00348 POP_ContextData* data,
00349 GU_Detail* gdp, GB_PrimitiveGroup* group,
00350 UT_Matrix4* xform, UT_Matrix3* xformv,
00351 POP_AttribMap* map,
00352 GB_AttributeData* inherit,
00353 GB_AttributeData* split,
00354 POP_IntFunc originIndex, int originUse,
00355 float* born, GEO_PrimParticle* part,
00356 GB_PointGroup* birthGroup,
00357 POP_FloatFunc lifetime,
00358 POP_FloatFunc probability,
00359 POP_BirthAttribFunc birthAttrib,
00360 int whereFrom, int checkTrim,
00361 POP_JitterFunc jitter,
00362 const UT_String &distribAttrib,
00363 int maxAttempts);
00364
00365 private:
00366
00367 void computeBBox (void);
00368
00369 int myNumParticles;
00370 int myNumPoints;
00371 int myNumPrims;
00372 int myNumGroupEntries;
00373 GU_Detail* myBBGdp;
00374 UT_Vector3 myBBOrigin;
00375 UT_Vector3 myBBScale;
00376 float myTimeInc;
00377
00378 int myAllowGeneratorVar;
00379 int myVarDependent;
00380 int myVarTest;
00381
00382 GB_AttributeRef myAlphaOffset;
00383 GB_AttributeRef myDiffuseOffset;
00384 GB_AttributeRef myDistanceOffset;
00385 GB_AttributeRef myDragOffset;
00386 GB_AttributeRef myMassOffset;
00387 GB_AttributeRef myNormalOffset;
00388 GB_AttributeRef myScaleOffset;
00389 GB_AttributeRef mySpringKOffset;
00390 GB_AttributeRef myTensionOffset;
00391 GB_AttributeRef myTextureOffset;
00392 GB_AttributeRef myUpOffset;
00393 GB_AttributeRef myVelocityOffset;
00394 };
00395
00396 #endif