GA::kit v0.3
G&A's in-house C++ application framework
Loading...
Searching...
No Matches
ga::Node Class Reference

Node represents a basic "node" (or view) in the scenegraph. More...

#include <node.h>

Inheritance diagram for ga::Node:
ga::Transform

Public Member Functions

template<CLASS_INHERITS(NodeT, ga::Node) >
std::shared_ptr< NodeT > addChild (std::shared_ptr< NodeT > child=nullptr)
 
std::shared_ptr< NodeaddChild ()
 
template<CLASS_INHERITS(NodeT, ga::Node) >
std::shared_ptr< NodeT > insertChild (size_t index, std::shared_ptr< NodeT > child=nullptr)
 
std::shared_ptr< NodeinsertChild (size_t index)
 
void detach ()
 
bool removeChild (std::shared_ptr< Node > child)
 
bool removeDescendant (std::shared_ptr< Node > node)
 
void clearChildren ()
 
void sortChildren (std::function< bool(const std::shared_ptr< Node > &a, const std::shared_ptr< Node > &b)> comparisonFn)
 
bool isParentOf (const std::shared_ptr< Node > &child) const
 
bool isChildOf (const std::shared_ptr< Node > &parent) const
 
bool hasChild (const std::shared_ptr< Node > &child) const
 
bool hasDescendant (const std::shared_ptr< Node > &node) const
 
std::shared_ptr< NodegetParent () const
 
const std::vector< std::shared_ptr< Node > > & getChildren () const
 
bool hasChildren () const
 
bool hasParent () const
 
bool isRoot () const
 
bool hasScene () const
 
std::shared_ptr< ScenegetScene () const
 
size_t getSceneHierarchyLevel () const
 
size_t getSceneDrawIndex () const
 
void setName (const std::string &name)
 
const std::string & getName () const
 
void setUuid (const ga::Uuid &uuid)
 
const ga::UuidgetUuid ()
 
ga::TransformgetTransform ()
 
void setDrawFn (std::function< void()> drawFn)
 
void resetDrawFn ()
 
void setUpdateFn (std::function< void()> updateFn)
 
void resetUpdateFn ()
 
ga::Transform getSceneTransform ()
 
vec3 localPosToScene (const vec3 &pos)
 
vec3 scenePosToLocal (const vec3 &pos)
 
void disableUpdate ()
 
void enableUpdate ()
 
bool isUpdateEnabled () const
 
void disableDraw ()
 
void enableDraw ()
 
bool isDrawEnabled () const
 
template<CLASS_INHERITS(ComponentT, Component) >
std::shared_ptr< ComponentT > createComponent ()
 
template<CLASS_INHERITS(ComponentT, Component) >
std::shared_ptr< ComponentT > addComponent (std::shared_ptr< ComponentT > component)
 
template<CLASS_INHERITS(ComponentT, Component) >
std::shared_ptr< ComponentT > getComponent ()
 
template<CLASS_INHERITS(ComponentT, Component) >
bool removeComponent ()
 
template<CLASS_INHERITS(ComponentT, Component) >
ComponentT & component ()
 
virtual ~Node ()
 
- Public Member Functions inherited from ga::Transform
 Transform ()
 
 Transform (const mat4 &transform)
 
 Transform (const vec3 &translation, const quat &rotation, const vec3 &scale)
 
TransformsetMatrix (const mat4 &matrix)
 
Transformset (const mat4 &matrix)
 
TransformsetTranslation (const vec3 &translation)
 
TransformsetTranslation (const vec2 &translation)
 
TransformsetRotation (const quat &rotation)
 
TransformsetScale (const vec3 &scale)
 
TransformsetEulerRotation (const vec3 &radians)
 
const vec3 & getTranslation () const
 
const quat & getRotation () const
 
const vec3 & getScale () const
 
vec3 getEulerRotation () const
 
const mat4 & getMatrix () const
 
Transformtranslate (const vec3 &vec)
 
Transformtranslate (const vec2 &vec)
 
TransformtranslateX (float x)
 
TransformtranslateY (float y)
 
TransformtranslateZ (float z)
 
Transformscale (const vec3 &pct)
 
Transformscale (float pct)
 
Transformrotate (const vec3 &eulerRadians)
 
TransformrotateAround (const vec3 &axis, float radians)
 
TransformrotateX (float radians)
 
TransformrotateY (float radians)
 
TransformrotateZ (float radians)
 
 operator const mat4 & () const
 
Transformoperator= (const mat4 &m)
 
Transform operator* (const mat4 &m)
 
Transform operator* (const Transform &t)
 

Static Public Member Functions

template<CLASS_INHERITS(NodeT, ga::Node) >
static std::shared_ptr< NodeT > create ()
 
static std::shared_ptr< Nodecreate ()
 

Public Attributes

ga::Signal onWillUpdate
 
ga::Signal onDidUpdate
 
