20 Vertex(Vec3 nPosition) : position(nPosition), normal(0,0,0) {}
21 Vertex(Vec3 nPosition, Vec3 nNormal) : position(nPosition), normal(nNormal) {}
43 Vertex GetPointAt(
const float a,
const float b,
const float c)
const
45 return Vertex( A->position*a + B->position*b + C->position*c,
46 A->normal*a + B->normal*b + C->normal*c );
56 center = (A->position+B->position+C->position) * 0.33333f;
57 area = ( (A->position-B->position) ^ (A->position-C->position) ).
length() * 0.5f;
64 const int point = rand() % 6;
65 const float a = rand() / float(RAND_MAX*1.2f);
66 const float b = (1.0f - a) * rand() / float(RAND_MAX);
67 const float c = 1.0f - a - b;
70 case 0:
return GetPointAt(a,b,c);
71 case 1:
return GetPointAt(a,c,b);
72 case 2:
return GetPointAt(b,c,a);
73 case 3:
return GetPointAt(b,a,c);
74 case 4:
return GetPointAt(c,a,b);
75 default:
return GetPointAt(c,b,a);
84 class Mesh :
public osg::Referenced
92 unsigned int numOfTriangles;
96 unsigned int numOfVertices;
99 BoundingBox boundingBox;
102 void ComputeBoundingBox();
109 Mesh(
const float nMaxGrassHeight)
110 : maxGrassHeight(nMaxGrassHeight), Referenced()
123 delete [] triangleBuffer;
131 std::vector<Mesh *> Divide()
const;
142 #endif // GRASS_MESH_H