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