Public Member Functions | Public Attributes | Protected Member Functions

CollisionSphere Class Reference

Search for all occurrences

Detailed Description

See also:
Class ICollision, Class CollisionOps, Class CollisionPlane, Class CollisionVNormal, Class CollisionMesh, 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 SPHERICAL_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:

collisionsphere_radius

collisionsphere_node

Interval validity;

The validity interval.

Matrix3 tm;

The plane's TM.

Matrix3 invtm;

The inverse TM.

Matrix3 prevInvTm;

The cached previous inverse TM.

float radius;

The radius of the sphere.

#include <icollision.h>

Inheritance diagram for CollisionSphere:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  CollisionSphere ()
  ~CollisionSphere ()
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  SetRadius (TimeValue t, float r)
void  SetNode (TimeValue t, INode *n)
void  SetRadius (Control *c)
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
Matrix3  tm
Matrix3  invtm
Matrix3  prevInvTm
Point3  Vc
float  radius

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 SetRadius ( TimeValue  t,
float  r 
) [inline]
Remarks:
Sets the radius of the sphere.
Parameters:
TimeValue t

The time at which to set the radius.

float r

The radius.
Default Implementation:
{ pblock->SetValue(collisionsphere_radius,t,r); }
{ if (!pblock->GetControllerByID(collisionsphere_radius)) pblock->SetValue(collisionsphere_radius,t,r); }
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(collisionsphere_node,t,n); node = n; }
    { 
        {
            HoldSuspend hs;
            pblock->SetValue(collisionsphere_node,t,n);
        }
        node = n; 
}
void SetRadius ( Control c ) [inline]
Remarks:
Sets the radius controller.
Parameters:
Control *c

A pointer to the radius controller.
Default Implementation:
{ pblock->SetControllerByID(collisionsphere_radius,0,c); }
{ pblock->SetControllerByID(collisionsphere_radius,0,c,FALSE); }
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 SPHERICAL_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 
) [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.


Member Data Documentation

float radius

CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere
CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere CollisionSphere