Public Member Functions | Public Attributes | Protected Member Functions

CollisionMesh Class Reference

Search for all occurrences

Detailed Description

See also:
Class ICollision, Class CollisionOps, Class CollisionPlane, Class CollisionSphere, Class CollisionVNormal, Class Box3, Class Point3, Class IParamBlock2, Class INode, Class Control

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.

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.

#include <icollision.h>

Inheritance diagram for CollisionMesh:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  CollisionMesh ()
  ~CollisionMesh ()
int  SuppportedCollisions ()
void  PreFrame (TimeValue t, TimeValue dt)
void  PostFrame (TimeValue t, TimeValue dt)
BOOL  CheckCollision (TimeValue t, Point3 pos, Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel)
BOOL  CheckCollision (TimeValue t, Point3 pos, float radius, Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel)
BOOL  CheckCollision (TimeValue t, Box3 box, Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel)
BOOL  CheckCollision (TimeValue t, Point3 edgeA, Point3 edgeB, Point3 vel, float dt, float &at, Point3 &hitPoint, Point3 &norm, Point3 &friction, Point3 &inheritedVel)
void  SetNode (TimeValue t, INode *n)
void  DeleteThis ()
Class_ID  ClassID ()
SClass_ID  SuperClassID ()
int  NumRefs ()
RefTargetHandle  GetReference (int i)
RefTargetHandle  Clone (RemapDir &remap)
RefResult  NotifyRefChanged (Interval changeInt, RefTargetHandle hTarget, PartID &partID, RefMessage message)

Public Attributes

IParamBlock2 pblock
Interval  validity
DWORD  outFi
Point3  outBary
Matrix3  tm
Matrix3  invtm
Matrix3  tmPrev
Matrix3  invtmPrev
Mesh dmesh
int  nv
int  nf
CollisionVNormal vnorms
Point3 fnorms

Protected Member Functions

virtual void  SetReference (int i, RefTargetHandle rtarg)

Constructor & Destructor Documentation

Remarks:
Constructor.
Remarks:
Destructor.

Member Function Documentation

int SuppportedCollisions ( ) [inline, virtual]
Remarks:
This method determines the type of collisions that are supported.
Returns:
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; }

Implements ICollision.

        { 
        return POINT_COLLISION; 
        } 
void PreFrame ( TimeValue  t,
TimeValue  dt 
) [virtual]
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.

Implements ICollision.

void PostFrame ( TimeValue  t,
TimeValue  dt 
) [inline, virtual]
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:
{}

Implements ICollision.

{}
BOOL CheckCollision ( TimeValue  t,
Point3  pos,
Point3  vel,
float  dt,
float &  at,
Point3 hitPoint,
Point3 norm,
Point3 friction,
Point3 inheritedVel 
) [virtual]
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.
Returns:
TRUE if there's a collision, otherwise FALSE.

Implements ICollision.

BOOL CheckCollision ( TimeValue  t,
Point3  pos,
float  radius,
Point3  vel,
float  dt,
float &  at,
Point3 hitPoint,
Point3 norm,
Point3 friction,
Point3 inheritedVel 
) [inline, virtual]
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.
Returns:
TRUE if there's a collision, otherwise FALSE.

Implements ICollision.

        {
        return FALSE;
        }
BOOL CheckCollision ( TimeValue  t,
Box3  box,
Point3  vel,
float  dt,
float &  at,
Point3 hitPoint,
Point3 norm,
Point3 friction,
Point3 inheritedVel 
) [inline, virtual]
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.
Returns:
TRUE if there's a collision, otherwise FALSE.

Implements ICollision.

        {
        return FALSE;
        }
BOOL CheckCollision ( TimeValue  t,
Point3  edgeA,
Point3  edgeB,
Point3  vel,
float  dt,
float &  at,
Point3 hitPoint,
Point3 norm,
Point3 friction,
Point3 inheritedVel 
) [inline, virtual]
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.
Returns:
TRUE if there's a collision, otherwise FALSE.

Implements ICollision.

        {
        return FALSE;
        }
void SetNode ( TimeValue  t,
INode n 
) [inline]
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; }
                                         { 
//check for circle loop here

                                           pblock->SetValue(collisionmesh_node,t,n);
                                           node = n; }
void DeleteThis ( ) [virtual]
Remarks:
Self deletion.
Default Implementation:
{ delete this; }

Reimplemented from Animatable.

Class_ID ClassID ( ) [inline, virtual]
Remarks:
This method returns the class ID.
Default Implementation:
{return SPHERICAL_COLLISION_ID;}

Reimplemented from Animatable.

{return MESH_COLLISION_ID;}
SClass_ID SuperClassID ( ) [inline, virtual]
Remarks:
This method returns the super class ID.
Default Implementation:
{return REF_MAKER_CLASS_ID;}

Reimplemented from ReferenceTarget.

{return REF_MAKER_CLASS_ID;}
int NumRefs ( ) [inline, virtual]
Remarks:
This method returns the number of references.
Default Implementation:
{ return 1; }

Reimplemented from ReferenceMaker.

{ return 1; }
RefTargetHandle GetReference ( int  i ) [inline, virtual]
Remarks:
This method returns the I-th parameter block.
Default Implementation:
{ return pblock; }

Reimplemented from ReferenceMaker.

{ return pblock; }
virtual void SetReference ( int  i,
RefTargetHandle  rtarg 
) [inline, protected, virtual]
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;}

Reimplemented from ReferenceMaker.

{pblock = (IParamBlock2*)rtarg;}
RefTargetHandle Clone ( RemapDir remap ) [virtual]
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

This class is used for remapping references during a Clone. See Class RemapDir.
Returns:
A pointer to the cloned item.

Reimplemented from ReferenceTarget.

RefResult NotifyRefChanged ( Interval  changeInt,
RefTargetHandle  hTarget,
PartID partID,
RefMessage  message 
) [inline, virtual]
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 Reference Messages and PartID for more information.

RefMessage message

The msg parameters passed into this method is the specific message which needs to be handled. See Reference Messages.
Returns:
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.

Implements ReferenceMaker.

        {
        switch (message) {
            case REFMSG_CHANGE:
                if (hTarget == pblock)
                    validity.SetEmpty();
                break;
            }
//note this is ref_stop because we don't want the engine updating it references
//may need a flag to turn this off or on
        return( REF_STOP);
        }

Member Data Documentation

DWORD outFi
int nv
int nf

CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh
CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh CollisionMesh