SSParticle Class Reference

SSParticle Class Reference

#include <springsys.h>

Class Description

See also
Class SpringSys, Class SSSpring, Class SSConstraintPoint

This class represents the spring system particle.
+ Inheritance diagram for SSParticle:

Public Member Functions

 SSParticle ()
 
 ~SSParticle ()
 
SSParticleoperator= (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 ()
 
SSSpringGetSpring (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
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

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();

}
313  {
314  mass = 300.0f;
315  drag = 1.0f;
316  pos = vel = force = Point3(0.0f,0.0f,0.0f);
317  springs.removeAll();
318  }
Array< T > & removeAll()
Removes all the elements from the array.
Definition: Array.inline.h:317
Definition: point3.h:51
~SSParticle ( )
inline
Remarks
Destructor.
Default Implementation:
{ }
322 {}

Member Function Documentation

SSParticle& operator= ( const SSParticle from)
inline
Remarks
Assignment operator.
326  {
327  mass = from.mass;
328  drag = from.drag;
329  pos = from.pos;
330  vel = from.vel;
331  force = from.force;
332  springs.removeAll();
333  for (size_t i=0; i < from.springs.length(); i++)
334  {
335  SSSpring spring = from.springs[i];
336  springs.append(spring);
337  }
338  return *this;
339  }
Definition: springsys.h:145
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:158
Array< T > & removeAll()
Removes all the elements from the array.
Definition: Array.inline.h:317
size_t append(const T &value)
Appends a copy of value to the array.
Definition: Array.inline.h:294
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.
347  {
348  SSSpring spring;
349  mass = from.mass;
350  drag = from.drag;
351  pos = from.pos;
352  vel = from.vel;
353  force = from.force;
354  springs.removeAll();
355  for (size_t i = 0; i < from.springs.length(); i++)
356  {
357  spring.Copy(from.springs[i]);
358  springs.append(spring);
359  }
360  return *this;
361  }
Definition: springsys.h:145
SSSpring Copy(const SSSpring from)
Definition: springsys.h:217
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:158
Array< T > & removeAll()
Removes all the elements from the array.
Definition: Array.inline.h:317
size_t append(const T &value)
Appends a copy of value to the array.
Definition: Array.inline.h:294
float GetMass ( )
inline
Remarks
This method returns the spring particle mass.
364 {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.
369 {mass = m;}
float GetDrag ( )
inline
Remarks
This method returns the spring particle drag.
371 {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.
376 {drag = d;}
Point3 GetPos ( )
inline
Remarks
This method returns the spring particle position.
378 {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.
384 {pos = p;}
Point3 GetVel ( )
inline
Remarks
This method returns the spring particle velocity.
386 {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.
392 {vel = v;}
Point3 GetForce ( )
inline
Remarks
This method returns the spring particle force.
394 {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.
399 {force = f;}
MaxSDK::Array<SSSpring>* GetSprings ( )
inline
Remarks
This method returns a pointer to the collection of springs.
401 { 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.
407  {if (i>=0 && i < (int)springs.length()) return &(springs[i]);
408  else return NULL; }
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:158
#define NULL
Definition: autoptr.h:20
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.
416  {if (i>=0 && i < (int)springs.length())
417  springs[i] = spring; }
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:158
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.
423  {
424  springs.removeAll();
425  for (size_t i = 0; i < springsArray.length();i++)
426  {
427  springs.append(springsArray[i]);
428  }
429  }
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:158
Array< T > & removeAll()
Removes all the elements from the array.
Definition: Array.inline.h:317
size_t append(const T &value)
Appends a copy of value to the array.
Definition: Array.inline.h:294
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.
451  {
452  if ( index == 0 )
453  return;
454  for (size_t i = 0;i < springs.length(); i++)
455  {
456  if ( (springs[i].GetPointConstraint()->GetIndex()) == index)
457  springs.removeAt(i--);
458  else if (springs[i].GetPointConstraint()->GetIndex() > index)
459  springs[i].GetPointConstraint()->SetIndex(springs[i].GetPointConstraint()->GetIndex()-1);
460  }
461  }
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:158
Array< T > & removeAt(size_t index)
Removes a single element from the array.
Definition: Array.imp.h:318
bool operator== ( const SSParticle b) const
inline
Remarks
Compares this class instance to another one
465  {
466  return mass == b.mass && drag == b.drag && pos == b.pos && vel == b.vel && force == b.force && springs == b.springs;
467  }

Friends And Related Function Documentation

friend class SpringSys
friend