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::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::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 parent() const -> const SceneNode*
- Returns the parent node as constant, or
nullptrif there is none. - auto parent() -> SceneNode*
- Returns the parent node, or
nullptrif there is none. - auto setParent(SceneNode* parentNode) -> bool
- Sets the parent node.
- auto children() -> const SmallVectorImpl<SceneNode*>&
- Returns the array of child nodes.
- auto children() 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 childOrderIndex() 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 visitOrderState() const -> enum VisitOrderState
- Returns the node visit order state.
- void setVisitOrderState(enum VisitOrderState visitOrderState)
- Sets the node visit order state.
-
auto visitOrderIndex() 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 position() const -> Vector2f
- Returns the node position relative to its parent.
- auto absPosition() 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 absAnchorPoint() 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 scale() const -> const Vector2f&
- Returns the node scale factors.
- auto absScale() 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 rotation() const -> float
- Returns the node rotation in radians.
- auto absRotation() const -> float
- Returns the absolute node rotation in radians.
- void setRotation(float rotation)
- Sets the node rotation in radians.
- auto color() const -> Colorf
- Returns the node color.
- auto absColor() 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 alpha() const -> float
- Returns the node alpha.
- auto absAlpha() 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 layer() const -> std::
uint16_t - Returns the node rendering layer.
-
auto absLayer() const -> std::
uint16_t - Returns the absolute node rendering layer.
-
void setLayer(std::
uint16_t layer) - Sets the node rendering layer.
- auto worldMatrix() 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 localMatrix() 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 lastFrameUpdated() 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:: absLayer() 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.