This is the documentation for Enlighten.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

class Geo::TriGroupSelection

Utility for doing vertex-based chart identification.

This is the code used as part of the precompute for identifying the tri groups (aka charts) in an Enlighten::IPrecompInputMesh mesh for mesh projection and packing into lightmaps. It identifies tri groups based on the index buffer and a set of explicit links. It holds the chart information in two forms for convenience:

  1. A set of identified charts, with a list of triangle indices for each.

  2. An array of chart indices to match the vertex array.

A triangle group is any group of triangles that do not share vertices with any other group. This definition allows us to operate on groups independently without having to worry about the changes to one group affecting another.

There are two reasons triangles may be joined together into the same group:

  1. They share vertices and therefore cannot be separated

  2. They reference vertices that are explicitly linked together

The index buffer specifies all the information we need to determine which vertices are between triangles. Additional explicit links can also be added as an array of index pairs. The explicit links allow an opportunity to remove any unnecessary vertex duplication that may exist, such as vertices being duplicated to incorporate additional irrelevant data. Note that the actual vertex data is not required.

Variables

Name Description
const Geo::u8 groupTypeNormal = 0

Group type constants.

const Geo::u8 groupTypeSmoothBevel = 1

Group type constants.

Functions

Name Description
Create(const Geo::s32, const Geo::s32 *, Geo::s32, const IdxLink *, Geo::s32, const Geo::s16 *, const Geo::u8 *)

Create a tri group selection.

CreateExplicit(const Geo::s32, const Geo::s32, Geo::s32 *, Geo::s32 *, Geo::s32 *, Geo::s32 *, Geo::s16 *, Geo::u8 *)

Explicitly construct a TriGroupSelection from ready-made arrays.

GetChartTagForGroupIdx(Geo::s32)

Gets the chart tag for the given TriGroup index.

GetGroupTypeForGroupIdx(Geo::s32)

Gets the group type for the given TriGroup index.

GetNumTriGroups()

Get the number of tri groups.

GetNumTrisInGroupIdx(Geo::s32)

Returns the number of tris in the tri group specified by groupIdx.

GetPerVertexGroupIdxArray()

Access the array of group indices with the same length and format as the vertex buffer Will be null if numVertices was 0.

GetPerVertexGroupIdxArrayLength()

The length of the per vertex group idx array.

GetTriIdxArrayForGroupIdx(Geo::s32)

Get an array of triangle indices that comprise the group.

Release()

Release the object.

SetGroupTypeForGroupIdx(Geo::s32, Geo::u8)

Sets the group type for the given TriGroup index.


static TriGroupSelection* Geo::TriGroupSelection::Create


public: TriGroupSelection * Create
(
    const Geo::s32 numVertices,
    const Geo::s32 * indexBuffer,
    Geo::s32 numIndices,
    const IdxLink * linkBuffer,
    Geo::s32 numLinks,
    const Geo::s16 * chartTags,
    const Geo::u8 * faceTypes
)


Create a tri group selection.

Parameters
[in] numVertices

Must be zero or positive and larger than any index referenced by indexBuffer. Zero will succeed but contain no groups.

[in] indexBuffer

Array of indices to the vertex buffer. Can be null only if numVertices == numIndices == 0. Length should match numIndices.

[in] numIndices

Length of indexBuffer. Zero will succeed contain no groups.

[in] linkBuffer

Optional if numLinks == 0. An array of vertex index pairs to explicitly link.

[in] numLinks

The length of linkBuffer, or 0 for no links.

[in] chartTags

Array of user tags specified per face, can be NULL. Used to identify charts and to control auto UV generation and mesh projection.

[in] faceTypes

Array of face types, can be NULL. Used to identify different types of faces (i.e. bevel faces).


static TriGroupSelection* Geo::TriGroupSelection::CreateExplicit


public: TriGroupSelection * CreateExplicit
(
    const Geo::s32 numVertices,
    const Geo::s32 numGroups,
    Geo::s32 * numTrisInTriGroup,
    Geo::s32 * triGroupBufferOffset,
    Geo::s32 * sharedTriIdxBuffer,
    Geo::s32 * vertexGroupIdxArray,
    Geo::s16 * chartTags,
    Geo::u8 * chartTypes
)


Explicitly construct a TriGroupSelection from ready-made arrays.

This provides a means to wrap a TriGroupSelection object around a set of arrays that match the internal structure of this class. This function takes ownership of the arrays and will delete them on exit. The parameters correspond to the m_ member variable namesakes. Note that this function does no error checking so the caller must ensure the data is correctly structured.


Geo::s16 Geo::TriGroupSelection::GetChartTagForGroupIdx


public: Geo::s16 GetChartTagForGroupIdx
(
    Geo::s32 groupIdx
) const


Gets the chart tag for the given TriGroup index.

Parameters
[in] groupIdx

An index in the range 0 <= groupIdx < GetNumTriGroups()


Geo::u8 Geo::TriGroupSelection::GetGroupTypeForGroupIdx


public: Geo::u8 GetGroupTypeForGroupIdx
(
    Geo::s32 groupIdx
) const


Gets the group type for the given TriGroup index.

Parameters
[in] groupIdx

An index in the range 0 <= groupIdx < GetNumTriGroups()


Geo::s32 Geo::TriGroupSelection::GetNumTriGroups


public: Geo::s32 GetNumTriGroups() const


Get the number of tri groups.


Geo::s32 Geo::TriGroupSelection::GetNumTrisInGroupIdx


public: Geo::s32 GetNumTrisInGroupIdx
(
    Geo::s32 groupIdx
) const


Returns the number of tris in the tri group specified by groupIdx.

Parameters
[in] groupIdx

An index in the range 0 <= groupIdx < GetNumTriGroups()

Returns

The number of tris or -1 if groupIdx is out of range.


const Geo::s32* Geo::TriGroupSelection::GetPerVertexGroupIdxArray


public: const Geo::s32 * GetPerVertexGroupIdxArray() const


Access the array of group indices with the same length and format as the vertex buffer Will be null if numVertices was 0.


Geo::s32 Geo::TriGroupSelection::GetPerVertexGroupIdxArrayLength


public: Geo::s32 GetPerVertexGroupIdxArrayLength() const


The length of the per vertex group idx array.

This is the same as numVertices passed in during Create()


const Geo::s32* Geo::TriGroupSelection::GetTriIdxArrayForGroupIdx


public: const Geo::s32 * GetTriIdxArrayForGroupIdx
(
    Geo::s32 groupIdx
) const


Get an array of triangle indices that comprise the group.

Because all the vertices in a triangle are linked into the same group by definition we only need to store the indices of the triangles in a group. So all elements of the set {indexBuffer[i * 3 + 0..2]}, where i is a triangle index, will be in the same group. This class doesn't currently provide group indices in an index buffer format, but this can be easily and efficiently reconstructed from this data.

Parameters
[in] groupIdx

An index in the range 0 <= groupIdx < GetNumTriGroups()

Returns

The array of triangle indices.


void Geo::TriGroupSelection::Release


public: void Release()


Release the object.


void Geo::TriGroupSelection::SetGroupTypeForGroupIdx


public: void SetGroupTypeForGroupIdx
(
    Geo::s32 groupIdx,
    Geo::u8 groupType
)


Sets the group type for the given TriGroup index.

  • No labels