LightWrap++
AC++wrapperfortheLightWave3DSDK
lwpp::ParticleServices Class Reference

#include <particle_services.h>

+ Inheritance diagram for lwpp::ParticleServices:
+ Collaboration diagram for lwpp::ParticleServices:

List of all members.

Public Member Functions

 ParticleServices (LWPSysID _prtsv_id=0)
 Constructor.
LWPSBufID addBuffer (LWPSBufDesc lwbufdesc)
int addParticle ()
void attach (LWItemID lwitid)
void cleanup ()
LWPSysID create (int flags, int type=LWPST_PRTCL)
int destroy ()
void detach (LWItemID lwitid)
void * getAge (int index)
template<typename T >
void getBufferData (LWPSBufID buffer_id, T &data)
LWPSBufID getBufferID (int bufferFlag)
void * getCollisionAge (int index)
void * getForce (int index)
LWPSysID getID () const
 Returns the ID of the particle service.
void * getLink (int index)
void * getMass (int index)
void getParticle (LWPSBufID buffer_id, int index, void *data)
int getParticleCount ()
void * getParticleID (int index)
char getParticleState (int index)
LWPSysID * getParticleSystems (LWItemID lwitid)
void getPosition (int index, float *position)
Point3f getPosition (int index)
void * getPressure (int index)
void * getRelativeAge (int index)
void getRGBA (int index, unsigned char *RGBA)
void getRotation (int index, float *rotation)
void getScale (int index, float *scale)
void getSize (int index, float *size)
void * getStartPosition (int index, float *sposition)
void getStartRotation (int index, float *srotation)
void getStartScale (int index, float *sscale)
void * getTemperature (int index)
void getVelocity (int index, float *velocity)
int init (int num_particles)
bool isAlive (int index)
bool isDead (int index)
bool isLimbo (int index)
void load (LWLoadState *loadstate)
void removeParticle (int index)
void save (LWSaveState *savestate)
void setAge (int index, float *age)
template<typename T >
void setBufferData (LWPSBufID buffer_id, T data)
void setCollisionAge (int index, float cage)
void setForce (int index, float force)
void setLink (int index, int link)
void setMass (int index, float mass)
void setParticle (LWPSBufID buffer_id, int index, void *data)
void setParticleAlive (int index)
void setParticleDead (int index)
void setParticleID (int index, int PID)
void setParticleLimbo (int index)
void setParticleState (int index, char state)
void setPosition (int index, float *position)
void setPosition (int index, Point3d &position)
void setPressure (int index, float pressure)
void setRelativeAge (int index, float rage)
void setRGBA (int index, unsigned char *RGBA)
void setRotation (int index, float rotation)
void setScale (int index, float scale)
void setSize (int index, float size)
void setStartPosition (int index, float sposition)
void setStartRotation (int index, float srotation)
void setStartScale (int index, float sscale)
void setTemperature (int index, float temperature)
void setVelocity (int index, float velocity)

Protected Member Functions

bool _acquireGlobal ()
virtual bool available () const
 Check if the global is available.
virtual LWPSysFuncs * getGlobal ()
 Get the pointer to the global.
LWPSysFuncs * operator-> ()
 Get the pointer to the global.

Static Protected Attributes

static LWPSysFuncs * globPtr
 Pointer to the global functions.

Detailed Description

Allow you to create particle systems and to read and write particle data. Particles are typically used by volumetric renderers to define the extent and local density of a volume.

The host side of the particles global manages a database of particle systems. The global supplies methods for adding, deleting and reading particle data in the database. Having such a database allows one plug-in to create particle systems that others can later use.

You can allocate, initialize and read particle data either individually (one particle at a time) or all at once. Which approach you take will depend primarily on where the data comes from and how you use it.


Constructor & Destructor Documentation

lwpp::ParticleServices::ParticleServices ( LWPSysID  _prtsv_id = 0)
inline

Constructor.


Member Function Documentation

bool lwpp::GlobalBase< LWPSysFuncs >::_acquireGlobal ( )
inlineprotectedinherited
LWPSBufID lwpp::ParticleServices::addBuffer ( LWPSBufDesc  lwbufdesc)
inline

Add a custom per-particle buffer. Call this before any calls to init or addParticle. (The predefined buffer types should be added when create is called.) The structure used to define the buffer is described below. The buffer ID returned by this function can be used with the functions that get and set buffer data.

The function uses a buffer descriptor to define the buffer to be added. typedef struct st_LWPSBufDesc { const char *name; int dataType; int dataSize; } LWPSBufDesc;

