Public Member Functions | Protected Member Functions

SpringSys Class Reference

This reference page is linked to from the following overview topics: Plug-in Base Classes.


Search for all occurrences

Detailed Description

See also:
Class BaseInterfaceServer, Class SSParticle, Class SSParticleCache, Class SpringSysClient , Class IJiggle

Description:
This class is available in release 4.0 and later only.

This class is the main spring system class. This spring system is a multi-point spring-based dynamic system. In order to your the system you must derive from SpringSysClient and implement the SpringSysClient::GetForceMatrices() method You are responsible for gathering the spring constraint forces at any given time.

The spring system uses its own position and velocity to determine its motion, as well as allowing you to add multiple spring constraints to any other objects in the scene. Multiple constraints act like multiple links.

The solution is calculated using a start time and a step size. Solutions are cached once for the last tick calculated, and once per frame. Performance should be the same one each frame as you step forward, and significantly faster after the first pass if nothing changes. Cached values will be used if going backwards in time.

Data Members:
private:

float referenceTime;

The stored reference time.

float lastTime;

The stored last time.

bool isValid;

This flag indicates whether the spring system is valid.

SSParticleCache frameCache;

The spring system particle cache.

Tab<Point3> pos_cache;

The cached table of positions.

Tab<Point3> vel_cache;

The cached table of velocities.

Tab<Point3> initPosTab;

The table of initial positions.

Tab<SSParticle> parts;

The table of spring system particles.

SpringSysClient* client;

The spring system client object.

#include <springsys.h>

Inheritance diagram for SpringSys:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  SpringSys ()
  SpringSys (SpringSysClient *c, int count)
  ~SpringSys ()
SpringSysExport SpringSys operator= (const SpringSys &from)
SpringSysExport SpringSys  Copy (const SpringSys *from)
void  SetReferenceTime (float t)
float  GetReferenceTime ()
Tab< SSParticle > *  GetParticles ()
SSParticle GetParticle (int i)
SpringSysExport void  SetParticleCount (int count)
SpringSysExport void  SetInitialPosition (Point3 p, int partIndex)
SpringSysExport void  SetInitialVelocity (Point3 p, int partIndex)
SpringSysExport void  SetInitialBoneStates (Tab< Matrix3 > boneTMs)
SpringSysExport void  Invalidate ()
SpringSysExport void  Solve (int time, float TimeDelta)
SpringSysExport void  GetPosition (Point3 &p, int index)
SpringSysExport IOResult  Load (ILoad *iload)
SpringSysExport IOResult  Save (ISave *isave)

Protected Member Functions

float  GetTime ()
void  SetTime (float t)
SpringSysExport void  Clear_Forces (int index)
SpringSysExport void  Compute_Forces (TimeValue t, int index)
SpringSysExport void  ApplyDrag (int index)
SpringSysExport void  ApplyUnaryForces (TimeValue t, int index)
SpringSysExport void  ComputeControlledParticleForce (Matrix3 tm, int vertIndex, int springIndex)
SpringSysExport void  ApplySpring (TimeValue t, int index)
SpringSysExport void  UpdateParticleState (TimeValue t, Tab< Matrix3 > tmArray, int pIndex, TimeValue Delta)
SpringSysExport void  ComputeDerivative (int index, Point3 &pos, Point3 &vel)
SpringSysExport void  GetParticleState (int index, Point3 &pos, Point3 &vel)
SpringSysExport void  SetParticleState (int index, Point3 pos, Point3 vel)
SpringSysExport void  ScaleVectors (Point3 &pos, Point3 &vel, float delta)
SpringSysExport void  AddVectors (Point3 pos1, Point3 vel1, Point3 &pos, Point3 &vel)

Constructor & Destructor Documentation

SpringSys ( ) [inline]
Remarks:
Constructor.
        {
            client = NULL; 
            referenceTime = lastTime = 0.0f; 
            SetParticleCount(1);
            isValid = false; 
        }
SpringSys ( SpringSysClient c,
int  count 
) [inline]
Remarks:
Constructor.

Initialize the class with the specified data.
Parameters:
SpringSysClient* c

A pointer to the spring system client class.

int count

The number of spring system particles.
        { 
            client = c; 
            referenceTime = lastTime = 0.0f; 
            SetParticleCount(count);
            isValid = false; 
        }
~SpringSys ( ) [inline]
Remarks:
Destructor.
{}

Member Function Documentation

SpringSysExport SpringSys& operator= ( const SpringSys from )
Remarks:
Assignment operator.
SpringSysExport SpringSys Copy ( const SpringSys from )
Remarks:
This method allows you to copy the data from the specified spring system.
Parameters:
const SpringSys* from

The spring system to copy the data from.
void SetReferenceTime ( float  t ) [inline]
Remarks:
This method allows you to set the reference time.
Parameters:
float t

The reference time to set.
{ referenceTime = t; }
float GetReferenceTime ( ) [inline]
Remarks:
This method returns the reference time.
{ return referenceTime; }
Tab<SSParticle>* GetParticles ( ) [inline]
Remarks:
This method returns a pointer to the table of spring system particles.
{ return &parts;}
SSParticle* GetParticle ( int  i ) [inline]
Remarks:
This method returns a pointer to the I-th spring system particle.
Parameters:
int i

The index of the spring system particle in the table.
                                       { if (i >=0 && i< parts.Count()) return &(parts[i]);
                                            else return NULL; }
SpringSysExport void SetParticleCount ( int  count )
Remarks:
This method allows you to set the number of particles in the spring system.
Parameters:
int count

