![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CUParticleNode3.h>
Public Member Functions | |
ParticleNode () | |
~ParticleNode () | |
virtual void | dispose () override |
bool | initWithSystem (const std::shared_ptr< graphics::ParticleSystem > &system) |
bool | initWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &json) override |
virtual std::shared_ptr< SceneNode > | copy (const std::shared_ptr< SceneNode > &dst) const override |
std::shared_ptr< SceneNode > | clone () const |
std::shared_ptr< graphics::ParticleSystem > | getParticleSystem () const |
void | setParticleSystem (const std::shared_ptr< graphics::ParticleSystem > &system) |
std::shared_ptr< graphics::Texture > | getTexture () const |
void | setTexture (const std::shared_ptr< graphics::Texture > &value) |
![]() | |
SceneNode () | |
~SceneNode () | |
virtual void | dispose () |
virtual bool | init () |
virtual bool | initWithPosition (const Vec3 pos) |
bool | initWithPosition (float x, float y, float z) |
virtual bool | initWithAnchor (const Vec3 anchor) |
bool | initWithAnchor (float x, float y, float z) |
virtual bool | initWithAnchor (const Vec3 pos, const Vec3 anchor) |
virtual bool | initWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &json) |
virtual std::shared_ptr< SceneNode > | copy (const std::shared_ptr< SceneNode > &dst) const |
unsigned int | getTag () const |
void | setTag (unsigned int tag) |
const std::string | getName () const |
void | setName (const std::string name) |
const std::string | getClassName () const |
CUEnum | getBatchKey () const |
void | setBatchKey (CUEnum key) |
virtual std::string | toString (bool verbose=false) const |
operator std::string () const | |
const Vec3 | getPosition () const |
void | setPosition (const Vec3 position) |
void | setPosition (float x, float y, float z) |
Vec3 | getWorldPosition () const |
void | setAnchor (const Vec3 anchor) |
void | setAnchor (float x, float y, float z) |
const Vec3 | getAnchor () const |
bool | isVisible () const |
void | setVisible (bool visible) |
cugl::Vec3 | getScale () const |
void | setScale (float scale) |
void | setScale (const cugl::Vec3 scale) |
cugl::Quaternion | getRotation () const |
void | setRotation (cugl::Quaternion rot) |
const Mat4 & | getModelMatrix () const |
const Mat4 & | getNodeToParentTransform () const |
Mat4 | getParentToNodeTransform () const |
virtual Mat4 | getNodeToWorldTransform () const |
Mat4 | getWorldToNodeTransform () const |
Vec3 | screenToNodeCoords (const Vec2 screenPoint) const |
Vec3 | worldToNodeCoords (const Vec3 worldPoint) const |
Vec2 | nodeToScreenCoords (const Vec3 nodePoint) const |
Vec3 | nodeToWorldCoords (const Vec3 nodePoint) const |
Vec3 | parentToNodeCoords (const Vec3 parentPoint) const |
Vec3 | nodeToParentCoords (const Vec3 nodePoint) const |
size_t | getChildCount () const |
std::shared_ptr< SceneNode > | getChild (unsigned int pos) |
const std::shared_ptr< SceneNode > & | getChild (unsigned int pos) const |
template<typename T > | |
std::shared_ptr< T > | getChild (unsigned int pos) const |
std::shared_ptr< SceneNode > | getChildByTag (unsigned int tag) const |
template<typename T > | |
std::shared_ptr< T > | getChildByTag (unsigned int tag) const |
std::shared_ptr< SceneNode > | getChildByName (const std::string name) const |
template<typename T > | |
std::shared_ptr< T > | getChildByName (const std::string name) const |
std::vector< std::shared_ptr< SceneNode > > | getChildren () |
const std::vector< std::shared_ptr< SceneNode > > & | getChildren () const |
void | addChild (const std::shared_ptr< SceneNode > &child) |
void | addChildWithTag (const std::shared_ptr< SceneNode > &child, unsigned int tag) |
void | addChildWithName (const std::shared_ptr< SceneNode > &child, const std::string name) |
void | swapChild (const std::shared_ptr< SceneNode > &child1, const std::shared_ptr< SceneNode > &child2, bool inherit=false) |
SceneNode * | getParent () |
const SceneNode * | getParent () const |
Scene3 * | getScene () |
const Scene3 * | getScene () const |
void | removeFromParent () |
virtual void | removeChild (unsigned int pos) |
void | removeChild (const std::shared_ptr< SceneNode > &child) |
void | removeChildByTag (unsigned int tag) |
void | removeChildByName (const std::string name) |
virtual void | removeAllChildren () |
Static Public Member Functions | |
static std::shared_ptr< ParticleNode > | allocWithSystem (const std::shared_ptr< graphics::ParticleSystem > &system) |
static std::shared_ptr< ParticleNode > | allocWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &json) |
![]() | |
static std::shared_ptr< SceneNode > | alloc () |
static std::shared_ptr< SceneNode > | allocWithPosition (const Vec3 pos) |
static std::shared_ptr< SceneNode > | allocWithPosition (float x, float y, float z) |
static std::shared_ptr< SceneNode > | allocWithAnchor (const Vec3 anchor) |
static std::shared_ptr< SceneNode > | allocWithAnchor (float x, float y, float z) |
static std::shared_ptr< SceneNode > | allocWithAnchor (const Vec3 pos, const Vec3 anchor) |
static std::shared_ptr< SceneNode > | allocWithData (const AssetManager *manager, const std::shared_ptr< JsonValue > &json) |
Additional Inherited Members | |
![]() | |
unsigned int | _tag |
std::string | _name |
size_t | _hashOfName |
std::string | _classname |
bool | _isVisible |
cugl::Vec3 | _position |
cugl::Vec3 | _anchor |
cugl::Vec3 | _scale |
cugl::Quaternion | _rotate |
Mat4 | _modelmat |
std::vector< std::shared_ptr< SceneNode > > | _children |
SceneNode * | _parent |
Scene3 * | _graph |
int | _childOffset |
CUEnum | _batchkey |
std::shared_ptr< JsonValue > | _json |
This class represents an particle system in a 3d scene graph.
Particle systems contain the logic for creating particles, as well as the underlying mesh. However, they do not have a position/orientation, or even a texture. That information is factored out so that we can reuse particle systems, as they are fairly heavy weight.
Depending on the choice of texture, systems do support limited animation. However, that animation is manage through the graphics::ParticleInstance
objects. It is not managed in this node.
cugl::scene3::ParticleNode::ParticleNode | ( | ) |
Creates an uninitialized node.
You must initialize this model before use.
NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate a model on the heap, use one of the static constructors instead.
|
inline |
Deletes this node, disposing all resources
|
inlinestatic |
Returns a newly allocated node with the given JSON specification.
This initializer is designed to receive the "data" object from the JSON passed to Scene3Loader
. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attribute:
"system": A string with the name of a previously loaded particle system "texture": A string with the name of a previously loaded texture asset
All attributes are optional. However, not specifying the system means that nothing is drawn. In addition, remember that JSON can provide the user-defined update and allocation functions for the particle system. Hence those will need to be defined for any particles to be emitted.
manager | The asset manager handling this asset |
json | The JSON object specifying the node |
|
inlinestatic |
Returns a newly allocated node with the given particle system
This node will keep a reference to particle system, but it will have its own position, orientation, and texture. Therefore it is possible for multiple nodes to share the same particle system.
system | The particle system |
std::shared_ptr< SceneNode > cugl::scene3::ParticleNode::clone | ( | ) | const |
Returns a shallow copy of this node.
The nodes will initially share the same particle system and texture. However, the position and orientation are copied by value.
No children from this model are copied, and no children of dst are modified. In addition, the parents of both node are unchanged. However, all other attributes of this node are copied.
|
overridevirtual |
Performs a shallow copy of this node into dst.
The nodes will initially share the same particle system and texture. However, the position and orientation are copied by value.
No children from this model are copied, and no children of dst are modified. In addition, the parents of both node are unchanged. However, all other attributes of this node are copied.
dst | The node to copy into |
Reimplemented from cugl::scene3::SceneNode.
|
overridevirtual |
Disposes all of the resources used by this node.
A disposed node can be safely reinitialized. Any children owned by this node will be released. They will be deleted if no other object owns them.
It is unsafe to call this on a node that is still currently inside of a scene graph.
Reimplemented from cugl::scene3::SceneNode.
|
inline |
Returns the particle system associated with this node.
If this value is nullptr, nothing will be drawn for this node. If this value was initialized via JSON, you must provide this system with a user-defined update and allocation function.
|
inline |
Returns the texture associated with this particle system.
If this value is nullptr, the particles will be rendered as a single color.
|
overridevirtual |
Initializes a node with the given JSON specification.
This initializer is designed to receive the "data" object from the JSON passed to Scene3Loader
. This JSON format supports all of the attribute values of its parent class. In addition, it supports the following additional attribute:
"system": A string with the name of a previously loaded particle system "texture": A string with the name of a previously loaded texture asset
All attributes are optional. However, not specifying the system means that nothing is drawn. In addition, remember that JSON can provide the user-defined update and allocation functions for the particle system. Hence those will need to be defined for any particles to be emitted.
manager | The asset manager handling this asset |
json | The JSON object specifying the node |
Reimplemented from cugl::scene3::SceneNode.
bool cugl::scene3::ParticleNode::initWithSystem | ( | const std::shared_ptr< graphics::ParticleSystem > & | system | ) |
Initializes this node with the given particle system
This node will keep a reference to particle system, but it will have its own position, orientation, and texture. Therefore it is possible for multiple nodes to share the same particle system.
system | The particle system |
|
inline |
Sets the particle system associated with this node.
If this value is nullptr, nothing will be drawn for this node. If this value was initialized via JSON, you must provide this system with a user-defined update and allocation function.
system | The particle system mesh associated with this node. |
|
inline |
Sets the texture associated with this particle system.
If this value is nullptr, the particles will be rendered as a single color.
value | The texture associated with this particle system. |