In this page we describe the default template datas. In other words, we describe the attributes of the X3DTK::MESH::SFVertex, X3DTK::MESH::SFEdge, X3DTK::MESH::SFFace and X3DTK::MESH::Mesh classes.
For more informations about these classes, refer to the MESH scene graph API page The default mesh datas correspond to the datas of an X3DTK::X3D::IndexedFaceSet so that there is no loss of information between a standard X3D scene graph and a MESH scene graph.
For each class, two syntaxes are proposed. The first one is about the default classes, and the second one is for generic code.
// Defining the default vertex X3DTK::MESH::SFVertex *v; // Defining the generic vertex X3DTK::MESH::SFTemplateVertex<MData, VData, EData, FData> *gv;
// Defining a face X3DTK::MESH::SFFace *f; X3DTK::MESH::SFTemplateFace<MData, VData, EData, FData> *gf; // Getting the normal of face const SFVec3f &n = v->data().getNormalOfFace(f); const SFVec3f &gn = gv->template ogetData<X3DTK::MESH::VertexNormalData>().getNormalOfFace(gf); // Setting the normal of face v->data().setNormalOfFace(f, n); gv->template ogetData<X3DTK::MESH::VertexNormalData>().setNormalOfFace(gf, gn);
// Defining a face X3DTK::MESH::SFFace *f; X3DTK::MESH::SFTemplateFace<MData, VData, EData, FData> *gf; // Getting the color of face const SFColorRGBA &c = v->data().getColorOfFace(f); const SFColorRGBA &gc = gv->template ogetData<X3DTK::MESH::VertexColorData>().getColorOfFace(gf); // Setting the color of face v->data().setColorOfFace(f, c); gv->template ogetData<X3DTK::MESH::VertexColorData>().setColorOfFace(gf, gc);
// Getting the texture coordinate const SFPoint2f &p = v->data().getTexCoord(); const SFPoint2f &gp = gv->template ogetData<X3DTK::MESH::VertexTexCoordData>().getTexCoord(); // Setting the texture coordinate v->data().setTexCoord(p); gv->template ogetData<X3DTK::MESH::VertexTexCoordData>().setTexCoord(gp);
// Defining the default face X3DTK::MESH::SFFace *f; // Defining the generic face X3DTK::MESH::SFTemplateFace<MData, VData, EData, FData> *gf;
// Defining the default mesh X3DTK::MESH::Mesh *M; // Defining the generic mesh X3DTK::MESH::TemplateMesh<MData, VData, EData, FData> *GM; *
// Testing whether the mesh has normals or not bool n = M->data().hasNormal(); bool gn = M->data().template ogetData<X3DTK::MESH::MeshNormalData>.hasNormal(); // Testing whether the mesh has normals per vertex or not bool nv = M->data().getNormalPerVertex(); bool gnv = M->template ogetData<X3DTK::MESH::MeshNormalData>.getNormalPerVertex(); // Getting the crease angle float c = M->data().getCreaseAngle(); float gc = M->template ogetData<X3DTK::MESH::MeshNormalData>.getCreaseAngle(); // Setting the normal presence M->data().setNormal(n); M->data().template ogetData<X3DTK::MESH::MeshNormalData>.setNormal(gn); // Setting the normal per vertex M->data().setNormalPerVertex(nv); M->template ogetData<X3DTK::MESH::MeshNormalData>.setNormalPerVertex(gnv); // Setting the crease angle M->data().getCreaseAngle(c); M->template ogetData<X3DTK::MESH::MeshNormalData>.setCreaseAngle(gc);
// Testing whether the mesh has colors or not bool c = M->data().hasColor(); bool gc = M->data().template ogetData<X3DTK::MESH::MeshColorData>.hasColor(); // Testing whether the mesh has colors per vertex or not bool cv = M->data().getColorPerVertex(); bool gcv = M->template ogetData<X3DTK::MESH::MeshColorData>.getColorPerVertex(); // Testing whether colors are RGBA or not. bool a = M->data().getRGBA(); bool ga = M->template ogetData<X3DTK::MESH::MeshColorData>.getRGBA(); // Setting the color presence M->data().setColor(c); M->data().template ogetData<X3DTK::MESH::MeshColorData>.setColor(gc); // Testing whether the mesh has colors per vertex or not M->data().setColorPerVertex(cv); M->template ogetData<X3DTK::MESH::MeshColorData>.setColorPerVertex(gcv); // Testing whether colors are RGBA or not. M->data().setRGBA(a); M->template ogetData<X3DTK::MESH::MeshColorData>.setRGBA(ga);
// Testing whether the mesh has texture coordinates or not bool t = M->data().hasTexCoord(); bool gt = M->data().template ogetData<X3DTK::MESH::MeshTexCoordData>.hasTexCoord(); // Setting the texture coordinates presence M->data().setTexCoord(t); M->data().template ogetData<X3DTK::MESH::MeshTexCoordData>.setTexCoord(gt);
Suppose that you define an X3DTK::MESH::VertexDistanceData for the vertex entity. To aggregate the different data class you need for a vertex, you just have to use type lists like this:
// Defining a new information per vertex per face: class VertexDistanceData { public: VertexDistanceData(); void setDistanceOfFace(BaseSFFace *f, float distance); float getDistanceOfFace(BaseSFFace *f) const; }; typedef clist<tlist<VertexPointData, tlist<VertexColorData, tlist<VertexDistanceData> > > > MyVertexData; // Using the template type X3DTK::MESH::SFTemplateVertex<MyVertexData, EdgeData, FaceData, true> *v; //accessing directly the information float distance = v->data().getDistanceOfFace(f);
Then you have to write a processor that fills the distance values. For an example on how to define your own data, see meshExtension.