vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
grass_triangle_collector.h
Go to the documentation of this file.
1 #ifndef GRASS_TRIANGLE_COLLECTOR_H
2 #define GRASS_TRIANGLE_COLLECTOR_H
3 
4 #include <osg/TriangleFunctor>
5 #include <osg/Vec3>
6 #include <map>
7 #include <vector>
8 
9 #include "grass_mesh.h"
10 
11 using namespace std;
12 using namespace osg;
13 
14 namespace grass
15 {
16 
17 
18 
19 
20  // collects triangles od osg::Drawable and computes very interesting things
21  // like normals and area of those triangles.
23  {
24  public:
25  // this should be called for every triangle
26  void operator() (const osg::Vec3 v1, const osg::Vec3 v2, const osg::Vec3 v3, bool treatVertexDataAsTemporary);
27 
28  // returns mesh with all accesible triangles of given Geode
29  static Mesh * GetMesh(const Geode & geode, const float maxGrassHeight);
30  private:
31  Mesh * FinalizeAndReturn(const float maxGrassHeight);
32 
33  map<Vec3, unsigned int> verticesLookup; // key is a positon, value is its index
34  vector<Vec3> vertices;
35  vector<unsigned int> triangles;
36 
37  // returns index of vertex
38  unsigned int AddVertex(const Vec3 & v);
39  };
40 
41 
42 
43 
44 }; // end of namespace grass
45 
46 
47 #endif // GRASS_TRIANGLE_COLLECTOR_H