From d37a552873d6e6eeab7b0ac6abfb9e8f1a85880d Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Fri, 22 Sep 2023 16:40:10 +0800 Subject: [PATCH] write some printer for ck class --- LibCmo/CK2/CKTypes.hpp | 5 + LibCmo/CK2/ObjImpls/CKBeObject.cpp | 2 +- LibCmo/CK2/ObjImpls/CKBeObject.hpp | 10 +- LibCmo/CK2/ObjImpls/CKGroup.cpp | 6 +- LibCmo/CK2/ObjImpls/CKGroup.hpp | 6 +- LibCmo/CK2/ObjImpls/CKMesh.cpp | 4 + LibCmo/CK2/ObjImpls/CKMesh.hpp | 1 + Unvirt/AccessibleValue.cpp | 230 ++++++++++++++++++++++++++++- Unvirt/AccessibleValue.hpp | 42 +++++- Unvirt/StringHelper.cpp | 4 +- Unvirt/StructFormatter.cpp | 164 ++++++++++++++++++-- 11 files changed, 440 insertions(+), 34 deletions(-) diff --git a/LibCmo/CK2/CKTypes.hpp b/LibCmo/CK2/CKTypes.hpp index b1e4d03..03e458c 100644 --- a/LibCmo/CK2/CKTypes.hpp +++ b/LibCmo/CK2/CKTypes.hpp @@ -106,6 +106,11 @@ namespace LibCmo { #define PRIiCKINT PRIi32 +#define PRIfCKFLOAT "f" +#define PRIfCKDOUBLE "lf" +#define PRIeCKFLOAT "e" +#define PRIeCKDOUBLE "le" + #define PRIxCKPTR PRIx32 #define PRIXCKPTR PRIX32 diff --git a/LibCmo/CK2/ObjImpls/CKBeObject.cpp b/LibCmo/CK2/ObjImpls/CKBeObject.cpp index a4d1e35..dbde0bd 100644 --- a/LibCmo/CK2/ObjImpls/CKBeObject.cpp +++ b/LibCmo/CK2/ObjImpls/CKBeObject.cpp @@ -26,7 +26,7 @@ namespace LibCmo::CK2::ObjImpls { return true; } - bool CKBeObject::IsInGroup(CKGroup* group) { + bool CKBeObject::IsInGroup(CKGroup* group) const { if (group == nullptr) return false; CKDWORD idx = group->GetGroupIndex(); return XContainer::NSXBitArray::IsSet(m_Groups, idx); diff --git a/LibCmo/CK2/ObjImpls/CKBeObject.hpp b/LibCmo/CK2/ObjImpls/CKBeObject.hpp index 674803c..317f72a 100644 --- a/LibCmo/CK2/ObjImpls/CKBeObject.hpp +++ b/LibCmo/CK2/ObjImpls/CKBeObject.hpp @@ -14,12 +14,16 @@ namespace LibCmo::CK2::ObjImpls { virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEOBJECT; } - //virtual void PreSave(CKFileVisitor* file, CKDWORD flags) override; + virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) override; virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file) override; - //virtual void PostLoad() override; - bool IsInGroup(CKGroup* group); + /** + * @brief Check whether this object is in specified group. + * @param group[in] The group to be checked. + * @return True if in it. + */ + bool IsInGroup(CKGroup* group) const; /** * @brief Directly set group data. * @param pos diff --git a/LibCmo/CK2/ObjImpls/CKGroup.cpp b/LibCmo/CK2/ObjImpls/CKGroup.cpp index 745921f..be4016e 100644 --- a/LibCmo/CK2/ObjImpls/CKGroup.cpp +++ b/LibCmo/CK2/ObjImpls/CKGroup.cpp @@ -82,7 +82,7 @@ namespace LibCmo::CK2::ObjImpls { } } - CKDWORD CKGroup::GetGroupIndex() { + CKDWORD CKGroup::GetGroupIndex() const { return m_GroupIndex; } @@ -134,12 +134,12 @@ namespace LibCmo::CK2::ObjImpls { m_ObjectArray.clear(); } - CKBeObject* CKGroup::GetObject(CKDWORD pos) { + CKBeObject* CKGroup::GetObject(CKDWORD pos) const { if (pos >= m_ObjectArray.size()) return nullptr; else return static_cast(m_ObjectArray[pos]); } - CKDWORD CKGroup::GetObjectCount() { + CKDWORD CKGroup::GetObjectCount() const { return static_cast(m_ObjectArray.size()); } diff --git a/LibCmo/CK2/ObjImpls/CKGroup.hpp b/LibCmo/CK2/ObjImpls/CKGroup.hpp index f82e8ee..30363d4 100644 --- a/LibCmo/CK2/ObjImpls/CKGroup.hpp +++ b/LibCmo/CK2/ObjImpls/CKGroup.hpp @@ -26,7 +26,7 @@ namespace LibCmo::CK2::ObjImpls { // it only have special Show method virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW) override; - CKDWORD GetGroupIndex(); + CKDWORD GetGroupIndex() const; // ===== Insert ===== CKERROR AddObject(CKBeObject *o); @@ -37,8 +37,8 @@ namespace LibCmo::CK2::ObjImpls { void Clear(); // ===== Access ===== - CKBeObject* GetObject(CKDWORD pos); - CKDWORD GetObjectCount(); + CKBeObject* GetObject(CKDWORD pos) const; + CKDWORD GetObjectCount() const; protected: XContainer::XObjectPointerArray m_ObjectArray; diff --git a/LibCmo/CK2/ObjImpls/CKMesh.cpp b/LibCmo/CK2/ObjImpls/CKMesh.cpp index cb52eaa..862596e 100644 --- a/LibCmo/CK2/ObjImpls/CKMesh.cpp +++ b/LibCmo/CK2/ObjImpls/CKMesh.cpp @@ -381,6 +381,10 @@ namespace LibCmo::CK2::ObjImpls { SetLineCount(0); } + VxMath::VXMESH_FLAGS CKMesh::GetMeshFlags() const { + return m_Flags; + } + void CKMesh::BuildNormals() { if (m_FaceCount == 0 || m_VertexCount == 0) return; diff --git a/LibCmo/CK2/ObjImpls/CKMesh.hpp b/LibCmo/CK2/ObjImpls/CKMesh.hpp index eb2213c..06df00c 100644 --- a/LibCmo/CK2/ObjImpls/CKMesh.hpp +++ b/LibCmo/CK2/ObjImpls/CKMesh.hpp @@ -27,6 +27,7 @@ namespace LibCmo::CK2::ObjImpls { // ===== Misc Section ===== public: void CleanMesh(); + VxMath::VXMESH_FLAGS GetMeshFlags() const; protected: void BuildNormals(); void BuildFaceNormals(); diff --git a/Unvirt/AccessibleValue.cpp b/Unvirt/AccessibleValue.cpp index 9461376..e53e360 100644 --- a/Unvirt/AccessibleValue.cpp +++ b/Unvirt/AccessibleValue.cpp @@ -1,5 +1,4 @@ #include "AccessibleValue.hpp" -#include "StringHelper.hpp" #include #include @@ -279,7 +278,236 @@ namespace Unvirt::AccessibleValue { { LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION3, {"CHUNK_VERSION3"} }, { LibCmo::CK2::CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION4, {"CHUNK_VERSION4"} }, }; + const GeneralReflectionArray CK_OBJECT_FLAGS { + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_INTERFACEOBJ, {"CK_OBJECT_INTERFACEOBJ"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_PRIVATE, {"CK_OBJECT_PRIVATE"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_INTERFACEMARK, {"CK_OBJECT_INTERFACEMARK"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_FREEID, {"CK_OBJECT_FREEID"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_TOBEDELETED, {"CK_OBJECT_TOBEDELETED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NOTTOBESAVED, {"CK_OBJECT_NOTTOBESAVED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE, {"CK_OBJECT_VISIBLE"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NAMESHARED, {"CK_OBJECT_NAMESHARED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_DYNAMIC, {"CK_OBJECT_DYNAMIC"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE, {"CK_OBJECT_HIERACHICALHIDE"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_UPTODATE, {"CK_OBJECT_UPTODATE"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_TEMPMARKER, {"CK_OBJECT_TEMPMARKER"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_ONLYFORFILEREFERENCE, {"CK_OBJECT_ONLYFORFILEREFERENCE"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NOTTOBEDELETED, {"CK_OBJECT_NOTTOBEDELETED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_APPDATA, {"CK_OBJECT_APPDATA"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_SINGLEACTIVITY, {"CK_OBJECT_SINGLEACTIVITY"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_LOADSKIPBEOBJECT, {"CK_OBJECT_LOADSKIPBEOBJECT"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_NOTTOBELISTEDANDSAVED, {"CK_OBJECT_NOTTOBELISTEDANDSAVED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETEROUT_SETTINGS, {"CK_PARAMETEROUT_SETTINGS"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETEROUT_PARAMOP, {"CK_PARAMETEROUT_PARAMOP"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED, {"CK_PARAMETERIN_DISABLED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETERIN_THIS, {"CK_PARAMETERIN_THIS"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETERIN_SHARED, {"CK_PARAMETERIN_SHARED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_PARAMETEROUT_DELETEAFTERUSE, {"CK_PARAMETEROUT_DELETEAFTERUSE"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_PARAMMASK, {"CK_OBJECT_PARAMMASK"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_BEHAVIORIO_IN, {"CK_BEHAVIORIO_IN"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_BEHAVIORIO_OUT, {"CK_BEHAVIORIO_OUT"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_BEHAVIORIO_ACTIVE, {"CK_BEHAVIORIO_ACTIVE"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_IOTYPEMASK, {"CK_OBJECT_IOTYPEMASK"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_IOMASK, {"CK_OBJECT_IOMASK"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CKBEHAVIORLINK_RESERVED, {"CKBEHAVIORLINK_RESERVED"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CKBEHAVIORLINK_ACTIVATEDLASTFRAME, {"CKBEHAVIORLINK_ACTIVATEDLASTFRAME"} }, + { LibCmo::CK2::CK_OBJECT_FLAGS::CK_OBJECT_BEHAVIORLINKMASK, {"CK_OBJECT_BEHAVIORLINKMASK"} }, + }; + const GeneralReflectionArray CK_3DENTITY_FLAGS { + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_DUMMY, {"CK_3DENTITY_DUMMY"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_FRAME, {"CK_3DENTITY_FRAME"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_RESERVED0, {"CK_3DENTITY_RESERVED0"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_TARGETLIGHT, {"CK_3DENTITY_TARGETLIGHT"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_TARGETCAMERA, {"CK_3DENTITY_TARGETCAMERA"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_IGNOREANIMATION, {"CK_3DENTITY_IGNOREANIMATION"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_HIERARCHICALOBSTACLE, {"CK_3DENTITY_HIERARCHICALOBSTACLE"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_UPDATELASTFRAME, {"CK_3DENTITY_UPDATELASTFRAME"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_CAMERAIGNOREASPECT, {"CK_3DENTITY_CAMERAIGNOREASPECT"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_DISABLESKINPROCESS, {"CK_3DENTITY_DISABLESKINPROCESS"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_ENABLESKINOFFSET, {"CK_3DENTITY_ENABLESKINOFFSET"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID, {"CK_3DENTITY_PLACEVALID"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID, {"CK_3DENTITY_PARENTVALID"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_IKJOINTVALID, {"CK_3DENTITY_IKJOINTVALID"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_PORTAL, {"CK_3DENTITY_PORTAL"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_ZORDERVALID, {"CK_3DENTITY_ZORDERVALID"} }, + { LibCmo::CK2::CK_3DENTITY_FLAGS::CK_3DENTITY_CHARACTERDOPROCESS, {"CK_3DENTITY_CHARACTERDOPROCESS"} }, + }; + const GeneralReflectionArray CK_TEXTURE_SAVEOPTIONS { + { LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_RAWDATA, {"CKTEXTURE_RAWDATA"} }, + { LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_EXTERNAL, {"CKTEXTURE_EXTERNAL"} }, + { LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_IMAGEFORMAT, {"CKTEXTURE_IMAGEFORMAT"} }, + { LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_USEGLOBAL, {"CKTEXTURE_USEGLOBAL"} }, + { LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_INCLUDEORIGINALFILE, {"CKTEXTURE_INCLUDEORIGINALFILE"} }, + }; + const GeneralReflectionArray VX_PIXELFORMAT { + { LibCmo::VxMath::VX_PIXELFORMAT::UNKNOWN_PF, {"UNKNOWN_PF"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_ARGB8888, {"_32_ARGB8888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_RGB888, {"_32_RGB888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_24_RGB888, {"_24_RGB888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_RGB565, {"_16_RGB565"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_RGB555, {"_16_RGB555"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_ARGB1555, {"_16_ARGB1555"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_ARGB4444, {"_16_ARGB4444"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_8_RGB332, {"_8_RGB332"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_8_ARGB2222, {"_8_ARGB2222"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_ABGR8888, {"_32_ABGR8888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_RGBA8888, {"_32_RGBA8888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_BGRA8888, {"_32_BGRA8888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_BGR888, {"_32_BGR888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_24_BGR888, {"_24_BGR888"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_BGR565, {"_16_BGR565"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_BGR555, {"_16_BGR555"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_ABGR1555, {"_16_ABGR1555"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_ABGR4444, {"_16_ABGR4444"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_DXT1, {"_DXT1"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_DXT2, {"_DXT2"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_DXT3, {"_DXT3"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_DXT4, {"_DXT4"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_DXT5, {"_DXT5"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_V8U8, {"_16_V8U8"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_V16U16, {"_32_V16U16"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_16_L6V5U5, {"_16_L6V5U5"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_32_X8L8V8U8, {"_32_X8L8V8U8"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_8_ABGR8888_CLUT, {"_8_ABGR8888_CLUT"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_8_ARGB8888_CLUT, {"_8_ARGB8888_CLUT"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_4_ABGR8888_CLUT, {"_4_ABGR8888_CLUT"} }, + { LibCmo::VxMath::VX_PIXELFORMAT::_4_ARGB8888_CLUT, {"_4_ARGB8888_CLUT"} }, + }; + const GeneralReflectionArray VXTEXTURE_BLENDMODE { + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_DECAL, {"VXTEXTUREBLEND_DECAL"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_MODULATE, {"VXTEXTUREBLEND_MODULATE"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_DECALALPHA, {"VXTEXTUREBLEND_DECALALPHA"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_MODULATEALPHA, {"VXTEXTUREBLEND_MODULATEALPHA"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_DECALMASK, {"VXTEXTUREBLEND_DECALMASK"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_MODULATEMASK, {"VXTEXTUREBLEND_MODULATEMASK"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_COPY, {"VXTEXTUREBLEND_COPY"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_ADD, {"VXTEXTUREBLEND_ADD"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_DOTPRODUCT3, {"VXTEXTUREBLEND_DOTPRODUCT3"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_MAX, {"VXTEXTUREBLEND_MAX"} }, + { LibCmo::VxMath::VXTEXTURE_BLENDMODE::VXTEXTUREBLEND_MASK, {"VXTEXTUREBLEND_MASK"} }, + }; + const GeneralReflectionArray VXTEXTURE_FILTERMODE { + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_NEAREST, {"VXTEXTUREFILTER_NEAREST"} }, + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_LINEAR, {"VXTEXTUREFILTER_LINEAR"} }, + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_MIPNEAREST, {"VXTEXTUREFILTER_MIPNEAREST"} }, + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_MIPLINEAR, {"VXTEXTUREFILTER_MIPLINEAR"} }, + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_LINEARMIPNEAREST, {"VXTEXTUREFILTER_LINEARMIPNEAREST"} }, + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_LINEARMIPLINEAR, {"VXTEXTUREFILTER_LINEARMIPLINEAR"} }, + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_ANISOTROPIC, {"VXTEXTUREFILTER_ANISOTROPIC"} }, + { LibCmo::VxMath::VXTEXTURE_FILTERMODE::VXTEXTUREFILTER_MASK, {"VXTEXTUREFILTER_MASK"} }, + }; + const GeneralReflectionArray VXBLEND_MODE { + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_ZERO, {"VXBLEND_ZERO"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_ONE, {"VXBLEND_ONE"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_SRCCOLOR, {"VXBLEND_SRCCOLOR"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_INVSRCCOLOR, {"VXBLEND_INVSRCCOLOR"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_SRCALPHA, {"VXBLEND_SRCALPHA"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_INVSRCALPHA, {"VXBLEND_INVSRCALPHA"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_DESTALPHA, {"VXBLEND_DESTALPHA"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_INVDESTALPHA, {"VXBLEND_INVDESTALPHA"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_DESTCOLOR, {"VXBLEND_DESTCOLOR"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_INVDESTCOLOR, {"VXBLEND_INVDESTCOLOR"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_SRCALPHASAT, {"VXBLEND_SRCALPHASAT"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_BOTHSRCALPHA, {"VXBLEND_BOTHSRCALPHA"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_BOTHINVSRCALPHA, {"VXBLEND_BOTHINVSRCALPHA"} }, + { LibCmo::VxMath::VXBLEND_MODE::VXBLEND_MASK, {"VXBLEND_MASK"} }, + }; + const GeneralReflectionArray VXTEXTURE_ADDRESSMODE { + { LibCmo::VxMath::VXTEXTURE_ADDRESSMODE::VXTEXTURE_ADDRESSWRAP, {"VXTEXTURE_ADDRESSWRAP"} }, + { LibCmo::VxMath::VXTEXTURE_ADDRESSMODE::VXTEXTURE_ADDRESSMIRROR, {"VXTEXTURE_ADDRESSMIRROR"} }, + { LibCmo::VxMath::VXTEXTURE_ADDRESSMODE::VXTEXTURE_ADDRESSCLAMP, {"VXTEXTURE_ADDRESSCLAMP"} }, + { LibCmo::VxMath::VXTEXTURE_ADDRESSMODE::VXTEXTURE_ADDRESSBORDER, {"VXTEXTURE_ADDRESSBORDER"} }, + { LibCmo::VxMath::VXTEXTURE_ADDRESSMODE::VXTEXTURE_ADDRESSMIRRORONCE, {"VXTEXTURE_ADDRESSMIRRORONCE"} }, + { LibCmo::VxMath::VXTEXTURE_ADDRESSMODE::VXTEXTURE_ADDRESSMASK, {"VXTEXTURE_ADDRESSMASK"} }, + }; + const GeneralReflectionArray VXFILL_MODE { + { LibCmo::VxMath::VXFILL_MODE::VXFILL_POINT, {"VXFILL_POINT"} }, + { LibCmo::VxMath::VXFILL_MODE::VXFILL_WIREFRAME, {"VXFILL_WIREFRAME"} }, + { LibCmo::VxMath::VXFILL_MODE::VXFILL_SOLID, {"VXFILL_SOLID"} }, + { LibCmo::VxMath::VXFILL_MODE::VXFILL_MASK, {"VXFILL_MASK"} }, + }; + const GeneralReflectionArray VXSHADE_MODE { + { LibCmo::VxMath::VXSHADE_MODE::VXSHADE_FLAT, {"VXSHADE_FLAT"} }, + { LibCmo::VxMath::VXSHADE_MODE::VXSHADE_GOURAUD, {"VXSHADE_GOURAUD"} }, + { LibCmo::VxMath::VXSHADE_MODE::VXSHADE_PHONG, {"VXSHADE_PHONG"} }, + { LibCmo::VxMath::VXSHADE_MODE::VXSHADE_MASK, {"VXSHADE_MASK"} }, + }; + const GeneralReflectionArray VXCMPFUNC { + { LibCmo::VxMath::VXCMPFUNC::VXCMP_NEVER, {"VXCMP_NEVER"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_LESS, {"VXCMP_LESS"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_EQUAL, {"VXCMP_EQUAL"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_LESSEQUAL, {"VXCMP_LESSEQUAL"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_GREATER, {"VXCMP_GREATER"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_NOTEQUAL, {"VXCMP_NOTEQUAL"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_GREATEREQUAL, {"VXCMP_GREATEREQUAL"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_ALWAYS, {"VXCMP_ALWAYS"} }, + { LibCmo::VxMath::VXCMPFUNC::VXCMP_MASK, {"VXCMP_MASK"} }, + }; + const GeneralReflectionArray VX_EFFECT { + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_NONE, {"VXEFFECT_NONE"} }, + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_TEXGEN, {"VXEFFECT_TEXGEN"} }, + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_TEXGENREF, {"VXEFFECT_TEXGENREF"} }, + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_BUMPENV, {"VXEFFECT_BUMPENV"} }, + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_DP3, {"VXEFFECT_DP3"} }, + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_2TEXTURES, {"VXEFFECT_2TEXTURES"} }, + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_3TEXTURES, {"VXEFFECT_3TEXTURES"} }, + { LibCmo::VxMath::VX_EFFECT::VXEFFECT_MASK, {"VXEFFECT_MASK"} }, + }; + const GeneralReflectionArray VX_MOVEABLE_FLAGS { + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_PICKABLE, {"VX_MOVEABLE_PICKABLE"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_VISIBLE, {"VX_MOVEABLE_VISIBLE"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_UPTODATE, {"VX_MOVEABLE_UPTODATE"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERCHANNELS, {"VX_MOVEABLE_RENDERCHANNELS"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_USERBOX, {"VX_MOVEABLE_USERBOX"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_EXTENTSUPTODATE, {"VX_MOVEABLE_EXTENTSUPTODATE"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_BOXVALID, {"VX_MOVEABLE_BOXVALID"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERLAST, {"VX_MOVEABLE_RENDERLAST"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HASMOVED, {"VX_MOVEABLE_HASMOVED"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_WORLDALIGNED, {"VX_MOVEABLE_WORLDALIGNED"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_NOZBUFFERWRITE, {"VX_MOVEABLE_NOZBUFFERWRITE"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RENDERFIRST, {"VX_MOVEABLE_RENDERFIRST"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_NOZBUFFERTEST, {"VX_MOVEABLE_NOZBUFFERTEST"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INVERSEWORLDMATVALID, {"VX_MOVEABLE_INVERSEWORLDMATVALID"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_DONTUPDATEFROMPARENT, {"VX_MOVEABLE_DONTUPDATEFROMPARENT"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_INDIRECTMATRIX, {"VX_MOVEABLE_INDIRECTMATRIX"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_ZBUFONLY, {"VX_MOVEABLE_ZBUFONLY"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_STENCILONLY, {"VX_MOVEABLE_STENCILONLY"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_HIERARCHICALHIDE, {"VX_MOVEABLE_HIERARCHICALHIDE"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_CHARACTERRENDERED, {"VX_MOVEABLE_CHARACTERRENDERED"} }, + { LibCmo::VxMath::VX_MOVEABLE_FLAGS::VX_MOVEABLE_RESERVED2, {"VX_MOVEABLE_RESERVED2"} }, + }; + const GeneralReflectionArray VXMESH_FLAGS { + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_BOUNDINGUPTODATE, {"VXMESH_BOUNDINGUPTODATE"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_VISIBLE, {"VXMESH_VISIBLE"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_OPTIMIZED, {"VXMESH_OPTIMIZED"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_RENDERCHANNELS, {"VXMESH_RENDERCHANNELS"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_HASTRANSPARENCY, {"VXMESH_HASTRANSPARENCY"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_PRELITMODE, {"VXMESH_PRELITMODE"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_WRAPU, {"VXMESH_WRAPU"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_WRAPV, {"VXMESH_WRAPV"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_FORCETRANSPARENCY, {"VXMESH_FORCETRANSPARENCY"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_TRANSPARENCYUPTODATE, {"VXMESH_TRANSPARENCYUPTODATE"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_UV_CHANGED, {"VXMESH_UV_CHANGED"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_NORMAL_CHANGED, {"VXMESH_NORMAL_CHANGED"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_COLOR_CHANGED, {"VXMESH_COLOR_CHANGED"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_POS_CHANGED, {"VXMESH_POS_CHANGED"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_HINTDYNAMIC, {"VXMESH_HINTDYNAMIC"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_GENNORMALS, {"VXMESH_GENNORMALS"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALUV, {"VXMESH_PROCEDURALUV"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_PROCEDURALPOS, {"VXMESH_PROCEDURALPOS"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_STRIPIFY, {"VXMESH_STRIPIFY"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_MONOMATERIAL, {"VXMESH_MONOMATERIAL"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_PM_BUILDNORM, {"VXMESH_PM_BUILDNORM"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_BWEIGHTS_CHANGED, {"VXMESH_BWEIGHTS_CHANGED"} }, + { LibCmo::VxMath::VXMESH_FLAGS::VXMESH_ALLFLAGS, {"VXMESH_ALLFLAGS"} }, + }; + const GeneralReflectionArray VXTEXTURE_WRAPMODE { + { LibCmo::VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_NONE, {"VXTEXTUREWRAP_NONE"} }, + { LibCmo::VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_U, {"VXTEXTUREWRAP_U"} }, + { LibCmo::VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_V, {"VXTEXTUREWRAP_V"} }, + { LibCmo::VxMath::VXTEXTURE_WRAPMODE::VXTEXTUREWRAP_UV, {"VXTEXTUREWRAP_UV"} }, + }; } #pragma endregion diff --git a/Unvirt/AccessibleValue.hpp b/Unvirt/AccessibleValue.hpp index f5f2359..a03ab89 100644 --- a/Unvirt/AccessibleValue.hpp +++ b/Unvirt/AccessibleValue.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include "StringHelper.hpp" #include #include @@ -22,12 +23,15 @@ namespace Unvirt { return strl; } } - strl = c_InvalidEnumName; + StringHelper::StdstringPrintf(strl, "%s (0x%08" PRIXCKDWORD ")", + c_InvalidEnumName, + static_cast(val) + ); return strl; } template - std::string GetFlagEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc) { - std::string strl; + std::string GetFlagEnumName(_Ty val, const GeneralReflectionArray<_Ty>& desc, const char* splitor) { + std::string strl, cache; for (auto& item : desc) { // if it have exacelt same entry, return directly if (item.first == val) { @@ -37,14 +41,24 @@ namespace Unvirt { // check flag match if (LibCmo::EnumsHelper::Has(val, item.first)) { - if (strl.size() != 0u) strl += ", "; - strl += item.second.mName; + if (strl.size() != 0u && splitor != nullptr) { + strl += splitor; + } + + StringHelper::StdstringPrintf(cache, "%s (0x%08" PRIXCKDWORD ")", + item.second.mName, + static_cast(item.first) + ); + strl += cache; } } // if nothing was gotten. set to undefined if (strl.size() == 0u) { - strl = c_InvalidEnumName; + StringHelper::StdstringPrintf(strl, "%s (0x%08" PRIXCKDWORD ")", + c_InvalidEnumName, + static_cast(val) + ); } return strl; @@ -63,6 +77,22 @@ namespace Unvirt { extern const GeneralReflectionArray CK_STATECHUNK_CHUNKOPTIONS; extern const GeneralReflectionArray CK_STATECHUNK_DATAVERSION; extern const GeneralReflectionArray CK_STATECHUNK_CHUNKVERSION; + extern const GeneralReflectionArray CK_OBJECT_FLAGS; + extern const GeneralReflectionArray CK_3DENTITY_FLAGS; + extern const GeneralReflectionArray CK_TEXTURE_SAVEOPTIONS; + + extern const GeneralReflectionArray VX_PIXELFORMAT; + extern const GeneralReflectionArray VXTEXTURE_BLENDMODE; + extern const GeneralReflectionArray VXTEXTURE_FILTERMODE; + extern const GeneralReflectionArray VXBLEND_MODE; + extern const GeneralReflectionArray VXTEXTURE_ADDRESSMODE; + extern const GeneralReflectionArray VXFILL_MODE; + extern const GeneralReflectionArray VXSHADE_MODE; + extern const GeneralReflectionArray VXCMPFUNC; + extern const GeneralReflectionArray VX_EFFECT; + extern const GeneralReflectionArray VX_MOVEABLE_FLAGS; + extern const GeneralReflectionArray VXMESH_FLAGS; + extern const GeneralReflectionArray VXTEXTURE_WRAPMODE; } } diff --git a/Unvirt/StringHelper.cpp b/Unvirt/StringHelper.cpp index 499289f..bcc61f1 100644 --- a/Unvirt/StringHelper.cpp +++ b/Unvirt/StringHelper.cpp @@ -20,8 +20,8 @@ namespace Unvirt::StringHelper { if (count < 0) throw new std::length_error("Invalid length returned by vsnprintf."); va_end(args1); - strl.resize(count + 1); - int write_result = std::vsnprintf(strl.data(), strl.size(), format, args2); + strl.resize(count); + int write_result = std::vsnprintf(strl.data(), strl.size() + 1, format, args2); va_end(args2); if (write_result < 0 || write_result > count) throw new std::length_error("Invalid write result in vsnprintf."); diff --git a/Unvirt/StructFormatter.cpp b/Unvirt/StructFormatter.cpp index 49017a3..d8d2884 100644 --- a/Unvirt/StructFormatter.cpp +++ b/Unvirt/StructFormatter.cpp @@ -36,6 +36,22 @@ namespace Unvirt::StructFormatter { static void PrintCKGUID(const LibCmo::CK2::CKGUID& guid) { fprintf(stdout, "<0x%08" PRIxCKDWORD ", 0x%08" PRIxCKDWORD ">", guid.d1, guid.d2); } + static void PrintBool(bool v) { + fputs(v ? "true" : "false", stdout); + } + static void PrintColor(const LibCmo::VxMath::VxColor& col) { + LibCmo::CKDWORD argb = col.ToARGB(); + LibCmo::CKDWORD a = (argb & 0xFF000000) >> 24, + r = (argb & 0x00FF0000) >> 16, + g = (argb & 0x0000FF00) >> 8, + b = (argb & 0x000000FF); + fprintf(stdout, "A:%" PRIuCKDWORD " (%.4" PRIfCKFLOAT ") RGB(%" PRIuCKDWORD ", %" PRIuCKDWORD ", %" PRIuCKDWORD ") RGB#%" PRIxCKDWORD "%" PRIxCKDWORD "%" PRIxCKDWORD " RGBA#%" PRIxCKDWORD "%" PRIxCKDWORD "%" PRIxCKDWORD "%" PRIxCKDWORD, + a, col.a, + r, g, b, + r, g, b, + r, g, b, a + ); + } template static void GeneralPrintList( @@ -60,7 +76,7 @@ namespace Unvirt::StructFormatter { #pragma endregion #pragma region Object Printer - + static void PrintCKObjectDetail(LibCmo::CK2::ObjImpls::CKObject* obj) { fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKObject\n")), stdout); // print name @@ -72,7 +88,7 @@ namespace Unvirt::StructFormatter { // print class id fprintf(stdout, "Class ID: %" PRIiCLASSID " (%s)\n", obj->GetClassID(), AccessibleValue::GetClassIdHierarchy(obj->GetClassID()).c_str()); } - + static void PrintCKSceneObjectDetail(LibCmo::CK2::ObjImpls::CKSceneObject* obj) { PrintCKObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKSceneObject\n")), stdout); @@ -88,13 +104,13 @@ namespace Unvirt::StructFormatter { static void PrintCKGroupDetail(LibCmo::CK2::ObjImpls::CKGroup* obj) { PrintCKBeObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKGroup\n")), stdout); - + LibCmo::CKDWORD count = obj->GetObjectCount(); fprintf(stdout, "Group Object Count: %" PRIuCKDWORD "\n", count); fputs("Id\tType\tObject Pointer\tName\n", stdout); for (LibCmo::CKDWORD i = 0; i < count; ++i) { LibCmo::CK2::ObjImpls::CKBeObject* beobj = obj->GetObject(i); - + fprintf(stdout, "%" PRIuCKID "\t", beobj->GetID()); fputs(AccessibleValue::GetClassIdName(beobj->GetClassID()).c_str(), stdout); fputc('\t', stdout); @@ -104,41 +120,157 @@ namespace Unvirt::StructFormatter { fputc('\n', stdout); } } - + static void PrintCKRenderObjectDetail(LibCmo::CK2::ObjImpls::CKRenderObject* obj) { PrintCKBeObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKRenderObject\n")), stdout); fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout); } - + static void PrintCK3dEntityDetail(LibCmo::CK2::ObjImpls::CK3dEntity* obj) { PrintCKRenderObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CK3dEntity\n")), stdout); - fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout); + + fputs("== World Matrix ==\n", stdout); + auto mat = obj->GetWorldMatrix(); + for (LibCmo::CKDWORD i = 0; i < 4; ++i) { + fprintf(stdout, "%+" PRIeCKFLOAT "\t%+" PRIeCKFLOAT "\t%+" PRIeCKFLOAT "\t%+" PRIeCKFLOAT "\n", + mat[i].x, mat[i].y, mat[i].z, mat[i].w + ); + } + + fputs("== Flags ==\n", stdout); + fputs("3dEntity Flags:\n", stdout); + fputs(AccessibleValue::GetFlagEnumName(obj->GetEntityFlags(), AccessibleValue::EnumDesc::CK_3DENTITY_FLAGS, "\n").c_str(), stdout); + fputc('\n', stdout); + fputs("Moveable Flags:\n", stdout); + fputs(AccessibleValue::GetFlagEnumName(obj->GetMoveableFlags(), AccessibleValue::EnumDesc::VX_MOVEABLE_FLAGS, "\n").c_str(), stdout); + fputc('\n', stdout); + + fputs("== Meshs ==\n", stdout); + fputs("Index\tAddress\tName\n", stdout); + // print current mesh + auto curmesh = obj->GetCurrentMesh(); + fputs("->\t", stdout); + PrintPointer(curmesh); + fputc('\t', stdout); + if (curmesh != nullptr) + PrintCKSTRING(curmesh->GetName()); + fputc('\n', stdout); + for (LibCmo::CKDWORD i = 0; i < obj->GetPotentialMeshCount(); ++i) { + auto thismesh = obj->GetPotentialMesh(i); + fprintf(stdout, "#%" PRIuCKDWORD "\t", i); + PrintPointer(thismesh); + fputc('\t', stdout); + PrintCKSTRING(thismesh->GetName()); + fputc('\n', stdout); + } + } - + static void PrintCK3dObjectDetail(LibCmo::CK2::ObjImpls::CK3dObject* obj) { PrintCK3dEntityDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CK3dObject\n")), stdout); fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout); } - + static void PrintCKTextureDetail(LibCmo::CK2::ObjImpls::CKTexture* obj) { PrintCKBeObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKTexture\n")), stdout); fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout); } - + static void PrintCKMaterialDetail(LibCmo::CK2::ObjImpls::CKMaterial* obj) { PrintCKBeObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKMaterial\n")), stdout); - fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout); + + // color + fputs("== Color ==\n", stdout); + + fputs("Diffuse: ", stdout); + PrintColor(obj->GetDiffuse()); + fputc('\n', stdout); + fputs("Ambient: ", stdout); + PrintColor(obj->GetAmbient()); + fputc('\n', stdout); + fputs("Specular: ", stdout); + PrintColor(obj->GetSpecular()); + fputc('\n', stdout); + fputs("Emissive: ", stdout); + PrintColor(obj->GetEmissive()); + fputc('\n', stdout); + + fprintf(stdout, "Specular Power: %.2" PRIfCKFLOAT "\n", obj->GetSpecularPower()); + + // basic data + fputs("== Basic ==\n", stdout); + fprintf(stdout, "Both Sided: "); + PrintBool(obj->GetTwoSidedEnabled()); + fputc('\n', stdout); + fprintf(stdout, "Fill Mode: %s\n", AccessibleValue::GetEnumName(obj->GetFillMode(), AccessibleValue::EnumDesc::VXFILL_MODE).c_str()); + fprintf(stdout, "Shade Mode: %s\n", AccessibleValue::GetEnumName(obj->GetShadeMode(), AccessibleValue::EnumDesc::VXSHADE_MODE).c_str()); + + // textures + fputs("== Texture ==\n", stdout); + fputs("Textures:\n", stdout); + fputs("Index\tAddress\tName\n", stdout); + for (LibCmo::CKDWORD i = 0; i < 4; ++i) { + auto tex = obj->GetTexture(i); + fprintf(stdout, "#%" PRIuCKDWORD "\t", i); + PrintPointer(tex); + fputc('\t', stdout); + if (tex != nullptr) + PrintCKSTRING(tex->GetName()); + fputc('\n', stdout); + } + fprintf(stdout, "Texture Blend: %s\n", AccessibleValue::GetEnumName(obj->GetTextureBlendMode(), AccessibleValue::EnumDesc::VXTEXTURE_BLENDMODE).c_str()); + fprintf(stdout, "Filter Min: %s\n", AccessibleValue::GetEnumName(obj->GetTextureMinMode(), AccessibleValue::EnumDesc::VXTEXTURE_FILTERMODE).c_str()); + fprintf(stdout, "Filter Mag: %s\n", AccessibleValue::GetEnumName(obj->GetTextureMagMode(), AccessibleValue::EnumDesc::VXTEXTURE_FILTERMODE).c_str()); + fprintf(stdout, "Address Mode: %s\n", AccessibleValue::GetEnumName(obj->GetTextureAddressMode(), AccessibleValue::EnumDesc::VXTEXTURE_ADDRESSMODE).c_str()); + fprintf(stdout, "Perspective Correct: "); + PrintBool(obj->GetPerspectiveCorrectionEnabled()); + fputc('\n', stdout); + + // alpha test + fputs("== Alpha Test ==\n", stdout); + fprintf(stdout, "Enabled: "); + PrintBool(obj->GetAlphaTestEnabled()); + fputc('\n', stdout); + fprintf(stdout, "Alpha Function: %s\n", AccessibleValue::GetEnumName(obj->GetAlphaFunc(), AccessibleValue::EnumDesc::VXCMPFUNC).c_str()); + fprintf(stdout, "Alpha Ref Value: %" PRIuCKBYTE "\n", obj->GetAlphaRef()); + + // alpha blend + fputs("== Alpha Blend ==\n", stdout); + fprintf(stdout, "Enabled: "); + PrintBool(obj->GetAlphaBlendEnabled()); + fputc('\n', stdout); + fprintf(stdout, "Source Blend: %s\n", AccessibleValue::GetEnumName(obj->GetSourceBlend(), AccessibleValue::EnumDesc::VXBLEND_MODE).c_str()); + fprintf(stdout, "Destination Blend: %s\n", AccessibleValue::GetEnumName(obj->GetDestBlend(), AccessibleValue::EnumDesc::VXBLEND_MODE).c_str()); + + // z buffer + fputs("== Z-Buffer Write ==\n", stdout); + fprintf(stdout, "Enabled: "); + PrintBool(obj->GetZWriteEnabled()); + fputc('\n', stdout); + fprintf(stdout, "Z Compare Function: %s\n", AccessibleValue::GetEnumName(obj->GetZFunc(), AccessibleValue::EnumDesc::VXCMPFUNC).c_str()); + + // effect + fputs("== Effect ==\n", stdout); + fprintf(stdout, "Effect: %s\n", AccessibleValue::GetEnumName(obj->GetEffect(), AccessibleValue::EnumDesc::VX_EFFECT).c_str()); + } - + static void PrintCKMeshDetail(LibCmo::CK2::ObjImpls::CKMesh* obj) { PrintCKBeObjectDetail(obj); fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKMesh\n")), stdout); - + + fputs("== Flags ==\n", stdout); + fputs("Mesh Flags:\n", stdout); + fputs(AccessibleValue::GetFlagEnumName(obj->GetMeshFlags(), AccessibleValue::EnumDesc::VXMESH_FLAGS, "\n").c_str(), stdout); + fputc('\n', stdout); + + // vertex data + fputs("== Vertex ==\n", stdout); fprintf(stdout, "Vertex Count: %" PRIuCKDWORD "\n", obj->GetVertexCount()); fputs("Address\tSize\tType\n", stdout); @@ -155,9 +287,11 @@ namespace Unvirt::StructFormatter { PrintPointer(obj->GetVertexWeights()); fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tWeights\n", obj->GetVertexCount() * CKSizeof(LibCmo::CKFLOAT)); + // face data + fputs("== Face ==\n", stdout); fprintf(stdout, "Face Count: %" PRIuCKDWORD "\n", obj->GetFaceCount()); fputs("Address\tSize\tType\n", stdout); - + PrintPointer(obj->GetFaceIndices()); fprintf(stdout, "\t0x%" PRIxCKDWORD " bytes\tIndices\n", obj->GetFaceCount() * 3 * CKSizeof(LibCmo::CKWORD)); PrintPointer(obj->GetFaceMaterialSlotIndexs()); @@ -189,7 +323,7 @@ namespace Unvirt::StructFormatter { ); fprintf(stdout, "Save Flags: %s\n", AccessibleValue::GetFlagEnumName( - fileinfo.FileWriteMode, AccessibleValue::EnumDesc::CK_FILE_WRITEMODE + fileinfo.FileWriteMode, AccessibleValue::EnumDesc::CK_FILE_WRITEMODE, ", " ).c_str()); fprintf(stdout, "File Size: %s\n", AccessibleValue::GetReadableFileSize(fileinfo.FileSize).c_str());