Visualization Library 2.1.0
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
The ActorTree class implements a generic tree whose nodes contain Actors. More...
#include <ActorTree.hpp>
Public Member Functions | |
ActorTree () | |
virtual int | childrenCount () const |
Returns the number of child nodes of an ActorTreeAbstract node. More... | |
virtual ActorTreeAbstract * | child (int i) |
Returns the i-th child node of an ActorTreeAbstract node. More... | |
virtual const ActorTreeAbstract * | child (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 ActorTreeAbstract * | parent () const |
Returns the parent of a node. More... | |
ActorTreeAbstract * | parent () |
Returns the parent of a node. More... | |
const ActorCollection * | actors () const |
Returns the actors contained in a ActorTree node. More... | |
ActorCollection * | actors () |
Returns the actors contained in a ActorTree node. More... | |
const AABB & | aabb () 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... | |
ActorTreeAbstract * | eraseActor (Actor *actor) |
Removes the given Actor from the ActorTreeAbstract. More... | |
Actor * | addActor (Renderable *renderable, Effect *eff, Transform *tr=NULL) |
Utility function that adds an Actor and binds it to the given Renderable, Effect and Transform. More... | |
Actor * | addActor (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... | |
Object & | operator= (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... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () 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 | |
ActorTreeAbstract * | mParent |
ActorCollection | mActors |
AABB | mAABB |
bool | mEnabled |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
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 () |
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.
Definition at line 62 of file ActorTree.hpp.
|
inline |
Definition at line 67 of file ActorTree.hpp.
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().
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().
|
inlinevirtual |
Returns the i-th child node of an ActorTreeAbstract node.
Implements vl::ActorTreeAbstract.
Definition at line 73 of file ActorTree.hpp.
|
inlinevirtual |
Returns the i-th child node of an ActorTreeAbstract node.
Implements vl::ActorTreeAbstract.
Definition at line 74 of file ActorTree.hpp.
|
inline |
The list of child nodes.
Definition at line 92 of file ActorTree.hpp.
|
inlinevirtual |
Returns the number of child nodes of an ActorTreeAbstract node.
Implements vl::ActorTreeAbstract.
Definition at line 72 of file ActorTree.hpp.
void ActorTree::eraseAllChildren | ( | ) |
Removes all the child nodes.
Definition at line 38 of file ActorTree.cpp.
bool ActorTree::eraseChild | ( | ActorTreeAbstract * | node | ) |
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.
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().
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().
|
protected |
Definition at line 95 of file ActorTree.hpp.
Referenced by addChild(), eraseAllChildren(), eraseChild(), findChild(), and setChild().
Visualization Library 2.1.0 Reference Documentation
Updated on Wed Mar 10 2021 16:02:46.
© Copyright Michele Bosi. All rights reserved.