H3D API
2.4.1
|
The ParticleSystem node specifies a complete particle system. More...
#include <H3D/ParticleSystem.h>
Public Member Functions | |
ParticleSystem (Inst< SFAppearanceNode > _appearance=0, Inst< SFGeometryNode > _geometry=0, Inst< SFHapticGeometry > _hapticGeometry=0, Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< SFVec3f > _bboxCenter=0, Inst< SFVec3f > _bboxSize=0, Inst< DisplayList > _displayList=0, Inst< SFBool > _createParticles=0, Inst< SFBool > _enabled=0, Inst< SFFloat > _lifetimeVariation=0, Inst< SFInt32 > _maxParticles=0, Inst< SFFloat > _particleLifetime=0, Inst< SFVec2f > _particleSize=0, Inst< SFBool > _isActive=0, Inst< SFColorNode > _colorRamp=0, Inst< MFFloat > _colorKey=0, Inst< SFEmitterNode > _emitter=0, Inst< SFString > _geometryType=0, Inst< MFPhysicsModelNode > _physics=0, Inst< SFTextureCoordinate > _texCoordRamp=0, Inst< MFFloat > _texCoordKey=0) | |
Constructor. | |
virtual void | initialize () |
Sets up the bound field using the bboxCenter and bboxSize fields. More... | |
virtual void | render () |
Render the shape using OpenGL. | |
virtual void | traverseSG (TraverseInfo &ti) |
Traverse the scenegraph. Calls traverseSG on appeance and geometry. | |
X3DParticleEmitterNode::Particle::ParticleType | getCurrentParticleType () |
Returns the enum equivalent to the particle type specified with the geometryType field. | |
![]() | |
X3DShapeNode (Inst< SFAppearanceNode > _appearance=0, Inst< SFGeometryNode > _geometry=0, Inst< SFHapticGeometry > _hapticGeometry=0, Inst< SFNode > _metadata=0, Inst< SFBound > _bound=0, Inst< SFVec3f > _bboxCenter=0, Inst< SFVec3f > _bboxSize=0, Inst< DisplayList > _displayList=0) | |
Constructor. | |
virtual bool | lineIntersect (const Vec3f &from, const Vec3f &to, LineIntersectResult &result) |
Detect intersection between a line segment and the X3DGeometryNode in the field geometry. More... | |
virtual void | closestPoint (const Vec3f &p, NodeIntersectResult &result) |
Find closest point on the node in the field geometry. More... | |
virtual bool | movingSphereIntersect (H3DFloat radius, const Vec3f &from, const Vec3f &to, NodeIntersectResult &result) |
Detect collision between a moving sphere and the geometry in the geometry field. More... | |
![]() | |
X3DChildNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
![]() | |
X3DNode (Inst< SFNode > _metadata=0) | |
Constructor. | |
X3DMetadataObject * | getMetadataByName (const string &_name) |
Given a name, the first X3DMetadataObject in the metadata field that matches that name is returned. More... | |
![]() | |
Node () | |
Constructor. | |
virtual Node * | clone (bool deepCopy=true, DeepCopyMap *deepCopyMap=NULL) |
Returns a new instance of this node type with the same state as this one. More... | |
virtual | ~Node () |
Destructor. | |
X3DPrototypeInstance * | getProtoInstanceParent () |
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that node. More... | |
void | setProtoInstanceParent (X3DPrototypeInstance *p) |
Set the X3DPrototypeInstance this node is the the root node if applicaple. | |
virtual string | defaultXMLContainerField () |
Returns the default xml containerField attribute value. More... | |
virtual Field * | getField (const string &_name) const |
return a pointer to the field specified by name within this instance | |
int | addDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
int | removeDestructCallback (void(*func)(Node *, void *), void *args) |
Add a callback function to be run on destruction of node. More... | |
![]() | |
H3DBoundedObject (Inst< SFBound > _bound=0) | |
Constructor. | |
![]() | |
H3DDisplayListObject (Inst< DisplayList > _displayList=0) | |
Constructor. | |
Static Public Member Functions | |
static H3DFloat | getVariationValue (H3DFloat main_value, H3DFloat variation) |
Returns a random value in the range main_value +- (variation * main_value ) | |
static H3DFloat | getRandomValue (H3DFloat min, H3DFloat max) |
Returns a random value in the given range. | |
static Vec3f | getRandomPointOnUnitSphere () |
Returns a random point on the unit sphere. | |
static const ParticleSystemList & | getAllParticleSystems () |
Returns a list of all current ParticleSystem instances. | |
![]() | |
static unsigned int | nrNodesAlive () |
Returns the nr of nodes currently alive, i.e. nodes created but not destructed. | |
static int | nrNodesCreated () |
Returns the number of nodes created in total since the start of the program. | |
Public Attributes | |
H3DUniquePtr< SFBool > | createParticles |
The createParticles field is used to control whether any further new particles should be created. More... | |
H3DUniquePtr< SFBool > | enabled |
The enabled field controls whether this ParticleSystem is currently active and rendering particles this frame. More... | |
H3DUniquePtr< SFFloat > | lifetimeVariation |
The lifetimeVariation field controls the variation in a particles lifetime. More... | |
H3DUniquePtr< SFInt32 > | maxParticles |
The maximum number of particles to be generated. More... | |
H3DUniquePtr< SFFloat > | particleLifetime |
The particleLifetime field controls the lifetime of a particle i.e. More... | |
H3DUniquePtr< SFVec2f > | particleSize |
The particleSize field describes the dimensions in metres of the width and height of each particle. More... | |
H3DUniquePtr< SFBool > | isActive |
The isActive field indicates whether the particle system is currently running, based on the setup of the node. More... | |
H3DUniquePtr< SFColorNode > | colorRamp |
The colorRamp field holds a series of colour values to be used at the given colorKey points in time for the particle over its lifetime. More... | |
H3DUniquePtr< MFFloat > | colorKey |
The colorKey field represents the time of the particle in seconds and are the keys to use for the colorRamp field. More... | |
H3DUniquePtr< SFEmitterNode > | emitter |
The emitter field specifies the type of emitter geometry and properties that the particles are given for their initial positions. More... | |
H3DUniquePtr< SFString > | geometryType |
The geometryType field specifies the type of geometry that should be used to represent individual particles. More... | |
H3DUniquePtr< MFPhysicsModelNode > | physics |
The physics field contains the physics models that should affect the particles after they have been created, e.g. More... | |
H3DUniquePtr< SFTextureCoordinate > | texCoordRamp |
The texCoordRamp fields control the texture coordinates of the provided texture(s) in the Appearance node, over time. More... | |
H3DUniquePtr< MFFloat > | texCoordKey |
The colorKey field represents the time of the particle in seconds and are the keys to use for the texCoordRamp field. More... | |
![]() | |
H3DUniquePtr< SFAppearanceNode > | appearance |
The field containing the X3DAppearance node to be used when rendering the shape. More... | |
H3DUniquePtr< SFGeometryNode > | geometry |
Contains the X3DGeometryNode to be rendered. More... | |
H3DUniquePtr< SFHapticGeometry > | hapticGeometry |
If specified, contains a X3DGeometryNode to be rendered haptically. More... | |
H3DUniquePtr< SFShadowObjectNode > | shadowVolume |
If specified, contains a H3DShadowObjectNode to be used for shadows. More... | |
![]() | |
H3DUniquePtr< SFNode > | metadata |
Meta data about the node. More... | |
![]() | |
H3DUniquePtr< SFVec3f > | bboxCenter |
Specifies a the center of an axis-aligned bounding box enclosing the node. More... | |
H3DUniquePtr< SFVec3f > | bboxSize |
Specifies a the size of an axis-aligned bounding box enclosing the node. More... | |
![]() | |
H3DUniquePtr< SFBound > | bound |
The field containing the bound object. More... | |
![]() | |
H3DUniquePtr< DisplayList > | displayList |
The DisplayList instance handling the OpenGL caching of this object. | |
Static Public Attributes | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
static bool | disable_lighting_if_no_app = true |
Set to true if lighting should be disabled when no Appearance or Material node has been specified as per X3D spec. More... | |
![]() | |
static H3DNodeDatabase | database |
The H3DNodeDatabase for this node. | |
Additional Inherited Members | |
![]() | |
enum | GeometryRenderMode { TRANSPARENT_ONLY , TRANSPARENT_FRONT , TRANSPARENT_BACK , SOLID , ALL } |
Tells which type of geometry should be rendered. More... | |
typedef DependentSFNode< X3DAppearanceNode, FieldRef< H3DDisplayListObject, H3DDisplayListObject::DisplayList, &H3DDisplayListObject::displayList >, true > | SFAppearanceNode |
SFAppearanceNode is dependent on the displayList field of its encapsulated X3DAppearanceNode node, i.e. More... | |
typedef TypedSFNode< X3DGeometryNode > | SFHapticGeometry |
SFHapticGeometry contains a X3DGeometryNode. | |
![]() | |
typedef std::map< Node *, Node * > | DeepCopyMap |
A map type used during a deep copy clone() to map from original nodes to cloned nodes. | |
![]() | |
void | cloneFieldValue (Field &_from, Field &_to, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for the clone() method. More... | |
![]() | |
static Node * | getClonedInstance (Node *original, bool deepCopy, DeepCopyMap &deepCopyMap) |
A helper function for nodes that implement clone() More... | |
The ParticleSystem node specifies a complete particle system.
The geometryType field specifies the type of geometry that should be used to represent individual particles. Typically, a particle is calculated as a point in space at which the geometry is placed and then rendered using the appearance attributes.
The types of geometry are defined to render in the following way:
The geometry field specifies the geometry to be used for each particle when the geometryType field has value "GEOMETRY".
The appearance field holds information that is used for the geometry. All effects, such as material colours and/or multi-textures, are applied to each particle. If a texture coordinate ramp and key is supplied with this geometry, it shall be used in preference to any automatic texture coordinate generation. If automatic texture coordinate generation is used, results shall be based on the entire volume that the particles consume, not locally applied to each particle.
Procedural shaders may also be supplied. The particle system shall manage the position of all particles each frame. This position becomes the initial geometry input to the shader.
The emitter field specifies the type of emitter geometry and properties that the particles are given for their initial positions. After being created, the individual particles are then manipulated according to the physics model(s) specified in the physics field.
The colorRamp and colorKey fields specify how to change the base colour of the particle over the lifetime of an individual particle. The colorKey field represents the time of the particle in seconds, while the colorRamp field holds a series of colour values to be used at the given key points in time. Between keys, colour values are interpreted in a linear HSV space, using the same rules defined for the ColorInterpolator node. The colour values are defined as per-vertex colour values. Consequently, if an appearance node with material is provided, the material properties will override the colour ramp.
The isActive outputOnly field indicates whether the particle system is currently running, based on the setup of the node.
The isActive field sends a value of FALSE when activity has stopped occurring. A particle system without an emitter set can never be active. If the emitter is defined by an EXTERNPROTO that has not yet resolved, isActive shall initially be FALSE, until the point the EXTERNPROTO has loaded and is verified as being a correct node type. If these validity checks pass, isActive is set to TRUE and this defines the local time zero to start the particle effects.
The enabled field controls whether this ParticleSystem is currently active and rendering particles this frame. Setting this value to FALSE will immediately remove all visible particles from the scene from the next frame onwards. Setting the field to TRUE will start the system again from a local time zero. It does not start off from where it was previously. In doing so, it will issue another value of TRUE for isActive. If a value of FALSE is set for enabled, isActive will also be set to FALSE.
The createParticles field is used to control whether any further new particles should be created. This allows the user to stop production of new particles, but keep those already existing in the scene to continue to animate. This differs from the enabled field that would immediately remove all particles. The createParticles field keeps the existing particles in existence until the end of their lifetimes. If there are no particles left in the scene, the system is still considered both active and enabled.
The particleSize field describes the dimensions in metres of the width and height of each particle. Changing this value dynamically will only change new particles created after the change. Particles created before this timestamp will remain at the old size. This field only effects particles using "LINE", "QUAD", "SPRITE", and "TRIANGLE" geometry types.
The texCoordRamp and texCoordKey fields control the texture coordinates of the provided texture(s) in the Appearance node, over time. Particle systems frequently like to change the texture on a particle as it ages, yet there is no good way of accomplishing this through standard interpolators because interpolators have no concept of particle time. This pair of fields hold time-dependent values for the texture coordinates to be applied to the particle. When a particle reaches the next time stamp it moves to the next set of texture coordinates. There is no interpolation of the texture coordinates, just sequenced according to the times defined by texCoordKey.
The node placed in texCoordRamp shall have enough values to work with the numbers required by geometryType. The following numbers and rules for mapping texture coordinates to the quad shall be used:
Examples:
|
virtual |
Sets up the bound field using the bboxCenter and bboxSize fields.
If bboxSize is (-1, -1, -1) the bound will be the bound of the geometry field. Otherwise it will be a BoxBound with center and origin determined by the bboxCenter and bboxOrigin fields.
Reimplemented from H3D::X3DShapeNode.
References H3D::X3DBoundedObject::bboxCenter, H3D::X3DBoundedObject::bboxSize, H3D::H3DBoundedObject::bound, H3D::BoxBound::center, H3DUtil::RefCountedClass::initialize(), and H3D::BoxBound::size.
H3DUniquePtr< MFFloat > H3D::ParticleSystem::colorKey |
The colorKey field represents the time of the particle in seconds and are the keys to use for the colorRamp field.
Access type: inputOutput
H3DUniquePtr< SFColorNode > H3D::ParticleSystem::colorRamp |
The colorRamp field holds a series of colour values to be used at the given colorKey points in time for the particle over its lifetime.
Between keys, colour values are interpreted in a linear HSV space, using the same rules defined for the ColorInterpolator node. The colour values are defined as per-vertex colour values. Consequently, if an appearance node with material is provided, the material properties will override the colour ramp.
Access type: inputOutput
H3DUniquePtr< SFBool > H3D::ParticleSystem::createParticles |
The createParticles field is used to control whether any further new particles should be created.
This allows the user to stop production of new particles, but keep those already existing in the scene to continue to animate. This differs from the enabled field that would immediately remove all particles.
Access type: inputOutput
Default value: TRUE
Referenced by ParticleSystem(), and traverseSG().
H3DUniquePtr< SFEmitterNode > H3D::ParticleSystem::emitter |
The emitter field specifies the type of emitter geometry and properties that the particles are given for their initial positions.
After being created, the individual particles are then manipulated according to the physics model(s) specified in the physics field.
Access type: inputOutput
Referenced by traverseSG().
H3DUniquePtr< SFBool > H3D::ParticleSystem::enabled |
The enabled field controls whether this ParticleSystem is currently active and rendering particles this frame.
Setting this value to FALSE will immediately remove all visible particles from the scene from the next frame onwards. Setting the field to TRUE will start the system again from a local time zero. It does not start off from where it was previously. In doing so, it will issue another value of TRUE for isActive. If a value of FALSE is set for enabled, isActive will also be set to FALSE.
Access type: inputOutput
Default value: TRUE
Referenced by ParticleSystem(), and traverseSG().
H3DUniquePtr< SFString > H3D::ParticleSystem::geometryType |
The geometryType field specifies the type of geometry that should be used to represent individual particles.
Typically, a particle is calculated as a point in space at which the geometry is placed and then rendered using the appearance attributes.
Access type: inputOutput Default value: "QUAD" Allowed values: "LINE", "POINT", "QUAD", "SPRITE", "TRIANGLE", "GEOMETRY"
Referenced by getCurrentParticleType(), ParticleSystem(), render(), and traverseSG().
H3DUniquePtr< SFBool > H3D::ParticleSystem::isActive |
The isActive field indicates whether the particle system is currently running, based on the setup of the node.
Access type: outputOnly
H3DUniquePtr< SFFloat > H3D::ParticleSystem::lifetimeVariation |
The lifetimeVariation field controls the variation in a particles lifetime.
It describes the allowed deviation in particle liftime from the value in particleLifetime. The variation is the maximum bound of that value, described as a proportion of the original value. A variation value of zero does not allow any randomness.
Access type: inputOutput Default value: 0.25
Referenced by ParticleSystem().
H3DUniquePtr< SFInt32 > H3D::ParticleSystem::maxParticles |
The maximum number of particles to be generated.
Access type: inputOutput Default value: 200
Referenced by ParticleSystem().
H3DUniquePtr< SFFloat > H3D::ParticleSystem::particleLifetime |
The particleLifetime field controls the lifetime of a particle i.e.
the time in seconds the particle exists from the point it is being emitted. See also the lifetimeVariation field.
Access type: inputOutput Default value: 5
Referenced by ParticleSystem().
H3DUniquePtr< SFVec2f > H3D::ParticleSystem::particleSize |
The particleSize field describes the dimensions in metres of the width and height of each particle.
Changing this value dynamically will only change new particles created after the change. Particles created before this timestamp will remain at the old size. This field only effects particles using "LINE", "QUAD", "SPRITE", and "TRIANGLE" geometry types.
Access type: inputOutput Default value: 0.02 0.02
Referenced by ParticleSystem(), and traverseSG().
H3DUniquePtr< MFPhysicsModelNode > H3D::ParticleSystem::physics |
The physics field contains the physics models that should affect the particles after they have been created, e.g.
gravity and wind effects.
Access type: inputOutput
Referenced by traverseSG().
H3DUniquePtr< MFFloat > H3D::ParticleSystem::texCoordKey |
The colorKey field represents the time of the particle in seconds and are the keys to use for the texCoordRamp field.
Access type: inputOutput
H3DUniquePtr< SFTextureCoordinate > H3D::ParticleSystem::texCoordRamp |
The texCoordRamp fields control the texture coordinates of the provided texture(s) in the Appearance node, over time.
Access type: inputOutput