name A string that names the buffer. In the future, this may allow users or plug-ins to refer to the buffer by name. dataType The data type of the data in the buffer. LWPSBT_FLOAT 0 LWPSBT_INT 1 LWPSBT_CHAR 2 dataSize The number of values per particle in the buffer (and not the number of bytes).

int lwpp::ParticleServices::addParticle ( )
inline

Add a particle.

void lwpp::ParticleServices::attach ( LWItemID  lwitid)
inline

Associate a particle system with an item in the scene, usually an object. More than one particle system can be attached to an item, and more than one item can share the same particle system. Attaching a particle system to an item makes it possible for others, Hypervoxels in particular, to use the getPSys function to find it.

virtual bool lwpp::GlobalBase< LWPSysFuncs >::available ( ) const
inlinevirtualinherited

Check if the global is available.

void lwpp::ParticleServices::cleanup ( )
inline

Frees the memory allocated by init and addParticle.

LWPSysID lwpp::ParticleServices::create ( int  flags,
int  type = LWPST_PRTCL 
)
inline

Create a particle system. The flags indicate which buffers should be allocated for the particles and can be any of the following, combined using bitwise-or. LWPSB_POS position float[3] LWPSB_SIZ size float LWPSB_SCL scale float[3] LWPSB_ROT rotation float[3] LWPSB_VEL velocity float[3] LWPSB_AGE age float LWPSB_FCE force float LWPSB_PRS pressure float LWPSB_TMP temperature float LWPSB_MAS mass float LWPSB_LNK link to particle (for trails) int LWPSB_ID ID (unique index for the particle) int LWPSB_ENB enable state (dead/alive/limbo) char LWPSB_RGBA display color and alpha char[4] LWPSB_CAGE time since last collision float

The particle type can be either LWPST_PRTCL (single points) or LWPST_TRAIL (line segments). LWPST_TRAIL particle systems has the LWPSB_LNK buffer for the second point in each trail created automatically.

int lwpp::ParticleServices::destroy ( )
inline

Free the particle system.

void lwpp::ParticleServices::detach ( LWItemID  lwitid)
inline

Remove the association between a particle system and an item.

void* lwpp::ParticleServices::getAge ( int  index)
inline

Returns the Age of a particle

Parameters:
indexIndex of the particle
template<typename T >
void lwpp::ParticleServices::getBufferData ( LWPSBufID  buffer_id,
T &  data 
)
inline

Set the buffer values for all particles. The data is an array of the appropriate type for the buffer, with a number of entries equal to the number of particles. Use setParticle to set the buffer data for one particle at a time.

LWPSBufID lwpp::ParticleServices::getBufferID ( int  bufferFlag)
inline

Returns a buffer ID for one of the predefined buffers. This is used with the functions that get and set buffer data. The second argument is one of the buffer flags passed to create.

void* lwpp::ParticleServices::getCollisionAge ( int  index)
inline

Returns the Collision Age (time since last collision) of a particle

Parameters:
indexIndex of the particle
void* lwpp::ParticleServices::getForce ( int  index)
inline

Returns the Force of a particle

Parameters:
indexIndex of the particle
virtual LWPSysFuncs * lwpp::GlobalBase< LWPSysFuncs >::getGlobal ( )
inlinevirtualinherited

Get the pointer to the global.

LWPSysID lwpp::ParticleServices::getID ( void  ) const
inline

Returns the ID of the particle service.

void* lwpp::ParticleServices::getLink ( int  index)
inline

Returns the particle Link of a particle

Parameters:
indexIndex of the particle
void* lwpp::ParticleServices::getMass ( int  index)
inline

Returns the Mass of a particle

Parameters:
indexIndex of the particle
void lwpp::ParticleServices::getParticle ( LWPSBufID  buffer_id,
int  index,
void *  data 
)
inline

Get the buffer value for a particle. Particles are numbered from 0 to getPCount-1 in the order in which they're added.

int lwpp::ParticleServices::getParticleCount ( )
inline

Returns the number of particles.

void* lwpp::ParticleServices::getParticleID ( int  index)
inline

Returns the particle ID of a particle

Parameters:
indexIndex of the particle
char lwpp::ParticleServices::getParticleState ( int  index)
inline

Returns the particle state of a particle

Parameters:
indexIndex of the particle Particle state values #define LWPST_DEAD 0 #define LWPST_ALIVE 1 #define LWPST_LIMBO 2
LWPSysID* lwpp::ParticleServices::getParticleSystems ( LWItemID  lwitid)
inline

Returns a NULL-terminated array of particle system IDs that have been associated with the item by the attach function.

void lwpp::ParticleServices::getPosition ( int  index,
float *  position 
)
inline

