5#ifndef DCPP_I_SCENE_NODE_HPP_INCLUDED
6#define DCPP_I_SCENE_NODE_HPP_INCLUDED
8#include <duckcpp/core/engine/IAttributeExchangingObject.hpp>
9#include <duckcpp/core/engine/ESceneNodeTypes.hpp>
10#include <duckcpp/core/engine/ESceneNodeUpdateAbs.hpp>
11#include <duckcpp/core/engine/ECullingTypes.hpp>
12#include <duckcpp/core/engine/EDebugSceneTypes.hpp>
13#include <duckcpp/core/engine/ISceneNodeAnimator.hpp>
14#include <duckcpp/core/engine/ITriangleSelector.hpp>
15#include <duckcpp/core/engine/SMaterial.hpp>
16#include <duckcpp/core/engine/irrString.hpp>
17#include <duckcpp/core/engine/aabbox3d.hpp>
18#include <duckcpp/core/engine/matrix4.hpp>
19#include <duckcpp/core/engine/irrList.hpp>
20#include <duckcpp/core/engine/IAttributes.hpp>
71 ISceneNodeAnimatorList::Iterator ait =
Animators.begin();
98 ISceneNodeList::Iterator it =
Children.begin();
100 (*it)->OnRegisterSceneNode();
117 ISceneNodeAnimatorList::Iterator ait =
Animators.begin();
125 if ( anim->isEnabled() )
136 ISceneNodeList::Iterator it =
Children.begin();
138 (*it)->OnAnimate(timeMs);
300 if (child && (child !=
this))
322 ISceneNodeList::Iterator it =
Children.begin();
342 ISceneNodeList::Iterator it =
Children.begin();
389 ISceneNodeAnimatorList::Iterator it =
Animators.begin();
392 if ((*it) == animator)
407 ISceneNodeAnimatorList::Iterator it =
Animators.begin();
824 ISceneNodeList::Iterator it = toCopyFrom->
Children.begin();
825 for (; it != toCopyFrom->
Children.end(); ++it)
826 (*it)->clone(
this, newManager);
830 ISceneNodeAnimatorList::Iterator ait = toCopyFrom->
Animators.begin();
831 for (; ait != toCopyFrom->
Animators.end(); ++ait)
848 ISceneNodeList::Iterator it =
Children.begin();
850 (*it)->setSceneManager(newManager);
bool drop() const
Drops the object. Decrements the reference counter by one.
Definition IReferenceCounted.hpp:126
void grab() const
Grabs the object. Increments the reference counter by one.
Definition IReferenceCounted.hpp:96
An object which is able to serialize and deserialize its attributes into an attributes object.
Definition IAttributeExchangingObject.hpp:54
Provides a generic interface for attributes and their values and the possibility to serialize them.
Definition IAttributes.hpp:42
virtual void addVector3d(const dcpp::char_kt *attributeName, const dcpp::nub::vector3df &value)=0
Adds an attribute as 3d vector.
virtual dcpp::nub::string getAttributeAsString(const dcpp::char_kt *attributeName, const dcpp::nub::string &defaultNotFound=dcpp::nub::string()) const =0
virtual void addString(const dcpp::char_kt *attributeName, const dcpp::char_kt *value)=0
Adds an attribute as string.
virtual void addEnum(const dcpp::char_kt *attributeName, const dcpp::char_kt *enumValue, const dcpp::char_kt *const *enumerationLiterals)=0
Adds an attribute as enum.
virtual bool existsAttribute(const dcpp::char_kt *attributeName) const =0
Returns if an attribute with a name exists.
virtual void addInt(const dcpp::char_kt *attributeName, dcpp::int32_kt value)=0
Adds an attribute as integer.
virtual bool getAttributeAsBool(const dcpp::char_kt *attributeName, bool defaultNotFound=false) const =0
virtual dcpp::nub::vector3df getAttributeAsVector3d(const dcpp::char_kt *attributeName, const dcpp::nub::vector3df &defaultNotFound=dcpp::nub::vector3df(0, 0, 0)) const =0
virtual void addBool(const dcpp::char_kt *attributeName, bool value)=0
Adds an attribute as bool.
virtual const dcpp::char_kt * getAttributeAsEnumeration(const dcpp::char_kt *attributeName, const dcpp::char_kt *defaultNotFound=0) const =0
virtual dcpp::int32_kt getAttributeAsInt(const dcpp::char_kt *attributeName, dcpp::int32_kt defaultNotFound=0) const =0
class holding data describing options
Definition IAttributeExchangingObject.hpp:35
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
vector3d< T > getTranslation() const
Gets the current translation.
Definition matrix4.hpp:814
void transformVect(vector3df &vect) const
Transforms the vector by this matrix.
Definition matrix4.hpp:1224
PMatrix4< T > & setTranslation(const vector3d< T > &translation)
Set the translation of the current matrix. Will erase any previous values.
Definition matrix4.hpp:821
PMatrix4< T > & setScale(const vector3d< T > &scale)
Set Scale.
Definition matrix4.hpp:845
void transformBoxEx(dcpp::nub::aabbox3df &box) const
Transforms a axis aligned bounding box.
Definition matrix4.hpp:1314
PMatrix4< T > & setRotationDegrees(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.hpp:881
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
void getEdges(vector3d< T > *edges) const
Stores all 8 edges of the box into an array.
Definition aabbox3d.hpp:150
const T * data() const
Returns character string.
Definition irrString.hpp:537
3d vector template class with lots of operators and methods.
Definition vector3d.hpp:32
The Scene Manager manages scene nodes, mesh resources, cameras and all the other stuff.
Definition ISceneManager.hpp:160
Animates a scene node. Can animate position, rotation, material, and so on.
Definition ISceneNodeAnimator.hpp:32
virtual void animateNode(ISceneNode *node, dcpp::uint32_kt timeMs)=0
Animates a scene node.
virtual ISceneNodeAnimator * createClone(ISceneNode *node, ISceneManager *newManager=0)=0
Creates a clone of this animator.
Scene node interface.
Definition ISceneNode.hpp:43
virtual void setDebugDataVisible(dcpp::uint32_kt state)
Sets if debug data like bounding boxes should be drawn.
Definition ISceneNode.hpp:581
virtual void OnRegisterSceneNode()
This method is called just before the rendering process of the whole scene.
Definition ISceneNode.hpp:94
virtual ~ISceneNode()
Destructor.
Definition ISceneNode.hpp:65
virtual const dcpp::nub::vector3df & getRotation() const
Gets the rotation of the node relative to its parent.
Definition ISceneNode.hpp:496
virtual void setPosition(const dcpp::nub::vector3df &newpos)
Sets the position of the node relative to its parent.
Definition ISceneNode.hpp:524
const dcpp::nub::list< ISceneNodeAnimator * > & getAnimators() const
Get a list of all scene node animators.
Definition ISceneNode.hpp:377
virtual const dcpp::nub::matrix4 & getAbsoluteTransformation() const
Get the absolute transformation of the node. Is recalculated every OnAnimate()-call.
Definition ISceneNode.hpp:213
virtual void serializeAttributes(dcpp::io::IAttributes *out, dcpp::io::SAttributeReadWriteOptions *options=0) const override
Writes attributes of the scene node.
Definition ISceneNode.hpp:724
virtual const dcpp::nub::vector3df & getPosition() const
Gets the position of the node relative to its parent.
Definition ISceneNode.hpp:515
virtual dcpp::video::SMaterial & getMaterial(dcpp::uint32_kt num)
Returns the material based on the zero based index i.
Definition ISceneNode.hpp:423
dcpp::nub::string Name
Name of the scene node.
Definition ISceneNode.hpp:854
virtual void setVisible(bool isVisible)
Sets if the node should be visible or not.
Definition ISceneNode.hpp:270
ISceneNode * Parent
Pointer to the parent.
Definition ISceneNode.hpp:869
virtual void setScale(const dcpp::nub::vector3df &scale)
Sets the relative scale of the scene node.
Definition ISceneNode.hpp:485
dcpp::nub::list< ISceneNode * > Children
List of all children of this node.
Definition ISceneNode.hpp:872
void setMaterialFlag(dcpp::video::E_MATERIAL_FLAG flag, bool newvalue)
Sets all material flags at once to a new value.
Definition ISceneNode.hpp:442
virtual void setParent(ISceneNode *newParent)
Changes the parent of the scene node.
Definition ISceneNode.hpp:624
void setUpdateAbsolutePosBehavior(ESCENE_NODE_UPDATE_ABS behavior)
Set how updateAbsolutePosition calculates the absolute transformation matrix.
Definition ISceneNode.hpp:565
virtual ISceneNode * clone(ISceneNode *newParent=0, ISceneManager *newManager=0)
Creates a clone of this scene node and its children.
Definition ISceneNode.hpp:786
virtual void addChild(ISceneNode *child)
Adds a child to this scene node.
Definition ISceneNode.hpp:298
dcpp::nub::list< ISceneNodeAnimator * > Animators
List of all animator nodes.
Definition ISceneNode.hpp:875
virtual const dcpp::nub::aabbox3df getTransformedBoundingBox() const
Get the axis aligned, transformed and animated absolute bounding box of this node.
Definition ISceneNode.hpp:186
virtual dcpp::int32_kt getID() const
Get the id of the scene node.
Definition ISceneNode.hpp:279
ISceneNode(ISceneNode *parent, ISceneManager *mgr, dcpp::int32_kt id=-1, const dcpp::nub::vector3df &position=dcpp::nub::vector3df(0, 0, 0), const dcpp::nub::vector3df &rotation=dcpp::nub::vector3df(0, 0, 0), const dcpp::nub::vector3df &scale=dcpp::nub::vector3df(1.0f, 1.0f, 1.0f))
Constructor.
Definition ISceneNode.hpp:47
virtual void removeAnimators()
Removes all animators from this scene node.
Definition ISceneNode.hpp:405
void setMaterialTexture(dcpp::uint32_kt textureLayer, dcpp::video::ITexture *texture)
Sets the texture of the specified layer in all materials of this scene node to the new texture.
Definition ISceneNode.hpp:453
virtual void remove()
Removes this scene node from the scene.
Definition ISceneNode.hpp:356
dcpp::nub::vector3df RelativeTranslation
Relative translation of the scene node.
Definition ISceneNode.hpp:860
dcpp::int32_kt ID
ID of the node.
Definition ISceneNode.hpp:884
ISceneManager * SceneManager
Pointer to the scene manager.
Definition ISceneNode.hpp:878
virtual dcpp::nub::vector3df getAbsolutePosition() const
Gets the absolute position of the node in world coordinates.
Definition ISceneNode.hpp:539
dcpp::uint32_kt isDebugDataVisible() const
Returns if debug data like bounding boxes are drawn.
Definition ISceneNode.hpp:589
virtual void updateAbsolutePosition()
Updates the absolute tranformation or position based on the relative and the parents transformation.
Definition ISceneNode.hpp:681
virtual void getTransformedBoundingBoxEdges(dcpp::nub::array< dcpp::nub::vector3df > &edges) const
Definition ISceneNode.hpp:198
dcpp::uint32_kt DebugDataVisible
Flag if debug data should be drawn, such as Bounding Boxes.
Definition ISceneNode.hpp:893
ESCENE_NODE_UPDATE_ABS getUpdateAbsolutePosBehavior() const
Get how updateAbsolutePosition calculates the absolute transformation matrix.
Definition ISceneNode.hpp:571
virtual void addAnimator(ISceneNodeAnimator *animator)
Adds an animator which should animate this node.
Definition ISceneNode.hpp:365
virtual void setName(const dcpp::nub::string &name)
Sets the name of the node.
Definition ISceneNode.hpp:165
virtual void setID(dcpp::int32_kt id)
Sets the id of the scene node.
Definition ISceneNode.hpp:288
void setAutomaticCulling(dcpp::uint32_kt state)
Set a culling style or disable culling completely.
Definition ISceneNode.hpp:551
virtual void deserializeAttributes(dcpp::io::IAttributes *in, dcpp::io::SAttributeReadWriteOptions *options=0) override
Reads attributes of the scene node.
Definition ISceneNode.hpp:750
virtual void removeAll()
Removes all children of this scene node.
Definition ISceneNode.hpp:340
virtual dcpp::uint32_kt getMaterialCount() const
Get amount of materials used by this scene node.
Definition ISceneNode.hpp:431
const dcpp::nub::list< ISceneNode * > & getChildren() const
Returns a const reference to the list of all children.
Definition ISceneNode.hpp:616
bool isDebugObject() const
Returns if this scene node is a debug object.
Definition ISceneNode.hpp:608
virtual const dcpp::nub::aabbox3df & getBoundingBox() const =0
Get the axis aligned, not transformed bounding box of this node.
void setMaterialType(dcpp::video::E_MATERIAL_TYPE newType)
Sets the material type of all materials in this scene node to a new material type.
Definition ISceneNode.hpp:465
virtual const dcpp::char_kt * getName() const
Returns the name of the node.
Definition ISceneNode.hpp:149
virtual void setName(const dcpp::char_kt *name)
Sets the name of the node.
Definition ISceneNode.hpp:157
dcpp::scene::ISceneNode * getParent() const
Returns the parent of this scene node.
Definition ISceneNode.hpp:703
void setIsDebugObject(bool debugObject)
Sets if this scene node is a debug object.
Definition ISceneNode.hpp:598
virtual void removeAnimator(ISceneNodeAnimator *animator)
Removes an animator from this scene node.
Definition ISceneNode.hpp:387
virtual bool isVisible() const
Returns whether the node should be visible (if all of its parents are visible).
Definition ISceneNode.hpp:246
virtual void setTriangleSelector(ITriangleSelector *selector)
Sets the triangle selector of the scene node.
Definition ISceneNode.hpp:663
bool IsDebugObject
Is debug object?
Definition ISceneNode.hpp:899
virtual ISceneManager * getSceneManager(void) const
Retrieve the scene manager for this node.
Definition ISceneNode.hpp:793
dcpp::uint32_kt getAutomaticCulling() const
Gets the automatic culling state.
Definition ISceneNode.hpp:559
ESCENE_NODE_UPDATE_ABS UpdateAbsolutePosBehavior
How updateAbsolutePosition calculates AbsoluteTransformation.
Definition ISceneNode.hpp:887
virtual dcpp::nub::matrix4 getRelativeTransformation() const
Returns the relative transformation of the scene node.
Definition ISceneNode.hpp:224
dcpp::nub::matrix4 AbsoluteTransformation
Absolute transformation of the node.
Definition ISceneNode.hpp:857
virtual ESCENE_NODE_TYPE getType() const
Returns type of the scene node.
Definition ISceneNode.hpp:711
dcpp::nub::vector3df RelativeRotation
Relative rotation of the scene node.
Definition ISceneNode.hpp:863
virtual void render()=0
Renders the node.
virtual void OnAnimate(dcpp::uint32_kt timeMs)
OnAnimate() is called just before rendering the whole scene.
Definition ISceneNode.hpp:111
virtual const dcpp::nub::vector3df & getScale() const
Gets the scale of the scene node relative to its parent.
Definition ISceneNode.hpp:477
ITriangleSelector * TriangleSelector
Pointer to the triangle selector.
Definition ISceneNode.hpp:881
void cloneMembers(ISceneNode *toCopyFrom, ISceneManager *newManager)
A clone function for the ISceneNode members.
Definition ISceneNode.hpp:802
dcpp::nub::vector3df RelativeScale
Relative scale of the scene node.
Definition ISceneNode.hpp:866
void setSceneManager(ISceneManager *newManager)
Definition ISceneNode.hpp:844
bool IsVisible
Is the node visible?
Definition ISceneNode.hpp:896
dcpp::uint32_kt AutomaticCullingState
Automatic culling state.
Definition ISceneNode.hpp:890
virtual bool isTrulyVisible() const
Check whether the node is truly visible, taking into accounts its parents' visibility.
Definition ISceneNode.hpp:254
virtual ITriangleSelector * getTriangleSelector() const
Returns the triangle selector attached to this scene node.
Definition ISceneNode.hpp:648
virtual void setRotation(const dcpp::nub::vector3df &rotation)
Sets the rotation of the node relative to its parent.
Definition ISceneNode.hpp:505
virtual bool removeChild(ISceneNode *child)
Removes a child from this scene node.
Definition ISceneNode.hpp:320
Interface to return triangles with specific properties.
Definition ITriangleSelector.hpp:74
Interface of a Video Driver dependent Texture.
Definition ITexture.hpp:186
Class for holding parameters for a material renderer.
Definition SMaterial.hpp:304
void setTexture(dcpp::uint32_kt i, ITexture *tex)
Sets the i-th texture.
Definition SMaterial.hpp:538
E_MATERIAL_TYPE MaterialType
Type of the material. Specifies how everything is blended together.
Definition SMaterial.hpp:324
void setFlag(E_MATERIAL_FLAG flag, bool value)
Sets the Material flag to the given value.
Definition SMaterial.hpp:548
ESCENE_NODE_UPDATE_ABS
Options how ISceneNode::updateAbsolutePosition calculates the AbsoluteTransformation.
Definition ESceneNodeUpdateAbs.hpp:13
@ ESNUA_TRANSFORM_MATRIX
Node and parent transformation matrices are multiplied (default)
Definition ESceneNodeUpdateAbs.hpp:15
@ ESNUA_TRANSFORM_POSITION
Definition ESceneNodeUpdateAbs.hpp:20
ESCENE_NODE_TYPE
An enumeration for all types of built-in scene nodes.
Definition ESceneNodeTypes.hpp:20
@ ESNT_UNKNOWN
Unknown scene node.
Definition ESceneNodeTypes.hpp:96
const dcpp::char_kt *const AutomaticCullingNames[]
Names for culling type.
Definition ECullingTypes.hpp:26
@ EDS_OFF
No Debug Data ( Default )
Definition EDebugSceneTypes.hpp:17
const dcpp::char_kt *const SceneNodeUpdateAbsNames[]
Names for culling type.
Definition ESceneNodeUpdateAbs.hpp:24
DUCKCPP_API SMaterial IdentityMaterial
global const identity Material
E_MATERIAL_FLAG
Material flags.
Definition EMaterialFlags.hpp:15
E_MATERIAL_TYPE
Abstracted and easy to use fixed function/programmable pipeline material modes.
Definition EMaterialTypes.hpp:15
const dcpp::uint32_kt MATERIAL_MAX_TEXTURES
Maximum number of texture an SMaterial can have.
Definition SMaterial.hpp:283
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition shared_device.hpp:34
char char_kt
8 bit character variable.
Definition irrTypes.hpp:37
unsigned int uint32_kt
32 bit unsigned variable.
Definition irrTypes.hpp:64
signed int int32_kt
32 bit signed variable.
Definition irrTypes.hpp:72