leocad/common/lc_mesh.h

118 lines
2.3 KiB
C
Raw Normal View History

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();
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>
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
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
};
extern lcMesh* gPlaceholderMesh;
2013-08-09 06:57:18 +02:00
#endif // _LC_MESH_H_