newest version using plus components
This commit is contained in:
parent
89d09cb1b4
commit
70bad7207c
|
@ -1,44 +1,65 @@
|
||||||
#include <stdio.h>
|
#include<iostream>
|
||||||
#include<vcg/simplex/vertex/vertex.h>
|
|
||||||
#include<vcg/simplex/vertex/with/vn.h>
|
|
||||||
#include<vcg/simplex/face/with/fn.h>
|
|
||||||
#include<vcg/simplex/face/with/fcfn.h>
|
|
||||||
#include<vcg/complex/trimesh/base.h>
|
#include<vcg/complex/trimesh/base.h>
|
||||||
#include<vcg/complex/trimesh/create/platonic.h>
|
#include<vcg/simplex/vertexplus/base.h>
|
||||||
|
#include<vcg/simplex/vertexplus/component.h>
|
||||||
|
#include<vcg/simplex/faceplus/base.h>
|
||||||
|
#include<vcg/simplex/faceplus/component.h>
|
||||||
#include<vcg/complex/trimesh/update/normal.h>
|
#include<vcg/complex/trimesh/update/normal.h>
|
||||||
|
#include<vcg/complex/trimesh/create/platonic.h>
|
||||||
|
|
||||||
using namespace vcg;
|
#include<vcg/space/color4.h>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class AEdge; // dummy prototype never used
|
|
||||||
class AFace;
|
class AFace;
|
||||||
class AVertex : public vcg::Vertex< double,AEdge,AFace > {};
|
class AVertex;
|
||||||
class AFace : public vcg::FaceFCFN< AVertex,AEdge,AFace > {};
|
class AEdge; // dummy prototype never used
|
||||||
class AMesh : public vcg::tri::TriMesh< std::vector<AVertex>, std::vector<AFace> > {};
|
class AVertex : public vcg::VertexSimp2< AVertex, AEdge, AFace, vcg::vert::Coord3f>{};
|
||||||
|
class AFace : public vcg::FaceSimp2< AVertex, AEdge, AFace, vcg::face::VertexRef,vcg::face::Color4b,vcg::face::Normal3f> {};
|
||||||
|
|
||||||
|
class AMesh : public vcg::tri::TriMesh< std::vector<AVertex>, std::vector<AFace> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AMesh()
|
||||||
|
:vcg::tri::TriMesh< std::vector<AVertex>, std::vector<AFace> >()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class CEdge; // dummy prototype never used
|
|
||||||
class CFace;
|
class CFace;
|
||||||
class CVertex : public vcg::VertexVN< double,CEdge,CFace > {};
|
class CVertex;
|
||||||
class CFace : public vcg::FaceFN< CVertex,CEdge,CFace > {};
|
class CEdge; // dummy prototype never used
|
||||||
class CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> > {};
|
class CVertex : public vcg::VertexSimp2< CVertex, CEdge, CFace, vcg::vert::Coord3f,vcg::vert::Normal3f>{};
|
||||||
|
class CFace : public vcg::FaceSimp2< CVertex, CEdge, CFace, vcg::face::VertexRef, vcg::face::Normal3f> {};
|
||||||
|
|
||||||
|
class CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMesh()
|
||||||
|
:vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> >()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
int main(int , char **)
|
int main(int , char **)
|
||||||
{
|
{
|
||||||
AMesh am;
|
AMesh am;
|
||||||
CMesh cm;
|
CMesh cm;
|
||||||
tri::Tetrahedron(cm);
|
vcg::tri::Tetrahedron(cm);
|
||||||
tri::Tetrahedron(am);
|
vcg::tri::Tetrahedron(am);
|
||||||
|
|
||||||
printf("Generated mesh has %i vertices and %i triangular faces\n",cm.vn,cm.fn);
|
std::cout << "Generated mesh has " << cm.vn << " vertices and " << cm.fn << " triangular faces" << std::endl;
|
||||||
|
|
||||||
/// Calculates both vertex and face normals.
|
/// Calculates both vertex and face normals.
|
||||||
/// The normal of a vertex v is the weigthed average of the normals of the faces incident on v.
|
/// The normal of a vertex v is the weigthed average of the normals of the faces incident on v.
|
||||||
/// normals are not normalized
|
/// normals are not normalized
|
||||||
tri::UpdateNormals<CMesh>::PerVertexPerFace(cm);
|
vcg::tri::UpdateNormals<CMesh>::PerVertexPerFace(cm);
|
||||||
printf("Normal of face 0 is %f %f %f",cm.face[0].N()[0],cm.face[0].N()[1],cm.face[0].N()[2]);
|
std::cout << "[cm mesh] Normal of face 0 is [" << cm.face[0].N()[0] << "," << cm.face[0].N()[1] << "," << cm.face[0].N()[2] << "]" << std::endl;
|
||||||
|
std::cout << "[cm mesh] Normal of vertex 0 is [" << cm.vert[0].N()[0] << "," << cm.vert[0].N()[1] << "," << cm.vert[0].N()[2] << "]" << std::endl;
|
||||||
tri::UpdateNormals<AMesh>::PerFace(am);
|
|
||||||
|
|
||||||
|
/// Calculates face normals.
|
||||||
|
/// normals are not normalized
|
||||||
|
vcg::tri::UpdateNormals<AMesh>::PerFace(am);
|
||||||
|
std::cout << "[am mesh] Normal of face 0 is [" << cm.face[0].N()[0] << "," << cm.face[0].N()[1] << "," << cm.face[0].N()[2] << "]" << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue