struct SMeshTexCoord { float s, t; struct SMeshColor { uint8 r, g, b, a; struct SMeshFace { int v[3]; unsigned char nSubset; }; struct SMeshTangents { Vec4sf Tangent; Vec4sf Binormal; struct SMeshQTangents { Vec4sf TangentBinormal; struct SMeshBoneMapping_uint16 { BoneId boneIds[4]; Weight weights[4]; struct SMeshBoneMapping_uint8 { BoneId boneIds[4]; Weight weights[4]; struct SMeshSubset { Vec3 vCenter; float fRadius; float fTexelDensity; int nFirstIndexId; int nNumIndices; int nFirstVertId; int nNumVerts; int nMatID; int nMatFlags; int nPhysicalizeType; }; class CMeshHelpers; class CMesh; struct IIndexedMesh { struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; }; }; }; }; }; }; }; };
IIndexedMesh.h
2D Texture coordinates used by CMesh.
struct SMeshColor { uint8 r, g, b, a; struct SMeshFace { int v[3]; unsigned char nSubset; }; struct SMeshTangents { Vec4sf Tangent; Vec4sf Binormal; struct SMeshQTangents { Vec4sf TangentBinormal; struct SMeshBoneMapping_uint16 { BoneId boneIds[4]; Weight weights[4]; struct SMeshBoneMapping_uint8 { BoneId boneIds[4]; Weight weights[4]; struct SMeshSubset { Vec3 vCenter; float fRadius; float fTexelDensity; int nFirstIndexId; int nNumIndices; int nFirstVertId; int nNumVerts; int nMatID; int nMatFlags; int nPhysicalizeType; }; class CMeshHelpers; class CMesh; struct IIndexedMesh { struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; }; }; }; }; }; }; };
IIndexedMesh.h
RGBA Color description structure used by CMesh.
struct SMeshFace { int v[3]; unsigned char nSubset; };
IIndexedMesh.h
Members |
Description |
int v[3]; |
indices to vertex, normals and optionally tangent basis arrays |
unsigned char nSubset; |
index to mesh subsets array. |
Defines a single triangle face in the CMesh topology.
struct SMeshTangents { Vec4sf Tangent; Vec4sf Binormal; struct SMeshQTangents { Vec4sf TangentBinormal; struct SMeshBoneMapping_uint16 { BoneId boneIds[4]; Weight weights[4]; struct SMeshBoneMapping_uint8 { BoneId boneIds[4]; Weight weights[4]; struct SMeshSubset { Vec3 vCenter; float fRadius; float fTexelDensity; int nFirstIndexId; int nNumIndices; int nFirstVertId; int nNumVerts; int nMatID; int nMatFlags; int nPhysicalizeType; }; class CMeshHelpers; class CMesh; struct IIndexedMesh { struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; }; }; }; }; }; };
IIndexedMesh.h
Mesh tangents (tangent space normals).
struct SMeshQTangents { Vec4sf TangentBinormal; struct SMeshBoneMapping_uint16 { BoneId boneIds[4]; Weight weights[4]; struct SMeshBoneMapping_uint8 { BoneId boneIds[4]; Weight weights[4]; struct SMeshSubset { Vec3 vCenter; float fRadius; float fTexelDensity; int nFirstIndexId; int nNumIndices; int nFirstVertId; int nNumVerts; int nMatID; int nMatFlags; int nPhysicalizeType; }; class CMeshHelpers; class CMesh; struct IIndexedMesh { struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; }; }; }; }; };
IIndexedMesh.h
struct SMeshBoneMapping_uint16 { BoneId boneIds[4]; Weight weights[4]; struct SMeshBoneMapping_uint8 { BoneId boneIds[4]; Weight weights[4]; struct SMeshSubset { Vec3 vCenter; float fRadius; float fTexelDensity; int nFirstIndexId; int nNumIndices; int nFirstVertId; int nNumVerts; int nMatID; int nMatFlags; int nPhysicalizeType; }; class CMeshHelpers; class CMesh; struct IIndexedMesh { struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; }; }; }; };
IIndexedMesh.h
for skinning every vertex has 4 bones and 4 weights.
struct SMeshBoneMapping_uint8 { BoneId boneIds[4]; Weight weights[4]; struct SMeshSubset { Vec3 vCenter; float fRadius; float fTexelDensity; int nFirstIndexId; int nNumIndices; int nFirstVertId; int nNumVerts; int nMatID; int nMatFlags; int nPhysicalizeType; }; class CMeshHelpers; class CMesh; struct IIndexedMesh { struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; }; }; };
IIndexedMesh.h
class CMesh;
IIndexedMesh.h
General purpose mesh class.
enum EStream { POSITIONS = 0, POSITIONSF16, NORMALS, FACES, TOPOLOGY_IDS, TEXCOORDS, COLORS_0, COLORS_1, INDICES, TANGENTS, BONEMAPPING, VERT_MATS, QTANGENTS, PS3EDGEDATA, P3S_C4B_T2S, EXTRABONEMAPPING, LAST_STREAM };
IIndexedMesh.h
Members |
Description |
EXTRABONEMAPPING |
Extra stream. Does not have a stream ID in the CGF. Its data is saved at the end of the BONEMAPPING stream. |
AABB m_bbox;
Bounding box.
int m_nCoorCount;
number of texture coordinates in m_pTexCoord array
uint32 m_nSharedStreamMask;
Mask that indicate if this stream is using not allocated in Mesh pointer; ex. if (m_nSharedStreamMask & (1
SMeshBoneMapping_uint16* m_pBoneMapping;
bone-mapping for the final render-mesh
SMeshColor* m_pColor0;
SMeshColor* m_pColor1;
SMeshBoneMapping_uint16* m_pExtraBoneMapping;
bone indices and weights for bones 5 to 8.
SMeshFace* m_pFaces;
faces are used in mesh processing/compilation
vtx_idx* m_pIndices;
indices are used for the final render-mesh
Vec3* m_pNorms;
SVF_P3S_C4B_T2S* m_pP3S_C4B_T2S;
Vec3* m_pPositions;
Vec3f16* m_pPositionsF16;
SMeshQTangents* m_pQTangents;
uint8 * m_ps3EdgeData;
SMeshTangents* m_pTangents;
SMeshTexCoord* m_pTexCoord;
int32* m_pTopologyIds;
int * m_pVertMats;
int m_streamSize[LAST_STREAM];
DynArray<SMeshSubset> m_subsets;
Array of mesh subsets.
float m_texMappingDensity;
Texture space area divided by geometry area. Zero if cannot compute.
virtual ~CMesh();
const char* Append(const CMesh& mesh);
Add streams from source mesh to the end of existing streams.
const char* Append(const CMesh& mesh, int fromVertex, int vertexCount, int fromFace, int faceCount);
Add streams from source mesh to the end of existing streams.
static uint32 ApproximateRenderMeshMemoryUsage(int nVertexCount, int nIndexCount);
This function used when we do not have an actual mesh, but only vertex/index count of it.
CMesh();
bool CompareStreams(const CMesh& mesh) const;
bool ComputeSubsetTexMappingAreas(size_t subsetIndex, float& computedPosArea, float& computedTexArea, const char*& errorText);
void Copy(const CMesh& mesh);
Copy mesh from source mesh.
uint32 EstimateRenderMeshMemoryUsage() const;
Estimates the size of the render mesh.
void FreeStreams();
int GetFaceCount() const;
int GetIndexCount() const;
void GetMemoryUsage(class ICrySizer * pSizer) const;
void GetStreamInfo(int stream, void*& pStream, int& nElementSize) const;
template <class T> T* GetStreamPtr(int stream, int* pElementCount = 0) const;
int GetSubSetCount() const;
int GetTangentCount() const;
int GetTexCoordCount() const;
int GetVertexCount() const;
virtual void ReallocStream(int stream, int nNewCount);
bool RecomputeTexMappingDensity();
this function doesn't work for "old" uncompressed meshes (with faces instead of indices)
void RemoveRangeFromStream(int stream, int nFirst, int nCount);
void SetFaceCount(int nNewCount);
void SetIndexCount(int nNewCount);
void SetSharedStream(int stream, void * pStream, int nElementCount);
Set specific stream as shared.
void SetTexCoordsAndTangentsCount(int nNewCount);
void SetTexCoordsCount(int nNewCount);
void SetVertexCount(int nNewCount);
bool Validate(const char** const ppErrorDescription) const;
class CMeshHelpers;
IIndexedMesh.h
template <class TPosition, class TTexCoordinates, class TIndex> static bool ComputeTexMappingAreas(size_t indexCount, const TIndex* pIndices, size_t vertexCount, const TPosition* pPositions, size_t stridePositions, const TTexCoordinates* pTexCoords, size_t strideTexCoords, float& computedPosArea, float& computedTexArea, const char*& errorText);
struct IIndexedMesh { struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; }; };
IIndexedMesh.h
Editable mesh interface. IndexedMesh can be created directly or loaded from CGF file, before rendering it is converted into IRenderMesh. IStatObj is used to host IIndexedMesh, and corresponding IRenderMesh.
struct SMeshDescription { const SMeshFace* m_pFaces; const Vec3* m_pVerts; const Vec3f16* m_pVertsF16; const Vec3* m_pNorms; const SMeshColor* m_pColor; const SMeshTexCoord* m_pTexCoord; const vtx_idx* m_pIndices; int m_nFaceCount; int m_nVertCount; int m_nCoorCount; int m_nIndexCount; };
IIndexedMesh.h
Members |
Description |
const SMeshFace* m_pFaces; |
pointer to array of faces |
const Vec3* m_pVerts; |
pointer to array of vertices in f32 format |
const Vec3f16* m_pVertsF16; |
pointer to array of vertices in f16 format |
const Vec3* m_pNorms; |
pointer to array of normals |
const SMeshColor* m_pColor; |
pointer to array of vertex colors |
const SMeshTexCoord* m_pTexCoord; |
pointer to array of texture coordinates |
const vtx_idx* m_pIndices; |
pointer to array of indices |
int m_nFaceCount; |
number of elements m_pFaces array |
int m_nVertCount; |
number of elements in m_pVerts, m_pNorms and m_pColor arrays |
int m_nCoorCount; |
number of elements in m_pTexCoord array |
int m_nIndexCount; |
number of elements in m_pIndices array |
! Structure used for read-only access to mesh data. Used by GetMesh() function
virtual ~IIndexedMesh();
virtual void AllocateBoneMapping() = 0;
Allocates m_pBoneMapping in CMesh
virtual void CalcBBox() = 0;
virtual void FreeStreams() = 0;
! Frees vertex and face streams. Calling this function invalidates SMeshDescription pointers
virtual AABB GetBBox() const = 0;
virtual int GetFaceCount() const = 0;
! Return number of allocated faces
virtual int GetIndexCount() const = 0;
Get number of indices in the mesh.
virtual CMesh* GetMesh() = 0;
virtual void GetMeshDescription(SMeshDescription & meshDesc) const = 0;
! Gives read-only access to mesh data
virtual const SMeshSubset& GetSubSet(int nIndex) const = 0;
virtual int GetSubSetCount() const = 0;
Subset access.
virtual int GetTangentCount() const = 0;
! Return number of allocated tangents.
virtual int GetTexCoordCount() const = 0;
! Return number of allocated texture coordinates
virtual int GetVertexCount() const = 0;
! Return number of allocated vertices, normals and colors
virtual void Release() = 0;
Release indexed mesh.
virtual void RestoreFacesFromIndices() = 0;
virtual void SetBBox(const AABB & box) = 0;
Mesh bounding box.
virtual void SetColorCount(int nNewCount) = 0;
! Reallocates colors. Calling this function invalidates SMeshDescription pointers
virtual void SetFaceCount(int nNewCount) = 0;
! Reallocates faces. Calling this function invalidates SMeshDescription pointers
virtual void SetIndexCount(int nNewCount) = 0;
Set number of indices in the mesh.
virtual void SetMesh(CMesh & mesh) = 0;
virtual void SetSubsetBounds(int nIndex, const Vec3& vCenter, float fRadius) = 0;
virtual void SetSubSetCount(int nSubsets) = 0;
virtual void SetSubsetIndexVertexRanges(int nIndex, int nFirstIndexId, int nNumIndices, int nFirstVertId, int nNumVerts) = 0;
virtual void SetSubsetMaterialId(int nIndex, int nMatID) = 0;
virtual void SetSubsetMaterialProperties(int nIndex, int nMatFlags, int nPhysicalizeType) = 0;
virtual void SetTangentCount(int nNewCount) = 0;
! Reallocates tangents. Calling this function invalidates SMeshDescription pointers
virtual void SetTexCoordCount(int nNewCount) = 0;
! Reallocates texture coordinates. Calling this function invalidates SMeshDescription pointers
virtual void SetVertexCount(int nNewCount) = 0;
! Reallocates vertices, normals and colors. Calling this function invalidates SMeshDescription pointers
struct SMeshSubset { Vec3 vCenter; float fRadius; float fTexelDensity; int nFirstIndexId; int nNumIndices; int nFirstVertId; int nNumVerts; int nMatID; int nMatFlags; int nPhysicalizeType; };
IIndexedMesh.h
Subset of mesh is a continuous range of vertices and indices that share same material.
float fRadius;
float fTexelDensity;
int nFirstIndexId;
int nFirstVertId;
int nMatFlags;
Special Material flags.
int nMatID;
Material Sub-object id.
int nNumIndices;
int nNumVerts;
int nPhysicalizeType;
Type of physicalization for this subset.
Vec3 vCenter;
void FixRanges(vtx_idx* pIndices);
fix numVerts
void GetMemoryUsage(class ICrySizer * pSizer) const;
SMeshSubset();
BoneId boneIds[4];
Weight weights[4];
template <> inline Vec2 CMeshHelpers::ToVec2<SMeshTexCoord>(const SMeshTexCoord& v);
template <> inline Vec2 CMeshHelpers::ToVec2(const Vec2& v);
template <> inline Vec3 CMeshHelpers::ToVec3(const Vec3& v);
typedef uint8 BoneId;
typedef uint8 Weight;
BoneId boneIds[4];
Weight weights[4];
typedef uint16 BoneId;
typedef uint8 Weight;
Vec4sf TangentBinormal;
Vec4sf Binormal;
Vec4sf Tangent;
uint8 a;
uint8 b;
uint8 g;
uint8 r;
float s;
float t;
bool operator !=(const SMeshTexCoord& other) const;
bool operator ==(const SMeshTexCoord& other) const;