PathEngine home previous: iRender3DLinesCallBack::vertex()next: iFaceVertexMesh::faceAttribute()
Contents, API Reference, Interfaces, iFaceVertexMesh

Interface iFaceVertexMesh

Description

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 2D Content Processing for information about PathEngine's 2D content processing functionality.

Refer to 3D Content Processing for information about PathEngine's 3D content processing functionality.

This interface is defined in SDKRoot/include/i_pathengine.h.

Methods:

faceAttribute

Used to obtain information about a face.

faces

Returns the number of faces (tris) in this object.

vertexIndex

Used to obtain unique vertex indices for the vertices around a face.

vertexX

Used to obtain vertex coordinates.

vertexY

Used to obtain vertex coordinates.

vertexZ

Used to obtain vertex coordinates.

vertices

Returns the number of unique vertices in this object.

Example implementation

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<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.24 - Copyright © 2002-2010 PathEnginenext: iFaceVertexMesh::faceAttribute()