17 #ifndef _OM_DIRECTIONS_GEO_HXX_
18 #define _OM_DIRECTIONS_GEO_HXX_
28 template <
class Mesh,
class Vector>
29 OMDirectionsGeometry<Mesh, Vector>::OMDirectionsGeometry(Mesh &mesh, OpenMesh::VPropHandleT<Vector> handle, ScalarT norm, Vec4f defaultColor)
31 ref_ptr<Vec3Array> vertices =
new Vec3Array();
32 DrawElementsUInt *indices =
new DrawElementsUInt(PrimitiveSet::LINES, 0);
33 ref_ptr<Vec4Array> colors =
new Vec4Array();
36 Mesh::VertexIter end = mesh.vertices_end();
40 for (Mesh::VertexIter it = mesh.vertices_begin(); it != end; ++it)
42 point = mesh.point(it);
43 normal = mesh.property(handle, it);
45 vertices->push_back(Vec3(point[0], point[1], point[2]));
46 vertices->push_back(Vec3(normal[0]+point[0], normal[1]+point[1], normal[2]+point[2]));
48 indices->push_back(i);
49 indices->push_back(i+1);
54 colors->push_back(defaultColor);
55 setColorArray(colors);
56 setColorBinding(Geometry::BIND_PER_PRIMITIVE_SET);
57 getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
58 setVertexArray(vertices);
59 addPrimitiveSet(indices);
70 template <
class Mesh,
class Vector>
71 OMDirectionsGeometry<Mesh, Vector>::OMDirectionsGeometry(Mesh &mesh, OpenMesh::FPropHandleT<Vector> handle, ScalarT norm, Vec4f defaultColor)
73 ref_ptr<Vec3Array> vertices =
new Vec3Array();
74 DrawElementsUInt *indices =
new DrawElementsUInt(PrimitiveSet::LINES, 0);
75 ref_ptr<Vec4Array> colors =
new Vec4Array();
78 Mesh::FaceIter end = mesh.faces_end();
83 for (Mesh::FaceIter it = mesh.faces_begin(); it != end; ++it)
85 mesh.calc_face_centroid(it, point);
86 normal = mesh.property(handle, it);
88 vertices->push_back(Vec3(point[0], point[1], point[2]));
89 vertices->push_back(Vec3(normal[0]+point[0], normal[1]+point[1], normal[2]+point[2]));
91 indices->push_back(i);
92 indices->push_back(i+1);
97 colors->push_back(defaultColor);
98 setColorArray(colors);
99 setColorBinding(Geometry::BIND_PER_PRIMITIVE_SET);
100 getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
101 setVertexArray(vertices);
102 addPrimitiveSet(indices);