Moreover the scene graph is templated by the datas stored per vertex, edge, face and mesh, ensuring a fully customizable structure. We present here the form of a classical MESH scene graph and the interface of the different entities of a Mesh node.
fig 1: on the left, a typical X3D scene graph, on the right the translation into the MESH scene graph.
The translation of an X3D scene graph into a MESH scene graph conserves the global structure, but some differences are introduced. the X3DTK::X3D::IndexedFaceSet
node is replaced by a template winged-edge node, X3DTK::MESH::Mesh<MData, VData, EData, FData, readOnly>
, X3DTK::X3D::Coordinate
is replaced by another template node: X3DTK::MESH::Vertex<>
. The list of node attributes like X3DTK::X3D::Normal
is removed, the information is placed into the template nodes.
Concerning the X3DTK::X3D::Appearance
, the X3D sub-graph is cloned without translating it into a MESH node.
Notice that there is a difference between the X3DTK::X3D::Coordinate
node and the X3DTK::MESH::Vertex<>
. The former stores coordinates, the latter stores vertices. Indeed same 3D coordinates can lead to several vertices.
// Default vertex (with default template datas) X3DTK::MESH::DefSFVertex *v; // User datas vertex X3DTK::MESH::SFVertex<MyMeshData, MyVertexData, MyEdgeData, MyFaceData, true> *u;
Template datas are explained later.
From a vertex:
X3DTK::MESH::DefSFVertex *v; // Getting the rounding edges const typename X3DTK::MESH::DefSFVertex::MFEdge &me = v->getEdges(); // Getting the rounding faces const typename X3DTK::MESH::DefSFVertex::MFFace &mf = v->getFaces();
From an edge:
X3DTK::MESH::DefSFEdge *e; // Getting the symetric edge X3DTK::MESH::DefSFEdge *s = e->getSymetric(); // Getting the from vertex X3DTK::MESH::DefSFVertex *f = e->getFromVertex(); // Getting the to vertex X3DTK::MESH::DefSFVertex *t = e->getToVertex(); // Getting the right faces const typename X3DTK::MESH::DefSFEdge::MFFace &mf = e->getRightFaces(); // Getting all the faces typename X3DTK::MESH::DefSFEdge::MFFace af = e->getFaces();
From a face:
X3DTK::MESH::DefSFFace *f; // Getting the edges of the face const typename X3DTK::MESH::DefSFFace::MFEdge &me = e->getEdges();
Letīs take the example of vertex. A standard X3D file defines at most, a coordinate, a normal, a color and a texture coordinate per vertex. However you are a user of the library and you need to code an algorithm that only requires coordinates and normals. Colors and texture coordinates are useless and take overload memory. You want that vertices only store coordinate and normal information. The MESH scene graph is customizable and allows you to choose which information are stored per entity. Furthermore you can also define your own information per vertex, by adding a weight property for instance.