SSParticle Class Reference
 
 
 
SSParticle Class Reference

#include <springsys.h>

Inheritance diagram for SSParticle:
MaxHeapOperators

Class Description

See also:
Class SpringSys, Class SSSpring, Class SSConstraintPoint

This class represents the spring system particle.

Public Member Functions

  SSParticle ()
  ~SSParticle ()
SSParticle operator= (const SSParticle &from)
SSParticle  Copy (const SSParticle from)
float  GetMass ()
void  SetMass (float m)
float  GetDrag ()
void  SetDrag (float d)
Point3  GetPos ()
void  SetPos (Point3 p)
Point3  GetVel ()
void  SetVel (Point3 v)
Point3  GetForce ()
void  SetForce (Point3 f)
MaxSDK::Array< SSSpring > *  GetSprings ()
SSSpring GetSpring (int i)
void  SetSpring (int i, SSSpring spring)
void  SetSprings (const MaxSDK::Array< SSSpring > &springsArray)
SpringSysExport BOOL  AddSpring (SSConstraintPoint *bone, Point3 length, float tension=2.0f, float dampening=1.0f)
void  DeleteSpring (int index)
bool  operator== (const SSParticle &b) const

Friends

class  SpringSys

Constructor & Destructor Documentation

SSParticle ( ) [inline]
Remarks:
Constructor.
Default Implementation:
{

mass = 300.0f;

drag = 1.0f;

pos = vel = force = Point3(0.0f,0.0f,0.0f);

springs.ZeroCount();

}
                {
                        mass = 300.0f; 
                        drag = 1.0f; 
                        pos = vel = force = Point3(0.0f,0.0f,0.0f); 
                        springs.removeAll();
                }
~SSParticle ( ) [inline]
Remarks:
Destructor.
Default Implementation:
{ }
{}

Member Function Documentation

SSParticle& operator= ( const SSParticle from ) [inline]
Remarks:
Assignment operator.
                {
                        mass = from.mass;
                        drag = from.drag;
                        pos = from.pos;
                        vel = from.vel;
                        force = from.force;
                        springs.removeAll();
                        for (size_t i=0; i < from.springs.length(); i++)
                        {
                                SSSpring spring = from.springs[i];
                                springs.append(spring);
                        }
                        return *this;
                }
SSParticle Copy ( const SSParticle  from ) [inline]
Remarks:
This method allows you to copy the data from the specified SSParticle.
Parameters:
const SSParticle from

The spring system particle to copy from.
                {
                        SSSpring spring;
                        mass = from.mass;
                        drag = from.drag;
                        pos = from.pos;
                        vel = from.vel;
                        force = from.force;
                        springs.removeAll();
                        for (size_t i = 0; i < from.springs.length(); i++)
                        {
                                spring.Copy(from.springs[i]);
                                springs.append(spring);
                        }
                        return *this;
                }
float GetMass ( ) [inline]
Remarks:
This method returns the spring particle mass.
{return mass;}
void SetMass ( float  m ) [inline]
Remarks:
This method allows you to set the spring particle mass.
Parameters:
float m

The mass to set.
{mass = m;}
float GetDrag ( ) [inline]
Remarks:
This method returns the spring particle drag.
{return drag;}
void SetDrag ( float  d ) [inline]
Remarks:
This method allows you to set the spring particle drag.
Parameters:
float d

The drag value to set.
{drag = d;}
Point3 GetPos ( ) [inline]
Remarks:
This method returns the spring particle position.
{return pos;}
void SetPos ( Point3  p ) [inline]
Remarks:
This method allows you to set the spring particle position.
Parameters:
Point3 p

The position to set.
{pos = p;}
Point3 GetVel ( ) [inline]
Remarks:
This method returns the spring particle velocity.
{return vel;}
void SetVel ( Point3  v ) [inline]
Remarks:
This method allows you to set the spring particle velocity.
Parameters:
Point3 v

The velocity to set.
{vel = v;}
Point3 GetForce ( ) [inline]
Remarks:
This method returns the spring particle force.
{return force;}
void SetForce ( Point3  f ) [inline]
Remarks:
This method allows you to set the spring particle force.
Parameters:
Point3 f

The force to set.
{force = f;}
MaxSDK::Array<SSSpring>* GetSprings ( ) [inline]
Remarks:
This method returns a pointer to the collection of springs.
{ return &springs;}
SSSpring* GetSpring ( int  i ) [inline]
Remarks:
This method returns a pointer to the I-th spring in the array.
Parameters:
int i

The index of the spring to return.
                                           {if (i>=0 && i < (int)springs.length()) return &(springs[i]);
                                                                        else return NULL; }
void SetSpring ( int  i,
SSSpring  spring 
) [inline]
Remarks:
This method allows you to set the specified spring at the specified I-th index in the array.
Parameters:
int i

The index of the spring to set.

SSSpring spring

The spring to set.
                                                       {if (i>=0 && i < (int)springs.length()) 
                                                                                                        springs[i] = spring; }
void SetSprings ( const MaxSDK::Array< SSSpring > &  springsArray ) [inline]
Remarks:
This method allows you to set the entire spring array.
Parameters:
MaxSDK::Array<SSSpring>springsArray

The array of springs to set.
                { 
                        springs.removeAll(); 
                        for (size_t i = 0; i < springsArray.length();i++)
                        {
                                springs.append(springsArray[i]);
                        } 
                }
SpringSysExport BOOL AddSpring ( SSConstraintPoint bone,
Point3  length,
float  tension = 2.0f,
float  dampening = 1.0f 
)
Remarks:
This method allows you to add a spring to the array. Note that if the spring already exists it will be made stronger.
Parameters:
SSConstraintPoint *bone

A pointer to the spring system constraint point to set.

Point3 length

The length of the spring.

tension=2.0f

The tension of the spring.

float dampening = 1.0f

The dampening value of the spring.
Returns:
TRUE if the spring was added, FALSE if the spring was made stronger.
void DeleteSpring ( int  index ) [inline]
Remarks:
This method allows you to delete a spring.
Parameters:
int index

The index in the array of the spring to delete.
                {               
                        if ( index == 0 ) 
                                return;
                        for (size_t i = 0;i < springs.length(); i++)
                        {
                                if ( (springs[i].GetPointConstraint()->GetIndex()) == index)
                                        springs.removeAt(i--);
                                else if (springs[i].GetPointConstraint()->GetIndex() > index)
                                        springs[i].GetPointConstraint()->SetIndex(springs[i].GetPointConstraint()->GetIndex()-1);
                        }
                }
bool operator== ( const SSParticle b ) const [inline]
Remarks:
Compares this class instance to another one
                {
                        return mass == b.mass && drag == b.drag && pos == b.pos && vel == b.vel && force == b.force && springs == b.springs;
                }

Friends And Related Function Documentation

friend class SpringSys [friend]