Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shapes.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 
44 #ifndef __SHAPES_H__
45 #define __SHAPES_H__
46 
47 // A collection of renderable shapes
48 #include "CoreConfig.h"
49 #include "Select.h"
50 #include "GLNode.h"
51 
52 #include "graphCommon.h"
53 
54 namespace Menge {
55 
56  namespace SceneGraph {
57 
69  MENGE_API void initShapes();
70 
79  MENGE_API void glSphere( int samples );
80 
84  class MENGE_API Shape: public GLNode, public Selectable {
85  public:
89  Shape(): GLNode(), Selectable(), _r(1.f), _g(1.f), _b(1.f), _style(GL_FILL) {}
90 
99  Shape( float r, float g, float b, GLenum s=GL_FILL ): GLNode(), Selectable(), _r(r), _g(g), _b(b), _style(s) {}
100 
106  void setColor( const Vector3 & vec ) { _r=vec.x(); _g=vec.y(); _b=vec.z(); }
107 
115  void setColor( float r, float g, float b ) { _r=r; _g=g; _b=b; }
116 
122  void setStyle( GLenum style ) { _style = style; }
123 
124  protected:
128  float _r;
129 
133  float _g;
134 
138  float _b;
139 
143  GLenum _style;
144  };
145 
150  class MENGE_API Circle : public Shape {
151  public:
155  Circle():Shape(), _radius(1.f){}
156 
164  Circle(float r, float g, float b):Shape(r,g,b), _radius(1.f) {}
165 
175  void drawGL( bool select=false );
176 
190  static void drawCircle( float radius, float r, float g, float b, float a, GLenum style=GL_FILL );
191 
195  static void drawUnit();
196 
202  static void init();
203 
204  protected:
208  float _radius;
209 
213  static bool IS_REGISTERED;
214 
218  static void newGLContext();
219 
223  static int GL_ID;
224  };
225 
231  class MENGE_API Cylinder : public Shape {
232  public:
236  Cylinder():Shape(), _radius(1.f), _height(1.f){}
237 
244  Cylinder( float radius, float height ):Shape(), _radius(radius), _height(height){}
245 
254  Cylinder( float radius, float height, float r, float g, float b ):Shape(r,g,b), _radius(radius), _height(height){}
255 
260  void drawGL( bool select=false );
261 
274  static void drawCylinder( float radius, float height, float r, float g, float b, float a, GLenum style=GL_FILL );
275 
279  static void init();
280 
281  protected:
285  float _radius;
286 
290  float _height;
291 
292  // This functionality works with the context manager
296  static bool IS_REGISTERED;
297 
301  static void newGLContext();
302 
306  static int GL_ID;
307  };
308  }
309 } // namespace Menge
310 #endif // __SHAPES_H__
Cylinder(float radius, float height, float r, float g, float b)
Full constructor. Sets the size and color of the cylinder.
Definition: shapes.h:254
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
static int GL_ID
The identifier for the display list for this primitive.
Definition: shapes.h:306
float _r
The red component of the shape's color.
Definition: shapes.h:128
An abstact class – a generic, scene graph node.
Definition: GLNode.h:66
Sets up the proper compiler directives for platform and dll export/import.
float _radius
The radius of the circle (in world space units).
Definition: shapes.h:208
Type y() const
Get the y-value.
Definition: Vector3.h:115
Cylinder()
Default constructor. Unit size and default shape color.
Definition: shapes.h:236
Shape(float r, float g, float b, GLenum s=GL_FILL)
Constructor with color and drawing style.
Definition: shapes.h:99
float _radius
The radius of the cylinder.
Definition: shapes.h:285
static bool IS_REGISTERED
Determines if the Circle::newGLContext has been registered.
Definition: shapes.h:213
float _height
The height of the cylinder.
Definition: shapes.h:290
void setColor(float r, float g, float b)
Set the shape color from three separate values.
Definition: shapes.h:115
float _g
The green component of the shape's color.
Definition: shapes.h:133
The basic scene graph node. Any object which can be placed into the scene graph is an instance or sub...
Cylinder(float radius, float height)
Size constructor. Sets the size of the cylinder to the specified radius and height and default shape ...
Definition: shapes.h:244
A GLNode for drawing cylinders. The cylinder has unit radius and unit height and the bottom of the cy...
Definition: shapes.h:231
The SceneGraph (SceneGraph) name space, containing all elements to use in a SceneGraph.
GLenum _style
The shape's OpenGL rendering style. Should be one of GL_FILL, GL_LINE, or GL_POINT.
Definition: shapes.h:143
Functionality to make nodes in the scene graph selectable by mouse clicking.
static bool IS_REGISTERED
Reports if the class has been registered with the context manager.
Definition: shapes.h:296
void setColor(const Vector3 &vec)
Set the shape color from a vector.
Definition: shapes.h:106
A GLNode for drawing circles. The circle is drawn around the world space origin, lying on the x-z pla...
Definition: shapes.h:150
Shape()
Default constructor.
Definition: shapes.h:89
void setStyle(GLenum style)
Set the shape's render style.
Definition: shapes.h:122
static int GL_ID
OpenGL display list for drawing a circle.
Definition: shapes.h:223
Type x() const
Get the x-value.
Definition: Vector3.h:108
Type z() const
Get the z-value.
Definition: Vector3.h:122
float _b
The blue component of the shape's color.
Definition: shapes.h:138
Various important pre-compiler directives for the scene graph.
The basic shape class - a selectable GLNode.
Definition: shapes.h:84
Circle()
Default constructor.
Definition: shapes.h:155
Circle(float r, float g, float b)
Constructor with color.
Definition: shapes.h:164
The class interface for selectable objects – objects which can be selectedc in the OpenGL context by...
Definition: Select.h:59