2011-09-07 23:06:51 +02:00
|
|
|
#ifndef _PIECEINF_H_
|
|
|
|
#define _PIECEINF_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2012-06-07 02:08:59 +02:00
|
|
|
#include "lc_math.h"
|
2014-04-23 16:53:43 +02:00
|
|
|
#include "lc_array.h"
|
|
|
|
#include "lc_mesh.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2012-10-03 00:16:36 +02:00
|
|
|
#define LC_PIECE_HAS_DEFAULT 0x01 // Piece has triangles using the default color
|
|
|
|
#define LC_PIECE_HAS_SOLID 0x02 // Piece has triangles using a solid color
|
|
|
|
#define LC_PIECE_HAS_TRANSLUCENT 0x04 // Piece has triangles using a translucent color
|
|
|
|
#define LC_PIECE_HAS_LINES 0x08 // Piece has lines
|
2012-11-08 05:05:52 +01:00
|
|
|
#define LC_PIECE_PLACEHOLDER 0x10 // Placeholder for a piece not in the library
|
2015-07-22 06:00:47 +02:00
|
|
|
#define LC_PIECE_MODEL 0x20 // Piece is a model
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
#define LC_PIECE_NAME_LEN 256
|
|
|
|
|
|
|
|
class PieceInfo
|
|
|
|
{
|
2012-10-03 00:16:36 +02:00
|
|
|
public:
|
2014-05-08 00:58:59 +02:00
|
|
|
PieceInfo();
|
2012-10-03 00:16:36 +02:00
|
|
|
~PieceInfo();
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-12-26 18:09:11 +01:00
|
|
|
QString GetSaveID() const;
|
|
|
|
|
2014-12-31 17:38:30 +01:00
|
|
|
lcMesh* GetMesh() const
|
|
|
|
{
|
|
|
|
return mMesh;
|
|
|
|
}
|
|
|
|
|
2015-01-17 19:29:10 +01:00
|
|
|
lcModel* GetModel() const
|
|
|
|
{
|
|
|
|
return mModel;
|
|
|
|
}
|
|
|
|
|
2014-12-31 17:38:30 +01:00
|
|
|
void SetMesh(lcMesh* Mesh)
|
|
|
|
{
|
|
|
|
mMesh = Mesh;
|
|
|
|
}
|
|
|
|
|
2015-02-22 03:39:15 +01:00
|
|
|
void AddRef()
|
2012-10-12 01:55:55 +02:00
|
|
|
{
|
|
|
|
mRefCount++;
|
|
|
|
|
2015-11-16 03:41:16 +01:00
|
|
|
if (!mLoaded)
|
2012-10-12 01:55:55 +02:00
|
|
|
Load();
|
|
|
|
}
|
|
|
|
|
2015-11-16 03:41:16 +01:00
|
|
|
void Release(bool AllowUnload)
|
2012-10-12 01:55:55 +02:00
|
|
|
{
|
|
|
|
mRefCount--;
|
|
|
|
|
2015-11-16 03:41:16 +01:00
|
|
|
if (!mRefCount && AllowUnload)
|
|
|
|
Unload();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnloadIfUnused()
|
|
|
|
{
|
|
|
|
if (!mRefCount && mLoaded)
|
2012-10-12 01:55:55 +02:00
|
|
|
Unload();
|
|
|
|
}
|
|
|
|
|
2015-01-07 17:52:42 +01:00
|
|
|
bool IsLoaded() const
|
|
|
|
{
|
2015-11-16 03:41:16 +01:00
|
|
|
return mLoaded;
|
2015-01-07 17:52:42 +01:00
|
|
|
}
|
|
|
|
|
2015-04-26 20:41:16 +02:00
|
|
|
bool IsPlaceholder() const
|
|
|
|
{
|
|
|
|
return (mFlags & LC_PIECE_PLACEHOLDER) != 0;
|
|
|
|
}
|
|
|
|
|
2015-02-22 03:39:15 +01:00
|
|
|
bool IsModel() const
|
|
|
|
{
|
|
|
|
return (mFlags & LC_PIECE_MODEL) != 0;
|
|
|
|
}
|
|
|
|
|
2015-01-07 17:52:42 +01:00
|
|
|
bool IsTemporary() const
|
|
|
|
{
|
|
|
|
return (mFlags & (LC_PIECE_PLACEHOLDER | LC_PIECE_MODEL)) != 0;
|
|
|
|
}
|
|
|
|
|
2014-05-08 00:58:59 +02:00
|
|
|
void SetZipFile(int ZipFileType, int ZipFileIndex)
|
|
|
|
{
|
|
|
|
mZipFileType = ZipFileType;
|
|
|
|
mZipFileIndex = ZipFileIndex;
|
|
|
|
}
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
bool IsPatterned() const
|
|
|
|
{
|
|
|
|
const char* Name = m_strName;
|
|
|
|
|
|
|
|
while (*Name)
|
|
|
|
{
|
|
|
|
if (*Name < '0' || *Name > '9')
|
|
|
|
break;
|
|
|
|
|
|
|
|
Name++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*Name == 'P')
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsSubPiece() const
|
|
|
|
{
|
|
|
|
return (m_strDescription[0] == '~');
|
|
|
|
}
|
|
|
|
|
2012-06-07 00:34:38 +02:00
|
|
|
lcVector3 GetCenter() const
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
2012-06-07 00:34:38 +02:00
|
|
|
return lcVector3((m_fDimensions[0] + m_fDimensions[3]) * 0.5f,
|
|
|
|
(m_fDimensions[1] + m_fDimensions[4]) * 0.5f,
|
|
|
|
(m_fDimensions[2] + m_fDimensions[5]) * 0.5f);
|
2011-09-07 23:06:51 +02:00
|
|
|
}
|
|
|
|
|
2015-01-02 12:58:14 +01:00
|
|
|
void ZoomExtents(const lcMatrix44& ProjectionMatrix, lcMatrix44& ViewMatrix, float* EyePos = NULL) const;
|
2015-02-23 01:50:37 +01:00
|
|
|
void AddRenderMesh(lcScene& Scene);
|
2014-12-24 16:52:52 +01:00
|
|
|
void AddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int ColorIndex, bool Focused, bool Selected);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2012-02-05 06:03:59 +01:00
|
|
|
void CreatePlaceholder(const char* Name);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2015-01-08 05:50:38 +01:00
|
|
|
void SetPlaceholder();
|
2015-02-23 01:50:37 +01:00
|
|
|
void SetModel(lcModel* Model, bool UpdateMesh);
|
2014-12-24 16:52:52 +01:00
|
|
|
bool IncludesModel(const lcModel* Model) const;
|
2014-12-26 16:44:46 +01:00
|
|
|
bool MinIntersectDist(const lcMatrix44& WorldMatrix, const lcVector3& WorldStart, const lcVector3& WorldEnd, float& MinDistance) const;
|
|
|
|
bool BoxTest(const lcMatrix44& WorldMatrix, const lcVector4 Planes[6]) const;
|
2014-12-30 17:30:12 +01:00
|
|
|
void GetPartsList(int DefaultColorIndex, lcArray<lcPartsListEntry>& PartsList) const;
|
|
|
|
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const;
|
2015-01-17 19:29:10 +01:00
|
|
|
void UpdateBoundingBox(lcArray<lcModel*>& UpdatedModels);
|
2014-12-24 16:52:52 +01:00
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
public:
|
|
|
|
// Attributes
|
|
|
|
char m_strName[LC_PIECE_NAME_LEN];
|
2012-09-29 02:16:43 +02:00
|
|
|
char m_strDescription[128];
|
2011-09-07 23:06:51 +02:00
|
|
|
float m_fDimensions[6];
|
2014-05-08 00:58:59 +02:00
|
|
|
int mZipFileType;
|
|
|
|
int mZipFileIndex;
|
2012-10-03 00:16:36 +02:00
|
|
|
lcuint32 mFlags;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
protected:
|
2015-11-16 03:41:16 +01:00
|
|
|
bool mLoaded;
|
2012-10-12 01:55:55 +02:00
|
|
|
int mRefCount;
|
2014-12-24 16:52:52 +01:00
|
|
|
lcModel* mModel;
|
2014-12-31 17:38:30 +01:00
|
|
|
lcMesh* mMesh;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2012-10-12 01:55:55 +02:00
|
|
|
void Load();
|
|
|
|
void Unload();
|
2011-09-07 23:06:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _PIECEINF_H_
|