| PathEngine home | previous: | next: |
The iFaceVertexMesh abstract interface class is key to PathEngine's
content processing functionality.
Classes derived from this interface are built by application developers to wrap application and platform specific geometry representations and to enable PathEngine's content processing to operate directly on these content representations.
Face/vertex representations do not generally provide a way to directly specify connectivity between
edges in pairs of faces.
This will be implied by PathEngine's content processing functionality
from they way in which vertices are shared between faces -
edges that share the same two vertices (but in reverse order)
are assumed to be connected.
The following is a stripped down version of the wrapper class used by the PathEngine 3DS Max exporter.
(Stripped down by the removal of attribute generation.)
This can be used to provide a starting point for your own mesh wrapper class.
Attribute generation is generally a case of enabling faces to be marked in
certain ways by content and then enabling this information to be passed through
by the faceAttribute() method.
In this implementation the wrapper performs scaling and transformation of the vertices in the original Max mesh,
so these transformed vertices are stored in buffers in the wrapper.
#include "i_pathengine.h"
#include <vector>
#include "Max.h"
class cMaxMeshWrapper : public iFaceVertexMesh
{
const Mesh& _mesh;
std::vector<long> _transformedVertexXY;
std::vector<float> _transformedVertexZ;
public:
cMaxMeshWrapper(const Mesh& mesh, const Matrix3& matrix, float scale);
// iFaceVertexMesh interface
long faces() const;
long vertices() const;
long vertexIndex(long face, long vertexInFace) const;
long vertexX(long vertex) const;
long vertexY(long vertex) const;
float vertexZ(long vertex) const;
long faceAttribute(long face, long attributeIndex) const;
};
static void
TransformVertices(const Mesh& mesh, const Matrix3& matrix, float scale,
std::vector<long>& resultXY,
std::vector<float>& resultZ)
{
long verts = mesh.getNumVerts();
resultXY.resize(verts * 2);
resultZ.resize(verts);
long i;
for(i = 0; i < verts; i++)
{
Point3 multiplied = mesh.verts[i] * matrix;
resultXY[i * 2 + 0] = static_cast<long>(multiplied.x * scale);
resultXY[i * 2 + 1] = static_cast<long>(multiplied.y * scale);
resultZ[i] = multiplied.z * scale;
}
}
cMaxMeshWrapper::cMaxMeshWrapper(const Mesh& mesh, const Matrix3& matrix, float scale) :
_mesh(mesh)
{
TransformVertices(mesh, matrix, scale, _transformedVertexXY, _transformedVertexZ);
}
long
cMaxMeshWrapper::faces() const
{
return _mesh.getNumFaces();
}
long
cMaxMeshWrapper::vertices() const
{
return _mesh.getNumVerts();
}
long
cMaxMeshWrapper::vertexIndex(long face, long vertexInFace) const
{
return _mesh.faces[face].v[2 - vertexInFace];
}
long
cMaxMeshWrapper::vertexX(long vertex) const
{
return _transformedVertexXY[vertex * 2 + 0];
}
long
cMaxMeshWrapper::vertexY(long vertex) const
{
return _transformedVertexXY[vertex * 2 + 1];
}
float
cMaxMeshWrapper::vertexZ(long vertex) const
{
return _transformedVertexZ[vertex];
}
long
cMaxMeshWrapper::faceAttribute(long face, long attributeIndex) const
{
return -1;
}
|
| Documentation for PathEngine release 5.17 - Copyright © 2002-2008 PathEngine | next: |