PathEngine home | previous: | next: |
An interface class for passing geometry represented in the form of indexed tris and vertices into PathEngine.
The client application creates objects deriving from this interface to
represent geometry to be processed by PathEngine's content processing functionality.
This interface is used to pass data in to PathEngine's 2D and 3D content processing functionality.
Refer to
Refer to
This interface is defined in SDKRoot/code/externalAPI/i_pathengine.h.
Used to obtain information about a face. | ||
Returns the number of faces (tris) in this object. | ||
Enables you to obtain the indices of vertices around a given face. | ||
Used to obtain vertex coordinates. | ||
Used to obtain vertex coordinates. | ||
Used to obtain vertex coordinates. | ||
Returns the number of unique vertices in this object. |
This interface can be implemented in different ways, depending on the specific content processing situation.
In situations where the relevant information is already included in some data structure, a wrapper class approach should be used.
In situations where a wrapper class is not straightforward to set up, a container class approach can be used.
In other situations, other implementations, such as procedural generation of points, could also make sense.
The following is a stripped down version of the wrapper class used by the PathEngine 3DS Max exporter, which can be used as a starting point for your own mesh wrapper class.
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.
Attribute generation is not shown.
Where face attributes are required
the faceAttribute() method will need to be filled in accordingly.
#include "i_pathengine.h" #include <vector> #include "Max.h" class cMaxMeshWrapper : public iFaceVertexMesh { const Mesh& _mesh; std::vector<int32_t> _transformedVertexXY; std::vector<float> _transformedVertexZ; public: cMaxMeshWrapper(const Mesh& mesh, const Matrix3& matrix, float scale); // iFaceVertexMesh interface int32_t faces() const; int32_t vertices() const; int32_t vertexIndex(int32_t face, int32_t vertexInFace) const; int32_t vertexX(int32_t vertex) const; int32_t vertexY(int32_t vertex) const; float vertexZ(int32_t vertex) const; int32_t faceAttribute(int32_t face, int32_t attributeIndex) const; }; static void TransformVertices(const Mesh& mesh, const Matrix3& matrix, float scale, std::vector<int32_t>& resultXY, std::vector<float>& resultZ) { int32_t 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<int32_t>(multiplied.x * scale); resultXY[i * 2 + 1] = static_cast<int32_t>(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); } int32_t cMaxMeshWrapper::faces() const { return _mesh.getNumFaces(); } int32_t cMaxMeshWrapper::vertices() const { return _mesh.getNumVerts(); } int32_t cMaxMeshWrapper::vertexIndex(int32_t face, int32_t vertexInFace) const { return _mesh.faces[face].v[2 - vertexInFace]; } int32_t cMaxMeshWrapper::vertexX(int32_t vertex) const { return _transformedVertexXY[vertex * 2 + 0]; } int32_t cMaxMeshWrapper::vertexY(int32_t vertex) const { return _transformedVertexXY[vertex * 2 + 1]; } float cMaxMeshWrapper::vertexZ(int32_t vertex) const { return _transformedVertexZ[vertex]; } int32_t cMaxMeshWrapper::faceAttribute(int32_t face, int32_t attributeIndex) const { return -1; } |
A generic implementation of this interface, as a container class, can also be found at SDKRoot/code/sampleShared/FaceVertexMesh.h.
Documentation for PathEngine release 6.04 - Copyright © 2002-2024 PathEngine | next: |