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

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

Member Function Documentation

SSParticle& operator= ( const SSParticle from)
inline
Remarks
Assignment operator.
324  {
325  mass = from.mass;
326  drag = from.drag;
327  pos = from.pos;
328  vel = from.vel;
329  force = from.force;
330  springs.removeAll();
331  for (size_t i=0; i < from.springs.length(); i++)
332  {
333  SSSpring spring = from.springs[i];
334  springs.append(spring);
335  }
336  return *this;
337  }
Definition: springsys.h:143
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:156
Array< T > & removeAll()
Removes all the elements from the array.
Definition: Array.inline.h:315
size_t append(const T &value)
Appends a copy of value to the array.
Definition: Array.inline.h:292
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.
345  {
346  SSSpring spring;
347  mass = from.mass;
348  drag = from.drag;
349  pos = from.pos;
350  vel = from.vel;
351  force = from.force;
352  springs.removeAll();
353  for (size_t i = 0; i < from.springs.length(); i++)
354  {
355  spring.Copy(from.springs[i]);
356  springs.append(spring);
357  }
358  return *this;
359  }
Definition: springsys.h:143
SSSpring Copy(const SSSpring from)
Definition: springsys.h:215
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:156
Array< T > & removeAll()
Removes all the elements from the array.
Definition: Array.inline.h:315
size_t append(const T &value)
Appends a copy of value to the array.
Definition: Array.inline.h:292
float GetMass ( )
inline
Remarks
This method returns the spring particle mass.
362 {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.
367 {mass = m;}
float GetDrag ( )
inline
Remarks
This method returns the spring particle drag.
369 {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.
374 {drag = d;}
Point3 GetPos ( )
inline
Remarks
This method returns the spring particle position.
376 {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.
382 {pos = p;}
Point3 GetVel ( )
inline
Remarks
This method returns the spring particle velocity.
384 {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.
390 {vel = v;}
Point3 GetForce ( )
inline
Remarks
This method returns the spring particle force.
392 {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.
397 {force = f;}
MaxSDK::Array<SSSpring>* GetSprings ( )
inline
Remarks
This method returns a pointer to the collection of springs.
399 { 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.
405  {if (i>=0 && i < (int)springs.length()) return &(springs[i]);
406  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:156
#define NULL
Definition: autoptr.h:18
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.
414  {if (i>=0 && i < (int)springs.length())
415  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:156
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.
421  {
422  springs.removeAll();
423  for (size_t i = 0; i < springsArray.length();i++)
424  {
425  springs.append(springsArray[i]);
426  }
427  }
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:156
Array< T > & removeAll()
Removes all the elements from the array.
Definition: Array.inline.h:315
size_t append(const T &value)
Appends a copy of value to the array.
Definition: Array.inline.h:292
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.
449  {
450  if ( index == 0 )
451  return;
452  for (size_t i = 0;i < springs.length(); i++)
453  {
454  if ( (springs[i].GetPointConstraint()->GetIndex()) == index)
455  springs.removeAt(i--);
456  else if (springs[i].GetPointConstraint()->GetIndex() > index)
457  springs[i].GetPointConstraint()->SetIndex(springs[i].GetPointConstraint()->GetIndex()-1);
458  }
459  }
size_t length() const
Returns the number of used elements (as opposed to simply allocated/reserved) in the array...
Definition: Array.inline.h:156
Array< T > & removeAt(size_t index)
Removes a single element from the array.
Definition: Array.imp.h:316
bool operator== ( const SSParticle b) const
inline
Remarks
Compares this class instance to another one
463  {
464  return mass == b.mass && drag == b.drag && pos == b.pos && vel == b.vel && force == b.force && springs == b.springs;
465  }

Friends And Related Function Documentation

friend class SpringSys
friend