Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::ActorTree Class Reference

The ActorTree class implements a generic tree whose nodes contain Actors. More...

#include <ActorTree.hpp>

+ Inheritance diagram for vl::ActorTree:

Public Member Functions

 ActorTree ()
 
virtual int childrenCount () const
 Returns the number of child nodes of an ActorTreeAbstract node. More...
 
virtual ActorTreeAbstractchild (int i)
 Returns the i-th child node of an ActorTreeAbstract node. More...
 
virtual const ActorTreeAbstractchild (int i) const
 Returns the i-th child node of an ActorTreeAbstract node. More...
 
void addChild (ActorTreeAbstract *node)
 Adds a child node to the current node. More...
 
void addChildOnce (ActorTreeAbstract *node)
 Adds a child node to the current node if not already present. More...
 
void setChild (int i, ActorTreeAbstract *node)
 Sets the i-th child node to be node More...
 
int findChild (ActorTreeAbstract *node)
 Returns the index of the given node or -1 if not found. More...
 
bool eraseChild (ActorTreeAbstract *node)
 Removes the given node. More...
 
void eraseChild (int i, int count=1)
 Removes count nodes starting from the i-th included. More...
 
void eraseAllChildren ()
 Removes all the child nodes. More...
 
const std::vector< ref< ActorTreeAbstract > > & children () const
 The list of child nodes. More...
 
- Public Member Functions inherited from vl::ActorTreeAbstract
 ActorTreeAbstract ()
 
const ActorTreeAbstractparent () const
 Returns the parent of a node. More...
 
ActorTreeAbstractparent ()
 Returns the parent of a node. More...
 
const ActorCollectionactors () const
 Returns the actors contained in a ActorTree node. More...
 
ActorCollectionactors ()
 Returns the actors contained in a ActorTree node. More...
 
const AABBaabb () const
 Returns the bounding box of a node. Such bounding box contains both the bounding boxes of the node's Actors and of the child nodes. More...
 
void computeAABB ()
 Recursively computes the bounding box of a node so that it includes the bounding boxes of the node's Actors and of the child nodes. More...
 
void extractActors (ActorCollection &list)
 Extracts all the Actors contained in th ActorTree hierarchy and appends them to the given ActorCollection. More...
 
void extractVisibleActors (ActorCollection &list, const Camera *camera, unsigned enable_mask=0xFFFFFFFF)
 Extracts the enabled and visible Actors contained in th ActorTree hierarchy and appends them to the given ActorCollection. More...
 
ActorTreeAbstracteraseActor (Actor *actor)
 Removes the given Actor from the ActorTreeAbstract. More...
 
ActoraddActor (Renderable *renderable, Effect *eff, Transform *tr=NULL)
 Utility function that adds an Actor and binds it to the given Renderable, Effect and Transform. More...
 
ActoraddActor (Actor *actor)
 Utility function equivalent to 'actors()->push_back(actor)'. More...
 
void setParent (ActorTreeAbstract *p)
 For internal use only. More...
 
void setEnabled (bool enabled)
 If false then extractVisibleActors() will ignore this node and all its children. More...
 
bool isEnabled () const
 If false then extractVisibleActors() will ignore this node and all its children. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

std::vector< ref< ActorTreeAbstract > > mChildren
 
- Protected Attributes inherited from vl::ActorTreeAbstract
ActorTreeAbstractmParent
 
ActorCollection mActors
 
AABB mAABB
 
bool mEnabled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Static Public Member Functions inherited from vl::ActorTreeAbstract
static void prepareActors (ActorCollection &actors)
 Updates the Transform and the bounds of the given Actors. More...
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

The ActorTree class implements a generic tree whose nodes contain Actors.

Each node of the tree can have any number of children.

Use this class when you want to have direct control over how the Actors are grouped together or to implement specific space partitioning schemes like BSP trees, Quadtrees, Octrees etc. For example you can use the ActorTree class to build a quadtree by assigning 4 children per node and filling them appropriately. Of course you can also use an ActorTree to group a set of Actors based on any other principle. For example animated Actors are usually kept in separate "flat" trees (for example all in a single node) as the computational cost of rebuilding every frame the BSP tree, Quadtree, Octree etc. might be to high.

Note that for performance reasons the ActorKdTree class derives from the ActorTreeAbstract and implements a space partitioning scheme (based on a binary tree) where the splitting planes are in turn choosen so that they are aligned to the world space x, y and z axes.

See also

Definition at line 62 of file ActorTree.hpp.

Constructor & Destructor Documentation

◆ ActorTree()

vl::ActorTree::ActorTree ( )
inline

Definition at line 67 of file ActorTree.hpp.

Member Function Documentation

◆ addChild()

void ActorTree::addChild ( ActorTreeAbstract node)

Adds a child node to the current node.

Definition at line 46 of file ActorTree.cpp.

References vl::Log::error(), mChildren, vl::ActorTreeAbstract::parent(), and vl::ActorTreeAbstract::setParent().

Referenced by addChildOnce().

◆ addChildOnce()

void ActorTree::addChildOnce ( ActorTreeAbstract node)

Adds a child node to the current node if not already present.

Definition at line 56 of file ActorTree.cpp.

References addChild(), and findChild().

◆ child() [1/2]

virtual ActorTreeAbstract* vl::ActorTree::child ( int  i)
inlinevirtual

Returns the i-th child node of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 73 of file ActorTree.hpp.

◆ child() [2/2]

virtual const ActorTreeAbstract* vl::ActorTree::child ( int  i) const
inlinevirtual

Returns the i-th child node of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 74 of file ActorTree.hpp.

◆ children()

const std::vector< ref<ActorTreeAbstract> >& vl::ActorTree::children ( ) const
inline

The list of child nodes.

Definition at line 92 of file ActorTree.hpp.

◆ childrenCount()

virtual int vl::ActorTree::childrenCount ( ) const
inlinevirtual

Returns the number of child nodes of an ActorTreeAbstract node.

Implements vl::ActorTreeAbstract.

Definition at line 72 of file ActorTree.hpp.

◆ eraseAllChildren()

void ActorTree::eraseAllChildren ( )

Removes all the child nodes.

Definition at line 38 of file ActorTree.cpp.

References mChildren, and NULL.

◆ eraseChild() [1/2]

bool ActorTree::eraseChild ( ActorTreeAbstract node)

Removes the given node.

Definition at line 73 of file ActorTree.cpp.

References findChild().

◆ eraseChild() [2/2]

void ActorTree::eraseChild ( int  i,
int  count = 1 
)

Removes count nodes starting from the i-th included.

Definition at line 95 of file ActorTree.cpp.

References mChildren, and NULL.

◆ findChild()

int ActorTree::findChild ( ActorTreeAbstract node)

Returns the index of the given node or -1 if not found.

Definition at line 63 of file ActorTree.cpp.

References mChildren.

Referenced by addChildOnce(), and eraseChild().

◆ setChild()

void ActorTree::setChild ( int  i,
ActorTreeAbstract node 
)

Sets the i-th child node to be node

Definition at line 84 of file ActorTree.cpp.

References vl::Log::error(), mChildren, NULL, vl::ActorTreeAbstract::parent(), and vl::ActorTreeAbstract::setParent().

Member Data Documentation

◆ mChildren

std::vector< ref<ActorTreeAbstract> > vl::ActorTree::mChildren
protected

Definition at line 95 of file ActorTree.hpp.

Referenced by addChild(), eraseAllChildren(), eraseChild(), findChild(), and setChild().


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