ga::Signal onWillUpdateChildren
 
ga::Signal onDidUpdateChildren
 
ga::Signal onWillDraw
 
ga::Signal onDidDraw
 
ga::Signal onWillDrawChildren
 
ga::Signal onDidDrawChildren
 

Protected Member Functions

 Node ()
 
virtual void setup ()
 
virtual void update ()
 
virtual void draw ()
 
virtual void onDrawIndexChange ()
 
void setDrawIndex (size_t index)
 
void setScene (std::shared_ptr< Scene > scene)
 
void setParent (std::shared_ptr< Node > parent)
 
void updateTree ()
 
void drawTree ()
 
void walkTree (std::function< void(std::shared_ptr< Node >)> fn)
 
- Protected Member Functions inherited from ga::Transform
void flagDirty ()
 
void clean () const
 
void decompose ()
 

Protected Attributes

std::weak_ptr< Scenem_scene
 
std::weak_ptr< Nodem_parent
 
std::vector< std::shared_ptr< Node > > m_children
 
std::unordered_map< std::type_index, std::shared_ptr< Component > > m_components
 
std::string m_name
 
ga::Uuid m_uuid
 
size_t m_drawIndex
 
std::function< void()> m_updateFn
 
std::function< void()> m_drawFn
 
bool m_isDrawEnabled = true
 
bool m_isUpdateEnabled = true
 
- Protected Attributes inherited from ga::Transform
vec3 m_translation
 
vec3 m_scale
 
quat m_rotation
 
mat4 m_transform
 
bool m_dirty
 

Friends

class Scene
 

Detailed Description

Node represents a basic "node" (or view) in the scenegraph.

Nodes keep:

  • name (std::string)
  • unique id
  • local Transform
  • Component list
  • reference to a Scene owner
  • reference to a parent Node
  • vector of references to child Nodes

Constructor & Destructor Documentation

◆ ~Node()

virtual ga::Node::~Node ( )
inlinevirtual

◆ Node()

ga::Node::Node ( )
protected

Member Function Documentation

◆ addChild() [1/2]

std::shared_ptr< Node > ga::Node::addChild ( )

◆ addChild() [2/2]

template<CLASS_INHERITS(NodeT, ga::Node) >
std::shared_ptr< NodeT > ga::Node::addChild ( std::shared_ptr< NodeT >  child = nullptr)

◆ addComponent()

template<CLASS_INHERITS(ComponentT, Component) >
std::shared_ptr< ComponentT > ga::Node::addComponent ( std::shared_ptr< ComponentT >  component)

◆ clearChildren()

void ga::Node::clearChildren ( )

◆ component()

template<CLASS_INHERITS(ComponentT, Component) >
ComponentT & ga::Node::component ( )

◆ create() [1/2]

template<CLASS_INHERITS(NodeT, ga::Node) >
static std::shared_ptr< NodeT > ga::Node::create ( )
static

◆ create() [2/2]

std::shared_ptr< NodeT > ga::Node::create ( )
inlinestatic

◆ createComponent()

template<CLASS_INHERITS(ComponentT, Component) >
std::shared_ptr< ComponentT > ga::Node::createComponent ( )

◆ detach()

void ga::Node::detach ( )

◆ disableDraw()

void ga::Node::disableDraw ( )

◆ disableUpdate()

void ga::Node::disableUpdate ( )

◆ draw()

void ga::Node::draw ( )
protectedvirtual

◆ drawTree()

void ga::Node::drawTree ( )
protected

◆ enableDraw()

void ga::Node::enableDraw ( )

◆ enableUpdate()

void ga::Node::enableUpdate ( )

◆ getChildren()

const std::vector< std::shared_ptr< Node > > & ga::Node::getChildren ( ) const

◆ getComponent()

template<CLASS_INHERITS(ComponentT, Component) >
std::shared_ptr< ComponentT > ga::Node::getComponent ( )

◆ getName()

const std::string & ga::Node::getName ( ) const
inline

◆ getParent()

std::shared_ptr< Node > ga::Node::getParent ( ) const

◆ getScene()

std::shared_ptr< Scene > ga::Node::getScene ( ) const

◆ getSceneDrawIndex()

size_t ga::Node::getSceneDrawIndex ( ) const

◆ getSceneHierarchyLevel()

size_t ga::Node::getSceneHierarchyLevel ( ) const

◆ getSceneTransform()

ga::Transform ga::Node::getSceneTransform ( )

◆ getTransform()

ga::Transform & ga::Node::getTransform ( )
inline

◆ getUuid()

const ga::Uuid & ga::Node::getUuid ( )
inline

◆ hasChild()

bool ga::Node::hasChild ( const std::shared_ptr< Node > &  child) const
inline

◆ hasChildren()

bool ga::Node::hasChildren ( ) const
inline

◆ hasDescendant()