Returns the position of a particle

Parameters:
indexIndex of the particle
positionPointer to a float[3] array were store the position of the particle
Point3f lwpp::ParticleServices::getPosition ( int  index)
inline

Returns the position of a particle

Parameters:
indexIndex of the particle
void* lwpp::ParticleServices::getPressure ( int  index)
inline

Returns the Pressure of a particle

Parameters:
indexIndex of the particle
void* lwpp::ParticleServices::getRelativeAge ( int  index)
inline

Returns the Relative Age (provide information about the life expectancy) of a particle

Parameters:
indexIndex of the particle
void lwpp::ParticleServices::getRGBA ( int  index,
unsigned char *  RGBA 
)
inline

Returns the RGBA of a particle

Parameters:
indexIndex of the particle
RGBAPointer to a char[4] array were store the RGBA of the particle
void lwpp::ParticleServices::getRotation ( int  index,
float *  rotation 
)
inline

Returns the rotation of a particle

Parameters:
indexIndex of the particle
rotationPointer to a float[3] array were store the rotation of the particle
void lwpp::ParticleServices::getScale ( int  index,
float *  scale 
)
inline

Returns the scale of a particle

Parameters:
indexIndex of the particle
scalePointer to a float[3] array were store the scale of the particle
void lwpp::ParticleServices::getSize ( int  index,
float *  size 
)
inline

Returns the Size of a particle

Parameters:
[in]indexIndex of the particle
[out]sizeA float storing containing the size
void* lwpp::ParticleServices::getStartPosition ( int  index,
float *  sposition 
)
inline

Returns the start position of a particle

Parameters:
indexIndex of the particle
spositionPointer to a float[3] array were store the start position of the particle
void lwpp::ParticleServices::getStartRotation ( int  index,
float *  srotation 
)
inline

Returns the start rotation of a particle

Parameters:
indexIndex of the particle
srotationPointer to a float[3] array were store the rotation of the particle
void lwpp::ParticleServices::getStartScale ( int  index,
float *  sscale 
)
inline

Returns the start scale of a particle

Parameters:
indexIndex of the particle
sscalePointer to a float[3] array were store the start scale of the particle
void* lwpp::ParticleServices::getTemperature ( int  index)
inline

Returns the Temperature of a particle

Parameters:
indexIndex of the particle
void lwpp::ParticleServices::getVelocity ( int  index,
float *  velocity 
)
inline

Returns the velocity of a particle

Parameters:
indexIndex of the particle
velocityPointer to a float[3] array were store the velocity of the particle
int lwpp::ParticleServices::init ( int  num_particles)
inline

Allocate memory for the particles. This is equivalent to calling the addParticle function nparticles times.

bool lwpp::ParticleServices::isAlive ( int  index)
inline

Returns true if the particle is Alive

Parameters:
indexIndex of the particle
bool lwpp::ParticleServices::isDead ( int  index)
inline

Returns true if the particle is Dead

Parameters:
indexIndex of the particle
bool lwpp::ParticleServices::isLimbo ( int  index)
inline

Returns true if the particle is in Limbo

Parameters:
indexIndex of the particle
void lwpp::ParticleServices::load ( LWLoadState *  loadstate)
inline

Read the particle system data from a file. This will typically be used by handler load callbacks.

LWPSysFuncs * lwpp::GlobalBase< LWPSysFuncs >::operator-> ( )
inlineinherited

Get the pointer to the global.

void lwpp::ParticleServices::removeParticle ( int  index)
inline

Remove a particle.

void lwpp::ParticleServices::save ( LWSaveState *  savestate)
inline

Write the particle system data to a file. This will typically be used by handler save callbacks.

void lwpp::ParticleServices::setAge ( int  index,
float *  age 
)
inline

Changes the Age of a particle

Parameters:
indexIndex of the particle
agePointer to a float with the new Age of the particle
template<typename T >
void lwpp::ParticleServices::setBufferData ( LWPSBufID  buffer_id,
data 
)
inline

Set the buffer values for all particles. The data is an array of the appropriate type for the buffer, with a number of entries equal to the number of particles. Use setParticle to set the buffer data for one particle at a time.

void lwpp::ParticleServices::setCollisionAge ( int  index,
float  cage 
)
inline

Changes the Collision Age (time since last collision) of a particle

Parameters:
indexIndex of the particle
cagePointer to a float with the new Collision Age of the particle
void lwpp::ParticleServices::setForce ( int  index,
float  force 
)
inline

Changes the Force of a particle

Parameters:
indexIndex of the particle
forcePointer to a float with the new Force of the particle
void lwpp::ParticleServices::setLink ( int  index,
int  link 
)
inline

