Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
|
Scene node interface. More...
#include <nirtcpp/core/engine/ISceneNode.hpp>
Public Member Functions | |
ISceneNode (ISceneNode *parent, ISceneManager *mgr, s32 id=-1, const core::vector3df &position=core::vector3df(0, 0, 0), const core::vector3df &rotation=core::vector3df(0, 0, 0), const core::vector3df &scale=core::vector3df(1.0f, 1.0f, 1.0f)) | |
Constructor. | |
virtual | ~ISceneNode () |
Destructor. | |
virtual void | OnRegisterSceneNode () |
This method is called just before the rendering process of the whole scene. | |
virtual void | OnAnimate (u32 timeMs) |
OnAnimate() is called just before rendering the whole scene. | |
virtual void | render ()=0 |
Renders the node. | |
virtual const c8 * | getName () const |
Returns the name of the node. | |
virtual void | setName (const c8 *name) |
Sets the name of the node. | |
virtual void | setName (const core::stringc &name) |
Sets the name of the node. | |
virtual const core::aabbox3d< f32 > & | getBoundingBox () const =0 |
Get the axis aligned, not transformed bounding box of this node. | |
virtual const core::aabbox3d< f32 > | getTransformedBoundingBox () const |
Get the axis aligned, transformed and animated absolute bounding box of this node. | |
virtual void | getTransformedBoundingBoxEdges (core::array< core::vector3d< f32 > > &edges) const |
virtual const core::matrix4 & | getAbsoluteTransformation () const |
Get the absolute transformation of the node. Is recalculated every OnAnimate()-call. | |
virtual core::matrix4 | getRelativeTransformation () const |
Returns the relative transformation of the scene node. | |
virtual bool | isVisible () const |
Returns whether the node should be visible (if all of its parents are visible). | |
virtual bool | isTrulyVisible () const |
Check whether the node is truly visible, taking into accounts its parents' visibility. | |
virtual void | setVisible (bool isVisible) |
Sets if the node should be visible or not. | |
virtual s32 | getID () const |
Get the id of the scene node. | |
virtual void | setID (s32 id) |
Sets the id of the scene node. | |
virtual void | addChild (ISceneNode *child) |
Adds a child to this scene node. | |
virtual bool | removeChild (ISceneNode *child) |
Removes a child from this scene node. | |
virtual void | removeAll () |
Removes all children of this scene node. | |
virtual void | remove () |
Removes this scene node from the scene. | |
virtual void | addAnimator (ISceneNodeAnimator *animator) |
Adds an animator which should animate this node. | |
const core::list< ISceneNodeAnimator * > & | getAnimators () const |
Get a list of all scene node animators. | |
virtual void | removeAnimator (ISceneNodeAnimator *animator) |
Removes an animator from this scene node. | |
virtual void | removeAnimators () |
Removes all animators from this scene node. | |
virtual video::SMaterial & | getMaterial (u32 num) |
Returns the material based on the zero based index i. | |
virtual u32 | getMaterialCount () const |
Get amount of materials used by this scene node. | |
void | setMaterialFlag (video::E_MATERIAL_FLAG flag, bool newvalue) |
Sets all material flags at once to a new value. | |
void | setMaterialTexture (u32 textureLayer, video::ITexture *texture) |
Sets the texture of the specified layer in all materials of this scene node to the new texture. | |
void | setMaterialType (video::E_MATERIAL_TYPE newType) |
Sets the material type of all materials in this scene node to a new material type. | |
virtual const core::vector3df & | getScale () const |
Gets the scale of the scene node relative to its parent. | |
virtual void | setScale (const core::vector3df &scale) |
Sets the relative scale of the scene node. | |
virtual const core::vector3df & | getRotation () const |
Gets the rotation of the node relative to its parent. | |
virtual void | setRotation (const core::vector3df &rotation) |
Sets the rotation of the node relative to its parent. | |
virtual const core::vector3df & | getPosition () const |
Gets the position of the node relative to its parent. | |
virtual void | setPosition (const core::vector3df &newpos) |
Sets the position of the node relative to its parent. | |
virtual core::vector3df | getAbsolutePosition () const |
Gets the absolute position of the node in world coordinates. | |
void | setAutomaticCulling (u32 state) |
Set a culling style or disable culling completely. | |
u32 | getAutomaticCulling () const |
Gets the automatic culling state. | |
void | setUpdateAbsolutePosBehavior (ESCENE_NODE_UPDATE_ABS behavior) |
Set how updateAbsolutePosition calculates the absolute transformation matrix. | |
ESCENE_NODE_UPDATE_ABS | getUpdateAbsolutePosBehavior () const |
Get how updateAbsolutePosition calculates the absolute transformation matrix. | |
virtual void | setDebugDataVisible (u32 state) |
Sets if debug data like bounding boxes should be drawn. | |
u32 | isDebugDataVisible () const |
Returns if debug data like bounding boxes are drawn. | |
void | setIsDebugObject (bool debugObject) |
Sets if this scene node is a debug object. | |
bool | isDebugObject () const |
Returns if this scene node is a debug object. | |
const core::list< ISceneNode * > & | getChildren () const |
Returns a const reference to the list of all children. | |
virtual void | setParent (ISceneNode *newParent) |
Changes the parent of the scene node. | |
virtual ITriangleSelector * | getTriangleSelector () const |
Returns the triangle selector attached to this scene node. | |
virtual void | setTriangleSelector (ITriangleSelector *selector) |
Sets the triangle selector of the scene node. | |
virtual void | updateAbsolutePosition () |
Updates the absolute tranformation or position based on the relative and the parents transformation. | |
scene::ISceneNode * | getParent () const |
Returns the parent of this scene node. | |
virtual ESCENE_NODE_TYPE | getType () const |
Returns type of the scene node. | |
virtual void | serializeAttributes (io::IAttributes *out, io::SAttributeReadWriteOptions *options=0) const override |
Writes attributes of the scene node. | |
virtual void | deserializeAttributes (io::IAttributes *in, io::SAttributeReadWriteOptions *options=0) override |
Reads attributes of the scene node. | |
virtual ISceneNode * | clone (ISceneNode *newParent=0, ISceneManager *newManager=0) |
Creates a clone of this scene node and its children. | |
virtual ISceneManager * | getSceneManager (void) const |
Retrieve the scene manager for this node. | |
Public Member Functions inherited from nirt::IReferenceCounted | |
IReferenceCounted () | |
Constructor. | |
virtual | ~IReferenceCounted () |
Destructor. | |
void | grab () const |
Grabs the object. Increments the reference counter by one. | |
bool | drop () const |
Drops the object. Decrements the reference counter by one. | |
s32 | getReferenceCount () const |
Get the reference count. | |
const c8 * | getDebugName () const |
Returns the debug name of the object. | |
Protected Member Functions | |
void | cloneMembers (ISceneNode *toCopyFrom, ISceneManager *newManager) |
A clone function for the ISceneNode members. | |
void | setSceneManager (ISceneManager *newManager) |
Protected Member Functions inherited from nirt::IReferenceCounted | |
void | setDebugName (const c8 *newName) |
Sets the debug name of the object. | |
Protected Attributes | |
core::stringc | Name |
Name of the scene node. | |
core::matrix4 | AbsoluteTransformation |
Absolute transformation of the node. | |
core::vector3df | RelativeTranslation |
Relative translation of the scene node. | |
core::vector3df | RelativeRotation |
Relative rotation of the scene node. | |
core::vector3df | RelativeScale |
Relative scale of the scene node. | |
ISceneNode * | Parent |
Pointer to the parent. | |
core::list< ISceneNode * > | Children |
List of all children of this node. | |
core::list< ISceneNodeAnimator * > | Animators |
List of all animator nodes. | |
ISceneManager * | SceneManager |
Pointer to the scene manager. | |
ITriangleSelector * | TriangleSelector |
Pointer to the triangle selector. | |
s32 | ID |
ID of the node. | |
ESCENE_NODE_UPDATE_ABS | UpdateAbsolutePosBehavior |
How updateAbsolutePosition calculates AbsoluteTransformation. | |
u32 | AutomaticCullingState |
Automatic culling state. | |
u32 | DebugDataVisible |
Flag if debug data should be drawn, such as Bounding Boxes. | |
bool | IsVisible |
Is the node visible? | |
bool | IsDebugObject |
Is debug object? | |
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.
|
inlinevirtual |
Adds an animator which should animate this node.
animator | A pointer to the new animator. |
|
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. |
|
inlinevirtual |
Creates a clone of this scene node and its children.
newParent | An optional new parent. |
newManager | An optional new scene manager. |
Reimplemented in nirt::scene::IAnimatedMeshSceneNode.
|
inlineprotected |
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. |
|
inlineoverridevirtual |
Reads attributes of the scene node.
Implement this to set the attributes of your scene node for scripting languages, editors, debuggers or xml deserialization purposes.
in | The attribute container to read from. |
options | Additional options which might influence the deserialization. |
Reimplemented from nirt::io::IAttributeExchangingObject.
Reimplemented in nirt::scene::IParticleSystemSceneNode, and nirt::scene::ICameraSceneNode.
|
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().
|
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().
|
inline |
Get a list of all scene node animators.
|
inline |
Gets the automatic culling state.
|
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 nirt::scene::ITerrainSceneNode, and nirt::scene::IBoneSceneNode.
|
inline |
Returns a const reference to the list of all children.
|
inlinevirtual |
Get the id of the scene node.
This id can be used to identify the node.
|
inlinevirtual |
Returns the material based on the zero based index i.
To get the amount of materials used by this scene node, use getMaterialCount(). This function is needed for inserting the node into the scene hierarchy at an optimal position for minimizing renderstate changes, but can also be used to directly modify the material of a scene node.
num | Zero based index. The maximal value is getMaterialCount() - 1. |
|
inlinevirtual |
Get amount of materials used by this scene node.
|
inlinevirtual |
Returns the name of the node.
|
inline |
Returns the parent of this scene node.
|
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.
|
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.
|
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()
|
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()
|
inlinevirtual |
Retrieve the scene manager for this node.
|
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.
|
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 |
|
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.
|
inlinevirtual |
Returns type of the scene node.
Reimplemented in nirt::scene::IVolumeLightSceneNode.
|
inline |
Returns if debug data like bounding boxes are drawn.
|
inline |
Returns if this scene node is a debug object.
Debug objects have some special properties, for example they can be easily excluded from collision detection or from serialization, etc.
|
inlinevirtual |
Check whether the node is truly visible, taking into accounts its parents' visibility.
|
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
|
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 nirt::scene::IBoneSceneNode.
|
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:
|
inlinevirtual |
Removes this scene node from the scene.
If no other grab exists for this node, it will be deleted.
|
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.
|
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. |
|
inlinevirtual |
Removes all animators from this scene node.
The animators might also be deleted if no other grab exists for them.
|
inlinevirtual |
Removes a child from this scene node.
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. |
|
pure virtual |
Renders the node.
Implemented in nirt::scene::IBoneSceneNode.
|
inlineoverridevirtual |
Writes attributes of the scene node.
Implement this to expose the attributes of your scene node for scripting languages, editors, debuggers or xml serialization purposes.
out | The attribute container to write into. |
options | Additional options which might influence the serialization. |
Reimplemented from nirt::io::IAttributeExchangingObject.
Reimplemented in nirt::scene::IParticleSystemSceneNode, and nirt::scene::ICameraSceneNode.
|
inline |
Set a culling style or disable culling completely.
Box cullling (EAC_BOX) is set by default. Note that not all SceneNodes support culling and that some nodes always cull their geometry because it is their only reason for existence, for example the OctreeSceneNode.
state | The culling state to be used. Check E_CULLING_TYPE for possible values. |
|
inlinevirtual |
Sets if debug data like bounding boxes should be drawn.
A bitwise OR of the types from nirt::scene::E_DEBUG_SCENE_TYPE. Please note that not all scene nodes support all debug data types.
state | The debug data visibility state to be used. |
|
inlinevirtual |
Sets the id of the scene node.
This id can be used to identify the node.
id | The new id. |
|
inline |
Sets if this scene node is a debug object.
Debug objects have some special properties, for example they can be easily excluded from collision detection or from serialization, etc.
|
inline |
Sets all material flags at once to a new value.
Useful, for example, if you want the whole mesh to be affected by light.
flag | Which flag of all materials to be set. |
newvalue | New value of that flag. |
|
inline |
Sets the texture of the specified layer in all materials of this scene node to the new texture.
textureLayer | Layer of texture to be set. Must be a value smaller than MATERIAL_MAX_TEXTURES. |
texture | New texture to be used. |
|
inline |
Sets the material type of all materials in this scene node to a new material type.
newType | New type of material to be set. |
|
inlinevirtual |
Sets the name of the node.
name | New name of the scene node. |
|
inlinevirtual |
Sets the name of the node.
name | New name of the scene node. |
|
inlinevirtual |
Changes the parent of the scene node.
newParent | The new parent to be used. |
|
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. |
|
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 nirt::scene::ICameraSceneNode.
|
inlinevirtual |
Sets the relative scale of the scene node.
scale | New scale of the node, relative to its parent. |
|
inlineprotected |
Sets the new scene manager for this node and all children. Called by addChild when moving nodes between scene managers
|
inlinevirtual |
Sets the triangle selector of the 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(). Some nodes may create their own selector by default, so it would be good to check if there is already a selector in this node by calling ISceneNode::getTriangleSelector().
selector | New triangle selector for this scene node. |
|
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. |
Reimplemented in nirt::scene::ILightSceneNode.
|
inlinevirtual |
Updates the absolute tranformation or position based on the relative and the parents transformation.
It's exact behavior can be controlled by setUpdateAbsolutePosBehavior. 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.