Visualization Library 2.1.0

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

VL     Star     Watch     Fork     Issue

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

The ActorTreeAbstract class implements the interface of a generic tree containing Actors in its nodes. More...

#include <ActorTreeAbstract.hpp>

+ Inheritance diagram for vl::ActorTreeAbstract:

Public Member Functions

 ActorTreeAbstract ()
 
virtual int childrenCount () const =0
 Returns the number of child nodes of an ActorTreeAbstract node. More...
 
virtual ActorTreeAbstractchild (int i)=0
 Returns the i-th child node of an ActorTreeAbstract node. More...
 
virtual const ActorTreeAbstractchild (int i) const =0
 Returns the i-th child node of an ActorTreeAbstract node. More...
 
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...
 

Static Public Member Functions

static void prepareActors (ActorCollection &actors)
 Updates the Transform and the bounds of the given Actors. More...
 

Protected Attributes

ActorTreeAbstractmParent
 
ActorCollection mActors
 
AABB mAABB
 
bool mEnabled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

The ActorTreeAbstract class implements the interface of a generic tree containing Actors in its nodes.

The interface of ActorTreeAbstract allows you to:

Does not allow you to:

See also

Definition at line 55 of file ActorTreeAbstract.hpp.

Constructor & Destructor Documentation

◆ ActorTreeAbstract()

ActorTreeAbstract::ActorTreeAbstract ( )

Definition at line 38 of file ActorTreeAbstract.cpp.

References mActors, mEnabled, mParent, NULL, and vl::Object::setAutomaticDelete().

Member Function Documentation

◆ aabb()

const AABB& vl::ActorTreeAbstract::aabb ( ) const
inline

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.

Definition at line 80 of file ActorTreeAbstract.hpp.

References NULL.

Referenced by computeAABB(), and extractVisibleActors().

◆ actors() [1/2]

const ActorCollection* vl::ActorTreeAbstract::actors ( ) const
inline

◆ actors() [2/2]

ActorCollection* vl::ActorTreeAbstract::actors ( )
inline

Returns the actors contained in a ActorTree node.

Definition at line 77 of file ActorTreeAbstract.hpp.

◆ addActor() [1/2]

Actor * ActorTreeAbstract::addActor ( Renderable renderable,
Effect eff,
Transform tr = NULL 
)

Utility function that adds an Actor and binds it to the given Renderable, Effect and Transform.

Definition at line 125 of file ActorTreeAbstract.cpp.

References actors(), vl::ref< T >::get(), and vl::Collection< T >::push_back().

◆ addActor() [2/2]

Actor * ActorTreeAbstract::addActor ( Actor actor)

Utility function equivalent to 'actors()->push_back(actor)'.

Definition at line 132 of file ActorTreeAbstract.cpp.

References actors(), and vl::Collection< T >::push_back().

◆ child() [1/2]

virtual ActorTreeAbstract* vl::ActorTreeAbstract::child ( int  i)
pure virtual

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

Implemented in vl::ActorTree, and vl::ActorKdTree.

Referenced by computeAABB(), eraseActor(), extractActors(), and extractVisibleActors().

◆ child() [2/2]

virtual const ActorTreeAbstract* vl::ActorTreeAbstract::child ( int  i) const
pure virtual

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

Implemented in vl::ActorTree, and vl::ActorKdTree.

◆ childrenCount()

virtual int vl::ActorTreeAbstract::childrenCount ( ) const
pure virtual

Returns the number of child nodes of an ActorTreeAbstract node.

Implemented in vl::ActorTree, and vl::ActorKdTree.

Referenced by computeAABB(), eraseActor(), extractActors(), and extractVisibleActors().

◆ computeAABB()

void ActorTreeAbstract::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.

Definition at line 46 of file ActorTreeAbstract.cpp.

References aabb(), actors(), vl::Collection< T >::at(), vl::Actor::boundingBox(), child(), childrenCount(), computeAABB(), vl::Actor::computeBounds(), mAABB, and vl::Collection< T >::size().

