Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GlutPrimitiveNode.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $Author$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50
51
52 //=============================================================================
53 //
54 // CLASS GlutPrimitiveNode
55 //
56 //=============================================================================
57
58
59 #ifndef ACG_GLUT_PRIMITIVE_NODE_HH
60 #define ACG_GLUT_PRIMITIVE_NODE_HH
61
62
63 //== INCLUDES =================================================================
64
65
66 #include "BaseNode.hh"
67 #include "DrawModes.hh"
68 #include <string>
69
70 #include <ACG/GL/GLPrimitives.hh>
71
72
73 //== NAMESPACES ===============================================================
74
75 namespace ACG {
76 namespace SceneGraph {
77
78
79 //== CLASS DEFINITION =========================================================
80
81
88 class ACGDLLEXPORT GlutPrimitiveNode : public BaseNode
89 {
90
91 public:
92
94 enum GlutPrimitiveType
95 {
96 CONE=0,
97 CUBE,
98 DODECAHEDRON,
99 ICOSAHEDRON,
100 OCTAHEDRON,
101 SPHERE,
102 TEAPOT,
103 TETRAHEDRON,
104 TORUS
105 };
106
107
108 struct Primitive
109 {
110 Vec3d position; // position
111 Vec3d axis; // direction / axis vector
112
113 GlutPrimitiveType type; // glut primitive type
114
115 ACG::Vec4f color; // color
116
117 // glut primitive resolution
118 double size;
119 double innersize; // size of inner loop for torus, height for cone
120 unsigned int slices, stacks;
121
122 // Constructor
123 Primitive(GlutPrimitiveType _t)
124 {
125 // Set the type
126 type = _t;
127
128 // default axis is negative z
129 axis = Vec3d(0,0,1);
130
131 // set default resolution
132 size = 1.0;
133 innersize = 1.0;
134 slices = 20;
135 stacks = 20;
136 }
137
138 Primitive(GlutPrimitiveType _t, Vec3d _p, Vec3d _a, ACG::Vec4f _c)
139 {
140 type = _t;
141 position = _p;
142 axis = _a;
143 color = _c;
144
145 // set default resolution
146 size = 1.0;
147 innersize = 1.0;
148 slices = 20;
149 stacks = 20;
150 }
151
152 // Copy Constructor
153 Primitive( const Primitive& _p)
154 {
155 // use defined = operator
156 *this = _p;
157 }
158
159 // = operator
160 Primitive& operator=(const Primitive& _p)
161 {
162 type = _p.type;
163 position = _p.position;
164 axis = _p.axis;
165 color = _p.color;
166 size = _p.size;
167 innersize = _p.innersize;
168 slices = _p.slices;
169 stacks = _p.stacks;
170
171 return *this;
172 }
173 };
174
175
176 GlutPrimitiveNode( BaseNode* _parent=0,
177 std::string _name="<GlutPrimitive>" );
178
179
180 GlutPrimitiveNode( GlutPrimitiveType _type,
181 BaseNode* _parent=0,
182 std::string _name="<GlutPrimitive>" );
183
184
186 virtual ~GlutPrimitiveNode() {}
187
193 size_t add_primitive(GlutPrimitiveType _type, Vec3d _pos, Vec3d _axis, ACG::Vec4f _color);
194
195 void clear(){primitives_.clear();};
196
198 void set_position(const Vec3d& _p, int _idx = 0);
200 const Vec3d get_position(int _idx = 0) const;
201
203 Primitive& get_primitive(int _idx){return primitives_[_idx];};
204
206 void set_size(double _s, int _idx = 0);
208 double get_size(int _idx = 0) const;
209
210 ACG_CLASSNAME(GlutPrimitiveNode);
211
213 DrawModes::DrawMode availableDrawModes() const;
214
216 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
217
219 void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
220 void draw_obj(int _idx) const;
221
223 void pick(GLState& _state, PickTarget _target);
224
230 void setColorInternal(bool _set) { setColor_ = _set; };
231
239 void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat);
240
241 private:
242
243 std::vector<Primitive> primitives_;
244
245 bool setColor_;
246
247 // Sphere rendering
248 ACG::GLSphere* sphere_;
249
250 };
251
252
253 //=============================================================================
254 } // namespace SceneGraph
255 } // namespace ACG
256 //=============================================================================
257 #endif // ACG_GLUT_PRIMITIVE_NODE_HH
258 //=============================================================================
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:135
ACG::SceneGraph::PickTarget
PickTarget
What target to use for picking.
Definition: BaseNode.hh:99
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:127
ACG::GLState
Definition: GLState.hh:220
ACG::GLSphere
Definition: GLPrimitives.hh:137
ACG::IRenderer
Definition: IRenderer.hh:84
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:294
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::SceneGraph::GlutPrimitiveNode::Primitive
Definition: GlutPrimitiveNode.hh:108
ACG::SceneGraph::GlutPrimitiveNode::GlutPrimitiveType
GlutPrimitiveType
Lists all available primivites.
Definition: GlutPrimitiveNode.hh:94
ACG::SceneGraph::GlutPrimitiveNode::get_primitive
Primitive & get_primitive(int _idx)
get a primitive
Definition: GlutPrimitiveNode.hh:203
ACG::SceneGraph::GlutPrimitiveNode::setColorInternal
void setColorInternal(bool _set)
Disable internal color processing.
Definition: GlutPrimitiveNode.hh:230
ACG::SceneGraph::Material
Definition: MaterialNode.hh:85
ACG::SceneGraph::GlutPrimitiveNode::~GlutPrimitiveNode
virtual ~GlutPrimitiveNode()
destructor
Definition: GlutPrimitiveNode.hh:186
ACG::SceneGraph::GlutPrimitiveNode
Definition: GlutPrimitiveNode.hh:88