Developer Documentation
Loading...
Searching...
No Matches
MeshNodeDeprecatedT.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//
49// CLASS MeshNodeT
50//
51//=============================================================================
52
53#ifndef DOXY_IGNORE_THIS
54#ifndef ACG_MESHNODE_HH
55#define ACG_MESHNODE_HH
56
57//== INCLUDES =================================================================
58
59#include "BaseNode.hh"
60#include <vector>
61#include <string>
62#include "../ShaderUtils/GLSLShader.hh"
63
64
65//== NAMESPACES ===============================================================
66
67
68namespace ACG {
69namespace SceneGraph {
70
71
72//== CLASS DEFINITION =========================================================
73
74
86template <class Mesh>
87class MeshNodeDeprecatedT : public BaseNode
88{
89
90public:
91
98 MeshNodeDeprecatedT(const Mesh& _mesh,
99 BaseNode* _parent=0,
100 std::string _name="<MeshNode>");
101
103 virtual ~MeshNodeDeprecatedT();
104
105
106 ACG_CLASSNAME(MeshNode);
107
108
110 DrawModes::DrawMode availableDrawModes() const;
112 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
114 void draw(GLState& _state, const DrawModes::DrawMode& _drawMode);
116 void pick(GLState& _state, PickTarget _target);
117
118
120 const Mesh& mesh() const { return mesh_; }
121
122
124 void update_geometry();
127 virtual void update_topology();
128
136 void setTextureMap( std::map< int, GLuint>* _map){ textureMap_ = _map; };
137
143 void set_property_map( std::map< int, std::string>* _map){ propertyMap_ = _map; };
144
150 void setHalfedgeTextcoordPropertyName( std::string _default_halfedge_textcoord_property )
151 { default_halfedge_textcoord_property_ = _default_halfedge_textcoord_property; };
152
160 void setIndexPropertyName( std::string _index_property_name) { indexPropertyName_ = _index_property_name; };
161
162protected:
163
164
165 // types
166 enum FaceMode { FACE_NORMALS, FACE_COLORS, PER_VERTEX, FACE_NORMALS_COLORS, FACE_HALFEDGE_TEXTURED };
167
168 // draw vertices
169 void draw_vertices();
170 // draw polygons. to be overridden by TriStripNodeT
171 virtual void draw_faces(FaceMode _mode);
172
173 // pick vertices
174 void pick_vertices(GLState& _state, bool _front = false);
175 // pick polygons. to be overridden by TriMeshNodeT
176 void pick_faces(GLState& _state);
177 // pick edges
178 void pick_edges(GLState& _state, bool _front = false);
179 // pick anything
180 void pick_any(GLState& _state);
181
182 // update pick buffer sizes
183 void update_pick_buffers ();
184
185 // opengl vertex array stuff
186 enum ArrayType
187 {
188 NONE = 0,
189 VERTEX_ARRAY = 1,
190 NORMAL_ARRAY = 2,
191 COLOR_ARRAY = 4,
192 TEXTURE_COORD_1D_ARRAY = 8,
193 TEXTURE_COORD_2D_ARRAY = 16,
194 TEXTURE_COORD_3D_ARRAY = 32
195 };
196
197 // enable/disable vertex arrays according to the bits in _arrays
198 void enable_arrays(unsigned int _arrays);
199
200
201
202protected:
203
204 // mesh reference
205 const Mesh& mesh_;
206
207 // which arrays are currently enabled?
208 unsigned int enabled_arrays_;
209
210 // vertex buffer objects
211 unsigned int face_index_buffer_, vertex_buffer_, normal_buffer_;
212
213 // index list for fast rendering (will be accessed by TriStripNodeT
214 std::vector<unsigned int> indices_;
215
216private:
217
218 bool vertexBufferInitialized_;
219 bool normalBufferInitialized_;
220 bool faceIndexBufferInitialized_;
221
222 // Internal buffer used when rendering non float vertex coordinates
223 std::vector< ACG::Vec3f > vertices_;
224
225 // Internal buffer used when rendering non float normals
226 std::vector< ACG::Vec3f > normals_;
227
228 // Mapping of mesh face texture indices to gltexture id ( has to be provided externally )
229 std::map< int, GLuint>* textureMap_;
230
231 // Mapping of mesh face texture indices to coordinate property names ( has to be provided externally )
232 std::map< int, std::string>* propertyMap_;
233
234 // Property name of the per face texture coordinates
235 std::string default_halfedge_textcoord_property_;
236
237 // Property name of the per face texture index.
238 std::string indexPropertyName_;
239
240 // display Lists used for picking
241 GLuint faceList_;
242 GLuint vertexList_;
243 GLuint edgeList_;
244 GLuint anyList_;
245
246 // do we need to update our display lists?
247 bool updateFaceList_;
248 bool updateVertexList_;
249 bool updateEdgeList_;
250 bool updateAnyList_;
251 unsigned int faceBaseIndex_;
252 unsigned int vertexBaseIndex_;
253 unsigned int edgeBaseIndex_;
254 unsigned int anyBaseIndex_;
255
256 // buffers for draw arrays during picking
257 std::vector< ACG::Vec3f > pickVertexBuf_;
258 std::vector< ACG::Vec4uc > pickColorBuf_;
259
260 // bounding box
261 Vec3d bbMin_;
262 Vec3d bbMax_;
263};
264
265
266//=============================================================================
267} // namespace SceneGraph
268} // namespace ACG
269//=============================================================================
270#if defined(INCLUDE_TEMPLATES) && !defined(ACG_MESHNODE_C)
271#define ACG_MESHNODE_TEMPLATES
272#include "MeshNodeT.cc"
273#endif
274//=============================================================================
275#endif // ACG_MESHNODE_HH defined
276#endif // DOXY_IGNORE_THIS
277//=============================================================================
DrawMode NONE
not a valid draw mode
Definition DrawModes.cc:71
Namespace providing different geometric functions concerning angles.