Referenced by computeAABB().

◆ eraseActor()

ActorTreeAbstract * ActorTreeAbstract::eraseActor ( Actor actor)

◆ extractActors()

void ActorTreeAbstract::extractActors ( ActorCollection list)

Extracts all the Actors contained in th ActorTree hierarchy and appends them to the given ActorCollection.

This ignores the Actors isEnabled() and enableMask() and the ActorTreeAbstract::isEnabled() flag as well.

Definition at line 65 of file ActorTreeAbstract.cpp.

References actors(), child(), childrenCount(), extractActors(), vl::Collection< T >::push_back(), and vl::Collection< T >::size().

Referenced by extractActors(), and vl::ActorKdTree::rebuildKdTree().

◆ extractVisibleActors()

void ActorTreeAbstract::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.

This function implements a hierarchycal frustum culling algorithm that culls the nodes of the bounding box tree first and then the single Actors contained in the nodes that could not be culled. If camera is NULL no frustum culling is performed. This function alwasy take into consideration the Actors isEnabled() and enableMask() and the ActorTreeAbstract::isEnabled() flag as well.

See also
SceneManager::enableMask(), Actor::enableMask(), Actor::isEnabled(), ActorTreeAbstract::isEnabled()

Definition at line 78 of file ActorTreeAbstract.cpp.

References aabb(), actors(), vl::Collection< T >::at(), child(), childrenCount(), vl::Actor::computeBounds(), vl::Frustum::cull(), vl::Actor::enableMask(), extractVisibleActors(), vl::Camera::frustum(), isEnabled(), vl::Actor::isEnabled(), vl::Collection< T >::push_back(), and vl::Collection< T >::size().

Referenced by extractVisibleActors().

◆ isEnabled()

bool vl::ActorTreeAbstract::isEnabled ( ) const
inline

◆ parent() [1/2]

const ActorTreeAbstract* vl::ActorTreeAbstract::parent ( ) const
inline

Returns the parent of a node.

Definition at line 70 of file ActorTreeAbstract.hpp.

Referenced by vl::ActorTree::addChild(), and vl::ActorTree::setChild().

◆ parent() [2/2]

ActorTreeAbstract* vl::ActorTreeAbstract::parent ( )
inline

Returns the parent of a node.

Definition at line 72 of file ActorTreeAbstract.hpp.

◆ prepareActors()

void ActorTreeAbstract::prepareActors ( ActorCollection actors)
static

Updates the Transform and the bounds of the given Actors.

Before you create a bounding box tree or a kd-tree of Actors you have to make sure that their Transform and bounding volumes are up-to-date. This is an utility function that lets you do that in a simple an quick way.

Definition at line 138 of file ActorTreeAbstract.cpp.

References vl::Collection< T >::size().

Referenced by vl::ActorKdTree::buildKdTree().

◆ setEnabled()

void vl::ActorTreeAbstract::setEnabled ( bool  enabled)
inline

◆ setParent()

void vl::ActorTreeAbstract::setParent ( ActorTreeAbstract p)
inline

For internal use only.

Definition at line 121 of file ActorTreeAbstract.hpp.

Referenced by vl::ActorTree::addChild(), and vl::ActorTree::setChild().

Member Data Documentation

◆ mAABB

AABB vl::ActorTreeAbstract::mAABB
protected

◆ mActors

ActorCollection vl::ActorTreeAbstract::mActors
protected

Definition at line 133 of file ActorTreeAbstract.hpp.

Referenced by ActorTreeAbstract(), and vl::ActorKdTree::rebuildKdTree().

◆ mEnabled

bool vl::ActorTreeAbstract::mEnabled
protected

Definition at line 135 of file ActorTreeAbstract.hpp.

Referenced by ActorTreeAbstract().

◆ mParent

ActorTreeAbstract* vl::ActorTreeAbstract::mParent
protected

Definition at line 132 of file ActorTreeAbstract.hpp.

Referenced by ActorTreeAbstract(), and vl::ActorKdTree::childP().


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