2013-08-09 06:57:18 +02:00
|
|
|
#ifndef _LC_MESH_H_
|
|
|
|
#define _LC_MESH_H_
|
|
|
|
|
|
|
|
#include "lc_math.h"
|
|
|
|
|
|
|
|
#define LC_MESH_FILE_ID LC_FOURCC('M', 'E', 'S', 'H')
|
2016-08-22 03:11:32 +02:00
|
|
|
#define LC_MESH_FILE_VERSION 0x0111
|
|
|
|
|
|
|
|
enum lcMeshPrimitiveType
|
|
|
|
{
|
|
|
|
LC_MESH_LINES,
|
|
|
|
LC_MESH_TRIANGLES,
|
|
|
|
LC_MESH_TEXTURED_LINES,
|
|
|
|
LC_MESH_TEXTURED_TRIANGLES,
|
|
|
|
LC_MESH_CONDITIONAL_LINES,
|
|
|
|
LC_MESH_NUM_PRIMITIVE_TYPES
|
|
|
|
};
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
struct lcVertex
|
|
|
|
{
|
|
|
|
lcVector3 Position;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lcVertexTextured
|
|
|
|
{
|
|
|
|
lcVector3 Position;
|
|
|
|
lcVector2 TexCoord;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lcMeshSection
|
|
|
|
{
|
|
|
|
int ColorIndex;
|
|
|
|
int IndexOffset;
|
|
|
|
int NumIndices;
|
2016-08-22 03:11:32 +02:00
|
|
|
lcMeshPrimitiveType PrimitiveType;
|
2013-08-09 06:57:18 +02:00
|
|
|
lcTexture* Texture;
|
|
|
|
};
|
|
|
|
|
2015-05-24 06:36:25 +02:00
|
|
|
struct lcMeshLod
|
|
|
|
{
|
|
|
|
lcMeshSection* Sections;
|
|
|
|
int NumSections;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
LC_MESH_LOD_HIGH,
|
|
|
|
LC_MESH_LOD_LOW,
|
|
|
|
LC_NUM_MESH_LODS
|
|
|
|
};
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
class lcMesh
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
lcMesh();
|
|
|
|
~lcMesh();
|
|
|
|
|
2015-05-24 06:36:25 +02:00
|
|
|
void Create(lcuint16 NumSections[LC_NUM_MESH_LODS], int NumVertices, int NumTexturedVertices, int NumIndices);
|
2013-08-09 06:57:18 +02:00
|
|
|
void CreateBox();
|
|
|
|
|
2015-07-22 06:00:47 +02:00
|
|
|
bool FileLoad(lcMemFile& File);
|
|
|
|
bool FileSave(lcMemFile& File);
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
template<typename IndexType>
|
|
|
|
void ExportPOVRay(lcFile& File, const char* MeshName, const char* ColorTable);
|
|
|
|
void ExportPOVRay(lcFile& File, const char* MeshName, const char* ColorTable);
|
|
|
|
|
|
|
|
template<typename IndexType>
|
|
|
|
void ExportWavefrontIndices(lcFile& File, int DefaultColorIndex, int VertexOffset);
|
|
|
|
void ExportWavefrontIndices(lcFile& File, int DefaultColorIndex, int VertexOffset);
|
|
|
|
|
|
|
|
template<typename IndexType>
|
2016-02-29 21:13:54 +01:00
|
|
|
bool MinIntersectDist(const lcVector3& Start, const lcVector3& End, float& MinDist);
|
|
|
|
bool MinIntersectDist(const lcVector3& Start, const lcVector3& End, float& MinDist);
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
template<typename IndexType>
|
|
|
|
bool IntersectsPlanes(const lcVector4 Planes[6]);
|
|
|
|
bool IntersectsPlanes(const lcVector4 Planes[6]);
|
|
|
|
|
2015-05-24 06:36:25 +02:00
|
|
|
int GetLodIndex(float Distance) const;
|
|
|
|
|
|
|
|
lcMeshLod mLods[LC_NUM_MESH_LODS];
|
2016-02-19 18:53:54 +01:00
|
|
|
lcBoundingBox mBoundingBox;
|
2015-05-24 06:36:25 +02:00
|
|
|
float mRadius;
|
2013-08-09 06:57:18 +02:00
|
|
|
|
2015-04-26 20:14:33 +02:00
|
|
|
void* mVertexData;
|
|
|
|
int mVertexDataSize;
|
|
|
|
void* mIndexData;
|
|
|
|
int mIndexDataSize;
|
|
|
|
int mVertexCacheOffset;
|
|
|
|
int mIndexCacheOffset;
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
int mNumVertices;
|
|
|
|
int mNumTexturedVertices;
|
|
|
|
int mIndexType;
|
|
|
|
};
|
|
|
|
|
2015-05-04 02:51:41 +02:00
|
|
|
enum lcRenderMeshState
|
|
|
|
{
|
|
|
|
LC_RENDERMESH_NONE,
|
|
|
|
LC_RENDERMESH_SELECTED,
|
|
|
|
LC_RENDERMESH_FOCUSED
|
|
|
|
};
|
|
|
|
|
2014-04-20 03:50:41 +02:00
|
|
|
struct lcRenderMesh
|
|
|
|
{
|
2014-12-24 16:52:52 +01:00
|
|
|
lcMatrix44 WorldMatrix;
|
2014-04-20 03:50:41 +02:00
|
|
|
lcMesh* Mesh;
|
|
|
|
float Distance;
|
2015-02-08 19:54:51 +01:00
|
|
|
int ColorIndex;
|
2015-05-24 06:36:25 +02:00
|
|
|
int LodIndex;
|
2015-05-04 02:51:41 +02:00
|
|
|
lcRenderMeshState State;
|
2014-04-20 03:50:41 +02:00
|
|
|
};
|
|
|
|
|
2015-01-08 05:50:38 +01:00
|
|
|
extern lcMesh* gPlaceholderMesh;
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
#endif // _LC_MESH_H_
|