2017-07-19 14:20:32 -07:00
|
|
|
#pragma once
|
2011-09-07 21:06:51 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2012-06-07 00:08:59 +00:00
|
|
|
#include "lc_math.h"
|
2014-04-23 14:53:43 +00:00
|
|
|
#include "lc_array.h"
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2012-10-02 22:16:36 +00: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 04:05:52 +00:00
|
|
|
#define LC_PIECE_PLACEHOLDER 0x10 // Placeholder for a piece not in the library
|
2015-07-22 04:00:47 +00:00
|
|
|
#define LC_PIECE_MODEL 0x20 // Piece is a model
|
2016-11-25 17:12:19 -08:00
|
|
|
#define LC_PIECE_PROJECT 0x40 // Piece is a project
|
2017-03-22 23:35:02 -07:00
|
|
|
#define LC_PIECE_HAS_TEXTURE 0x80 // Piece has sections using textures
|
2011-09-07 21:06:51 +00:00
|
|
|
|
|
|
|
#define LC_PIECE_NAME_LEN 256
|
|
|
|
|
2017-01-22 19:28:05 -08:00
|
|
|
enum lcPieceInfoState
|
|
|
|
{
|
|
|
|
LC_PIECEINFO_UNLOADED,
|
|
|
|
LC_PIECEINFO_LOADING,
|
|
|
|
LC_PIECEINFO_LOADED
|
|
|
|
};
|
|
|
|
|
2016-03-04 03:18:23 +00:00
|
|
|
class lcSynthInfo;
|
2016-02-29 20:13:54 +00:00
|
|
|
|
2011-09-07 21:06:51 +00:00
|
|
|
class PieceInfo
|
|
|
|
{
|
2012-10-02 22:16:36 +00:00
|
|
|
public:
|
2014-05-07 22:58:59 +00:00
|
|
|
PieceInfo();
|
2012-10-02 22:16:36 +00:00
|
|
|
~PieceInfo();
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2016-02-19 17:53:54 +00:00
|
|
|
const lcBoundingBox& GetBoundingBox() const
|
|
|
|
{
|
|
|
|
return mBoundingBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBoundingBox(const lcVector3& Min, const lcVector3& Max)
|
|
|
|
{
|
|
|
|
mBoundingBox.Min = Min;
|
|
|
|
mBoundingBox.Max = Max;
|
|
|
|
}
|
|
|
|
|
2016-02-29 20:13:54 +00:00
|
|
|
lcSynthInfo* GetSynthInfo() const
|
|
|
|
{
|
|
|
|
return mSynthInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSynthInfo(lcSynthInfo* SynthInfo)
|
|
|
|
{
|
|
|
|
mSynthInfo = SynthInfo;
|
|
|
|
}
|
|
|
|
|
2014-12-31 16:38:30 +00:00
|
|
|
lcMesh* GetMesh() const
|
|
|
|
{
|
|
|
|
return mMesh;
|
|
|
|
}
|
|
|
|
|
2015-01-17 18:29:10 +00:00
|
|
|
lcModel* GetModel() const
|
|
|
|
{
|
|
|
|
return mModel;
|
|
|
|
}
|
|
|
|
|
2018-01-06 10:15:24 -08:00
|
|
|
Project* GetProject() const
|
|
|
|
{
|
|
|
|
return mProject;
|
|
|
|
}
|
|
|
|
|
2017-01-22 19:28:05 -08:00
|
|
|
void SetMesh(lcMesh* Mesh);
|
2014-12-31 16:38:30 +00:00
|
|
|
|
2017-01-22 19:28:05 -08:00
|
|
|
int AddRef()
|
2012-10-11 23:55:55 +00:00
|
|
|
{
|
|
|
|
mRefCount++;
|
2017-01-22 19:28:05 -08:00
|
|
|
return mRefCount;
|
2012-10-11 23:55:55 +00:00
|
|
|
}
|
|
|
|
|
2017-01-22 19:28:05 -08:00
|
|
|
int Release()
|
2012-10-11 23:55:55 +00:00
|
|
|
{
|
|
|
|
mRefCount--;
|
2017-01-22 19:28:05 -08:00
|
|
|
return mRefCount;
|
2012-10-11 23:55:55 +00:00
|
|
|
}
|
|
|
|
|
2017-01-22 19:28:05 -08:00
|
|
|
int GetRefCount() const
|
2015-01-07 16:52:42 +00:00
|
|
|
{
|
2017-01-22 19:28:05 -08:00
|
|
|
return mRefCount;
|
2015-01-07 16:52:42 +00:00
|
|
|
}
|
|
|
|
|
2015-04-26 18:41:16 +00:00
|
|
|
bool IsPlaceholder() const
|
|
|
|
{
|
|
|
|
return (mFlags & LC_PIECE_PLACEHOLDER) != 0;
|
|
|
|
}
|
|
|
|
|
2015-02-22 02:39:15 +00:00
|
|
|
bool IsModel() const
|
|
|
|
{
|
|
|
|
return (mFlags & LC_PIECE_MODEL) != 0;
|
|
|
|
}
|
|
|
|
|
2016-11-25 17:12:19 -08:00
|
|
|
bool IsProject() const
|
|
|
|
{
|
|
|
|
return (mFlags & LC_PIECE_PROJECT) != 0;
|
|
|
|
}
|
|
|
|
|
2015-01-07 16:52:42 +00:00
|
|
|
bool IsTemporary() const
|
|
|
|
{
|
2016-11-25 17:12:19 -08:00
|
|
|
return (mFlags & (LC_PIECE_PLACEHOLDER | LC_PIECE_MODEL | LC_PIECE_PROJECT)) != 0;
|
2015-01-07 16:52:42 +00:00
|
|
|
}
|
|
|
|
|
2014-05-07 22:58:59 +00:00
|
|
|
void SetZipFile(int ZipFileType, int ZipFileIndex)
|
|
|
|
{
|
|
|
|
mZipFileType = ZipFileType;
|
|
|
|
mZipFileIndex = ZipFileIndex;
|
|
|
|
}
|
|
|
|
|
2011-09-07 21:06:51 +00:00
|
|
|
bool IsPatterned() const
|
|
|
|
{
|
2017-07-27 09:21:55 -07:00
|
|
|
const char* Name = mFileName;
|
2011-09-07 21:06:51 +00:00
|
|
|
|
|
|
|
while (*Name)
|
|
|
|
{
|
|
|
|
if (*Name < '0' || *Name > '9')
|
|
|
|
break;
|
|
|
|
|
|
|
|
Name++;
|
|
|
|
}
|
|
|
|
|
2017-07-27 09:21:55 -07:00
|
|
|
if (*Name == 'P' || *Name == 'p')
|
2011-09-07 21:06:51 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsSubPiece() const
|
|
|
|
{
|
|
|
|
return (m_strDescription[0] == '~');
|
|
|
|
}
|
|
|
|
|
2017-12-21 14:02:16 -08:00
|
|
|
void ZoomExtents(float FoV, float AspectRatio, lcMatrix44& ProjectionMatrix, lcMatrix44& ViewMatrix) const;
|
2015-02-23 00:50:37 +00:00
|
|
|
void AddRenderMesh(lcScene& Scene);
|
2018-04-07 11:45:00 -07:00
|
|
|
void AddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2012-02-05 05:03:59 +00:00
|
|
|
void CreatePlaceholder(const char* Name);
|
2011-09-07 21:06:51 +00:00
|
|
|
|
2015-01-08 04:50:38 +00:00
|
|
|
void SetPlaceholder();
|
2017-07-01 17:12:09 -07:00
|
|
|
void SetModel(lcModel* Model, bool UpdateMesh, Project* CurrentProject, bool SearchProjectFolder);
|
2017-07-27 09:21:55 -07:00
|
|
|
void CreateProject(Project* Project, const char* PieceName);
|
2018-03-29 10:20:36 -07:00
|
|
|
bool GetPieceWorldMatrix(lcPiece* Piece, lcMatrix44& WorldMatrix) const;
|
2014-12-24 15:52:52 +00:00
|
|
|
bool IncludesModel(const lcModel* Model) const;
|
2016-02-29 20:13:54 +00:00
|
|
|
bool MinIntersectDist(const lcVector3& Start, const lcVector3& End, float& MinDistance) const;
|
2014-12-26 15:44:46 +00:00
|
|
|
bool BoxTest(const lcMatrix44& WorldMatrix, const lcVector4 Planes[6]) const;
|
2017-11-19 14:12:27 -08:00
|
|
|
void GetPartsList(int DefaultColorIndex, bool IncludeSubmodels, lcPartsList& PartsList) const;
|
2014-12-30 16:30:12 +00:00
|
|
|
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcArray<lcModelPartsEntry>& ModelParts) const;
|
2015-01-17 18:29:10 +00:00
|
|
|
void UpdateBoundingBox(lcArray<lcModel*>& UpdatedModels);
|
2014-12-24 15:52:52 +00:00
|
|
|
|
2017-01-22 19:28:05 -08:00
|
|
|
void Load();
|
|
|
|
void Unload();
|
|
|
|
|
2011-09-07 21:06:51 +00:00
|
|
|
public:
|
2017-07-27 09:21:55 -07:00
|
|
|
char mFileName[LC_PIECE_NAME_LEN];
|
2012-09-29 00:16:43 +00:00
|
|
|
char m_strDescription[128];
|
2014-05-07 22:58:59 +00:00
|
|
|
int mZipFileType;
|
|
|
|
int mZipFileIndex;
|
2017-12-02 12:22:04 -08:00
|
|
|
quint32 mFlags;
|
2017-01-22 19:28:05 -08:00
|
|
|
lcPieceInfoState mState;
|
2017-11-26 19:21:54 -08:00
|
|
|
int mFolderType;
|
|
|
|
int mFolderIndex;
|
2011-09-07 21:06:51 +00:00
|
|
|
|
|
|
|
protected:
|
2017-07-01 17:12:09 -07:00
|
|
|
void ReleaseMesh();
|
|
|
|
|
2012-10-11 23:55:55 +00:00
|
|
|
int mRefCount;
|
2014-12-24 15:52:52 +00:00
|
|
|
lcModel* mModel;
|
2016-11-25 17:12:19 -08:00
|
|
|
Project* mProject;
|
2014-12-31 16:38:30 +00:00
|
|
|
lcMesh* mMesh;
|
2016-02-19 17:53:54 +00:00
|
|
|
lcBoundingBox mBoundingBox;
|
2016-02-29 20:13:54 +00:00
|
|
|
lcSynthInfo* mSynthInfo;
|
2011-09-07 21:06:51 +00:00
|
|
|
};
|
|
|
|
|