Class CollisionMesh
See Also: Class ICollision, Class CollisionOps, Class CollisionPlane, Class CollisionSphere, Class CollisionVNormal, Class Box3, Class Point3, Class IParamBlock2, Class INode, Class Control
class CollisionMesh : public ICollision
Description:
This class is available in release 4.0 and later only.
This class represents the planar collision object with the ClassID defined as MESH_COLLISION_ID. This class allows you to define a plane in space and determine if a particle hit it.
Data Members:
private:
INode *node;
The associated node.
public:
IParamBlock2 *pblock;
The parameter block data. You can use the following enum parameter ID’s:
collisionmesh_hit_face_index
collisionmesh_hit_bary
collisionmesh_node
Interval validity;
The validity interval.
Matrix3 tm;
The plane’s TM.
Matrix3 invtm;
The inverse TM.
Matrix3 tmPrev;
The previous TM.
Matrix3 prevInvTm;
The cached previous inverse TM.
float radius;
The radius of the sphere.
Mesh *dmesh;
The mesh pointer.
int nv, nf;
The mesh number of vertices and number of faces.
CollisionVNormal *vnorms;
The collision vertex normals.
Point3 *fnorms;
The face normals.
Methods:
public:
Prototype:
CollisionMesh();
Remarks:
Constructor.
Prototype:
~CollisionMesh();
Remarks:
Destructor.
Prototype:
int SuppportedCollisions();
Remarks:
This method determines the type of collisions that are supported.
Return Value:
One of the following;
POINT_COLLISION for point collision, currently supported.
SPHERE_COLLISION for spherical collision, currently not supported.
BOX_COLLISION for box collision, currently not supported.
EDGE_COLLISION for edge collision, currently not supported.
Default Implementation:
{ return POINT_COLLISION; }
Prototype:
void PreFrame(TimeValue t, TimeValue dt);
Remarks:
This method will be called once before the checkcollision is called for each frame which allows you to do any required initialization.
Parameters:
TimeValue t
The time at which to initialize.
TimeValue dt
The delta of time the particle wil travel.
Prototype:
void PostFrame(TimeValue t, TimeValue dt);
Remarks:
This method will be called at the end of each frame solve to allow you to destroy and deallocate any data you no longer need.
Parameters:
TimeValue t
The time at which to initialize.
TimeValue dt
The delta of time the particle wil travel.
Default Implementation:
{}
Prototype:
virtual BOOL CheckCollision (TimeValue t, Point3 pos, Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel) = 0;
Remarks:
This method will be called to execute a point to surface collision and compute the time at which the particle hit the surface.
Parameters:
TimeValue t
The end time of the particle.
Point3 pos
The position of the particle in world space.
Point3 vel
The velocity of the particle in world space.
float dt
The delta of time that the particle travels (t-dt being the start of time of the particle)
float &at
The point in time that the collision occurs with respect to the dt.
Point3 &hitPoint
The point of collision.
Point3 &norm
The bounce vector component of the final velocity.
Point3 &friction
The friction vector component of the final velocity.
Point3 inheritedVel
The approximated amount of velocity inherited from the motion of the deflector.
Return Value:
TRUE if there’s a collision, otherwise FALSE.
Prototype:
virtual BOOL CheckCollision (TimeValue t,Point3 pos, float radius, Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel) = 0;;
Remarks:
This method will be called to execute a sphere to surface collision and compute the time at which the particle hit the surface.
Parameters:
TimeValue t
The end time of the particle.
Point3 pos
The position of the particle in world space.
float radius
The radius of the sphere.
Point3 vel
The velocity of the particle in world space.
float dt
The delta of time that the particle travels (t-dt being the start of time of the particle)
float &at
The point in time that the collision occurs with respect to the dt.
Point3 &hitPoint
The point of collision.
Point3 &norm
The bounce vector component of the final velocity.
Point3 &friction
The friction vector component of the final velocity.
Point3 inheritedVel
The approximated amount of velocity inherited from the motion of the deflector.
Return Value:
TRUE if there’s a collision, otherwise FALSE.
Prototype:
virtual BOOL CheckCollision (TimeValue t, Box3 box, Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel) = 0;
Remarks:
This method will be called to execute a box to surface collision and compute the time at which the particle hit the surface.
Parameters:
TimeValue t
The end time of the particle.
Box3 box
The box itself.
Point3 vel
The velocity of the particle in world space.
float dt
The delta of time that the particle travels (t-dt being the start of time of the particle)
float &at
The point in time that the collision occurs with respect to the dt.
Point3 &hitPoint
The point of collision.
Point3 &norm
The bounce vector component of the final velocity.
Point3 &friction
The friction vector component of the final velocity.
Point3 inheritedVel
The approximated amount of velocity inherited from the motion of the deflector.
Return Value:
TRUE if there’s a collision, otherwise FALSE.
Prototype:
virtual BOOL CheckCollision (TimeValue t,Point3 edgeA,Point3 edgeB ,Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel) = 0;
Remarks:
This method will be called to execute an edge to surface collision and compute the time at which the particle hit the surface.
Parameters:
TimeValue t
The end time of the particle.
Point3 edgeA
The first edge.
Point3 edgeB
The second edge.
Point3 vel
The velocity of the particle in world space.
float dt
The delta of time that the particle travels (t-dt being the start of time of the particle)
float &at
The point in time that the collision occurs with respect to the dt.
Point3 &hitPoint
The point of collision.
Point3 &norm
The bounce vector component of the final velocity.
Point3 &friction
The friction vector component of the final velocity.
Point3 inheritedVel
The approximated amount of velocity inherited from the motion of the deflector.
Return Value:
TRUE if there’s a collision, otherwise FALSE.
Prototype:
void SetNode(TimeValue t, INode *n);
Remarks:
Sets the node which drives the TM to put the plane in world space.
Parameters:
TimeValue t
The time at which to set the node.
INode *n
The node to set.
Default Implementation:
{ pblock->SetValue(collisionmesh_node,t,n); node = n; }
Prototype:
void DeleteThis();
Remarks:
Self deletion.
Default Implementation:
{ delete this; }
Prototype:
Class_ID ClassID();
Remarks:
This method returns the class ID.
Default Implementation:
{return SPHERICAL_COLLISION_ID;}
Prototype:
SClass_ID SuperClassID();
Remarks:
This method returns the super class ID.
Default Implementation:
{return REF_MAKER_CLASS_ID;}
Prototype:
int NumRefs();
Remarks:
This method returns the number of references.
Default Implementation:
{ return 1; }
Prototype:
RefTargetHandle GetReference(int i);
Remarks:
This method returns the I-th parameter block.
Default Implementation:
{ return pblock; }
Prototype:
void SetReference(int i, RefTargetHandle rtarg);
Remarks:
This method allows you to set the I-th parameter block.
Parameters:
int i
The I-th parameter block to set.
RefTargetHandle rtarg
The reference target handle to the parameter block.
Default Implementation:
{pblock = (IParamBlock2*)rtarg;}
Prototype:
RefTargetHandle Clone(RemapDir &remap = NoRemap());
Remarks:
This method is called to have the plug-in clone itself. This method should copy both the data structure and all the data residing in the data structure of this reference target. The plug-in should clone all its references as well.
Parameters:
RemapDir &remap = NoRemap()
This class is used for remapping references during a Clone. See Class RemapDir.
Return Value:
A pointer to the cloned item.
Prototype:
RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID,RefMessage message);
Remarks:
A plug-in which makes references must implement this method to receive and respond to messages broadcast by its dependents.
Parameters:
Interval changeInt
This is the interval of time over which the message is active.
RefTargetHandle hTarget
This is the handle of the reference target the message was sent by. The reference maker uses this handle to know specifically which reference target sent the message.
PartID& partID
This contains information specific to the message passed in. Some messages don't use the partID at all. See the section List of Reference Messages for more information about the meaning of the partID for some common messages.
RefMessage message
The msg parameters passed into this method is the specific message which needs to be handled. See List of Reference Messages.
Return Value:
The return value from this method is of type RefResult. This is usually REF_SUCCEED indicating the message was processed. Sometimes, the return value may be REF_STOP. This return value is used to stop the message from being propagated to the dependents of the item.