2017-07-19 23:20:32 +02:00
|
|
|
#pragma once
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2012-06-07 02:08:59 +02:00
|
|
|
#include "lc_math.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2019-07-21 18:26:36 +02:00
|
|
|
enum class lcPieceInfoType
|
|
|
|
{
|
|
|
|
Part,
|
|
|
|
Placeholder,
|
|
|
|
Model,
|
|
|
|
Project
|
|
|
|
};
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
#define LC_PIECE_NAME_LEN 256
|
|
|
|
|
2021-11-15 03:34:24 +01:00
|
|
|
enum class lcPieceInfoState
|
2017-01-23 04:28:05 +01:00
|
|
|
{
|
2021-11-15 03:34:24 +01:00
|
|
|
Unloaded,
|
|
|
|
Loading,
|
|
|
|
Loaded
|
2017-01-23 04:28:05 +01:00
|
|
|
};
|
|
|
|
|
2019-05-26 20:08:47 +02:00
|
|
|
struct lcModelPartsEntry
|
|
|
|
{
|
|
|
|
lcMatrix44 WorldMatrix;
|
2019-05-28 01:39:51 +02:00
|
|
|
const PieceInfo* Info;
|
2019-05-26 20:08:47 +02:00
|
|
|
lcMesh* Mesh;
|
|
|
|
int ColorIndex;
|
|
|
|
};
|
|
|
|
|
2016-03-04 04:18:23 +01:00
|
|
|
class lcSynthInfo;
|
2021-01-18 21:09:33 +01:00
|
|
|
enum class lcZipFileType;
|
2016-02-29 21:13:54 +01:00
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
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
|
|
|
|
2020-05-04 00:39:39 +02:00
|
|
|
PieceInfo(const PieceInfo&) = delete;
|
|
|
|
PieceInfo(PieceInfo&&) = delete;
|
|
|
|
PieceInfo& operator=(const PieceInfo&) = delete;
|
|
|
|
PieceInfo& operator=(PieceInfo&&) = delete;
|
|
|
|
|
2016-02-19 18:53:54 +01:00
|
|
|
const lcBoundingBox& GetBoundingBox() const
|
|
|
|
{
|
|
|
|
return mBoundingBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBoundingBox(const lcVector3& Min, const lcVector3& Max)
|
|
|
|
{
|
|
|
|
mBoundingBox.Min = Min;
|
|
|
|
mBoundingBox.Max = Max;
|
|
|
|
}
|
|
|
|
|
2016-02-29 21:13:54 +01:00
|
|
|
lcSynthInfo* GetSynthInfo() const
|
|
|
|
{
|
|
|
|
return mSynthInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSynthInfo(lcSynthInfo* SynthInfo)
|
|
|
|
{
|
|
|
|
mSynthInfo = SynthInfo;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-06 19:15:24 +01:00
|
|
|
Project* GetProject() const
|
|
|
|
{
|
|
|
|
return mProject;
|
|
|
|
}
|
|
|
|
|
2017-01-23 04:28:05 +01:00
|
|
|
void SetMesh(lcMesh* Mesh);
|
2014-12-31 17:38:30 +01:00
|
|
|
|
2017-01-23 04:28:05 +01:00
|
|
|
int AddRef()
|
2012-10-12 01:55:55 +02:00
|
|
|
{
|
|
|
|
mRefCount++;
|
2017-01-23 04:28:05 +01:00
|
|
|
return mRefCount;
|
2012-10-12 01:55:55 +02:00
|
|
|
}
|
|
|
|
|
2017-01-23 04:28:05 +01:00
|
|
|
int Release()
|
2012-10-12 01:55:55 +02:00
|
|
|
{
|
|
|
|
mRefCount--;
|
2017-01-23 04:28:05 +01:00
|
|
|
return mRefCount;
|
2012-10-12 01:55:55 +02:00
|
|
|
}
|
|
|
|
|
2017-01-23 04:28:05 +01:00
|
|
|
int GetRefCount() const
|
2015-01-07 17:52:42 +01:00
|
|
|
{
|
2017-01-23 04:28:05 +01:00
|
|
|
return mRefCount;
|
2015-01-07 17:52:42 +01:00
|
|
|
}
|
|
|
|
|
2015-04-26 20:41:16 +02:00
|
|
|
bool IsPlaceholder() const
|
|
|
|
{
|
2019-07-21 18:26:36 +02:00
|
|
|
return mType == lcPieceInfoType::Placeholder;
|
2015-04-26 20:41:16 +02:00
|
|
|
}
|
|
|
|
|
2015-02-22 03:39:15 +01:00
|
|
|
bool IsModel() const
|
|
|
|
{
|
2019-07-21 18:26:36 +02:00
|
|
|
return mType == lcPieceInfoType::Model;
|
2015-02-22 03:39:15 +01:00
|
|
|
}
|
|
|
|
|
2016-11-26 02:12:19 +01:00
|
|
|
bool IsProject() const
|
|
|
|
{
|
2019-07-21 18:26:36 +02:00
|
|
|
return mType == lcPieceInfoType::Project;
|
2016-11-26 02:12:19 +01:00
|
|
|
}
|
|
|
|
|
2015-01-07 17:52:42 +01:00
|
|
|
bool IsTemporary() const
|
|
|
|
{
|
2019-07-21 18:26:36 +02:00
|
|
|
return mType != lcPieceInfoType::Part;
|
2015-01-07 17:52:42 +01:00
|
|
|
}
|
|
|
|
|
2021-01-18 21:09:33 +01:00
|
|
|
void SetZipFile(lcZipFileType ZipFileType, int ZipFileIndex)
|
2014-05-08 00:58:59 +02:00
|
|
|
{
|
|
|
|
mZipFileType = ZipFileType;
|
|
|
|
mZipFileIndex = ZipFileIndex;
|
|
|
|
}
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
bool IsPatterned() const
|
|
|
|
{
|
2020-03-14 19:24:56 +01:00
|
|
|
if (mType != lcPieceInfoType::Part)
|
|
|
|
return false;
|
|
|
|
|
2017-07-27 18:21:55 +02:00
|
|
|
const char* Name = mFileName;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2020-10-17 19:32:22 +02:00
|
|
|
// Heuristic: Names matching '^[Uu]?[0-9]*[A-Za-z][^.][^.]' are patterned.
|
|
|
|
|
|
|
|
if (*Name == 'U' || *Name == 'u')
|
|
|
|
Name++;
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
while (*Name)
|
|
|
|
{
|
|
|
|
if (*Name < '0' || *Name > '9')
|
|
|
|
break;
|
|
|
|
|
|
|
|
Name++;
|
|
|
|
}
|
|
|
|
|
2020-10-17 19:32:22 +02:00
|
|
|
if (!*Name || !((*Name >= 'A' && *Name <= 'Z') || (*Name >= 'a' && *Name <= 'z')))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (Name[1] && Name[1] != '.' && Name[2] && Name[2] != '.')
|
2011-09-07 23:06:51 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsSubPiece() const
|
|
|
|
{
|
|
|
|
return (m_strDescription[0] == '~');
|
|
|
|
}
|
|
|
|
|
2022-07-06 16:23:31 +02:00
|
|
|
bool IsProjectPiece() const;
|
2017-12-21 23:02:16 +01:00
|
|
|
void ZoomExtents(float FoV, float AspectRatio, lcMatrix44& ProjectionMatrix, lcMatrix44& ViewMatrix) const;
|
2015-02-23 01:50:37 +01:00
|
|
|
void AddRenderMesh(lcScene& Scene);
|
2020-12-05 20:02:10 +01:00
|
|
|
void AddRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const;
|
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();
|
2017-07-02 02:12:09 +02:00
|
|
|
void SetModel(lcModel* Model, bool UpdateMesh, Project* CurrentProject, bool SearchProjectFolder);
|
2017-07-27 18:21:55 +02:00
|
|
|
void CreateProject(Project* Project, const char* PieceName);
|
2018-03-29 19:20:36 +02:00
|
|
|
bool GetPieceWorldMatrix(lcPiece* Piece, lcMatrix44& WorldMatrix) const;
|
2014-12-24 16:52:52 +01:00
|
|
|
bool IncludesModel(const lcModel* Model) const;
|
2021-12-25 00:42:37 +01:00
|
|
|
bool MinIntersectDist(const lcVector3& Start, const lcVector3& End, float& MinDistance, lcPieceInfoRayTest& PieceInfoRayTest) const;
|
2014-12-26 16:44:46 +01:00
|
|
|
bool BoxTest(const lcMatrix44& WorldMatrix, const lcVector4 Planes[6]) const;
|
2020-01-11 21:45:36 +01:00
|
|
|
void GetPartsList(int DefaultColorIndex, bool ScanSubModels, bool AddSubModels, lcPartsList& PartsList) const;
|
2019-05-28 01:39:51 +02:00
|
|
|
void GetModelParts(const lcMatrix44& WorldMatrix, int DefaultColorIndex, std::vector<lcModelPartsEntry>& ModelParts) const;
|
2020-04-11 20:04:27 +02:00
|
|
|
void CompareBoundingBox(const lcMatrix44& WorldMatrix, lcVector3& Min, lcVector3& Max) const;
|
2020-12-31 19:22:12 +01:00
|
|
|
void AddSubModelBoundingBoxPoints(const lcMatrix44& WorldMatrix, std::vector<lcVector3>& Points) const;
|
2019-03-17 21:27:57 +01:00
|
|
|
void UpdateBoundingBox(std::vector<lcModel*>& UpdatedModels);
|
2014-12-24 16:52:52 +01:00
|
|
|
|
2017-01-23 04:28:05 +01:00
|
|
|
void Load();
|
|
|
|
void Unload();
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
public:
|
2017-07-27 18:21:55 +02:00
|
|
|
char mFileName[LC_PIECE_NAME_LEN];
|
2024-06-02 02:18:47 +02:00
|
|
|
char m_strDescription[256];
|
2021-01-18 21:09:33 +01:00
|
|
|
lcZipFileType mZipFileType;
|
2014-05-08 00:58:59 +02:00
|
|
|
int mZipFileIndex;
|
2017-01-23 04:28:05 +01:00
|
|
|
lcPieceInfoState mState;
|
2017-11-27 04:21:54 +01:00
|
|
|
int mFolderType;
|
|
|
|
int mFolderIndex;
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
protected:
|
2017-07-02 02:12:09 +02:00
|
|
|
void ReleaseMesh();
|
|
|
|
|
2012-10-12 01:55:55 +02:00
|
|
|
int mRefCount;
|
2019-07-21 18:26:36 +02:00
|
|
|
lcPieceInfoType mType;
|
2014-12-24 16:52:52 +01:00
|
|
|
lcModel* mModel;
|
2016-11-26 02:12:19 +01:00
|
|
|
Project* mProject;
|
2014-12-31 17:38:30 +01:00
|
|
|
lcMesh* mMesh;
|
2016-02-19 18:53:54 +01:00
|
|
|
lcBoundingBox mBoundingBox;
|
2016-02-29 21:13:54 +01:00
|
|
|
lcSynthInfo* mSynthInfo;
|
2011-09-07 23:06:51 +02:00
|
|
|
};
|
|
|
|
|