Changes the particle Link of a particle

Parameters:
indexIndex of the particle
linkPointer to a float with the new Mass of the particle
void lwpp::ParticleServices::setMass ( int  index,
float  mass 
)
inline

Changes the Mass of a particle

Parameters:
indexIndex of the particle
massPointer to a float with the new Mass of the particle
void lwpp::ParticleServices::setParticle ( LWPSBufID  buffer_id,
int  index,
void *  data 
)
inline

Set the buffer value for a particle. Particles are numbered from 0 to getPCount-1 in the order in which they're added.

void lwpp::ParticleServices::setParticleAlive ( int  index)
inline

Changes the state of a particle to Alive

Parameters:
indexIndex of the particle
void lwpp::ParticleServices::setParticleDead ( int  index)
inline

Changes the state of a particle to Dead

Parameters:
indexIndex of the particle
void lwpp::ParticleServices::setParticleID ( int  index,
int  PID 
)
inline

Changes the particle ID of a particle

Parameters:
indexIndex of the particle
PIDPointer to a int PID the new particle ID of the particle
void lwpp::ParticleServices::setParticleLimbo ( int  index)
inline

Changes the state of a particle to Limbo

Parameters:
indexIndex of the particle
void lwpp::ParticleServices::setParticleState ( int  index,
char  state 
)
inline

Changes the state of a particle

Parameters:
indexIndex of the particle
statePointer to a char with the new state of the particle
void lwpp::ParticleServices::setPosition ( int  index,
float *  position 
)
inline

Changes the position of a particle

Parameters:
indexIndex of the particle
positionPointer to a float[3] array were is the new position of the particle
void lwpp::ParticleServices::setPosition ( int  index,
Point3d position 
)
inline

Changes the position of a particle

Parameters:
indexIndex of the particle
positionPointer to a Point3D were is the new position of the particle
void lwpp::ParticleServices::setPressure ( int  index,
float  pressure 
)
inline

Changes the Pressure of a particle

Parameters:
indexIndex of the particle
pressurePointer to a float with the new Pressure of the particle
void lwpp::ParticleServices::setRelativeAge ( int  index,
float  rage 
)
inline

Changes the Relative Age (provide information about the life expectancy) of a particle

Parameters:
indexIndex of the particle
ragePointer to a float with the new Relative Age of the particle
void lwpp::ParticleServices::setRGBA ( int  index,
unsigned char *  RGBA 
)
inline

Changes the the RGBA of a particle

Parameters:
indexIndex of the particle
RGBAPointer Pointer to a char[4] array were is the new RGBA of the particle
void lwpp::ParticleServices::setRotation ( int  index,
float  rotation 
)
inline

Changes the rotation of a particle

Parameters:
indexIndex of the particle
rotationPointer to a float[3] array were is the new rotation of the particle
void lwpp::ParticleServices::setScale ( int  index,
float  scale 
)
inline

Changes the scale of a particle

Parameters:
indexIndex of the particle
scalePointer to a float[3] array were is the new scale of the particle
void lwpp::ParticleServices::setSize ( int  index,
float  size 
)
inline

Changes the Size of a particle

Parameters:
[in]indexIndex of the particle
[in]sizea float with the new Size of the particle
void lwpp::ParticleServices::setStartPosition ( int  index,
float  sposition 
)
inline

Changes the start position of a particle

Parameters:
indexIndex of the particle
spositionPointer to a float[3] array were is the new start position of the particle
void lwpp::ParticleServices::setStartRotation ( int  index,
float  srotation 
)
inline

Changes the start rotation of a particle

Parameters:
indexIndex of the particle
srotationPointer to a float[3] array were is the new start rotation of the particle
void lwpp::ParticleServices::setStartScale ( int  index,
float  sscale 
)
inline

Changes the start scale of a particle

Parameters:
indexIndex of the particle
sscalePointer to a float[3] array were is the new start scale of the particle
void lwpp::ParticleServices::setTemperature ( int  index,
float  temperature 
)
inline

Changes the Temperature of a particle

Parameters:
indexIndex of the particle
temperaturePointer to a float with the new Temperature of the particle
void lwpp::ParticleServices::setVelocity ( int  index,
float  velocity 
)
inline

Changes the velocity of a particle

Parameters:
indexIndex of the particle
velocityPointer to a float[3] array were is the new velocity of the particle

Member Data Documentation

LWPSysFuncs * lwpp::GlobalBase< LWPSysFuncs >::globPtr
staticprotectedinherited

Pointer to the global functions.


The documentation for this class was generated from the following file: