PathEngine home previous: iFaceVertexMesh::vertices()next: iAnchorsAndPinnedShapes::anchor_Attribute()
Contents, API Reference, Interfaces, iAnchorsAndPinnedShapes

Interface iAnchorsAndPinnedShapes

Description

An interface class for passing content-side anchor and pinned shape information into PathEngine.
The client application creates objects derived from this interface to represent geometry to be processed by PathEngine's content processing functionality.

Application definied instances of this class can be passed into iMesh::addAnchorsAndShapes() for automated addition of anchor and shape content directly to a specified base mesh, or into iPathEngine::newContentChunk() for inclusion in the resulting content chunk object.

Refer to this page for some more information about PathEngine obstacle placement.

This interface is defined in SDKRoot/code/externalAPI/i_pathengine.h.

Methods:

anchor_Attribute

Used to query attributes of the specified anchor in an extensible manner.

anchor_HorizontalPosition

Returns the horizontal coordinates of the specified anchor.

anchor_Name

Returns the name of the specified anchor, as a 'C' string.

anchor_Orientation

Returns the facing direction for the specified anchor.

anchor_VerticalRange

Returns the vertical range of the specified anchor.

numberOfAnchors

Returns the number of anchors provided by this interface.

numberOfPinnedShapes

Returns the number of pinned shapes provided by this interface.

pinnedShape_AnchorIndex

Returns an index for the anchor that pins the specified shape to the ground geometry.

pinnedShape_Attribute

Used to query attributes of the specified shape in an extensible manner.

pinnedShape_Name

Returns the name of the specified shape, as a 'C' string.

pinnedShape_NumberOfVertices

Returns the number of vertices on the specified shape.

pinnedShape_Vertex

Returns coordinates of the specified shape vertex.

Example implementation

A example of a straightforward implementation of this interface, as a simple container of the relevant anchor and shape content data, is as follows.

Header:

#include "i_pathengine.h"
#include <vector>
#include <string>

class cAnchor
{
public:
    std::string _name;
    int32_t _orientation;
    int32_t _x, _y;
    float _zStart, _zEnd;
    bool _resolvesToTerrain;
};

class cPinnedShape
{
public:
    std::string _name;
    int32_t _anchorIndex;
    std::vector<int32_t> _coords;
    int32_t _type;
};

class cAnchorsAndPinnedShapes : public iAnchorsAndPinnedShapes
{
public:

    std::vector<cAnchor> _anchors;
    std::vector<cPinnedShape> _pinnedShapes;

// iAnchorsAndPinnedShapes

    int32_t numberOfAnchors() const;
    const char* anchor_Name(int32_t anchorIndex) const;
    void anchor_HorizontalPosition(int32_t anchorIndex, int32_t& x, int32_t& y) const;
    void anchor_VerticalRange(int32_t anchorIndex, float& zStart, float& zEnd) const;
    int32_t anchor_Orientation(int32_t anchorIndex) const;
    int32_t anchor_Attribute(int32_t anchorIndex, int32_t attributeIndex) const;

    int32_t numberOfPinnedShapes() const;
    const char* pinnedShape_Name(int32_t shapeIndex) const;
    int32_t pinnedShape_AnchorIndex(int32_t shapeIndex) const;
    int32_t pinnedShape_NumberOfVertices(int32_t shapeIndex) const;
    void pinnedShape_Vertex(int32_t shapeIndex, int32_t vertexIndex, int32_t& x, int32_t& y) const;
    int32_t pinnedShape_Attribute(int32_t shapeIndex, int32_t attributeIndex) const;
};

CPP file:

#include "platform_common/Header.h"
#include "interface/AnchorsAndPinnedShapes.h"

int32_t
cAnchorsAndPinnedShapes::numberOfAnchors() const
{
    return static_cast<int32_t>(_anchors.size());
}
const char*
cAnchorsAndPinnedShapes::anchor_Name(int32_t anchorIndex) const
{
    const cAnchor& anchor = _anchors[anchorIndex];
    return anchor._name.c_str();
}
void
cAnchorsAndPinnedShapes::anchor_HorizontalPosition(int32_t anchorIndex, int32_t& x, int32_t& y) const
{
    const cAnchor& anchor = _anchors[anchorIndex];
    x = anchor._x;
    y = anchor._y;
}
void
cAnchorsAndPinnedShapes::anchor_VerticalRange(int32_t anchorIndex, float& zStart, float& zEnd) const
{
    const cAnchor& anchor = _anchors[anchorIndex];
    zStart = anchor._zStart;
    zEnd = anchor._zEnd;
}
int32_t
cAnchorsAndPinnedShapes::anchor_Orientation(int32_t anchorIndex) const
{
    const cAnchor& anchor = _anchors[anchorIndex];
    return anchor._orientation;
}
int32_t
cAnchorsAndPinnedShapes::anchor_Attribute(int32_t anchorIndex, int32_t attributeIndex) const
{
    if(attributeIndex == PE_AnchorAttribute_ResolvesToTerrain)
    {
        const cAnchor& anchor = _anchors[anchorIndex];
        if(anchor._resolvesToTerrain)
        {
            return 1;
        }
        return 0;
    }
    return -1;
}
int32_t
cAnchorsAndPinnedShapes::numberOfPinnedShapes() const
{
    return static_cast<int32_t>(_pinnedShapes.size());
}
const char*
cAnchorsAndPinnedShapes::pinnedShape_Name(int32_t shapeIndex) const
{
    const cPinnedShape& shape = _pinnedShapes[shapeIndex];
    return shape._name.c_str();
}
int32_t
cAnchorsAndPinnedShapes::pinnedShape_AnchorIndex(int32_t shapeIndex) const
{
    const cPinnedShape& shape = _pinnedShapes[shapeIndex];
    return shape._anchorIndex;
}
int32_t
cAnchorsAndPinnedShapes::pinnedShape_NumberOfVertices(int32_t shapeIndex) const
{
    const cPinnedShape& shape = _pinnedShapes[shapeIndex];
    return SizeL(shape._coords) / 2;
}
void
cAnchorsAndPinnedShapes::pinnedShape_Vertex(int32_t shapeIndex, int32_t vertexIndex, int32_t& x, int32_t& y) const
{
    const cPinnedShape& shape = _pinnedShapes[shapeIndex];
    x = shape._coords[vertexIndex * 2];
    y = shape._coords[vertexIndex * 2 + 1];
}
int32_t
cAnchorsAndPinnedShapes::pinnedShape_Attribute(int32_t shapeIndex, int32_t attributeIndex) const
{
    if(attributeIndex == PE_PinnedShapeAttribute_Type)
    {
        const cPinnedShape& shape = _pinnedShapes[shapeIndex];
        return shape._type;
    }
    return -1;
}

Documentation for PathEngine release 6.00 - Copyright © 2002-2016 PathEnginenext: iAnchorsAndPinnedShapes::anchor_Attribute()