SceneNode class
#include <nCine/Graphics/SceneNode.h>
Base node of the scene graph transformation hierarchy.
Every drawable and grouping object derives from this class. A node owns a relative transform (position, anchor, scale, rotation), a color and a rendering layer, and keeps a list of child nodes. During a viewport visit the absolute transform is computed from the parent's, and the node and its children are drawn in layer and visit order.
Base classes
- class Object
- Base class of all nCine objects.
Derived classes
- class Jazz2::Editor::PlayTestRootNode
- Node every object of a level is under, it updates them with the time of the play-test.
- class Jazz2::Rendering::BlurRenderPass
- Applies blur to a scene.
- class Jazz2::Rendering::CombineRenderer
- Combines all previous passes of a scene into a resulting image.
- class Jazz2::Rendering::LightingRenderer
- Processes all lights in a scene into an intermediate target.
- class Jazz2::Rendering::UpscaleRenderPass
- Upscales input image usually to a native resolution.
- class Jazz2::Rendering::UpscaleRenderPass::AntialiasingSubpass
- Optional antialiasing subpass.
- class Jazz2::Rendering::WaterRenderer
- Draws the water in front of a layer behind the others.
- class Jazz2::Rendering::XRayMaskRenderer
- Renders the coverage of the actors behind the x-ray tile layers.
- class Jazz2::Tiles::TileMap
- Represents a renderable tile map, consists of multiple layers.
- class Jazz2::UI::Canvas
- Canvas.
- class DrawableNode
- Base class for scene nodes that can be drawn through the render queue.
- class ParticleSystem
- Scene node that emits and simulates a pool of textured particles.
Public types
- enum class VisitOrderState { Disabled, Enabled, SameAsParent }
- Whether a node uses its visit order to break ties between same-layer siblings.
Public static functions
- static auto sType() -> ObjectType
Constructors, destructors, conversion operators
- SceneNode(SceneNode* parent, float x, float y)
- Constructs a node with a parent and a relative position given as two coordinates.
- SceneNode(SceneNode* parent, Vector2f position)
- Constructs a node with a parent and a relative position given as a vector.
- SceneNode(SceneNode* parent) explicit
- Constructs a node with a parent, positioned at the relative origin.
- SceneNode()
- Constructs a node with no parent, positioned at the origin.
- ~SceneNode() override
- SceneNode(SceneNode&& other) noexcept
- SceneNode(const SceneNode& other) protected
- Protected copy constructor used to clone objects.
Public functions
- auto operator=(const SceneNode&) -> SceneNode& deleted
- auto operator=(SceneNode&& other) -> SceneNode& noexcept
- auto Clone() const -> SceneNode
- Returns a copy of this object.
- auto GetParent() const -> const SceneNode*
- Returns the parent node as constant, or
nullptrif there is none. - auto GetParent() -> SceneNode*
- Returns the parent node, or
nullptrif there is none. - auto SetParent(SceneNode* parentNode) -> bool
- Sets the parent node.
- auto GetChildren() -> const SmallVectorImpl<SceneNode*>&
- Returns the array of child nodes.
- auto GetChildren() const -> const SmallVectorImpl<const SceneNode*>&
- Returns the array of child nodes as constant.
- auto AddChildNode(SceneNode* childNode) -> bool
- Adds a node as a child of this one.
- auto RemoveChildNode(SceneNode* childNode) -> bool
- Removes a child of this node without reparenting its children.
-
auto RemoveChildNodeAt(std::
uint32_t index) -> bool - Removes the child at the specified index without reparenting its children.
- auto RemoveAllChildrenNodes() -> bool
- Removes all children without reparenting their children.
- auto UnlinkChildNode(SceneNode* childNode) -> bool
- Removes a child of this node, reparenting its children to this node.
-
auto GetChildOrderIndex() const -> std::
uint32_t - Returns the order index of this node among its siblings, or zero if it has no parent.
-
auto SwapChildrenNodes(std::
uint32_t firstIndex, std:: uint32_t secondIndex) -> bool - Swaps two children at the specified indices.
- auto SwapNodeForward() -> bool
- Moves this node one position forward in the parent's list of children.
- auto SwapNodeBack() -> bool
- Moves this node one position back in the parent's list of children.
- auto GetVisitOrderState() const -> enum VisitOrderState
- Returns the node visit order state.
- void SetVisitOrderState(enum VisitOrderState visitOrderState)
- Sets the node visit order state.
-
auto GetVisitOrderIndex() const -> std::
uint16_t - Returns the visit drawing order index of the node.
- void OnUpdate(float timeMult) virtual
- Called every frame to update the node state.
-
void OnVisit(RenderQueue& renderQueue,
std::
uint32_t& visitOrderIndex) virtual - Updates the absolute transform, draws the node and visits its children.
- auto OnDraw(RenderQueue& renderQueue) -> bool virtual
- Called when the node needs to be drawn, returning
trueif a command was added. - auto IsUpdateEnabled() const -> bool
- Returns
trueif node updating is enabled. - void SetUpdateEnabled(bool updateEnabled)
- Enables or disables node updating.
- auto IsDrawEnabled() const -> bool
- Returns
trueif node drawing is enabled. - void SetDrawEnabled(bool drawEnabled)
- Enables or disables node drawing.
- auto IsEnabled() const -> bool
- Returns
trueif the node is both updating and drawing. - void SetEnabled(bool isEnabled)
- Enables or disables both node updating and drawing.
- auto GetPosition() const -> Vector2f
- Returns the node position relative to its parent.
- auto GetAbsPosition() const -> Vector2f
- Returns the absolute node position.
- void SetPosition(float x, float y)
- Sets the node position through two coordinates.
- void SetPosition(Vector2f position)
- Sets the node position through a vector.
- void SetPositionX(float x)
- Sets the X coordinate of the node position.
- void SetPositionY(float y)
- Sets the Y coordinate of the node position.
- void Move(float x, float y)
- Moves the node by two offsets.
- void Move(Vector2f position)
- Moves the node by an offset vector.
- void MoveX(float x)
- Moves the node by an offset on the X axis.
- void MoveY(float y)
- Moves the node by an offset on the Y axis.
- auto GetAbsAnchorPoint() const -> Vector2f
- Returns the transformation anchor point in pixels.
- void SetAbsAnchorPoint(float x, float y)
- Sets the transformation anchor point in pixels through two coordinates.
- void SetAbsAnchorPoint(Vector2f point)
- Sets the transformation anchor point in pixels through a
Vector2f. - auto GetScale() const -> const Vector2f&
- Returns the node scale factors.
- auto GetAbsScale() const -> const Vector2f&
- Returns the absolute node scale factors.
- void SetScale(float scaleFactor)
- Sets a uniform scale factor for both axes.
- void SetScale(float scaleFactorX, float scaleFactorY)
- Sets the horizontal and vertical scale factors separately.
- void SetScale(Vector2f scaleFactor)
- Sets the horizontal and vertical scale factors through a
Vector2f. - auto GetRotation() const -> float
- Returns the node rotation in radians.
- auto GetAbsRotation() const -> float
- Returns the absolute node rotation in radians.
- void SetRotation(float rotation)
- Sets the node rotation in radians.
- auto GetColor() const -> Colorf
- Returns the node color.
- auto GetAbsColor() const -> Colorf
- Returns the absolute node color.
- void SetColor(const Color& color)
- Sets the node color through a
Colorobject. - void SetColor(const Colorf& color)
- Sets the node color through a
Colorfobject. - auto GetAlpha() const -> float
- Returns the node alpha.
- auto GetAbsAlpha() const -> float
- Returns the absolute node alpha.
-
void SetAlpha(std::
uint8_t alpha) - Sets the node alpha through an unsigned char component.
- void SetAlphaF(float alpha)
- Sets the node alpha through a float component.
-
auto GetLayer() const -> std::
uint16_t - Returns the node rendering layer.
-
auto GetAbsLayer() const -> std::
uint16_t - Returns the absolute node rendering layer.
-
void SetLayer(std::
uint16_t layer) - Sets the node rendering layer.
- auto GetWorldMatrix() const -> const Matrix4x4f&
- Returns the node world matrix.
- void SetWorldMatrix(const Matrix4x4f& worldMatrix)
- Sets the node world matrix (only useful when called inside
OnPostUpdate()). - auto GetLocalMatrix() const -> const Matrix4x4f&
- Returns the node local matrix.
- void SetLocalMatrix(const Matrix4x4f& localMatrix)
- Sets the node local matrix.
- auto DeleteChildrenOnDestruction() const -> bool
- Returns the delete children on destruction flag.
- void SetDeleteChildrenOnDestruction(bool shouldDeleteChildrenOnDestruction)
- Sets the delete children on destruction flag.
-
auto GetLastFrameUpdated() const -> std::
uint32_t - Returns the last frame in which any viewport updated this node.
Protected types
- enum DirtyBitPositions { TransformationBit = 0, ColorBit = 1, SizeBit = 2, TextureBit = 3, AabbBit = 4, TransformationUploadBit = 5, ColorUploadBit = 6 }
- Bit positions inside the dirty bitset.
Protected functions
- void SwapChildPointer(SceneNode* first, SceneNode* second)
- Swaps the child pointer of a parent when moving an object.
- void Transform() virtual
Protected variables
- SceneNode* _parent
- Pointer to the parent node.
- SmallVector<SceneNode*, 0> _children
- Array of child nodes.
-
std::
uint32_t _childOrderIndex - Order index of this node among its siblings.
- bool _updateEnabled
- bool _drawEnabled
- bool _withVisitOrder
- Whether the visit order resolves the drawing order of same-layer nodes.
- bool _shouldDeleteChildrenOnDestruction
- Whether the destructor should also delete all children.
- enum VisitOrderState _visitOrderState
- Visit order state of this node.
-
std::
uint16_t _visitOrderIndex - Visit order index of this node.
-
std::
uint16_t _layer - Node rendering layer.
- Vector2f _position
- Node position relative to its parent.
- Vector2f _anchorPoint
- Anchor point for transformations, in pixels.
- Vector2f _scaleFactor
- Horizontal and vertical scale factors for the node size.
- float _rotation
- Clockwise node rotation in radians.
- Colorf _color
- Node color for transparency and translucency.
- Vector2f _absPosition
- Absolute position as calculated by the
Transform()function. - Vector2f _absScaleFactor
- Absolute horizontal and vertical scale factors as calculated by the
Transform()function. - float _absRotation
- Absolute node rotation as calculated by the
Transform()function. - Colorf _absColor
- Absolute node color as calculated by the
Transform()function. -
std::
uint16_t _absLayer - Absolute node rendering layer as calculated by the
Transform()function. -
BitSet<std::
uint8_t> _dirtyBits - Bitset that stores the various dirty state bits.
- Matrix4x4f _worldMatrix
- World transformation matrix (calculated from the local and the parent's world matrix).
- Matrix4x4f _localMatrix
- Local transformation matrix.
-
std::
uint32_t _lastFrameUpdated - Last frame any viewport updated this node.
Constants
- static float MinRotation constexpr
- Minimum amount of rotation that triggers a sine and cosine recalculation.
Function documentation
std:: uint16_t nCine:: SceneNode:: GetAbsLayer() const
Returns the absolute node rendering layer.
void nCine:: SceneNode:: SetLayer(std:: uint16_t layer)
Sets the node rendering layer.
bool nCine:: SceneNode:: DeleteChildrenOnDestruction() const
Returns the delete children on destruction flag.
When the flag is true the children are deleted upon node destruction.
Variable documentation
std:: uint32_t nCine:: SceneNode:: _childOrderIndex protected
Order index of this node among its siblings.
bool nCine:: SceneNode:: _withVisitOrder protected
Whether the visit order resolves the drawing order of same-layer nodes.
std:: uint16_t nCine:: SceneNode:: _layer protected
Node rendering layer.
Even if the base scene node is not always drawable, it carries layer information to easily pass it down to its children.
Vector2f nCine:: SceneNode:: _anchorPoint protected
Anchor point for transformations, in pixels.
Colorf nCine:: SceneNode:: _color protected
Node color for transparency and translucency.
Even if the base scene node is not always drawable, it carries color information to easily pass it down to its children.