Developer Documentation

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
45
46 //=============================================================================
47 //
48 // CLASS GlutPrimitiveNode
49 //
50 //=============================================================================
51
52
53 #ifndef ACG_GLUT_PRIMITIVE_NODE_HH
54 #define ACG_GLUT_PRIMITIVE_NODE_HH
55
56
57 //== INCLUDES =================================================================
58
59
60 #include "BaseNode.hh"
61 #include "DrawModes.hh"
62 #include <string>
63
64 #include <ACG/GL/GLPrimitives.hh>
65
66
67 //== NAMESPACES ===============================================================
68
69 namespace ACG {
70 namespace SceneGraph {
71
72
73 //== CLASS DEFINITION =========================================================
74
75
82 class ACGDLLEXPORT GlutPrimitiveNode : public BaseNode
83 {
84
85 public:
86
88 enum GlutPrimitiveType
89 {
90 CONE=0,
91 CUBE,
92 DODECAHEDRON,
93 ICOSAHEDRON,
94 OCTAHEDRON,
95 SPHERE,
96 TETRAHEDRON,
97 TORUS
98 };
99
100
101 struct Primitive
102 {
103 Vec3d position; // position
104 Vec3d axis; // direction / axis vector
105
106 GlutPrimitiveType type; // glut primitive type
107
108 ACG::Vec4f color; // color
109
110 // glut primitive resolution
111 double size;
112 double innersize; // size of inner loop for torus, height for cone
113 unsigned int slices, stacks;
114
115 // Constructor
116 explicit Primitive(GlutPrimitiveType _t) :
117
118 // default axis is negative z
119 axis(Vec3d(0,0,1)),
120
121 // Set the type
122 type(_t),
123
124 // set default resolution
125 size(1.0),
126 innersize(1.0),
127 slices(20),
128 stacks(20)
129 {
130 }
131
132 Primitive(GlutPrimitiveType _t, Vec3d _p, Vec3d _a, ACG::Vec4f _c) :
133 position(_p),
134 axis(_a),
135 type(_t),
136 color(_c),
137
138 // set default resolution
139 size(1.0),
140 innersize(1.0),
141 slices(20),
142 stacks(20)
143 {
144
145 }
146
147 // Copy Constructor
148 Primitive( const Primitive& _p)
149 {
150 // use defined = operator
151 *this = _p;
152 }
153
154 // = operator
155 Primitive& operator=(const Primitive& _p)
156 {
157 type = _p.type;
158 position = _p.position;
159 axis = _p.axis;
160 color = _p.color;
161 size = _p.size;
162 innersize = _p.innersize;
163 slices = _p.slices;
164 stacks = _p.stacks;
165
166 return *this;
167 }
168 };
169
170
171 GlutPrimitiveNode( BaseNode* _parent=0,
172 const std::string & _name="<GlutPrimitive>" );
173
174
175 GlutPrimitiveNode( GlutPrimitiveType _type,
176 BaseNode* _parent=0,
177 const std::string & _name="<GlutPrimitive>" );
178
179
181 virtual ~GlutPrimitiveNode() {}
182
188 size_t add_primitive(GlutPrimitiveType _type, Vec3d _pos, Vec3d _axis, ACG::Vec4f _color);
189
190 void clear(){primitives_.clear();};
191
193 void set_position(const Vec3d& _p, int _idx = 0);
195 const Vec3d get_position(int _idx = 0) const;
196
198 Primitive& get_primitive(int _idx){return primitives_[_idx];};
199
201 void set_size(double _s, int _idx = 0);
203 double get_size(int _idx = 0) const;
204
205 ACG_CLASSNAME(GlutPrimitiveNode);
206
208 DrawModes::DrawMode availableDrawModes() const;
209
211 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
212
214 void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
215 void draw_obj(GLState& _state, size_t _idx) const;
216
218 void pick(GLState& _state, PickTarget _target);
219
225 void setColorInternal(bool _set) { setColor_ = _set; };
226
234 void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat);
235
236 private:
237
238 std::vector<Primitive> primitives_;
239
240 bool setColor_;
241
242 // Sphere rendering
243 ACG::GLSphere* sphere_;
244
245 };
246
247
248 //=============================================================================
249 } // namespace SceneGraph
250 } // namespace ACG
251 //=============================================================================
252 #endif // ACG_GLUT_PRIMITIVE_NODE_HH
253 //=============================================================================
ACG
Namespace providing different geometric functions concerning angles.
Definition: BaseObjectData.hh:68
ACG::SceneGraph::GlutPrimitiveNode::get_primitive
Primitive & get_primitive(int _idx)
get a primitive
Definition: GlutPrimitiveNode.hh:198
ACG::SceneGraph::GlutPrimitiveNode
Definition: GlutPrimitiveNode.hh:82
ACG::GLState
Definition: GLState.hh:213
ACG::SceneGraph::GlutPrimitiveNode::setColorInternal
void setColorInternal(bool _set)
Disable internal color processing.
Definition: GlutPrimitiveNode.hh:225
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:121
ACG::GLSphere
Definition: GLPrimitives.hh:139
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:288
ACG::SceneGraph::Material
Definition: MaterialNode.hh:79
ACG::SceneGraph::GlutPrimitiveNode::~GlutPrimitiveNode
virtual ~GlutPrimitiveNode()
destructor
Definition: GlutPrimitiveNode.hh:181
ACG::SceneGraph::GlutPrimitiveNode::Primitive
Definition: GlutPrimitiveNode.hh:101
SceneGraph
Definition: QtPrincipalAxisDialog.hh:67
ACG::SceneGraph::PickTarget
PickTarget
What target to use for picking.
Definition: PickTarget.hh:73
ACG::SceneGraph::BaseNode
Definition: BaseNode.hh:104
ACG::SceneGraph::GlutPrimitiveNode::GlutPrimitiveType
GlutPrimitiveType
Lists all available primivites.
Definition: GlutPrimitiveNode.hh:88
OpenMesh::VectorT
Definition: Vector11T.hh:83
ACG::IRenderer
Definition: IRenderer.hh:78