#include<kfbxmesh.h>
Functions to initialize, set and access vertices are provided in theKFbxGeometrybase class. A vertex is referred as a control point in theKFbxGeometrybase class. Though a control point is made of four elements, meshes only use the first tree to store the XYZ coordinates.
Since the mesh-related terminology of the FBX SDK differs a little from the standard, here are some definitions:
Definition at line70of filekfbxmesh.h.
Utility functions | |
enum | ESplitObject{eBY_NORMAL} |
Object of interest when spliting.More... | |
typedef KArrayTemplate <KDuplicateVertex> | KArrayOfDuplicateVertex |
Object of interest when spliting. | |
void | Reset() |
Reset the mesh to default values. | |
void | ComputeVertexNormals(bool pCW=false) |
Compute the vertex normals on the mesh. | |
bool | CheckIfVertexNormalsCCW() |
Compares the normals calculated by doing cross-products between the polygon vertex and by the ones stored in the normal array. | |
bool | CheckSamePointTwice() |
Verify if the mesh has polygons that are defined on the same point more than once. | |
int | RemoveBadPolygons() |
Remove bad polygons from a mesh. | |
Polygon Management | |
void | BeginPolygon(int pMaterial=-1, int pTexture=-1, int pGroup=-1, bool pLegacy=true) |
Begin writing a polygon. | |
void | BeginPolygonExt(int pMaterial, int *pTextures) |
Begin writing a polygon. | |
void | AddPolygon(int pIndex, int pTextureUVIndex=-1) |
Add an index to a control point (i.e. | |
void | EndPolygon() |
End writing a polygon. | |
int | GetPolygonCount() const |
Get the polygon count of this mesh. | |
int | GetPolygonSize(int pPolygonIndex) const |
Get the number of polygon vertices in a polygon. | |
int | GetPolygonGroup(int pPolygonIndex) const |
Get the group index assigned to a polygon. | |
int | GetPolygonVertex(int pPolygonIndex, int pPositionInPolygon) const |
Get a polygon vertex (i.e. | |
void | GetPolygonVertexNormal(int pPolyIndex, int pVertexIndex,KFbxVector4&pNormal) const |
Get the normal associated with a polygon/vertex. | |
int * | GetPolygonVertices() const |
Get the array of polygon vertices (i.e. | |
int | GetPolygonVertexCount() const |
Gets the number of polygon vertices in the mesh. | |
int | GetPolygonVertexIndex(int pPolygonIndex) const |
Gets the start index into the array returned byGetPolygonVertices()for the given polygon. | |
int | RemovePolygon(int pPolygonIndex) |
Remove this polygon from the mesh. | |
Texture UV Utility Functions. | |
The functions you will find in this section are utility functions to handle UV coordinates quickly. Internaly they refer toKFbxLayer andKFbxLayerElementUV methods to do the work. These functions are only working on Layer 0. Use theKFbxLayer methods directly to access other layers. | |
void | InitTextureUV(int pCount,KFbxLayerElement::ELayerElementTypepTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES) |
Init texture UV coordinates. | |
void | AddTextureUV(KFbxVector2pUV,KFbxLayerElement::ELayerElementTypepTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES) |
Add texture UV coordinates. | |
int | GetTextureUVCount(KFbxLayerElement::ELayerElementTypepTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES) |
Get the number of texture UV coordinates. | |
int | GetUVLayerCount() |
Get the number of layer containing at least one channel UVMap. | |
KArrayTemplate <KFbxLayerElement::ELayerElementType> | GetAllChannelUV(int pLayer) |
Get an array of UV of the different UV set for a layer. | |
Material, Texture and UV Indices Utility Functions. | |
The functions you will find in this section are utility functions to handle Material, Texture and UV indices. Internaly they refer toKFbxLayer andKFbxLayerElement methods to do the work. These functions are only working on Layer 0. Use theKFbxLayer methods directly to access other layers. | |
void | InitMaterialIndices(KFbxLayerElement::EMappingModepMappingMode) |
Initialize material indices. | |
void | InitTextureIndices(KFbxLayerElement::EMappingModepMappingMode,KFbxLayerElement::ELayerElementTypepTextureType) |
Initialize texture indices. | |
void | InitTextureUVIndices(KFbxLayerElement::EMappingModepMappingMode,KFbxLayerElement::ELayerElementTypepTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES) |
Initialize texture UV indices. | |
int | GetTextureUVIndex(int pPolygonIndex, int pPositionInPolygon,KFbxLayerElement::ELayerElementTypepTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES) |
Get a texture UV index associated with a polygon vertex (i.e. | |
void | SetTextureUVIndex(int pPolygonIndex, int pPositionInPolygon, int pIndex,KFbxLayerElement::ELayerElementTypepTypeIdentifier) |
Set a texture UV index associated with a polygon vertex (i.e. | |
Point Spliting/Merging utility functions | |
void | BuildSplitList(KArrayTemplate<KArrayOfDuplicateVertex*>&pSplitList,ESplitObjectpObject) |
Insert the DuplicateVertex information in the pSplitList for the points that have to be splited depending on pObject value. | |
void | SplitPointsForHardEdge(KArrayTemplate<KArrayOfDuplicateVertex*>&pSplitList,KFbxLayerElement::ELayerElementTypepTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES) |
Split the points specified in the list. | |
bool | BuildMergeList(KArrayTemplate<int>&pMergeList,ESplitObjectpObject, bool pExport=false) |
Insert the new indexes of the object that have to be merged. | |
void | MergePointsForPolygonVerteNormals(KArrayTemplate<int>&pMergeList) |
Merge the points specified in the list. | |
Edge management functions | |
void | BuildMeshEdgeArray() |
Automatically generate edge data for the mesh. | |
int | GetMeshEdgeCount() const |
Query the number of edges defined on this mesh. | |
int | GetMeshEdgeIndex(int pStartVertexIndex, int pEndVertexIndex, bool&pReversed) |
Get the index for the edge between the given vertices. | |
int | GetMeshEdgeIndexForPolygon(int pPolygon, int pPositionInPolygon) |
Get the index for the specific edge of pPolygon. | |
void | GetMeshEdgeVertices(int pEdgeIndex, int&pStartVertexIndex, int&pEndVertexIndex) |
Get the vertices for the given edge. | |
void | BeginGetMeshEdgeVertices() |
Use this method in before calling GetMeshEdgeVertices if making several calls to that method. | |
void | EndGetMeshEdgeVertices() |
Automatically generate edge data for the mesh. | |
void | SetMeshEdgeCount(int pEdgeCount) |
Presets the number edge data elements. | |
void | SetMeshEdge(int pEdgeIndex, int pValue) |
Sets element in edge array to specific value. | |
int | AddMeshEdgeIndex(int pStartVertexIndex, int pEndVertexIndex, bool pCheckForDuplicates) |
Add an edge with the given start/end points. | |
int | SetMeshEdgeIndex(int pEdgeIndex, int pStartVertexIndex, int pEndVertexIndex, bool pCheckForDuplicates) |
Set the index for the edge with the given start/end points. | |
void | BeginAddMeshEdgeIndex() |
Call this before calling AddMeshEdgeIndex or SetMeshEdgeIndex to increase peformance. | |
void | EndAddMeshEdgeIndex() |
See BeginAddMeshEdgeIndex. | |
int | AddMeshEdgeIndexForPolygon(int pPolygonIndex, int pPositionInPolygon) |
Adds an edge for the specified polygon, and edge number within the polygon see SetMeshEdgeIndex for notes the the parameters. | |
bool | SetMeshEdgeIndex(int pEdgeIndex, int pPolygonIndex, int pPositionInPolygon) |
Sets the specified edge to the specified polygon's edge. | |
void | ComputeComponentMaps(KFbxComponentMap&pEdgeToPolyMap, KFbxComponentMap&pPolyToEdgeMap) |
Computer component maps. | |
bool | IsTriangleMesh() const |
Determines if the mesh is composed entirely of triangles. | |
Public Member Functions | |
virtualEAttributeType | GetAttributeType() const |
Return the type of node attribute. | |
Classes | |
class | KDuplicateVertex |
Internal structure used to keep the duplicate vertex information.More... | |
class | KVertexNormalInfo |
Internal structure used to compute the normals on a mesh.More... |
typedef KArrayTemplate<KDuplicateVertex>KArrayOfDuplicateVertex |
Object of interest when spliting.
Definition at line376of filekfbxmesh.h.
enumESplitObject |
Object of interest when spliting.
eBY_NORMAL | Each splited point will have a different normal for polygon/vertex. This is for normal mapping emulation. |
Definition at line337of filekfbxmesh.h.
virtualEAttributeTypeGetAttributeType | ( | ) | const[virtual] |
Return the type of node attribute.
Reimplemented fromKFbxGeometry.
void BeginPolygon | ( | int | pMaterial=-1 , | |
int | pTexture=-1 , | |||
int | pGroup=-1 , | |||
bool | pLegacy=true | |||
) |
Begin writing a polygon.
pMaterial | Index of material to assign to this polygon if material mapping type iseBY_POLYGON. Otherwise it must be-1 . | |
pTexture | Index of texture to assign to this polygon if texture mapping type iseBY_POLYGON. Otherwise it must be-1 . | |
pGroup | Group index assigned to polygon. | |
pLegacy | When set totrue , automatically create a LayerElement of type Texture; this was the old behavior. |
void BeginPolygonExt | ( | int | pMaterial, | |
int * | pTextures | |||
) |
Begin writing a polygon.
pMaterial | Index of material to assign to this polygon if material mapping type iseBY_POLYGON. Otherwise it must be-1 . | |
pTextures | Array of index of texture to assign to this polygon if texture mapping type iseBY_POLYGON. Otherwise it must be an array of-1 . |
void AddPolygon | ( | int | pIndex, | |
int | pTextureUVIndex=-1 | |||
) |
Add an index to a control point (i.e.
a polygon vertex) to the current polygon.
pIndex | Index to a control point (i.e. a polygon vertex). | |
pTextureUVIndex | Index of texture UV coordinates to assign to this polygon if texture UV mapping type iseBY_POLYGON_VERTEX. Otherwise it must be-1 . |
void EndPolygon | ( | ) |
End writing a polygon.
int GetPolygonCount | ( | ) | const[inline] |
Get the polygon count of this mesh.
Definition at line117of filekfbxmesh.h.
int GetPolygonSize | ( | int | pPolygonIndex | ) | const[inline] |
Get the number of polygon vertices in a polygon.
pPolygonIndex | Index of the polygon. |
Definition at line124of filekfbxmesh.h.
int GetPolygonGroup | ( | int | pPolygonIndex | ) | const |
Get the group index assigned to a polygon.
pPolygonIndex | Index of the polygon. |
int GetPolygonVertex | ( | int | pPolygonIndex, | |
int | pPositionInPolygon | |||
) | const[inline] |
Get a polygon vertex (i.e.
an index to a control point).
pPolygonIndex | Index of polygon. The valid range for this parameter is 0 toKFbxMesh::GetPolygonCount() . | |
pPositionInPolygon | Position of polygon vertex in indexed polygon. The valid range for this parameter is 0 toKFbxMesh::GetPolygonSize(pPolygonIndex) . |
Definition at line143of filekfbxmesh.h.
void GetPolygonVertexNormal | ( | int | pPolyIndex, | |
int | pVertexIndex, | |||
KFbxVector4& | pNormal | |||
) | const |
Get the normal associated with a polygon/vertex.
pPolyIndex | Index of the polygon. | |
pVertexIndex | Index of the vertex in the polygon space. | |
pNormal | The returned normal. |
pNormal
remain unchanged if the requested vertex does not exists.int* GetPolygonVertices | ( | ) | const |
Get the array of polygon vertices (i.e.
index to control points). This array is a concatenation of the list of polygon vertices of all the polygons. Example: a mesh made of 2 triangles [1,2,3] and [2,3,4] results in [1,2,3,2,3,4]. The first polygon starts at position 0 and the second at position 3.
int GetPolygonVertexCount | ( | ) | const |
Gets the number of polygon vertices in the mesh.
int GetPolygonVertexIndex | ( | int | pPolygonIndex | ) | const |
Gets the start index into the array returned byGetPolygonVertices()for the given polygon.
pPolygonIndex | The polygon to query |
int RemovePolygon | ( | int | pPolygonIndex | ) |
Remove this polygon from the mesh.
Update layers accordingly.
pPolygonIndex | Index of the polygon. |
void InitTextureUV | ( | int | pCount, | |
KFbxLayerElement::ELayerElementType | pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES | |||
) |
Init texture UV coordinates.
pCount | Number of texture UV elements. | |
pTypeIdentifier |
pCount
must equal the number of control points of the Mesh if the UV mapping mode isKFbxLayerElement::eBY_CONTROL_POINT.void AddTextureUV | ( | KFbxVector2 | pUV, | |
KFbxLayerElement::ELayerElementType | pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES | |||
) |
Add texture UV coordinates.
Appends a new element at the end of the array of texture UV coordinates.
pUV | Texture UV coordinates, ranging between0 and1 . | |
pTypeIdentifier |
int GetTextureUVCount | ( | KFbxLayerElement::ELayerElementType | pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES | ) |
Get the number of texture UV coordinates.
pTypeIdentifier | Type of the layer. |
int GetUVLayerCount | ( | ) |
Get the number of layer containing at least one channel UVMap.
KArrayTemplate<KFbxLayerElement::ELayerElementType>GetAllChannelUV | ( | int | pLayer | ) |
Get an array of UV of the different UV set for a layer.
pLayer | Index of the layer. |
void InitMaterialIndices | ( | KFbxLayerElement::EMappingMode | pMappingMode | ) |
Initialize material indices.
pMappingMode | The mapping mode. This function must be called after functionKFbxGeometryBase::InitControlPoints(). The material indices refer to the position of a material in the KFbxLayerElementMaterial's direct array. SeeKFbxLayerElementMaterialfor more details. Supported mapping types areeBY_CONTROL_POINT,eBY_POLYGONandeALL_SAME.
|
void InitTextureIndices | ( | KFbxLayerElement::EMappingMode | pMappingMode, | |
KFbxLayerElement::ELayerElementType | pTextureType | |||
) |
Initialize texture indices.
pMappingMode | The mapping mode. The texture indices refer to the position of a texture in the KFbxLayerElementTexture's direct array. SeeKFbxLayerElementTexturefor more details. Supported mapping modes areeBY_POLYGONandeALL_SAME.
| |
pTextureType |
void InitTextureUVIndices | ( | KFbxLayerElement::EMappingMode | pMappingMode, | |
KFbxLayerElement::ELayerElementType | pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES | |||
) |
Initialize texture UV indices.
pMappingMode | The mapping mode. The texture UV indices refer to the index of an element in the KFbxLayerElementTexture's direct array. SeeKFbxLayerElementTexturefor more details. Supported mapping types areeBY_CONTROL_POINT,eBY_POLYGON_VERTEXandeALL_SAME.
| |
pTypeIdentifier |
int GetTextureUVIndex | ( | int | pPolygonIndex, | |
int | pPositionInPolygon, | |||
KFbxLayerElement::ELayerElementType | pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES | |||
) |
Get a texture UV index associated with a polygon vertex (i.e.
an index to a control point).
pPolygonIndex | Index of polygon. The valid range for this parameter is 0 toKFbxMesh::GetPolygonCount(). | |
pPositionInPolygon | Position of polygon vertex in indexed polygon. The valid range for this parameter is 0 to KFbxMesh::GetPolygonSize(pPolygonIndex). | |
pTypeIdentifier |
void SetTextureUVIndex | ( | int | pPolygonIndex, | |
int | pPositionInPolygon, | |||
int | pIndex, | |||
KFbxLayerElement::ELayerElementType | pTypeIdentifier | |||
) |
Set a texture UV index associated with a polygon vertex (i.e.
an index to a control point).
pPolygonIndex | Index of polygon. The valid range for this parameter is 0 toKFbxMesh::GetPolygonCount(). | |
pPositionInPolygon | Position of polygon vertex in indexed polygon. The valid range for this parameter is 0 to KFbxMesh::GetPolygonSize(pPolygonIndex). | |
pIndex | The index of the texture UV we want to assign to the polygon vertex. | |
pTypeIdentifier |
void Reset | ( | ) |
Reset the mesh to default values.
Frees and set toNULL
all layers and clear the polygon and the control point array.
void ComputeVertexNormals | ( | bool | pCW=false | ) |
Compute the vertex normals on the mesh.
The normals are per vertex and are the average of all the polygon normals associated with each vertex.
pCW | True if the normals are calculated clockwise, false otherwise (counter-clockwise). |
bool CheckIfVertexNormalsCCW | ( | ) |
Compares the normals calculated by doing cross-products between the polygon vertex and by the ones stored in the normal array.
false
if ALL of them are Clockwise. Returnstrue
otherwise.bool CheckSamePointTwice | ( | ) |
Verify if the mesh has polygons that are defined on the same point more than once.
int RemoveBadPolygons | ( | ) |
Remove bad polygons from a mesh.
Degenerate polygons use a vertex more than once. Remove them from the mesh and from the layer element indices as needed.
void BuildSplitList | ( | KArrayTemplate<KArrayOfDuplicateVertex*>& | pSplitList, | |
ESplitObject | pObject | |||
) |
Insert the DuplicateVertex information in the pSplitList for the points that have to be splited depending on pObject value.
pSplitList | The list containing theKDuplicateVertexinformation of the points that will be splited. | |
pObject | The object of interest of the split. |
void SplitPointsForHardEdge | ( | KArrayTemplate<KArrayOfDuplicateVertex*>& | pSplitList, | |
KFbxLayerElement::ELayerElementType | pTypeIdentifier=KFbxLayerElement::eDIFFUSE_TEXTURES | |||
) |
Split the points specified in the list.
pSplitList | The List containing the information on the points that will be splited. | |
pTypeIdentifier |
bool BuildMergeList | ( | KArrayTemplate<int>& | pMergeList, | |
ESplitObject | pObject, | |||
bool | pExport=false | |||
) |
Insert the new indexes of the object that have to be merged.
pMergeList | The list that will contain the indexes of the objects to merge. | |
pObject | The object of interest of the merge. | |
pExport | If set totrue , include the duplicate indexes in the merge list. |
void MergePointsForPolygonVerteNormals | ( | KArrayTemplate<int>& | pMergeList | ) |
Merge the points specified in the list.
pMergeList | list containing the information on the points that will be merge |
void BuildMeshEdgeArray | ( | ) |
Automatically generate edge data for the mesh.
Clears all previously stored edge information
int GetMeshEdgeCount | ( | ) | const |
Query the number of edges defined on this mesh.
int GetMeshEdgeIndex | ( | int | pStartVertexIndex, | |
int | pEndVertexIndex, | |||
bool& | pReversed | |||
) |
Get the index for the edge between the given vertices.
Note that the result of this method is the same if pStartVertexIndex and pEndVertexIndex are swapped.
pStartVertexIndex | The starting point of the edge | |
pEndVertexIndex | The ending point of the edge | |
pReversed | flag will be set to true if the reverse edge is found, false otherwise |
int GetMeshEdgeIndexForPolygon | ( | int | pPolygon, | |
int | pPositionInPolygon | |||
) |
Get the index for the specific edge of pPolygon.
pPolygon | The polygen. | |
pPositionInPolygon | The specific edge number in the polygon. |
void GetMeshEdgeVertices | ( | int | pEdgeIndex, | |
int& | pStartVertexIndex, | |||
int& | pEndVertexIndex | |||
) |
Get the vertices for the given edge.
Note that the values returned are indices into the control point array.
pEdgeIndex | The edge to query | |
pStartVertexIndex | The edge's starting point will be stored here | |
pEndVertexIndex | The edge's starting point will be stored here |
void BeginGetMeshEdgeVertices | ( | ) |
Use this method in before calling GetMeshEdgeVertices if making several calls to that method.
Once done calling that method, call EndGetMeshEdgeVertices. This will optimize access time. Do not modify the mesh inbetween calls to BeginGetMeshEdgeVertices and EndGetMeshEdgeVertices.
void EndGetMeshEdgeVertices | ( | ) |
Automatically generate edge data for the mesh.
Clears all previously stored edge information
void SetMeshEdgeCount | ( | int | pEdgeCount | ) |
Presets the number edge data elements.
pEdgeCount | The number of edges to allocate |
void SetMeshEdge | ( | int | pEdgeIndex, | |
int | pValue | |||
) | [inline] |
Sets element in edge array to specific value.
pEdgeIndex | The edge index | |
pValue | The edge data |
Definition at line482of filekfbxmesh.h.
int AddMeshEdgeIndex | ( | int | pStartVertexIndex, | |
int | pEndVertexIndex, | |||
bool | pCheckForDuplicates | |||
) |
Add an edge with the given start/end points.
Note that the inserted edge may start at the given end point, and end at the given start point.
pStartVertexIndex | The starting point of the edge | |
pEndVertexIndex | The ending point of the edge. | |
pCheckForDuplicates | Set to true to check if the mesh already contains an edge with these two points. Can be set to false to speed up this method, when the incoming edges are known to be consistent. |
int SetMeshEdgeIndex | ( | int | pEdgeIndex, | |
int | pStartVertexIndex, | |||
int | pEndVertexIndex, | |||
bool | pCheckForDuplicates | |||
) |
Set the index for the edge with the given start/end points.
Note that the edge may start at the given end point, and end at the given start point.
pEdgeIndex | The edge index of the edge. | |
pStartVertexIndex | The starting point of the edge | |
pEndVertexIndex | The ending point of the edge. | |
pCheckForDuplicates | Set to true to check if the mesh already contains an edge with these two points. Can be set to false to speed up this method, when the incoming edges are known to be consistent. |
void BeginAddMeshEdgeIndex | ( | ) |
Call this before calling AddMeshEdgeIndex or SetMeshEdgeIndex to increase peformance.
Once finished adding/setting edges EndAddMeshEdgeIndex should be called.
void EndAddMeshEdgeIndex | ( | ) |
See BeginAddMeshEdgeIndex.
int AddMeshEdgeIndexForPolygon | ( | int | pPolygonIndex, | |
int | pPositionInPolygon | |||
) |
Adds an edge for the specified polygon, and edge number within the polygon see SetMeshEdgeIndex for notes the the parameters.
pPolygonIndex | The polygon | |
pPositionInPolygon | The edge within the polygon |
bool SetMeshEdgeIndex | ( | int | pEdgeIndex, | |
int | pPolygonIndex, | |||
int | pPositionInPolygon | |||
) |
Sets the specified edge to the specified polygon's edge.
Note that the position in polygon ranges from 0 to GetPolygonSize(pPolygonindex) - 1 and represents the edge from GetPolygonVertex(pPolygonIndex, pPositionInPolygon) to GetPolygonVertex( pPolygonIndex, pPositionInPolygon + 1 ) or from pPositionInPolygon to 0 if pPositionInPolygon == GetPolygonSize(pPolygonindex) - 1
pEdgeIndex | The edge | |
pPolygonIndex | The polygon | |
pPositionInPolygon | The specific edge number in the polygon |
void ComputeComponentMaps | ( | KFbxComponentMap& | pEdgeToPolyMap, | |
KFbxComponentMap& | pPolyToEdgeMap | |||
) |
Computer component maps.
pEdgeToPolyMap | ||
pPolyToEdgeMap |
bool IsTriangleMesh | ( | ) | const |
Determines if the mesh is composed entirely of triangles.