PrimeWorldEditor/Resource/CCollisionMesh.h

90 lines
1.8 KiB
C++

#ifndef CCOLLISIONMESH_H
#define CCOLLISIONMESH_H
#include <Common/CAABox.h>
#include <OpenGL/CVertexBuffer.h>
#include <OpenGL/CIndexBuffer.h>
#include "CResource.h"
class CCollisionMesh : public CResource
{
friend class CCollisionLoader;
class CCollisionOctree
{
friend class CCollisionLoader;
struct SOctreeNode {};
struct SLeaf : public SOctreeNode
{
CAABox AABox;
std::vector<u16> FaceIndices;
};
struct SBranch : public SOctreeNode
{
u16 Flags;
SOctreeNode *pChildren[8];
};
SOctreeNode* Root;
};
struct SCollisionProperties
{
// todo: figure out what the other properties are
bool Invert;
};
class CCollisionVertex
{
public:
SCollisionProperties Properties;
CVector3f Pos;
};
class CCollisionLine
{
public:
SCollisionProperties Properties;
u16 Vertices[2];
};
class CCollisionFace
{
public:
SCollisionProperties Properties;
u16 Lines[3];
};
CVertexBuffer mVBO;
CIndexBuffer mIBO;
u32 mVertexCount;
u32 mLineCount;
u32 mFaceCount;
bool mBuffered;
CAABox mAABox;
CCollisionOctree *mOctree;
std::vector<u32> mFlags;
std::vector<CCollisionVertex> mCollisionVertices;
std::vector<CCollisionLine> mCollisionLines;
std::vector<CCollisionFace> mCollisionFaces;
bool mOctreeLoaded;
CCollisionVertex *GetVertex(u16 index);
CCollisionLine *GetLine(u16 index);
CCollisionFace *GetFace(u16 index);
public:
CCollisionMesh();
~CCollisionMesh();
EResType Type();
void BufferGL();
void Draw();
void DrawLines();
};
#endif // CCOLLISIONMESH_H