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]
ActorTreeAbstract.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef ActorTree_INCLUDE_ONCE
33 #define ActorTree_INCLUDE_ONCE
34 
35 #include <vlGraphics/Actor.hpp>
36 #include <vlCore/AABB.hpp>
37 #include <set>
38 
39 namespace vl
40 {
56  {
58 
59  public:
61 
63  virtual int childrenCount() const = 0;
65  virtual ActorTreeAbstract* child(int i) = 0;
67  virtual const ActorTreeAbstract* child(int i) const = 0;
68 
70  const ActorTreeAbstract* parent() const { return mParent; }
72  ActorTreeAbstract* parent() { return mParent; }
73 
75  const ActorCollection* actors() const { return &mActors; }
77  ActorCollection* actors() { return &mActors; }
78 
80  const AABB& aabb() const { return mAABB; }
81 
83  void computeAABB();
84 
89  void extractActors(ActorCollection& list);
90 
99  void extractVisibleActors(ActorCollection& list, const Camera* camera, unsigned enable_mask=0xFFFFFFFF);
100 
104  ActorTreeAbstract* eraseActor(Actor* actor);
105 
107  Actor* addActor(Renderable* renderable, Effect* eff, Transform* tr=NULL);
108 
110  Actor* addActor(Actor* actor);
111 
118  static void prepareActors(ActorCollection& actors);
119 
121  void setParent(ActorTreeAbstract* p) { mParent = p; }
122 
125  void setEnabled( bool enabled ) { mEnabled = enabled; }
126 
129  bool isEnabled() const { return mEnabled; }
130 
131  protected:
135  bool mEnabled;
136  };
137 }
138 
139 #endif
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
ActorCollection * actors()
Returns the actors contained in a ActorTree node.
Implements a 4x4 matrix transform used to define the position and orientation of an Actor...
Definition: Transform.hpp:72
ActorTreeAbstract * mParent
const ActorTreeAbstract * parent() const
Returns the parent of a node.
void setEnabled(bool enabled)
If false then extractVisibleActors() will ignore this node and all its children.
const AABB & aabb() const
Returns the bounding box of a node. Such bounding box contains both the bounding boxes of the node&#39;s ...
Visualization Library main namespace.
const ActorCollection * actors() const
Returns the actors contained in a ActorTree node.
The AABB class implements an axis-aligned bounding box using vl::real precision.
Definition: AABB.hpp:44
The base class for all the reference counted objects.
Definition: Object.hpp:158
An abstract class that represents all the objects that can be rendered.
Definition: Renderable.hpp:58
The ActorTreeAbstract class implements the interface of a generic tree containing Actors in its nodes...
#define NULL
Definition: OpenGLDefs.hpp:81
void setParent(ActorTreeAbstract *p)
For internal use only.
Defines the sequence of Shader objects used to render an Actor.
Definition: Effect.hpp:91
bool isEnabled() const
If false then extractVisibleActors() will ignore this node and all its children.
ActorTreeAbstract * parent()
Returns the parent of a node.
Defined as a simple subclass of Collection<Actor>, see Collection for more information.
Definition: Actor.hpp:479
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:145
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:49