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/code/externalAPI/i_pathengine.h.

Methods:

faceAttribute

Used to obtain information about a face.

faces

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

vertexIndex

Returns the number of unique vertices in this object.

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<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;
}

Container class

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