![]() |
CUGL 3.0
Cornell University Game Library
|
#include <CUSceneNode3.h>
Public Member Functions | |
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< 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) |
Protected Attributes | |
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 |
Friends | |
class | Scene3 |
This class provides a 3d scene graph node.
A base node is a cubic that can contain other (transformed) nodes. Each node forms a its own coordinate space. All rendering takes place inside of this coordinate space. By default, a mode does not render anything. Instead, all drawing is handled via Scene3Pipeline
, which traverses the scene graph tree before drawing.
Unlike the 2d scene graph nodes, we do not associate a bounding box (or volume with the node). While that is important for UI layout code, it is less important for 3d scene graphs. However, we do still have the concept of the anchor. All transforms (scaling and rotation) are applied relative to the anchor, not the node origin. But because there is no bounding box, this anchor is specified as a point in node space, and not a percentage.
cugl::scene3::SceneNode::SceneNode | ( | ) |
Creates an uninitialized node.
You must initialize this node before use.
NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate a node on the heap, use one of the static constructors instead.
|
inline |
Deletes this node, disposing all resources
void cugl::scene3::SceneNode::addChild | ( | const std::shared_ptr< SceneNode > & | child | ) |
Adds a child to this node.
Children are enumerated in the order that they are added. However, it is still best to For example, they may be resorted by their z-order. Hence you should generally attempt to retrieve a child by tag or by name instead.
child | A child node. |
|
inline |
Adds a child to this node with the given name.
For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is generally best to retrieve a child using either a tag or a name instead.
child | A child node. |
name | A string to identify the node. |
|
inline |
Adds a child to this node with the given tag.
For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is generally best to retrieve a child using either a tag or a name instead.
child | A child node. |
tag | An integer to identify the node easily. |
|
inlinestatic |
Returns a newly allocated node at the world origin.
The node has both position and size (0,0,0).
|
inlinestatic |
Returns a newly allocated node with the given anchor.
The anchor defines the transformation origin of the scene node. All scaling and rotation happens about the anchor, not the origin. This anchor is placed at (0,0,0) in parent space.
anchor | The anchor of this node |
|
inlinestatic |
Returns a newly allocated node with the given anchor and position.
The anchor defines the transformation origin of the scene node. All scaling and rotation happens about the anchor, not the origin. This anchor is placed at position pos in parent space.
pos | The node position |
anchor | The node anchor |
|
inlinestatic |
Returns a newly allocated node with the given anchor.
The anchor defines the transformation origin of the scene node. All scaling and rotation happens about the anchor, not the origin. This anchor is placed at (0,0,0) in parent space.
x | The x-coordinate of the anchor in node space |
y | The y-coordinate of the anchor in node space |
z | The z-coordinate of the anchor in node space |
|
inlinestatic |
Returns a newly allocated node with the given JSON specificaton.
This initializer is designed to receive the "data" object from the JSON passed to Scene3Loader
. This JSON format supports the following attribute values:
"position": A three-element number array "anchor": A three-element number array representing the anchor point "scale": Either a three-element number array or a single number "rotation": A JSON value representing rotation about an axis "visible": A boolean value, representing if the node is visible
All attributes are optional. There are no required attributes. Everything that is missing is assigned its default value.
The value "rotation" can either be a four-element array or a JSON object. If it is an array, it is interpreted as a quaternion. If it is an object, it supports the following attributes:
"angle": A number, representing the rotation in DEGREES, not radians "axis": A three-element number array
Once again, both are optional, though no rotation is applied if the angle is missing. If the axis is missing, rotation is about the z-axis
manager | The asset manager handling this asset |
json | The JSON object specifying the node |
|
inlinestatic |
Returns a newly allocated node at the given position.
The node has size (0,0,0). As a result, the position is identified with the origin of the node space.
pos | The origin of the node in parent space |
|
inlinestatic |
Returns a newly allocated node at the given position.
The node has size (0,0,0). As a result, the position is identified with the origin of the node space.
x | The x-coordinate of the node in parent space |
y | The y-coordinate of the node in parent space |
z | The z-coordinate of the node in parent space |
|
virtual |
Performs a shallow copy of this node into dst.
No children from this node 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 in cugl::scene3::BillboardNode, cugl::scene3::ObjNode, and cugl::scene3::ParticleNode.
|
virtual |
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 in cugl::scene3::BillboardNode, cugl::scene3::ObjNode, and cugl::scene3::ParticleNode.
|
inline |
Returns the anchor point.
The anchor point defines the relative origin of Node with respect to its parent. It is a "pin" where the Node is attached to its parent. In effect, the translation of a Node is defined by its position plus anchor point.
The anchor point is defined as a position in node space. It is the origin by default. Note that changing the anchor will not move the contents of the node in the parent space, but it will change the value of the node position.
|
inline |
Returns the batch key for this node type.
Batch keys are uses to identify the correct Scene3Batch
to use in Scene3Pipeline
. Each batch type has its own key. See Scene3Batch#getBatchKey
.
std::shared_ptr< SceneNode > cugl::scene3::SceneNode::getChild | ( | unsigned int | pos | ) |
Returns the child at the given position.
For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is generally best to retrieve a child using either a tag or a name instead.
pos | The child position. |
const std::shared_ptr< SceneNode > & cugl::scene3::SceneNode::getChild | ( | unsigned int | pos | ) | const |
Returns the child at the given position.
For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is generally best to retrieve a child using either a tag or a name instead.
pos | The child position. |
|
inline |
Returns the child at the given position, typecast to a shared T pointer.
This method is provided to simplify the polymorphism of a scene graph. While all children are a subclass of type Node, you may want to access them by their specific subclass. If the child is not an instance of type T (or a subclass), this method returns nullptr.
For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is generally best to retrieve a child using either a tag or a name instead.
pos | The child position. |
std::shared_ptr< SceneNode > cugl::scene3::SceneNode::getChildByName | ( | const std::string | name | ) | const |
Returns the (first) child with the given name.
If there is more than one child of the given name, it returns the first one that is found. For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is very important that names be unique.
name | An identifier to find the child node. |
|
inline |
Returns the (first) child with the given name, typecast to a shared T pointer.
This method is provided to simplify the polymorphism of a scene graph. While all children are a subclass of type Node, you may want to access them by their specific subclass. If the child is not an instance of type T (or a subclass), this method returns nullptr.
If there is more than one child of the given name, it returns the first one that is found. For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is very important that names be unique.
name | An identifier to find the child node. |
std::shared_ptr< SceneNode > cugl::scene3::SceneNode::getChildByTag | ( | unsigned int | tag | ) | const |
Returns the (first) child with the given tag.
If there is more than one child of the given tag, it returns the first one that is found. For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is very important that tags be unique.
tag | An identifier to find the child node. |
|
inline |
Returns the (first) child with the given tag, typecast to a shared T pointer.
This method is provided to simplify the polymorphism of a scene graph. While all children are a subclass of type Node, you may want to access them by their specific subclass. If the child is not an instance of type T (or a subclass), this method returns nullptr.
If there is more than one child of the given tag, it returns the first one that is found. For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for all subclasses of SceneNode. Hence it is very important that tags be unique.
tag | An identifier to find the child node. |
|
inline |
Returns the number of children of this node.
|
inline |
Returns the list of the node's children.
|
inline |
Returns the list of the node's children.
|
inline |
Returns the class name of this node.
This method is to help us speed up subclass-based polymorphism on the scene graphs.
|
inline |
Returns the model matrix of this node.
The model matrix defines the transform of this node in parent space.
|
inline |
Returns a string that is used to identify the node.
This name is used to access a child node, since child position may change. In addition, the name is useful for debugging. To work properly, a name should be unique within a scene graph. It is empty if undefined.
|
inline |
Returns the matrix transforming node space to parent space.
This value is the node's transform. It is computed from the anchor, scale, rotation, and position.
|
virtual |
Returns the matrix transforming node space to world space.
This matrix is used to convert node coordinates into OpenGL coordinates. It is the recursive (left-multiplied) node-to-parent transforms of all of its ancestors.
|
inline |
Returns a (weak) pointer to the parent node.
The purpose of this pointer is to climb back up the scene graph tree. No child asserts ownership of its parent.
|
inline |
Returns a (weak) pointer to the parent node.
The purpose of this pointer is to climb back up the scene graph tree. No child asserts ownership of its parent.
|
inline |
Returns the matrix transforming parent space to node space.
This value is the node's transform. It is computed from the anchor, scale, rotation, and position.
|
inline |
Returns the position of the node in its parent's coordinate system.
The node position is not necessarily the origin of the Node coordinate system. The relationship between the position and Node space is determined by the anchor point. See getAnchor()
for more details.
|
inline |
Returns the rotation quaterion of this node about the anchor.
This value rotates the node about the anchor, with the anchor unmoved. Rotations are represented by quaternions, which store both an axis and and angle of rotation (in radians).
|
inline |
Returns the non-uniform scaling factor for this node about the anchor.
This factor scales the node about the anchor (with the anchor unmoved). Hence this is not the same as a scale applied to Node space, as the origin may be different. Scaling is first, before any other transforms.
|
inline |
Returns a (weak) pointer to the scene graph.
The purpose of this pointer is to climb back up to the root of the scene graph tree. No node asserts ownership of its scene.
|
inline |
Returns a (weak) pointer to the scene graph.
The purpose of this pointer is to climb back up to the root of the scene graph tree. No node asserts ownership of its scene.
|
inline |
Returns a tag that is used to identify the node easily.
This tag is used to quickly access a child node, since child position may change. To work properly, a tag should be unique within a scene graph. It is 0 if undefined.
|
inline |
Returns the position of the anchor point node in world space.
Note that this is the position of the anchor point. This is not the same as the location of the node origin in world space.
|
inline |
Returns the matrix transforming node space to world space.
This matrix is used to convert OpenGL coordinates into node coordinates. This method is useful for converting global positions like touches or mouse clicks. It is the recursive (right-multiplied) parent-to-node transforms of all of its ancestors.
|
inlinevirtual |
Initializes a node at the world origin.
The node has both position and anchor (0,0,0).
|
inlinevirtual |
Initializes a node with the given anchor.
The anchor defines the transformation origin of the scene node. All scaling and rotation happens about the anchor, not the origin. This anchor is placed at (0,0,0) in parent space.
anchor | The node anchor |
Initializes a node with the given anchor and position.
The anchor defines the transformation origin of the scene node. All scaling and rotation happens about the anchor, not the origin. This anchor is placed at position pos in parent space.
pos | The node position |
anchor | The node anchor |
|
inline |
Initializes a node with the given anchor.
The anchor defines the transformation origin of the scene node. All scaling and rotation happens about the anchor, not the origin. This anchor is placed at (0,0,0) in parent space.
x | The x-coordinate of the anchor in node space |
y | The y-coordinate of the anchor in node space |
z | The z-coordinate of the anchor in node space |
|
virtual |
Initializes a node with the given JSON specificaton.
This initializer is designed to receive the "data" object from the JSON passed to Scene3Loader
. This JSON format supports the following attribute values:
"position": A three-element number array "anchor": A three-element number array representing the anchor point "scale": Either a three-element number array or a single number "rotation": A JSON value representing rotation about an axis "visible": A boolean value, representing if the node is visible
All attributes are optional. There are no required attributes. Everything that is missing is assigned its default value.
The value "rotation" can either be a four-element array or a JSON object. If it is an array, it is interpreted as a quaternion. If it is an object, it supports the following attributes:
"angle": A number, representing the rotation in DEGREES, not radians "axis": A three-element number array
Once again, both are optional, though no rotation is applied if the angle is missing. If the axis is missing, rotation is about the z-axis
manager | The asset manager handling this asset |
json | The JSON object specifying the node |
Reimplemented in cugl::scene3::BillboardNode, cugl::scene3::ObjNode, and cugl::scene3::ParticleNode.
|
virtual |
Initializes a node at the given position.
The node has anchor (0,0,0). As a result, the position is identified with the origin of the node space.
pos | The origin of the node in parent space |
|
inline |
Initializes a node at the given position.
The node has anchor (0,0,0). As a result, the position is identified with the origin of the node space.
x | The x-coordinate of the node in parent space |
y | The y-coordinate of the node in parent space |
z | The z-coordinate of the node in parent space |
|
inline |
Returns true if the node is visible.
If a node is not visible, then it is not drawn. This means that its children are not visible as well, regardless of their visibility settings. The default value is true, making the node visible.
Converts an node (local) space position to parent coordinates.
See getNodeToParentTransform() for how this conversion takes place. That method should be used instead if there are many points to convert, as this method will recompute the transform matrix each time.
nodePoint | A local position. |
Converts an node (local) position to screen coordinates.
This method is useful for converting back to global positions like touches or mouse clicks, which are represented in screen coordinates. Screen coordinates typically have the origin in the top left.
The screen coordinate system is defined by the scene's camera. The method converts the node point into world space, and then uses the camera to convert into screen space.
This method returns the original point if there is no active scene.
nodePoint | A local position. |
Converts an node (local) position to OpenGL coordinates.
See getNodeToWorldTransform() for how this conversion takes place. That method should be used instead if there are many points to convert, as this method will recompute the transform matrix each time.
nodePoint | A local position. |
|
inline |
Cast from a Node to a string.
Converts an parent space position to node (local) space coordinates.
See getParentToNodeTransform() for how this conversion takes place. That method should be used instead if there are many points to convert, as this method will recompute the transform matrix each time.
parentPoint | A parent position. |
|
virtual |
Removes all children from this Node.
void cugl::scene3::SceneNode::removeChild | ( | const std::shared_ptr< SceneNode > & | child | ) |
Removes a child from this Node.
Removing a child alters the position of every child after it. Hence it is unsafe to cache child positions.
If the child is not in this node, nothing happens.
child | The child node which will be removed. |
|
virtual |
Removes the child at the given position from this Node.
Removing a child alters the position of every child after it. Hence it is unsafe to cache child positions.
pos | The position of the child node which will be removed. |
void cugl::scene3::SceneNode::removeChildByName | ( | const std::string | name | ) |
Removes a child from the Node by name.
If there is more than one child of the given name, it removes the first one that is found. For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for subclasses of SceneNode. Hence it is very important that names be unique.
name | A string to identify the node. |
void cugl::scene3::SceneNode::removeChildByTag | ( | unsigned int | tag | ) |
Removes a child from the Node by tag value.
If there is more than one child of the given tag, it removes the first one that is found. For the base SceneNode class, children are always enumerated in the order that they are added. However, this is not guaranteed for subclasses of SceneNode. Hence it is very important that tags be unique.
tag | An integer to identify the node easily. |
|
inline |
Removes this node from its parent node.
If the node has no parent, nothing happens.
Converts a screen position to node (local) space coordinates.
This method is useful for converting global positions like touches or mouse clicks, which are represented in screen coordinates. Screen coordinates typically have the origin in the top left.
The screen coordinate system is defined by the scene's camera. The method uses the camera to convert into world space, and then converts from world space into not (local) space.
This method returns the original point if there is no active scene.
screenPoint | An position on the screen |
void cugl::scene3::SceneNode::setAnchor | ( | const Vec3 | anchor | ) |
Sets the anchor point.
The anchor point defines the relative origin of Node with respect to its parent. It is a "pin" where the Node is attached to its parent. In effect, the translation of a Node is defined by its position plus anchor point.
The anchor point is defined as a position in node space. It is the origin by default. Note that changing the anchor will not move the contents of the node in the parent space, but it will change the value of the node position.
anchor | The anchor point of node. |
void cugl::scene3::SceneNode::setAnchor | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the anchor point.
The anchor point defines the relative origin of Node with respect to its parent. It is a "pin" where the Node is attached to its parent. In effect, the translation of a Node is defined by its position plus anchor point.
The anchor point is defined as a position in node space. It it the origin by default. Note that changing the anchor will not move the contents of the node in the parent space, but it will change the value of the node position.
x | The x-coordinate of the anchor. |
y | The y-coordinate of the anchor. |
z | The z-coordinate of the anchor. |
|
inline |
Sets the batch key for this node type.
Batch keys are uses to identify the correct Scene3Batch
to use in Scene3Pipeline
. Each batch type has its own key. See Scene3Batch#getBatchKey
.
key | The batch key for this node type. |
|
inline |
Sets a string that is used to identify the node.
This name is used to access a child node, since child position may change. In addition, the name is useful for debugging. To work properly, a name should be unique within a scene graph. It is empty if undefined.
name | A string that is used to identify the node. |
void cugl::scene3::SceneNode::setPosition | ( | const Vec3 | position | ) |
Sets the position of the node in its parent's coordinate system.
The node position is not necessarily the origin of the Node coordinate system. The relationship between the position and Node space is determined by the anchor point. See getAnchor()
for more details.
position | The position of the node in its parent's coordinate system. |
void cugl::scene3::SceneNode::setPosition | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the position of the node in its parent's coordinate system.
The node position is not necessarily the origin of the Node coordinate system. The relationship between the position and Node space is determined by the anchor point. See getAnchor()
for more details.
x | The x-coordinate of the node in its parent's coordinate system. |
y | The x-coordinate of the node in its parent's coordinate system. |
z | The z-coordinate of the node in its parent's coordinate system. |
void cugl::scene3::SceneNode::setRotation | ( | cugl::Quaternion | rot | ) |
Sets the rotation quaterion of this node about the anchor.
This value rotates the node about the anchor, with the anchor unmoved. Rotations are represented by quaternions, which store both an axis and and angle of rotation (in radians).
rot | The rotation quaterion of this node about the anchor. |
void cugl::scene3::SceneNode::setScale | ( | const cugl::Vec3 | scale | ) |
Sets the non-uniform scaling factor for this node about the anchor.
This factor scales the node about the anchor (with the anchor unmoved). Hence this is not the same as a scale applied to Node space, as the origin may be different. Scaling is first, before any other transforms.
scale | The non-uniform scaling factor for this node about the anchor |
|
inline |
Sets the uniform scaling factor for this node about the anchor.
This factor scales the node about the anchor (with the anchor unmoved). Hence this is not the same as a scale applied to Node space, as the origin may be different. Scaling is first, before any other transforms.
scale | The uniform scaling factor for this node about the anchor |
|
inline |
Sets a tag that is used to identify the node easily.
This tag is used to quickly access a child node, since child position may change. To work properly, a tag should be unique within a scene graph. It is 0 if undefined.
tag | A tag that is used to identify the node easily. |
|
inline |
Sets whether the node is visible.
If a node is not visible, then it is not drawn. This means that its children are not visible as well, regardless of their visibility settings. The default value is true, making the node visible.
visible | true if the node is visible. |
void cugl::scene3::SceneNode::swapChild | ( | const std::shared_ptr< SceneNode > & | child1, |
const std::shared_ptr< SceneNode > & | child2, | ||
bool | inherit = false |
||
) |
Swaps the current child child1 with the new child child2.
If inherit is true, the children of child1 are assigned to child2 after the swap; this value is false by default. The purpose of this value is to allow transition nodes in the middle of the scene graph.
This method is undefined if child1 is not a child of this node.
child1 | The current child of this node |
child2 | The child to swap it with. |
inherit | Whether the new child should inherit the children of child1. |
|
virtual |
Returns a string representation of this node for debugging purposes.
If verbose is true, the string will include class information. This allows us to unambiguously identify the class.
verbose | Whether to include class information |
Converts an OpenGL position to node (local) space coordinates.
See getWorldtoNodeTransform() for how this conversion takes place. That method should be used instead if there are many points to convert, as this method will recompute the transform matrix each time.
worldPoint | An OpenGL position. |
|
protected |
The anchor point of the node.
The anchor point is a position in node space. All transforms applied to this node occur about the anchor, not the origin.
|
protected |
The batch key
|
protected |
The (current) child offset of this node (-1 if root)
|
protected |
The array of children nodes
|
protected |
The class name for the specific subclass
|
protected |
A weaker pointer to the scene (or null if not in a scene)
|
protected |
A cached has value of _name.
This value is used to speed up look-ups by string.
|
protected |
Whether this node is visible
|
protected |
The defining JSON data for this node (if any)
|
protected |
The model matrix for this node
|
protected |
A descriptive identifying tag.
Like tag, this value is used to quickly identify the child of a node. However, it is more descriptive, and so is useful in debugging.
|
protected |
A weaker pointer to the parent (or null if root)
|
protected |
The position of this node in the parent coordinate space.
|
protected |
The rotation to transform this node.
Rotation is applied after any scaling, but before the position translation. The node coordinate space remains unchanged.
|
protected |
The scaling factor to transform this node.
This scaling happens in the parent coordinate space. Scaling happens before any rotation. The node coordinate space remains unchanged.
|
protected |
An identifying tag.
This value is used to quickly identify the child of a node. To work properly, a tag should be unique within a scene graph. It is 0 if undefined.