![]() |
Houdini Development Toolkit - Version 6.5Side Effects Software Inc. 2004 |
Some useful methods:
float random (void)
random() returns a random number between 0-1. This should be used
instead of UTfastRandom() so that random numbers used within
POPs are completely deterministic.
GEO_PrimParticle* getPrimPart (POP_Node* node)
getPrimPart() returns the particle primitive generated by a
particular POP. If this particle doesn't exist already, it
creates a new one.
GEO_PrimParticle* hasPrimPart (POP_Node* node)
hasPrimPart() returns whether the particular POP already has a
corresponding particle primitive created for it.
GU_Detail* getDetail (void)
getDetail() returns the GU_Detail being processed by this POP_ContextData.
void addEvent (UT_String& events)
addEvent() signals that an event has occurred.
void removeEvent (UT_String& events)
removeEvent() signals that an event has ended.
void recacheOffset (void)
recacheOffset() reacquires all of the cached offset values in the
detail. This may be necessary, if the offsets have shifted around (which
is possible after a gdp merge).
int isGuideOnly (void)
isGuideOnly() returns whether to cook the guide geometry only.
int get____Offset (void)
There are many methods that retrieve attribute offsets.
The attribute offset that can be retrieved include:
Name | Description | Type | Size |
---|---|---|---|
Accel | Acceleration | UT_Vector3 | 1 |
Alpha | Point alpha | float | 1 |
Attract | Attractor index. Particle is attracted to this point number. | int | 1 |
Charge | Charge | float | 1 |
Diffuse | Diffuse color | float | 3 |
Distance | Distance to collision object. | float | 1 |
Drag | Drag | float | 1 |
Follow | Follow index. Particle will follow this leader number. | int | 1 |
Gen | Generation. | int | 1 |
HitDiffuse | Diffuse color at point of collision | float | 3 |
HitID | ID of collision | int | 1 |
HitNormal | Normal at point of collision | UT_Vector3 | 1 |
HitPos | Position where collision occurred | float | 3 |
HitPosUV | Parametric UV coordinates where collision occurred | float | 2 |
HitTime | When the collision occurred. | float | 1 |
HitUV | Texture UV at point of collision. | float | 3 |
ID | ID | int | 1 |
Instance | Instanced geometry | index | 1 |
Life | Total expected lifespan | float | 1 |
Mass | Mass | float | 1 |
Normal | Normal | UT_Vector3 | 1 |
NumHit | Number of times collision has occurred | int | 1 |
OrbitAxis | Orbit Axis | UT_Vector3 | 1 |
OrbitCenter | Orbit Center Position | float | 3 |
OrbitCntrID | Orbit Center ID | int | 1 |
OrbitRadius | Orbit Radius | float | 1 |
OrbitSpeed | Orbit Speed | float | 1 |
Origin | Birth origin | int | 1 |
Parent | ID of parent | int | 1 |
PrevVel | Previous velocity | UT_Vector3 | 1 |
Rot | Rotation about particle axis | float | 4 |
Scale | Scale | float | 1 |
SpeedLimit | Speed Limit | float | 2 |
springk | Spring Constant | float | 1 |
State | State of the particle | int | 1 |
tension | Spring Tension | float | 1 |
Texture | Texture UV | float | 3 |
Trans | Particle Axis Translation | UT_Vector3 | 1 |
Up | Up Vector | UT_Vector3 | 1 |
Velocity | Velocity | UT_Vector3 | 1 |
Some useful data:
float myTime;
Time when cook was requested.
float myTimeInc;
Time increment for this cook.
OP_Network* myXformObj;
Transform Object
UT_PtrArray<OP_Guide*> myOPGuides;
List of Guide Geometries.
UT_PtrArray<POP_Node*> myGuidePOPs;
List of POPs that add guide geometry.
Some useful methods:
void add____Attrib (POP_ContextData* data)
add____Attrib() is used to add attributes to the detail if
they don't exist already. Not only will the attribute be added,
but the offset value will also be set in the POP_ContextData.
The attributes that can be added include:
Name | Description | Type | Size |
---|---|---|---|
Alpha | Point alpha | float | 1 |
Attract | Attractor index. Particle is attracted to this point number. | int | 1 |
Charge | Charge | float | 1 |
Diffuse | Diffuse color | float | 3 |
Distance | Distance to collision object. | float | 1 |
Drag | Drag | float | 1 |
Follow | Follow index. Particle will follow this leader number. | int | 1 |
Gen | Generation. | int | 1 |
HitDiffuse | Diffuse color at point of collision | float | 3 |
HitID | ID of collision | int | 1 |
HitNormal | Normal at point of collision | UT_Vector3 | 1 |
HitPos | Position where collision occurred | float | 3 |
HitPosUV | Parametric UV coordinates where collision occurred | float | 2 |
HitTime | When the collision occurred. | float | 1 |
HitUV | Texture UV at point of collision. | float | 3 |
ID | ID | int | 1 |
Instance | Instanced geometry | index | 1 |
Mass | Mass | float | 1 |
NumHit | Number of times collision has occurred | int | 1 |
OrbitAxis | Orbit Axis | UT_Vector3 | 1 |
OrbitCenter | Orbit Center Position | float | 3 |
OrbitCntrID | Orbit Center ID | int | 1 |
OrbitRadius | Orbit Radius | float | 1 |
OrbitSpeed | Orbit Speed | float | 1 |
Origin | Birth origin | int | 1 |
Parent | ID of parent | int | 1 |
PrevVel | Previous velocity | UT_Vector3 | 1 |
Rot | Rotation about particle axis | float | 4 |
Scale | Scale | float | 1 |
SpeedLimit | Speed Limit | float | 2 |
SpringK | Spring Constant | float | 1 |
Tension | Spring Tension | float | 1 |
Trans | Particle Axis Translation | UT_Vector3 | 1 |
Up | Up Vector | UT_Vector3 | 1 |
int addUserVariable (const char* name, int size,
GB_AttribType type, const void* def, const char* local = 0);
addUserVariable() is used to add user defined attributes to the detail.
The method will also take care of adding local variables that correspond
to the attribute. The attribute will require the usual information like
a name, size (number of bytes the attribute requires), type (GB_ATTRIB_FLOAT,
GB_ATTRIB_INT or GB_ATTRIB_VECTOR) and default values. The parameter local
specifies the name of the local variable. It is optional. If it isn't
specifies, the name of the attribute, all uppercased is used. For example,
adding float attribute "abc" will create local variables "ABC1", "ABC2", etc.
Adding vector attribute "abc" will create local variables "ABCX", "ABCY",
and "ABCZ".
OP_ERROR buildParticleList (OP_Context &context);
buildParticleList() is used to build the list of particle
primitives that the POP should process.
void initParticleList (OP_Context &context,
GEO_PrimParticle* part = NULL);
initParticleList() is used to initialize the list of particle primitives
that the POP should process. Used by generators, it will initialize the
list with one specific primitive. It can also be used to clear the list
if the passed in primitive is NULL.
int addToParticleList (OP_Context &context,
GEO_PrimParticle* part);
addToParticleList() adds a primitive to the list of particle primitives
to process. If successful, the function returns 1. If the primitive is
already in the list, it is not added and the function returns 0.
void addAccelGuide (GEO_Point* ppt, float ax, float ay,
float az, float scale = 1.0f, int normalize = 0);
addAccelGuide() adds guide geometry to show accelerations. Useful for
modifier POPs that change the particle's acceleration.
int checkActivation (POP_ContextData* data,
POP_FParam activate);
checkActivation() will evaluate the activation parameter. It takes care
of allowing certain local variables in the parameter evaluation. It returns
1 if the POP should be active, and 0 otherwise.
GEO_ParticleVertex* | |
birthParticle | (POP_ContextData* data, |
GEO_PrimParticle* part, const UT_Vector4& pos, | |
POP_AttribMap* map, GB_AttributeData* inherit, | |
GB_AttributeData* split, POP_IntFunc originIndex, | |
int originGeo, int originUse, | |
POP_FloatFunc lifetime, | |
POP_BirthAttribFunc birthAttrib = NULL, | |
void* userData = NULL) |
data | POP_ContextData being used. |
part | Particle primitive to birth into. |
pos | Position of the birthed particle. |
map | A POP_AttribMap is a mapping of attribtues from one detail to another. This particular mapping is used for inheriting attributes from the inherit GB_AttributeData. Can be set to NULL. |
inherit | Attribute data to inherit general attributes (i.e. color, velocity, etc.). It is required when map is used. Can be set to NULL. |
split | Attribute data to inherit parental attributes (parent, origin, generation) from. Can be set to NULL. |
originIndex | Origin index value. |
originGeo | Origin from geometry number. |
originUse | How to set origin id (i.e. origin attribute). This is a bit mask:
|
lifetime | Total expected life of the particle. |
birthAttrib | Function to set attributes after particle is birthed. |
userdata | User data passed into birthAttrib. |
The originIndex and lifetime parameters are function pointers. Here are the prototypes and some examples for these functions.
void | |
intersectParticle | (POP_ContextData* data, |
float t, int behavior, GEO_Point* ppt, | |
UT_Vector4& p0, UT_Vector3& vel, | |
UT_Vector3& accel, | |
int* state, float timeinc, int isectMax, | |
POP_FloatFunc gainTan, POP_FloatFunc gainNml, | |
POP_IntFunc id, int addprim, | |
POP_VertexIntersectFunc vertexIntersect) |
data | POP_ContextData being used. |
t | Current time. |
behavior | Behavior:
|
ppt | Point being tested for intersection. |
p0 | Where the point is. |
vel | Current velocity of the particle. |
accel | Acceleration of the particle. |
state | Particle state (state attribute). |
timeinc | Time increment. How much time is passing during this cook. |
iSectMax | Maximum number of bounces to perform for bounce behavior. |
gainTan | Velocity gain factor in tangential direction for bounces. |
gainNml | Velocity gain factor in normal direction for bounces. |
id | Collision id to be used. The collision ID is just an integer number to associate with this collision. |
addprim | If 1, adds the primitive number collided against to the collision id. |
vertexIntersect | Function that performs interersection. |
The vertexIntersect is a function pointer. Here is the prototype and an example.
POP_ParticleList myParticleList;
List of particle primitives that this POP should process.
OP_Guide* myGuide;
Holds the guide geometry for this POP.
Some useful methods:
void setupVars (POP_ContextData* data,
GB_PointGroup* source = 0)
The setupVars() method should be called during cooking to initialize the
use of local variables by the POP.
void setupDynamicVars (POP_ContextData* data)
The setupDynamicVars() should be called at the beginning of cooking (right
after the lockInputs()) to initialize the use of user defined local
variables by the POP.
void allowVar (int val)
Although some parameters may allow the use of local variables, some may
not. If evaluating a parameter that should not be using local variables,
do something like this.
Some useful data:
GEO_Point* myCurrPt;
This GEO_Point represents the point that is currently being modified.
The myCurrPt variable should be updated as the processing occurs so that
the appropriate attributes can be retrieved.
int myCurrIter;
This integer represents the iteration number of the processing. It is
accessed with the $ITER variable. The variable should be updated as
the processing occurs.
Some useful methods:
void clear (void)
Clear the list.
void add (GEO_PrimParticle* part)
Add a new primitive to the list.
GEO_PrimParticle* iterateInit (void)
Return the first primitive in the list.
GEO_PrimParticle* iterateNext (void)
Return the next primitive in the list. iterateInit() should be called
before a call to iterateNext().
int find (GEO_PrimParticle* part)
Find out whether the primitive is in the list.