bool ga::Node::hasDescendant ( const std::shared_ptr< Node > &  node) const

◆ hasParent()

bool ga::Node::hasParent ( ) const
inline

◆ hasScene()

bool ga::Node::hasScene ( ) const
inline

◆ insertChild() [1/2]

std::shared_ptr< Node > ga::Node::insertChild ( size_t  index)

◆ insertChild() [2/2]

template<CLASS_INHERITS(NodeT, ga::Node) >
std::shared_ptr< NodeT > ga::Node::insertChild ( size_t  index,
std::shared_ptr< NodeT >  child = nullptr 
)

◆ isChildOf()

bool ga::Node::isChildOf ( const std::shared_ptr< Node > &  parent) const

◆ isDrawEnabled()

bool ga::Node::isDrawEnabled ( ) const
inline

◆ isParentOf()

bool ga::Node::isParentOf ( const std::shared_ptr< Node > &  child) const

◆ isRoot()

bool ga::Node::isRoot ( ) const
inline

◆ isUpdateEnabled()

bool ga::Node::isUpdateEnabled ( ) const
inline

◆ localPosToScene()

vec3 ga::Node::localPosToScene ( const vec3 &  pos)
inline

◆ onDrawIndexChange()

void ga::Node::onDrawIndexChange ( )
protectedvirtual

◆ removeChild()

bool ga::Node::removeChild ( std::shared_ptr< Node child)

◆ removeComponent()

template<CLASS_INHERITS(ComponentT, Component) >
bool ga::Node::removeComponent ( )

◆ removeDescendant()

bool ga::Node::removeDescendant ( std::shared_ptr< Node node)

◆ resetDrawFn()

void ga::Node::resetDrawFn ( )
inline

◆ resetUpdateFn()

void ga::Node::resetUpdateFn ( )
inline

◆ scenePosToLocal()

vec3 ga::Node::scenePosToLocal ( const vec3 &  pos)
inline

◆ setDrawFn()

void ga::Node::setDrawFn ( std::function< void()>  drawFn)
inline

◆ setDrawIndex()

void ga::Node::setDrawIndex ( size_t  index)
protected

◆ setName()

void ga::Node::setName ( const std::string &  name)
inline

◆ setParent()

void ga::Node::setParent ( std::shared_ptr< Node parent)
protected

◆ setScene()

void ga::Node::setScene ( std::shared_ptr< Scene scene)
protected

◆ setup()

void ga::Node::setup ( )
protectedvirtual

◆ setUpdateFn()

void ga::Node::setUpdateFn ( std::function< void()>  updateFn)
inline

◆ setUuid()

void ga::Node::setUuid ( const ga::Uuid uuid)
inline

◆ sortChildren()

void ga::Node::sortChildren ( std::function< bool(const std::shared_ptr< Node > &a, const std::shared_ptr< Node > &b)>  comparisonFn)

◆ update()

void ga::Node::update ( )
protectedvirtual

◆ updateTree()

void ga::Node::updateTree ( )
protected

◆ walkTree()

void ga::Node::walkTree ( std::function< void(std::shared_ptr< Node >)>  fn)
protected

Friends And Related Function Documentation

◆ Scene

friend class Scene
friend

Member Data Documentation

◆ m_children

std::vector<std::shared_ptr<Node> > ga::Node::m_children
protected

◆ m_components

std::unordered_map<std::type_index, std::shared_ptr<Component> > ga::Node::m_components
protected

◆ m_drawFn

std::function<void()> ga::Node::m_drawFn
protected

◆ m_drawIndex

size_t ga::Node::m_drawIndex
protected

◆ m_isDrawEnabled

bool ga::Node::m_isDrawEnabled = true
protected

◆ m_isUpdateEnabled

bool ga::Node::m_isUpdateEnabled = true
protected

◆ m_name

std::string ga::Node::m_name
protected

◆ m_parent

std::weak_ptr<Node> ga::Node::m_parent
protected

◆ m_scene

std::weak_ptr<Scene> ga::Node::m_scene
protected

◆ m_updateFn

std::function<void()> ga::Node::m_updateFn
protected

◆ m_uuid

ga::Uuid ga::Node::m_uuid
protected

◆ onDidDraw

ga::Signal ga::Node::onDidDraw

◆ onDidDrawChildren

ga::Signal ga::Node::onDidDrawChildren

◆ onDidUpdate

ga::Signal ga::Node::onDidUpdate

◆ onDidUpdateChildren

ga::Signal ga::Node::onDidUpdateChildren

◆ onWillDraw

ga::Signal ga::Node::onWillDraw

◆ onWillDrawChildren

ga::Signal ga::Node::onWillDrawChildren

◆ onWillUpdate

ga::Signal ga::Node::onWillUpdate

◆ onWillUpdateChildren

ga::Signal ga::Node::onWillUpdateChildren

The documentation for this class was generated from the following files: