MeshNode2T.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef ACG_MESHNODE_HH
00054 #define ACG_MESHNODE_HH
00055
00056
00057
00058
00059
00060
00061 #include "BaseNode.hh"
00062 #include <vector>
00063 #include <ACG/Scenegraph/StripProcessorT.hh>
00064
00065
00066
00067
00068 namespace ACG {
00069 namespace SceneGraph {
00070
00071
00072
00073
00074
00075
00081 template <class Mesh>
00082 class MeshNodeT : public BaseNode
00083 {
00084 public:
00085 ACG_CLASSNAME(MeshNode);
00086
00091 MeshNodeT(Mesh& _mesh,
00092 BaseNode* _parent=0,
00093 std::string _name="<MeshNode>" );
00094
00096 virtual ~MeshNodeT();
00097
00098
00104 void update_geometry();
00105
00113 void update_topology();
00114
00122 void update_color();
00123
00124 private:
00125
00130 typedef typename Mesh::Point Point;
00131 typedef typename Point::value_type PointScalar;
00132 typedef typename Mesh::Normal Normal;
00133 typedef typename Normal::value_type NormalScalar;
00134 typedef typename Mesh::Color Color;
00135 typedef typename Color::value_type ColorScalar;
00136
00137
00140
00141
00142 public:
00143
00146 const Mesh& mesh() const { return mesh_; }
00147
00148 private:
00150 Mesh& mesh_;
00151
00154
00157
00158 public:
00159
00160
00161 private:
00162 StripProcessorT<Mesh> stripProcessor_;
00163
00166
00169
00170
00171 public:
00172
00177 void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
00178
00179 private:
00180
00182 Vec3d bbMin_;
00183
00185 Vec3d bbMax_;
00186
00189
00192
00193
00194 private:
00195
00197 GLuint vertexBuffer_;
00198
00200 bool vertexBufferInitialized_;
00201
00203 std::vector< ACG::Vec3f > vertices_;
00204
00207
00210
00211
00212 public:
00214 bool normalsEnabled() { return enableNormals_; };
00215
00217 void enableNormals(bool _enable) { enableNormals_ = _enable; };
00218
00219 private:
00220
00222 bool enableNormals_;
00223
00225 GLuint normalVertexBuffer_;
00226
00228 bool normalVertexBufferInitialized_;
00229
00231 std::vector< ACG::Vec3f > normals_;
00232
00235
00238
00239 public:
00241 bool colorsEnabled() { return enableColors_; };
00242
00244 void enableColors(bool _enable) { enableColors_ = _enable; };
00245
00246 private:
00247
00248 bool enableColors_;
00249
00251 GLuint colorVertexbuffer_;
00252
00254 bool colorVertexBufferInitialized_;
00255
00257 std::vector< ACG::Vec4f > colors_;
00258
00261
00264
00265 public:
00267 bool texCoordEnabled() { return enableTexCoords_; };
00268
00270 void enableTexCoords(bool _enable) { enableTexCoords_ = _enable; };
00271
00272 private:
00273
00274 bool enableTexCoords_;
00275
00278
00281
00282 private:
00284 std::vector< unsigned int > lineIndices_;
00285
00287 GLuint lineIndexBuffer_;
00288
00290 bool lineIndexBufferInitialized_;
00291
00292
00295
00296
00297 public:
00298
00304 void enable_arrays(unsigned int _arrays);
00305
00306 private:
00307
00309 enum ArrayType
00310 {
00311 NONE = 0,
00312 VERTEX_ARRAY = 1,
00313 NORMAL_VERTEX_ARRAY = 2,
00314 COLOR_VERTEX_ARRAY = 4,
00315 TEXCOORD_VERTEX_ARRAY = 8,
00316 LINE_INDEX_ARRAY = 16,
00317 PER_EDGE_VERTEX_ARRAY = 32,
00318 PER_EDGE_COLOR_ARRAY = 64,
00319 PER_FACE_VERTEX_ARRAY = 128,
00320 PER_FACE_NORMAL_ARRAY = 256,
00321 PER_FACE_COLOR_ARRAY = 512,
00322 PER_FACE_TEXCOORD_ARRAY = 1024
00323 };
00324
00326 unsigned int enabled_arrays_;
00327
00328
00329
00332
00333
00334 public:
00338 void draw(GLState& _state, DrawModes::DrawMode _drawMode);
00339
00340 private:
00341
00342 enum FaceMode { PER_VERTEX, PER_FACE };
00343
00347 inline void draw_vertices();
00348
00352 inline void draw_lines();
00353
00357 void draw_faces(FaceMode _mode);
00358
00364 ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const;
00365
00366 private:
00367
00368
00371
00374
00375 public:
00379 void pick(GLState& _state, PickTarget _target);
00380
00383
00386
00387
00388 private:
00389
00393 void pick_vertices(GLState& _state, bool _front = false);
00394
00396 bool updateVertexPickingList_;
00397
00399 unsigned int vertexPickingBaseIndex_;
00400
00402 GLuint vertexPickingList_;
00403
00407
00410
00411
00412
00413 private:
00417 void pick_edges(GLState& _state, bool _front = false);
00418
00420 bool updateEdgePickingList_;
00421
00423 unsigned int edgePickingBaseIndex_;
00424
00426 GLuint edgePickingList_;
00427
00430
00433
00434
00435
00436 private:
00440 void pick_faces(GLState& _state);
00441
00443 bool updateFacePickingList_;
00444
00446 unsigned int facePickingBaseIndex_;
00447
00449 GLuint facePickingList_;
00450
00453
00456
00457
00458 private:
00459
00463 void pick_any(GLState& _state);
00464
00466 bool updateAnyPickingList_;
00467
00469 unsigned int anyPickingBaseIndex_;
00470
00472 GLuint anyPickingList_;
00473
00477
00480
00481 public:
00495 void setIndexPropertyName( std::string _indexPropertyName );
00496
00497
00503 void setHalfedgeTextcoordPropertyName( std::string _halfedgeTextcoordPropertyName );
00504
00505 public:
00506
00514 void setTextureMap( std::map< int, GLuint>* _map){ textureMap_ = _map; };
00515
00516 private:
00517
00519 bool perFaceTextureIndexAvailable_;
00520
00522 bool perFaceTextureCoordsAvailable_;
00523
00525 std::map< int, GLuint>* textureMap_;
00526
00529
00530
00531 public:
00532 void set_property_map( std::map< int, std::string>* _map){ };
00533
00534
00535
00536
00537 };
00538
00539
00540
00541 }
00542 }
00543
00544 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_MESHNODE_C)
00545 #define ACG_MESHNODE_TEMPLATES
00546 #include "MeshNode2T.cc"
00547 #endif
00548
00549 #endif // ACG_MESHNODE_HH defined
00550
00551