Saga3D API Documentation
1.0-RC4
|
Type for list of scene node animators. More...
#include <ISceneNode.h>
Public Member Functions | |
ISceneNode (const std::shared_ptr< ISceneNode > &parent, const std::shared_ptr< ISceneManager > &mgr, const glm::vec3 &position=glm::vec3(0, 0, 0), const glm::vec3 &rotation=glm::vec3(0, 0, 0), const glm::vec3 &scale=glm::vec3(1.0f, 1.0f, 1.0f)) | |
Constructor. More... | |
virtual void | onEvent (const SDL_Event &event) override |
Called when an SDL event is fired. More... | |
virtual | ~ISceneNode () |
Destructor. More... | |
void | setID (const ID id) |
const auto | getID () const |
virtual void | onRegisterSceneNode (video::RenderPassHandle pass) |
This method is called just before the rendering process of the whole scene. More... | |
virtual void | onUnregisterSceneNode (video::RenderPassHandle pass) |
void | setOnRender (std::function< void()> func) |
void | onRender () |
bool | hasDrawCommands () const |
void | setDrawCommands (video::DrawCommandList &&list) |
const auto & | getDrawCommands () const |
auto | getTexture (int slot) const |
auto & | getTextures () |
void | setTexture (int slot, video::TextureHandle texture) |
virtual void | setPipeline (video::PipelineHandle pipeline) |
auto | getPipeline () const |
virtual void | onAnimate (const float time) |
onAnimate() is called just before rendering the whole scene. More... | |
virtual const std::string & | getName () const |
Returns the name of the node. More... | |
virtual void | setName (const std::string &name) |
Sets the name of the node. More... | |
virtual const core::aabbox3d< float > & | getBoundingBox () const =0 |
Get the axis aligned, not transformed bounding box of this node. More... | |
virtual const core::aabbox3d< float > | getTransformedBoundingBox () const |
Get the axis aligned, transformed and animated absolute bounding box of this node. More... | |
virtual void | getTransformedBoundingBoxEdges (std::vector< glm::vec3 > &edges) const |
virtual const glm::mat4 & | getAbsoluteTransformation () const |
Get the absolute transformation of the node. Is recalculated every onAnimate()-call. More... | |
virtual glm::mat4 | getRelativeTransformation () const |
Returns the relative transformation of the scene node. More... | |
virtual bool | isVisible () const |
Returns whether the node should be visible (if all of its parents are visible). More... | |
virtual bool | isTrulyVisible () const |
Check whether the node is truly visible, taking into accounts its parents' visibility. More... | |
virtual void | setVisible (bool isVisible) |
Sets if the node should be visible or not. More... | |
virtual void | addChild (const std::shared_ptr< ISceneNode > &child) |
Adds a child to this scene node. More... | |
virtual bool | removeChild (const std::shared_ptr< ISceneNode > &child) |
virtual void | removeAll () |
Removes all children of this scene node. More... | |
virtual void | remove () |
Removes this scene node from the scene. More... | |
virtual void | addAnimator (const std::shared_ptr< ISceneNodeAnimator > &animator) |
Adds an animator which should animate this node. More... | |
const auto & | getAnimators () const |
Get a list of all scene node animators. More... | |
virtual void | removeAnimator (const std::shared_ptr< ISceneNodeAnimator > &animator) |
Removes an animator from this scene node. More... | |
virtual void | removeAnimators () |
Removes all animators from this scene node. More... | |
virtual const glm::vec3 & | getScale () const |
Gets the scale of the scene node relative to its parent. More... | |
virtual void | setScale (const glm::vec3 &scale) |
Sets the relative scale of the scene node. More... | |
virtual const glm::vec3 & | getRotation () const |
Gets the rotation of the node relative to its parent. More... | |
virtual void | setRotation (const glm::vec3 &rotation) |
Sets the rotation of the node relative to its parent. More... | |
virtual const glm::vec3 & | getPosition () const |
Gets the position of the node relative to its parent. More... | |
virtual void | setPosition (const glm::vec3 &newpos) |
Sets the position of the node relative to its parent. More... | |
virtual glm::vec3 | getAbsolutePosition () const |
Gets the absolute position of the node in world coordinates. More... | |
const std::vector< std::shared_ptr< ISceneNode > > & | getChildren () const |
Returns a const reference to the list of all children. More... | |
virtual void | setParent (const std::shared_ptr< ISceneNode > &newParent) |
Changes the parent of the scene node. More... | |
virtual void | updateAbsolutePosition () |
Returns the triangle selector attached to this scene node. More... | |
const std::shared_ptr< ISceneNode > & | getParent () const |
Returns the parent of this scene node. More... | |
virtual E_SCENE_NODE_TYPE | getType () const |
Returns type of the scene node. More... | |
virtual std::shared_ptr< ISceneNode > | clone (const std::shared_ptr< ISceneNode > &newParent=0) |
Creates a clone of this scene node and its children. More... | |
virtual const std::shared_ptr< ISceneManager > & | getSceneManager () const |
Retrieve the scene manager for this node. More... | |
![]() | |
virtual | ~IEventReceiver () |
Destructor. More... | |
Protected Attributes | |
ID | NodeID = INVALID_ID |
A clone function for the ISceneNode members. More... | |
std::string | Name |
Name of the scene node. More... | |
glm::mat4 | AbsoluteTransformation |
Absolute transformation of the node. More... | |
glm::vec3 | RelativeTranslation |
Relative translation of the scene node. More... | |
glm::vec3 | RelativeRotation |
Relative rotation of the scene node. More... | |
glm::vec3 | RelativeScale |
Relative scale of the scene node. More... | |
std::shared_ptr< ISceneNode > | Parent = nullptr |
Pointer to the parent. More... | |
std::vector< std::shared_ptr< ISceneNode > > | Children |
List of all children of this node. More... | |
std::array< video::STexture::HandleType, video::MAX_NODE_TEXTURES > | Textures = { video::NULL_GPU_RESOURCE_HANDLE } |
Texture list. More... | |
std::vector< std::shared_ptr< ISceneNodeAnimator > > | Animators |
List of all animator nodes. More... | |
std::shared_ptr< ISceneManager > | SceneManager = nullptr |
Pointer to the scene manager. More... | |
std::function< void()> | OnRenderCallback = nullptr |
Custom hook into rendering process of the scene node. More... | |
video::DrawCommandList | DrawCommands |
video::PipelineHandle | Pipeline = video::NULL_GPU_RESOURCE_HANDLE |
bool | IsVisible = true |
Is the node visible? More... | |
Type for list of scene node animators.
Scene node interface. A scene node is a node in the hierarchical scene graph. Every scene node may have children, which are also scene nodes. Children move relative to their parent's position. If the parent of a node is not visible, its children won't be visible either. In this way, it is for example easily possible to attach a light to a moving car, or to place a walking character on a moving platform on a moving ship.
Definition at line 41 of file ISceneNode.h.
|
inline |
Constructor.
Definition at line 46 of file ISceneNode.h.
|
inlinevirtual |
Destructor.
Definition at line 70 of file ISceneNode.h.
|
inlinevirtual |
Adds an animator which should animate this node.
animator | A pointer to the new animator. |
Definition at line 337 of file ISceneNode.h.
|
inlinevirtual |
Adds a child to this scene node.
If the scene node already has a parent it is first removed from the other parent.
child | A pointer to the new child. |
Definition at line 275 of file ISceneNode.h.
|
inlinevirtual |
Creates a clone of this scene node and its children.
newParent | An optional new parent. |
newManager | An optional new scene manager. |
Definition at line 525 of file ISceneNode.h.
|
inlinevirtual |
Gets the absolute position of the node in world coordinates.
If you want the position of the node relative to its parent, use getPosition() instead. NOTE: For speed reasons the absolute position is not automatically recalculated on each change of the relative position or by a position change of an parent. Instead the update usually happens once per frame in onAnimate. You can enforce an update with updateAbsolutePosition().
Definition at line 432 of file ISceneNode.h.
|
inlinevirtual |
Get the absolute transformation of the node. Is recalculated every onAnimate()-call.
NOTE: For speed reasons the absolute transformation is not automatically recalculated on each change of the relative transformation or by a transformation change of an parent. Instead the update usually happens once per frame in onAnimate. You can enforce an update with updateAbsolutePosition().
Definition at line 219 of file ISceneNode.h.
|
inline |
Get a list of all scene node animators.
Definition at line 348 of file ISceneNode.h.
|
pure virtual |
Get the axis aligned, not transformed bounding box of this node.
This means that if this node is an animated 3d character, moving in a room, the bounding box will always be around the origin. To get the box in real world coordinates, just transform it with the matrix you receive with getAbsoluteTransformation() or simply use getTransformedBoundingBox(), which does the same.
Implemented in saga::scene::IMeshSceneNode, and saga::scene::IBoneSceneNode.
|
inline |
Returns a const reference to the list of all children.
Definition at line 439 of file ISceneNode.h.
|
inline |
Definition at line 121 of file ISceneNode.h.
|
inline |
Definition at line 82 of file ISceneNode.h.
|
inlinevirtual |
Returns the name of the node.
Definition at line 165 of file ISceneNode.h.
|
inline |
Returns the parent of this scene node.
Definition at line 509 of file ISceneNode.h.
|
inline |
Definition at line 134 of file ISceneNode.h.
|
inlinevirtual |
Gets the position of the node relative to its parent.
Note that the position is relative to the parent. If you want the position in world coordinates, use getAbsolutePosition() instead.
Definition at line 410 of file ISceneNode.h.
|
inlinevirtual |
Returns the relative transformation of the scene node.
The relative transformation is stored internally as 3 vectors: translation, rotation and scale. To get the relative transformation matrix, it is calculated from these values.
Definition at line 229 of file ISceneNode.h.
|
inlinevirtual |
Gets the rotation of the node relative to its parent.
Note that this is the relative rotation of the node. If you want the absolute rotation, use getAbsoluteTransformation().getRotation()
Definition at line 393 of file ISceneNode.h.
|
inlinevirtual |
Gets the scale of the scene node relative to its parent.
This is the scale of this node relative to its parent. If you want the absolute scale, use getAbsoluteTransformation().getScale()
Definition at line 376 of file ISceneNode.h.
|
inlinevirtual |
Retrieve the scene manager for this node.
Definition at line 532 of file ISceneNode.h.
|
inline |
Definition at line 123 of file ISceneNode.h.
|
inline |
Definition at line 125 of file ISceneNode.h.
|
inlinevirtual |
Get the axis aligned, transformed and animated absolute bounding box of this node.
Note: The result is still an axis-aligned bounding box, so it's size changes with rotation.
Definition at line 191 of file ISceneNode.h.
|
inlinevirtual |
Get a the 8 corners of the original bounding box transformed and animated by the absolute transformation. Note: The result is not identical to getTransformedBoundingBox().getEdges(), but getting an aabbox3d of these edges would then be identical.
edges | Receives an array with the transformed edges |
Definition at line 204 of file ISceneNode.h.
|
inlinevirtual |
Returns type of the scene node.
Reimplemented in saga::scene::IMeshSceneNode.
Definition at line 516 of file ISceneNode.h.
|
inline |
Definition at line 117 of file ISceneNode.h.
|
inlinevirtual |
Check whether the node is truly visible, taking into accounts its parents' visibility.
Definition at line 250 of file ISceneNode.h.
|
inlinevirtual |
Returns whether the node should be visible (if all of its parents are visible).
This is only an option set by the user, but has nothing to do with geometry culling
Definition at line 242 of file ISceneNode.h.
|
inlinevirtual |
onAnimate() is called just before rendering the whole scene.
Nodes may calculate or store animations here, and may do other useful things, depending on what they are. Also, onAnimate() should be called for all child scene nodes here. This method will be called once per frame, independent of whether the scene node is visible or not.
timeMs | Current time in milliseconds. |
Reimplemented in saga::scene::IBoneSceneNode.
Definition at line 142 of file ISceneNode.h.
|
inlineoverridevirtual |
Called when an SDL event is fired.
Implements saga::IEventReceiver.
Definition at line 61 of file ISceneNode.h.
|
inlinevirtual |
This method is called just before the rendering process of the whole scene.
Nodes may register themselves in the render pipeline during this call, precalculate the geometry which should be renderered, and prevent their children from being able to register themselves if they are clipped by simply not calling their onRegisterSceneNode method. If you are implementing your own scene node, you should overwrite this method with an implementation code looking like this:
Reimplemented in saga::scene::IMeshSceneNode.
Definition at line 96 of file ISceneNode.h.
|
inline |
Definition at line 115 of file ISceneNode.h.
|
inlinevirtual |
Reimplemented in saga::scene::IMeshSceneNode.
Definition at line 106 of file ISceneNode.h.
|
inlinevirtual |
Removes this scene node from the scene.
If no other grab exists for this node, it will be deleted.
Definition at line 329 of file ISceneNode.h.
|
inlinevirtual |
Removes all children of this scene node.
The scene nodes found in the children list are also dropped and might be deleted if no other grab exists on them.
Definition at line 314 of file ISceneNode.h.
|
inlinevirtual |
Removes an animator from this scene node.
If the animator is found, it is also dropped and might be deleted if not other grab exists for it.
animator | A pointer to the animator to be deleted. |
Definition at line 358 of file ISceneNode.h.
|
inlinevirtual |
Removes all animators from this scene node.
The animators might also be deleted if no other grab exists for them.
Definition at line 366 of file ISceneNode.h.
|
inlinevirtual |
If found in the children list, the child pointer is also dropped and might be deleted if no other grab exists.
child | A pointer to the child which shall be removed. |
Definition at line 295 of file ISceneNode.h.
|
inline |
Definition at line 119 of file ISceneNode.h.
|
inline |
Definition at line 81 of file ISceneNode.h.
|
inlinevirtual |
Sets the name of the node.
name | New name of the scene node. |
Definition at line 172 of file ISceneNode.h.
|
inline |
Definition at line 113 of file ISceneNode.h.
|
inlinevirtual |
Changes the parent of the scene node.
newParent | The new parent to be used. |
Definition at line 446 of file ISceneNode.h.
|
inlinevirtual |
Reimplemented in saga::scene::IMeshSceneNode.
Definition at line 132 of file ISceneNode.h.
|
inlinevirtual |
Sets the position of the node relative to its parent.
Note that the position is relative to the parent.
newpos | New relative position of the scene node. |
Definition at line 418 of file ISceneNode.h.
|
inlinevirtual |
Sets the rotation of the node relative to its parent.
This only modifies the relative rotation of the node.
rotation | New rotation of the node in degrees. |
Reimplemented in saga::scene::ICameraSceneNode.
Definition at line 401 of file ISceneNode.h.
|
inlinevirtual |
Sets the relative scale of the scene node.
scale | New scale of the node, relative to its parent. |
Definition at line 383 of file ISceneNode.h.
|
inline |
Definition at line 127 of file ISceneNode.h.
|
inlinevirtual |
Sets if the node should be visible or not.
All children of this node won't be visible either, when set to false. Invisible nodes are not valid candidates for selection by collision manager bounding box methods.
isVisible | If the node shall be visible. |
Definition at line 266 of file ISceneNode.h.
|
inlinevirtual |
Returns the triangle selector attached to this scene node.
The Selector can be used by the engine for doing collision detection. You can create a TriangleSelector with ISceneManager::createTriangleSelector() or ISceneManager::createOctreeTriangleSelector and set it with ISceneNode::setTriangleSelector(). If a scene node got no triangle selector, but collision tests should be done with it, a triangle selector is created using the bounding box of the scene node.
selector | New triangle selector for this scene node. Updates the absolute position based on the relative and the parents position Note: This does not recursively update the parents absolute positions, so if you have a deeper hierarchy you might want to update the parents first. |
Definition at line 496 of file ISceneNode.h.
|
protected |
Absolute transformation of the node.
Definition at line 598 of file ISceneNode.h.
|
protected |
List of all animator nodes.
Definition at line 619 of file ISceneNode.h.
|
protected |
List of all children of this node.
Definition at line 613 of file ISceneNode.h.
|
protected |
Definition at line 631 of file ISceneNode.h.
|
protected |
Is the node visible?
Definition at line 636 of file ISceneNode.h.
|
protected |
Name of the scene node.
Definition at line 595 of file ISceneNode.h.
|
protected |
A clone function for the ISceneNode members.
This method can be used by clone() implementations of derived classes
toCopyFrom | The node from which the values are copied |
newManager | The new scene manager. Sets the new scene manager for this node and all children. Called by addChild when moving nodes between scene managers ID of this scene node |
Definition at line 592 of file ISceneNode.h.
|
protected |
Custom hook into rendering process of the scene node.
This function is called before the node is rendered by GPU. Use it to update node textures, UBO, push constants, SSBO, ...
Definition at line 629 of file ISceneNode.h.
|
protected |
Pointer to the parent.
Definition at line 610 of file ISceneNode.h.
|
protected |
Definition at line 633 of file ISceneNode.h.
|
protected |
Relative rotation of the scene node.
Definition at line 604 of file ISceneNode.h.
|
protected |
Relative scale of the scene node.
Definition at line 607 of file ISceneNode.h.
|
protected |
Relative translation of the scene node.
Definition at line 601 of file ISceneNode.h.
|
protected |
Pointer to the scene manager.
Definition at line 622 of file ISceneNode.h.
|
protected |
Texture list.
Definition at line 616 of file ISceneNode.h.