Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLNode.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright and trademark 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
45 #ifndef __GLNODE_H__
46 #define __GLNODE_H__
47 
48 #include "CoreConfig.h"
49 #include <list>
50 #include "graphCommon.h"
51 
52 namespace Menge {
53 
54  namespace SceneGraph {
55 
56  class GLDagNode;
57 
66  class MENGE_API GLNode {
67  public:
74  GLNode( GLDagNode * parent=0x0 );
75 
79  virtual ~GLNode();
80 
90  void setVisible( bool state ) { _visible = state; }
91 
102  virtual void drawGL( bool select=false ) = 0;
103 
111  virtual void newContext() { return; }
112 
118  GLDagNode * getParent() { return _parent; }
119 
120  friend class GLDagNode;
121  protected:
129  void setParent( GLDagNode * p ) { _parent = p; }
130 
135 
141  bool _visible;
142  };
143 
147  typedef std::list<GLNode *> GLNodeList;
148 
152  typedef GLNodeList::iterator GLNodeListItr;
153 
157  typedef GLNodeList::const_iterator GLNodeListCItr;
158 
169  class MENGE_API GLDagNode : public GLNode {
170  public:
177  GLDagNode( GLDagNode * parent=0x0 );
178 
182  virtual ~GLDagNode();
183 
191  void addChild( GLNode * child );
192 
197  virtual void newContext();
198 
206  virtual void drawGL( bool select=false );
207 
216  virtual void getMatrix( Matrix4x4 & mat ) { mat.identity(); }
217 
226  virtual void getInverseMatrix( Matrix4x4 & mat ) { mat.identity(); }
227 
238  virtual void getWorldMatrix( Matrix4x4 & mat );
239 
250  virtual void getWorldInverseMatrix( Matrix4x4 & mat );
251 
258  virtual void getParentMatrix( Matrix4x4 & mat );
259 
266  virtual void getParentInverseMatrix( Matrix4x4 & mat );
267 
268  protected:
273 
277  size_t _childCount;
278  };
279 
283  typedef std::list<GLDagNode *> GLDagNodeList;
284 
288  typedef GLDagNodeList::iterator GLDagNodeListItr;
289 
293  typedef GLDagNodeList::const_iterator GLDagNodeListCItr;
294 
295  } // namespace SceneGraph
296 } // namespace Menge
297 #endif // __GLNODE_H__
GLDagNode * _parent
The GLDagNode that serves as this node's parent.
Definition: GLNode.h:134
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
GLDagNode * getParent()
Returns a pointer to the node's parent (possibly NULL).
Definition: GLNode.h:118
bool _visible
The visibility state of this node. If visible (true) the node and its children will be drawn into the...
Definition: GLNode.h:141
An abstact class – a generic, scene graph node.
Definition: GLNode.h:66
Basic 4x4 matrix of floats.
Definition: Matrix.h:70
size_t _childCount
The number of child nodes this node contains.
Definition: GLNode.h:277
The node that provides the basis for a "hierarchy" in the scene graph.
Definition: GLNode.h:169
Sets up the proper compiler directives for platform and dll export/import.
virtual void getMatrix(Matrix4x4 &mat)
Reports the local object transform matrix.
Definition: GLNode.h:216
void setParent(GLDagNode *p)
Assigns this node to a parent GLDagNode.
Definition: GLNode.h:129
virtual void getInverseMatrix(Matrix4x4 &mat)
Reports the local object inverse transform matrix.
Definition: GLNode.h:226
The SceneGraph (SceneGraph) name space, containing all elements to use in a SceneGraph.
void identity()
Sets the matrix to the identity matrix.
Definition: Matrix.cpp:61
Various important pre-compiler directives for the scene graph.
void setVisible(bool state)
Sets the visible state of the node.
Definition: GLNode.h:90
virtual void newContext()
Allows the node to recreate any unique OpenGL objects based on the acquisition of a new OpenGL contex...
Definition: GLNode.h:111
GLNode ** _children
An array of child GLNodes.
Definition: GLNode.h:272