#include
<MPxEmitterNode.h>
MPxEmitterNode allows the creation and manipulation of dependency graph nodes representing particle emitters.
Public Types |
|
enum | MEmitterType
{ kDirectional = 0, kOmni, kSurface, kCurve, kVolume } |
Types of emitters. More... |
|
Public Member Functions |
|
MPxEmitterNode () | |
virtual | ~MPxEmitterNode () |
virtual MPxNode::Type | type () const |
virtual MStatus | compute (const MPlug &plug, MDataBlock &dataBlock) |
virtual void | draw (M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus) |
MEmitterType | getEmitterType (MDataBlock &block) |
MObject | getOwnerShape () |
MTime | getCurrentTime (MDataBlock &block) |
MTime | getStartTime (int plugIndex, MDataBlock &block) |
MTime | getDeltaTime (int plugIndex, MDataBlock &block) |
int | getRandomSeed (int plugIndex, MDataBlock &block) |
void | getRandomState (int plugIndex, MDataBlock &block) |
void | setRandomState (int plugIndex, MDataBlock &block) |
void | resetRandomState (int plugIndex, MDataBlock &block) |
double | randgen () |
double | getRate (MDataBlock &block) |
double | getMinDistance (MDataBlock &block) |
double | getMaxDistance (MDataBlock &block) |
MPoint | getWorldPosition () |
MMatrix | getWorldMatrix () |
bool | volumePrimitiveBoundingBox (MBoundingBox &box) |
bool | volumePrimitivePointInside (const MPoint &worldPoint, const MMatrix &emitterWorldMatrix) |
double | volumePrimitiveDistanceFromAxis (const MPoint &worldPoint, const MMatrix &emitterWorldMatrix) |
bool | hasValidEmission2dTexture (const MObject &texAttr, MStatus *status=NULL) |
MStatus | evalEmission2dTexture (const MObject &texAttr, MDoubleArray &uCoords, MDoubleArray &vCoords, MVectorArray *resultColors, MDoubleArray *resultAlphas) |
Static Public Attributes |
|
static MObject | mEmitterType |
emitter type attribute |
|
static MObject | mRate |
rate attribute |
|
static MObject | mSpeed |
speed attribute |
|
static MObject | mDirection |
direction attribute |
|
static MObject | mDirectionX |
X component of mDirection. |
|
static MObject | mDirectionY |
Y component of mDirection. |
|
static MObject | mDirectionZ |
Z component of mDirection. |
|
static MObject | mOwnerPosData |
owner postion attribute, multi |
|
static MObject | mOwnerVelData |
owner velocity attribute, multi |
|
static MObject | mOwnerCentroid |
owner centroid attribute |
|
static MObject | mOwnerCentroidX |
X component of mOwnerCentroid. |
|
static MObject | mOwnerCentroidY |
Y component of mOwnerCentroid. |
|
static MObject | mOwnerCentroidZ |
Z component of mOwnerCentroid. |
|
static MObject | mSweptGeometry |
input swept geometry attribute |
|
static MObject | mWorldMatrix |
world matrix attribute |
|
static MObject | mStartTime |
start time attribute |
|
static MObject | mDeltaTime |
delta time attribute |
|
static MObject | mIsFull |
flag for maximum count attribute |
|
static MObject | mInheritFactor |
inherit factor attribute |
|
static MObject | mSeed |
random seed attribute |
|
static MObject | mRandState |
random state attribute |
|
static MObject | mCurrentTime |
current time attribute |
|
static MObject | mOutput |
output particle attribute, multi |
|
static MObject | mMinDistance |
min distance attribute |
|
static MObject | mMaxDistance |
max distance attribute |
MPxEmitterNode::MPxEmitterNode | ( | ) |
Class constructor.
MPxEmitterNode::~MPxEmitterNode | ( | ) | [virtual] |
The class destructor.
MPxNode::Type MPxEmitterNode::type | ( | ) | const [virtual] |
This method returns the type of the node. It should not be overridden by the user. It will return MPxNode::kEmitterNode.
Reimplemented from MPxNode.
Reimplemented in MPxFluidEmitterNode.
MStatus MPxEmitterNode::compute | ( | const MPlug & | plug, | |
MDataBlock & | dataBlock | |||
) | [virtual] |
This method should be overridden in user defined nodes.
Recompute the given output based on the nodes inputs. The plug represents the data value that needs to be recomputed, and the data block holds the storage for all of the node's attributes.
The MDataBlock will provide smart handles for reading and writing this node's attribute values. Only these values should be used when performing computations.
When evaluating the dependency graph, Maya will first call the compute method for this node. If the plug that is provided to the compute indicates that that the attribute was defined by the Maya parent node, the compute method should return MS::kUnknownParameter. When this occurs, Maya will call the internal Maya node from which the user-defined node is derived to compute the plug's value.
This means that a user defined node does not need to be concerned with computing inherited output attributes. However, if desired, these can be safely recomputed by this method to change the behaviour of the node.
[in] | plug | plug representing the attribute that needs to be recomputed |
[in] | dataBlock | data block containing storage for the node's attributes |
Reimplemented from MPxNode.
Reimplemented in MPxFluidEmitterNode.
void MPxEmitterNode::draw | ( | M3dView & | view, | |
const MDagPath & | path, | |||
M3dView::DisplayStyle | style, | |||
M3dView::DisplayStatus | ||||
) | [virtual] |
Overriding this method allows the drawing of custom geometry using standard OpenGL calls. The OpenGL state should be left in the same state that it was in previously. The OpenGL routine glPushAttrib may be used to make this easier.
When this routine is called, the following conditions may be assumed:
[in] | view | 3D view that is being drawn into |
[in] | path | to this node in the DAG |
[in] | style | style to draw object in |
MPxEmitterNode::MEmitterType MPxEmitterNode::getEmitterType | ( | MDataBlock & | block | ) |
Retrieves the type of the emitter, determined by the "emitterType" attribute value. This is intended to be called from within the emitter's compute() method, in order to decide how the emitter should behave when evaluated.
[in] | block | data block containing storage for the node's attributes |
MObject MPxEmitterNode::getOwnerShape | ( | ) |
If the emitter is a emitting from an object, this method returns the shape node for the object.
MTime MPxEmitterNode::getCurrentTime | ( | MDataBlock & | block | ) |
Intended to be called from within the emitter's compute() method, this method returns the time at which the emitter is currently being evaluated. This is equivalent to querying the "currentTime" attribute on the emitter.
[in] | block | data block containing storage for the node's attributes |
MTime MPxEmitterNode::getStartTime | ( | int | plugIndex, | |
MDataBlock & | block | |||
) |
Intended to be called from within the emitter's compute() method, this method returns the start times for each particle system or fluid into which the emitter is emitting. Each of these "targets" is identified by an index value corresponding to the order in which they are connected to the emitter. The start time value gives the time at which the given target is to start receiving particles or fluid. If the current time is less than the start time for a target, then nothing should be emitted into that target in the current evaluation. This value is taken by evaluating an element of the emitter node's "startTime" array attribute.
[in] | plugIndex | identifies which emitter target's start time is to be evaluated. |
[in] | block | data block containing storage for the node's attributes |
MTime MPxEmitterNode::getDeltaTime | ( | int | plugIndex, | |
MDataBlock & | block | |||
) |
Intended to be called from within the emitter's compute() method, this method returns the width of the time interval represented by the current emitter evaluation. Usually emitter emission rates are given as rates per second, so by converting this deltaTime value to seconds, plugin emitters can determine how many particles or how much fluid to emit in the current evaluation. This value is taken from the emitter's "deltaTime" attribute value, and can vary between different emitter targets (particle systems or fluid shapes into which the emitter is emitting), due to potential differences in oversampling settings. The "plugIndex" parameter indicates which target's time delta is being evaluated.
[in] | plugIndex | identifies which emitter target's time delta is to be evaluated. |
[in] | block | data block containing storage for the node's attributes |
int MPxEmitterNode::getRandomSeed | ( | int | plugIndex, | |
MDataBlock & | block | |||
) |
Intended to be called from within the emitter's compute() method, this method returns the random seed for a specified emission target (particle system or fluid shape into which the emitter is emitting). This seed value is set on the target itself, and should be used to ensure that any randomized emission behavior is repeatable when animations are played back repeatedly. The resetRandomState() method uses this value (see its documentation for details on how to implement repeatable randomized behaviour in emitters). This value is obtained by evaluating an element of the emitter's "seed" array attribute.
[in] | plugIndex | identifies which emitter target's random seed is to be evaluated. |
[in] | block | data block containing storage for the node's attributes |
void MPxEmitterNode::getRandomState | ( | int | plugIndex, | |
MDataBlock & | block | |||
) |
Intended to be called from within the emitter's compute() method, this method copies the emitter node attribute representing the current random state for a particular emitter target into a local variable on the emitter object, to facilitate efficient random number generation using the randgen() method. See the documentation for resetRandomState() for a description of how to use this method in conjunction with the other random stream methods of this class.
There is only one local random state data member, so care should be taken not to inadvertently overwrite this member by calling getRandomState() on one target before setRandomState() has been called on a previously-evaluated target.
[in] | plugIndex | identifies which emitter target's random state is to be copied to the local random state data member. |
[in] | block | data block containing storage for the node's attributes |
void MPxEmitterNode::setRandomState | ( | int | plugIndex, | |
MDataBlock & | block | |||
) |
Intended to be called from within the emitter's compute() method, this method copies the emitter node class random state data member onto the emitter node's random state attribute. See the documentation for resetRandomState() for a description of how to use this method in conjunction with the other random stream methods of this class.
There is only one local random state data member, so care should be taken not to inadvertently write the wrong random state value to the attribute by calling setRandomState() on a target before getRandomState() has been called for that target.
[in] | plugIndex | identifies which emitter target's random state is to be written from the local random state data member. |
[in] | block | data block containing storage for the node's attributes |
void MPxEmitterNode::resetRandomState | ( | int | plugIndex, | |
MDataBlock & | block | |||
) |
Intended to be called from within the emitter's compute() method, this method resets the emitter's random state data member. To implement repeatable randomized emitter behavior, the following steps should be followed:
[in] | plugIndex | identifies which emitter target's random state is to be reset. |
[in] | block | data block containing storage for the node's attributes |
double MPxEmitterNode::randgen | ( | ) |
Intended to be called from within the emitter's compute() method, this method generates a double-precision random number in the rand [0,1]. The emitter object's random state data member is used to generate the random number, and will be updated after the number is generated. To generate a stream of random numbers for a particular target, ensure that getRandomState() is called before calling randgen(), and that setRandomState() is called after all the random numbers have been generated. See the documentation for resetRandomState() for a description of how to use this method in conjunction with the other random stream methods of this class.
double MPxEmitterNode::getRate | ( | MDataBlock & | block | ) |
Intended to be called from within the emitter's compute() method, this method retrieves the "rate" attribute value common to all particle and fluid emitters. For particle emitters, this indicates the number of particles to be emitted per second. For fluid emitters, this value is usually used as a multiplier applied to the emission rates for various fluid grids such as density, temperature, etc.
[in] | block | data block containing storage for the node's attributes |
double MPxEmitterNode::getMinDistance | ( | MDataBlock & | block | ) |
Intended to be called from within the emitter's compute() method, this method retrieves the "minDistance" attribute value common to all particle and fluid emitters. This value indicates the minimum distance from the emitter center at which fluid or particles will be emitted.
[in] | block | data block containing storage for the node's attributes |
double MPxEmitterNode::getMaxDistance | ( | MDataBlock & | block | ) |
Intended to be called from within the emitter's compute() method, this method retrieves the "maxDistance" attribute value common to all particle and fluid emitters. This value indicates the maximum distance from the emitter center at which fluid or particles will be emitted.
[in] | block | data block containing storage for the node's attributes |
MPoint MPxEmitterNode::getWorldPosition | ( | ) |
Returns the worldspace coordinates of the emitter. For curve, surface, and volume emitters, this returns the worldspace coordinates of the center of the emitter's local space. For point emitters, this value usually corresponds to the position of the emitter object itself.
MMatrix MPxEmitterNode::getWorldMatrix | ( | ) |
Returns the matrix that maps from the emitter's local space coordinates to worldspace.
bool MPxEmitterNode::volumePrimitiveBoundingBox | ( | MBoundingBox & | box | ) |
For volume emitters, this method returns the object-space bounding box of the volume primitive associated with the emitter.
[out] | box | receives the object space bounding box for the emission volume primitive. |
bool MPxEmitterNode::volumePrimitivePointInside | ( | const MPoint & | worldPoint, | |
const MMatrix & | emitterWorldMatrix | |||
) |
For volume emitters, this method determines whether a particular point in space lies within the volume defined by the emitter's volume primitive.
[in] | worldPoint | worldspace coordinates of the point to be tested. |
[in] | emitterWorldMatrix | object to worldspace matrix for the emitter, which can be obtained using the MPxEmitterNode::getWorldMatrix() method. |
double MPxEmitterNode::volumePrimitiveDistanceFromAxis | ( | const MPoint & | worldPoint, | |
const MMatrix & | emitterWorldMatrix | |||
) |
For volume emitters, this method determines the distance from a particular point to the major axis of the volumetric primitive associated with the emitter. For fluid emitters, this distance can be used to implement simple emission dropoff behavior.
[in] | worldPoint | worldspace coordinates of the point to be tested. |
[in] | emitterWorldMatrix | object to worldspace matrix for the emitter, which can be obtained using the MPxEmitterNode::getWorldMatrix() method. |
Certain aspects of Maya's particle and fluid emitters can be textured using 2d textures. For example, surface particle emitters can use a 2d texture to modulate the emission rate over the surface. For these purposes, only a subset of Maya's textures are supported, namely the default 2d textures (bulge, checker, cloth, file, fluid texture 2d, fractal, grid, mountain, movie, noise, ocean, ramp, water). No other nodes are supported. This method takes an attribute on an emitter, and determines if there is a supported texture connected to it. If the texture is supported, then the evalEmission2dTexture() method can be called to evaluate the texture at various (u,v) coordinate values.
[in] | texAttr | attribute to be tested for a valid texture connection. |
[out] | status | status code. |
MStatus MPxEmitterNode::evalEmission2dTexture | ( | const MObject & | texAttr, | |
MDoubleArray & | uCoords, | |||
MDoubleArray & | vCoords, | |||
MVectorArray * | resultColors, | |||
MDoubleArray * | resultAlphas | |||
) |
If a supported 2d texture (see hasValidEmission2dTexture() method documentation) is connected to the given emitter attribute, this method can be called to evaluate that texture at a number of (u,v) texture coordinate values.
[in] | texAttr | attribute whose connected texture is to be evaluated. |
[in] | uCoords | array of u coordinate values |
[in] | vCoords | array of v coordinate values |
[out] | resultColors | if non-NULL, receives the result of the connected texture's outColor attribute, evaluated at all the (u,v) coordinates given by the uCoords and vCoords arrays. |
[out] | resultAlphas | if non-NULL, receives the outAlpha values evaluated from the texture at these same points. |
Autodesk® Maya® 2011 © 1997-2010 Autodesk, Inc. All rights reserved. | Generated with 1.5.6 |