2023-09-15 13:21:49 +08:00
|
|
|
#pragma once
|
|
|
|
|
2024-08-17 20:43:27 +08:00
|
|
|
#include "../../VTInternal.hpp"
|
2023-09-15 13:21:49 +08:00
|
|
|
#include "CKBeObject.hpp"
|
|
|
|
|
|
|
|
namespace LibCmo::CK2::ObjImpls {
|
|
|
|
|
|
|
|
class CKMesh : public CKBeObject {
|
2023-10-01 23:48:55 +08:00
|
|
|
protected:
|
|
|
|
enum class VertexSaveFlags : CKDWORD {
|
|
|
|
None = 0,
|
|
|
|
SingleColor = 0x1u, /**< if not set, the VertexColor is a list, otherwise a single global CKDWORD.*/
|
|
|
|
SingleSpecularColor = 0x2u, /**< if not set, the VertexSpecularColor is a list, otherwise a single global CKDWORD. */
|
|
|
|
NoNormal = 0x4u, /**< if set, there are no normal data for vertex. */
|
|
|
|
SingleUV = 0x8u, /**< if not set, the VertexUV is a list, otherwise a single global VxVertex2. */
|
|
|
|
NoPos = 0x10u, /**< if set, there are no position data for vertex. */
|
|
|
|
};
|
|
|
|
|
2023-09-15 13:21:49 +08:00
|
|
|
public:
|
|
|
|
CKMesh(CKContext* ctx, CK_ID ckid, CKSTRING name);
|
|
|
|
virtual ~CKMesh();
|
2024-08-17 20:43:27 +08:00
|
|
|
YYCC_DEL_CLS_COPY_MOVE(CKMesh);
|
2023-09-15 13:21:49 +08:00
|
|
|
|
|
|
|
virtual CK_CLASSID GetClassID(void) override {
|
|
|
|
return CK_CLASSID::CKCID_MESH;
|
|
|
|
}
|
|
|
|
|
2023-09-20 15:25:43 +08:00
|
|
|
virtual void CheckPreDeletion() override;
|
|
|
|
|
|
|
|
// 2 RW functions
|
2023-09-15 13:21:49 +08:00
|
|
|
virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) override;
|
|
|
|
virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file) override;
|
2023-09-20 13:13:08 +08:00
|
|
|
|
|
|
|
// it only have special Show method
|
|
|
|
virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW) override;
|
|
|
|
|
2023-09-15 16:15:07 +08:00
|
|
|
// ===== Misc Section =====
|
|
|
|
public:
|
|
|
|
void CleanMesh();
|
2023-09-22 16:40:10 +08:00
|
|
|
VxMath::VXMESH_FLAGS GetMeshFlags() const;
|
2023-11-15 21:47:58 +08:00
|
|
|
void SetMeshFlags(VxMath::VXMESH_FLAGS flags);
|
|
|
|
VxMath::VXMESH_LITMODE GetLitMode() const;
|
|
|
|
void SetLitMode(VxMath::VXMESH_LITMODE mode);
|
|
|
|
VxMath::VXTEXTURE_WRAPMODE GetWrapMode() const;
|
|
|
|
void SetWrapMode(VxMath::VXTEXTURE_WRAPMODE mode);
|
2023-09-15 17:03:36 +08:00
|
|
|
protected:
|
2023-10-01 23:48:55 +08:00
|
|
|
VertexSaveFlags GenerateSaveFlags();
|
2023-09-15 17:03:36 +08:00
|
|
|
void BuildNormals();
|
|
|
|
void BuildFaceNormals();
|
2023-09-15 16:15:07 +08:00
|
|
|
|
2023-09-20 14:42:44 +08:00
|
|
|
// ===== Vertex Section =====
|
2023-09-15 16:15:07 +08:00
|
|
|
public:
|
2023-09-22 14:48:45 +08:00
|
|
|
CKDWORD GetVertexCount() const;
|
2023-09-15 16:15:07 +08:00
|
|
|
void SetVertexCount(CKDWORD count);
|
|
|
|
VxMath::VxVector3* GetVertexPositions();
|
|
|
|
VxMath::VxVector3* GetVertexNormals();
|
|
|
|
VxMath::VxVector2* GetVertexUVs();
|
|
|
|
CKDWORD* GetVertexColors();
|
|
|
|
CKDWORD* GetVertexSpecularColors();
|
|
|
|
|
|
|
|
// ===== Material Slot Section =====
|
|
|
|
public:
|
2023-09-22 14:48:45 +08:00
|
|
|
CKDWORD GetMaterialSlotCount() const;
|
2023-09-15 16:15:07 +08:00
|
|
|
void SetMaterialSlotCount(CKDWORD count);
|
2023-09-22 14:48:45 +08:00
|
|
|
CKMaterial** GetMaterialSlots();
|
2023-09-15 16:15:07 +08:00
|
|
|
|
|
|
|
// ===== Face Section =====
|
|
|
|
public:
|
2023-09-22 14:48:45 +08:00
|
|
|
CKDWORD GetFaceCount() const;
|
2023-09-15 16:15:07 +08:00
|
|
|
void SetFaceCount(CKDWORD count);
|
|
|
|
CKWORD* GetFaceIndices();
|
|
|
|
CKWORD* GetFaceMaterialSlotIndexs();
|
|
|
|
VxMath::VxVector3* GetFaceNormals(CKDWORD& stride);
|
|
|
|
|
|
|
|
// ===== Line Section =====
|
|
|
|
public:
|
2023-09-22 14:48:45 +08:00
|
|
|
CKDWORD GetLineCount() const;
|
2023-09-15 16:15:07 +08:00
|
|
|
void SetLineCount(CKDWORD count);
|
|
|
|
CKWORD* GetLineIndices();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
struct FaceData_t {
|
|
|
|
FaceData_t() :
|
2023-10-01 23:48:55 +08:00
|
|
|
m_Normal()
|
2023-09-15 16:15:07 +08:00
|
|
|
{}
|
|
|
|
VxMath::VxVector3 m_Normal;
|
|
|
|
};
|
|
|
|
VxMath::VXMESH_FLAGS m_Flags;
|
|
|
|
CKDWORD m_VertexCount;
|
|
|
|
CKDWORD m_LineCount;
|
2023-10-08 20:56:29 +08:00
|
|
|
CKDWORD m_MaterialSlotCount;
|
2023-09-15 16:15:07 +08:00
|
|
|
CKDWORD m_FaceCount;
|
|
|
|
|
|
|
|
XContainer::XArray<VxMath::VxVector3> m_VertexPosition;
|
|
|
|
XContainer::XArray<VxMath::VxVector3> m_VertexNormal;
|
|
|
|
XContainer::XArray<VxMath::VxVector2> m_VertexUV;
|
|
|
|
XContainer::XArray<CKDWORD> m_VertexColor;
|
|
|
|
XContainer::XArray<CKDWORD> m_VertexSpecularColor;
|
|
|
|
|
|
|
|
XContainer::XArray<CKMaterial*> m_MaterialSlot;
|
|
|
|
|
|
|
|
XContainer::XArray<CKWORD> m_FaceIndices;
|
|
|
|
XContainer::XArray<CKWORD> m_FaceMtlIndex;
|
2023-10-01 23:48:55 +08:00
|
|
|
XContainer::XArray<FaceData_t> m_FaceOthers;
|
2023-09-15 16:15:07 +08:00
|
|
|
|
|
|
|
XContainer::XArray<CKWORD> m_LineIndices;
|
2023-09-15 13:21:49 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|