Saga3D API Documentation
1.0-RC4
|
Go to the documentation of this file. 1 #ifndef __I_SCENE_NODE_H_INCLUDED__
2 #define __I_SCENE_NODE_H_INCLUDED__
12 #include <glm/gtx/euler_angles.hpp>
13 #include <glm/gtx/transform.hpp>
14 #include <glm/gtx/matrix_decompose.hpp>
47 const std::shared_ptr<ISceneNode>& parent,
48 const std::shared_ptr<ISceneManager>& mgr,
49 const glm::vec3& position = glm::vec3(0,0,0),
50 const glm::vec3& rotation = glm::vec3(0,0,0),
51 const glm::vec3& scale = glm::vec3(1.0f, 1.0f, 1.0f))
56 parent->addChild(shared_from_this());
61 virtual void onEvent(
const SDL_Event& event)
override
102 (*it)->onRegisterSceneNode(pass);
110 (*it)->onUnregisterSceneNode(pass);
150 anim->animateNode(*
this, time);
159 (*it)->onAnimate(time);
208 for (std::uint32_t i= 0; i<8; ++i)
234 return translation * rotation * scale;
258 return Parent->isTrulyVisible();
275 virtual void addChild(
const std::shared_ptr<ISceneNode>& child)
277 if (child && (child.get() !=
this))
286 child->Parent = shared_from_this();
295 virtual bool removeChild(
const std::shared_ptr<ISceneNode>& child)
299 if ((*it).get() == child.get())
332 Parent->removeChild(shared_from_this());
337 virtual void addAnimator(
const std::shared_ptr<ISceneNodeAnimator>& animator)
439 const std::vector<std::shared_ptr<ISceneNode>>&
getChildren()
const
446 virtual void setParent(
const std::shared_ptr<ISceneNode>& newParent)
453 Parent->addChild(shared_from_this());
525 virtual std::shared_ptr<ISceneNode>
clone(
const std::shared_ptr<ISceneNode>& newParent = 0)
610 std::shared_ptr<ISceneNode>
Parent =
nullptr;
619 std::vector<std::shared_ptr<ISceneNodeAnimator>>
Animators;
void setDrawCommands(video::DrawCommandList &&list)
const std::shared_ptr< ISceneNode > & getParent() const
Returns the parent of this scene node.
virtual const glm::mat4 & getAbsoluteTransformation() const
Get the absolute transformation of the node. Is recalculated every onAnimate()-call.
virtual void onAnimate(const float time)
onAnimate() is called just before rendering the whole scene.
virtual const glm::vec3 & getScale() const
Gets the scale of the scene node relative to its parent.
virtual const glm::vec3 & getPosition() const
Gets the position of the node relative to its parent.
virtual void setParent(const std::shared_ptr< ISceneNode > &newParent)
Changes the parent of the scene node.
constexpr SGPUResource::HandleType NULL_GPU_RESOURCE_HANDLE
virtual void setRotation(const glm::vec3 &rotation)
Sets the rotation of the node relative to its parent.
bool hasDrawCommands() const
virtual void setName(const std::string &name)
Sets the name of the node.
Type for list of scene node animators.
std::function< void()> OnRenderCallback
Custom hook into rendering process of the scene node.
video::PipelineHandle Pipeline
@ UNKNOWN
Unknown scene node.
glm::mat4 AbsoluteTransformation
Absolute transformation of the node.
virtual std::shared_ptr< ISceneNode > clone(const std::shared_ptr< ISceneNode > &newParent=0)
Creates a clone of this scene node and its children.
SGPUResource::HandleType PipelineHandle
ID NodeID
A clone function for the ISceneNode members.
const auto & getDrawCommands() const
E_SCENE_NODE_TYPE
An enumeration for all types of built-in scene nodes.
auto getTexture(int slot) const
bool IsVisible
Is the node visible?
const auto & getAnimators() const
Get a list of all scene node animators.
Interface of an object which can receive events (SDL_Event*)
std::vector< std::shared_ptr< ISceneNode > > Children
List of all children of this node.
const std::vector< std::shared_ptr< ISceneNode > > & getChildren() const
Returns a const reference to the list of all children.
constexpr auto INVALID_ID
virtual void removeAnimators()
Removes all animators from this scene node.
std::uint32_t ID
Type for node ID.
virtual const std::shared_ptr< ISceneManager > & getSceneManager() const
Retrieve the scene manager for this node.
virtual E_SCENE_NODE_TYPE getType() const
Returns type of the scene node.
SGPUResource::HandleType TextureHandle
virtual ~ISceneNode()
Destructor.
virtual const core::aabbox3d< float > & getBoundingBox() const =0
Get the axis aligned, not transformed bounding box of this node.
std::vector< std::shared_ptr< ISceneNode > > ISceneNodeList
Type for list of scene nodes.
virtual void onRegisterSceneNode(video::RenderPassHandle pass)
This method is called just before the rendering process of the whole scene.
void getEdges(glm::vec3 *edges) const
Stores all 8 edges of the box into an array.
glm::vec3 RelativeTranslation
Relative translation of the scene node.
virtual const glm::vec3 & getRotation() const
Gets the rotation of the node relative to its parent.
virtual void onUnregisterSceneNode(video::RenderPassHandle pass)
virtual bool removeChild(const std::shared_ptr< ISceneNode > &child)
virtual void setPosition(const glm::vec3 &newpos)
Sets the position of the node relative to its parent.
glm::vec3 RelativeScale
Relative scale of the scene node.
virtual void remove()
Removes this scene node from the scene.
std::vector< SDrawCommand > DrawCommandList
virtual const core::aabbox3d< float > getTransformedBoundingBox() const
Get the axis aligned, transformed and animated absolute bounding box of this node.
virtual void setPipeline(video::PipelineHandle pipeline)
std::shared_ptr< ISceneManager > SceneManager
Pointer to the scene manager.
virtual void setScale(const glm::vec3 &scale)
Sets the relative scale of the scene node.
virtual const std::string & getName() const
Returns the name of the node.
virtual void addChild(const std::shared_ptr< ISceneNode > &child)
Adds a child to this scene node.
virtual void onEvent(const SDL_Event &event) override
Called when an SDL event is fired.
std::array< video::STexture::HandleType, video::MAX_NODE_TEXTURES > Textures
Texture list.
void setTexture(int slot, video::TextureHandle texture)
virtual void updateAbsolutePosition()
Returns the triangle selector attached to this scene node.
virtual glm::vec3 getAbsolutePosition() const
Gets the absolute position of the node in world coordinates.
std::shared_ptr< ISceneNode > Parent
Pointer to the parent.
virtual glm::mat4 getRelativeTransformation() const
Returns the relative transformation of the scene node.
virtual void getTransformedBoundingBoxEdges(std::vector< glm::vec3 > &edges) const
virtual void setVisible(bool isVisible)
Sets if the node should be visible or not.
virtual bool isTrulyVisible() const
Check whether the node is truly visible, taking into accounts its parents' visibility.
SGPUResource::HandleType RenderPassHandle
virtual void removeAll()
Removes all children of this scene node.
void setOnRender(std::function< void()> func)
virtual void addAnimator(const std::shared_ptr< ISceneNodeAnimator > &animator)
Adds an animator which should animate this node.
virtual bool isVisible() const
Returns whether the node should be visible (if all of its parents are visible).
glm::vec3 RelativeRotation
Relative rotation of the scene node.
std::string Name
Name of the scene node.
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.
virtual void removeAnimator(const std::shared_ptr< ISceneNodeAnimator > &animator)
Removes an animator from this scene node.
video::DrawCommandList DrawCommands
std::vector< std::shared_ptr< ISceneNodeAnimator > > Animators
List of all animator nodes.