The number of particles to set.
SpringSysExport void SetInitialPosition ( Point3  p,
int  partIndex 
)
Remarks:
This method allows you to set the initial position for the specified spring system particle.
Parameters:
Point3 p

The initial position to set.

int partIndex

The index of the particle in the table for which to set the initial position.
SpringSysExport void SetInitialVelocity ( Point3  p,
int  partIndex 
)
Remarks:
This method allows you to set the initial velocity for the specified spring system particle.
Parameters:
Point3 p

The initial velocity to set.

int partIndex

The index of the particle in the table for which to set the initial velocity.
SpringSysExport void SetInitialBoneStates ( Tab< Matrix3 boneTMs )
Remarks:
This method allows you to set the initial bone states for the spring system.
Parameters:
Tab<Matrix3> boneTMs

The table of bone transformation matrices to set.
SpringSysExport void Invalidate ( )
Remarks:
This method will invalidate the spring system and issue the re-computation of the spring system state.
SpringSysExport void Solve ( int  time,
float  TimeDelta 
)
Remarks:
This method allows you to solve the spring system dynamics.
Parameters:
int time

The time at which to solve

float TimeDelta

The time difference.
SpringSysExport void GetPosition ( Point3 p,
int  index 
)
Remarks:
This method returns the position of the specified spring system particle.
Parameters:
Point3& p

The position which is returned

int index

The index of the spring system particle in the table.
protected:
SpringSysExport IOResult Load ( ILoad iload )
SpringSysExport IOResult Save ( ISave isave )
float GetTime ( ) [inline, protected]
Remarks:
This method allows you to get the spring system last time.
Default Implementation:
{ return lastTime; }
{ return lastTime; }
void SetTime ( float  t ) [inline, protected]
Remarks:
This method allows you to set the spring system last time.
Parameters:
float t

The time to set.
Default Implementation:
{ lastTime = t; }
{ lastTime = t; }
SpringSysExport void Clear_Forces ( int  index ) [protected]
Remarks:
This method will clear the forces acting upon the specified spring system particle.
Parameters:
int index

The index into the table of spring system particles.
SpringSysExport void Compute_Forces ( TimeValue  t,
int  index 
) [protected]
Remarks:
This method will compute the forces acting upon the specified spring system particle..
Parameters:
TimeValue t

The time at which to compute the forces.

int index

The index into the table of spring system particles.
SpringSysExport void ApplyDrag ( int  index ) [protected]
Remarks:
This method will apply the drag forces onto the specified spring system particle.
Parameters:
int index

The index into the table of spring system particles.
SpringSysExport void ApplyUnaryForces ( TimeValue  t,
int  index 
) [protected]
Remarks:
This method will apply the unary forces onto the specified spring system particle.
Parameters:
TimeValue t

The time at which to apply the unary forces.

int index

The index into the table of spring system particles.
SpringSysExport void ComputeControlledParticleForce ( Matrix3  tm,
int  vertIndex,
int  springIndex 
) [protected]
Remarks:
This method will compute the controlled particle force.
Parameters:
Matrix3 tm

The transformation matrix.

int vertIndex

The vertex index for which to compute the controlled particle force.

int springIndex

The index into the table of spring system particles.
SpringSysExport void ApplySpring ( TimeValue  t,
int  index 
) [protected]
Remarks:
This method will apply the spring to the specified spring system particle.
Parameters:
TimeValue t

The time at which to apply the unary forces.

int index

The index into the table of spring system particles.
SpringSysExport void UpdateParticleState ( TimeValue  t,
Tab< Matrix3 tmArray,
int  pIndex,
TimeValue  Delta 
) [protected]
Remarks:
This method will update the particle state.
Parameters:
TimeValue t

The time at which to apply the unary forces.

Tab<Matrix3> tmArray

The table of transformation matrices.

int pIndex

The index into the table of spring system particles.

TimeValue Delta

The time difference for which to update.
SpringSysExport void ComputeDerivative ( int  index,
Point3 pos,
Point3 vel 
) [protected]
Remarks:
This method will compute the derivative forces for the specified spring system particle.
Parameters:
int index

The index into the table of spring system particles.

Point3 &pos

The computed position.

Point3 &vel

The computed velocity.
SpringSysExport void GetParticleState ( int  index,
Point3 pos,
Point3 vel 
) [protected]
Remarks:
This method retrieves the state of the specified spring system particle.
Parameters:
int index

The index into the table of spring system particles.

Point3 &pos

The current position.

Point3 &vel

The current velocity.
SpringSysExport void SetParticleState ( int  index,
Point3  pos,
Point3  vel 
) [protected]
Remarks:
This method allows you to set the particle state of the specified spring system particle.
Parameters:
int index

The index into the table of spring system particles.

Point3 pos

The position to set.

Point3 vel

The velocity to set.
SpringSysExport void ScaleVectors ( Point3 pos,
Point3 vel,
float  delta 
) [protected]
Remarks:
This method allows you to scale the vectors by the specified difference.
Parameters:
Point3 &pos

The scaled position.

Point3 &vel

The scaled velocity.

float delta

The time difference to scale by.
SpringSysExport void AddVectors ( Point3  pos1,
Point3  vel1,
Point3 pos,
Point3 vel 
) [protected]
Remarks:
This method allows you to add vector forces to the spring system.
Parameters:
Point3 pos1, vel1

The position and velocity to add.

Point3 &pos, &vel

The position and velocity.

SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys
SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys SpringSys