3ds Max C++ API Reference
Loading...
Searching...
No Matches
SpringSys Class Reference

#include <springsys.h>

+ Inheritance diagram for SpringSys:

Public Member Functions

 SpringSys ()
 
 SpringSys (SpringSysClient *c, int count)
 
 ~SpringSys ()
 
SpringSysExport SpringSysoperator= (const SpringSys &from)
 
SpringSysExport SpringSys Copy (const SpringSys *from)
 
void SetReferenceTime (float t)
 
float GetReferenceTime ()
 
MaxSDK::Array< SSParticle > * GetParticles ()
 
SSParticleGetParticle (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)
 
- Public Member Functions inherited from BaseInterfaceServer
UtilExport BaseInterfaceGetInterface (Interface_ID id) override
 
virtual UtilExport int NumInterfaces () const
 
virtual UtilExport BaseInterfaceGetInterfaceAt (int i) const
 
virtual UtilExport ~BaseInterfaceServer ()
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor.
 
virtual UtilExport BaseInterfaceGetInterface (Interface_ID id)
 
template<class InterfaceType >
InterfaceType * GetTypedInterface ()
 

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)
 

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator.
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator.
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary.
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary.
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc.
 
- Protected Attributes inherited from BaseInterfaceServer
Tab< BaseInterface * > interfaces
 

Detailed Description

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

Description:
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.

Constructor & Destructor Documentation

◆ SpringSys() [1/2]

SpringSys ( )
inline
Remarks
Constructor.
540 {
541 client = NULL;
542 referenceTime = lastTime = 0.0f;
544 isValid = false;
545 }
#define NULL
Definition: autoptr.h:18
SpringSysExport void SetParticleCount(int count)

◆ SpringSys() [2/2]

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.
555 {
556 client = c;
557 referenceTime = lastTime = 0.0f;
558 SetParticleCount(count);
559 isValid = false;
560 }

◆ ~SpringSys()

~SpringSys ( )
inline
Remarks
Destructor.
563{}

Member Function Documentation

◆ operator=()

SpringSysExport SpringSys & operator= ( const SpringSys from)
Remarks
Assignment operator.

◆ Copy()

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.

◆ SetReferenceTime()

void SetReferenceTime ( float  t)
inline
Remarks
This method allows you to set the reference time.
Parameters:
float t

The reference time to set.
578{ referenceTime = t; }

◆ GetReferenceTime()

float GetReferenceTime ( )
inline
Remarks
This method returns the reference time.
580{ return referenceTime; }

◆ GetParticles()

MaxSDK::Array< SSParticle > * GetParticles ( )
inline
Remarks
This method returns a pointer to the array of spring system particles.
583{ return &parts;}

◆ GetParticle()

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 array.
589 { if (i >=0 && i< (int)parts.length()) return &(parts[i]);
590 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:160

◆ SetParticleCount()

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.

◆ SetInitialPosition()

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 array for which to set the initial position.

◆ SetInitialVelocity()

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 array for which to set the initial velocity.

◆ SetInitialBoneStates()

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 bone transformation matrices to set.

◆ Invalidate()

SpringSysExport void Invalidate ( )
Remarks
This method will invalidate the spring system and issue the re-computation of the spring system state.

◆ Solve()

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.

◆ GetPosition()

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 array.
protected:

◆ Load()

SpringSysExport IOResult Load ( ILoad iload)

◆ Save()

SpringSysExport IOResult Save ( ISave isave)

◆ GetTime()

float GetTime ( )
inlineprotected
Remarks
This method allows you to get the spring system last time.
Default Implementation:
{ return lastTime; }
650{ return lastTime; }

◆ SetTime()

void SetTime ( float  t)
inlineprotected
Remarks
This method allows you to set the spring system last time.
Parameters:
float t

The time to set.
Default Implementation:
{ lastTime = t; }
658{ lastTime = t; }

◆ Clear_Forces()

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 array of spring system particles.

◆ Compute_Forces()

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 array of spring system particles.

◆ ApplyDrag()

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 array of spring system particles.

◆ ApplyUnaryForces()

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 array of spring system particles.

◆ ComputeControlledParticleForce()

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 array of spring system particles.

◆ ApplySpring()

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 array of spring system particles.

◆ UpdateParticleState()

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.

◆ ComputeDerivative()

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.

◆ GetParticleState()

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.

◆ SetParticleState()

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.

◆ ScaleVectors()

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.

◆ AddVectors()

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.