diff --git a/.gitignore b/.gitignore
index 7769be8..b5cce05 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ CodeGen/*.cpp
CodeGen/EnumsMigration/dest/*.hpp
CodeGen/EnumsMigration/dest/*.cpp
+Tools/*.bin
Tools/*.obj
Tools/*.mtl
diff --git a/LibCmo/LibCmo.vcxproj b/LibCmo/LibCmo.vcxproj
index b93b09a..69b7aab 100644
--- a/LibCmo/LibCmo.vcxproj
+++ b/LibCmo/LibCmo.vcxproj
@@ -231,6 +231,7 @@
+
diff --git a/LibCmo/LibCmo.vcxproj.filters b/LibCmo/LibCmo.vcxproj.filters
index e3362aa..71d8e40 100644
--- a/LibCmo/LibCmo.vcxproj.filters
+++ b/LibCmo/LibCmo.vcxproj.filters
@@ -233,5 +233,8 @@
Headers
+
+ Headers
+
\ No newline at end of file
diff --git a/LibCmo/VTUserAll.hpp b/LibCmo/VTUserAll.hpp
new file mode 100644
index 0000000..ec9a793
--- /dev/null
+++ b/LibCmo/VTUserAll.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+/*
+This file is provided for user of LibCmo.
+This file should not be included in LibCmo project inside.
+Use VTAll.hpp for project internal including.
+*/
+
+#include "VTAll.hpp"
+#include "CK2/CKContext.hpp"
+#include "CK2/CKStateChunk.hpp"
+
+// Data handlers
+#include "CK2/DataHandlers/CKBitmapHandler.hpp"
+
+// Objects
+#include "CK2/ObjImpls/CKObject.hpp"
+#include "CK2/ObjImpls/CKSceneObject.hpp"
+#include "CK2/ObjImpls/CKBeObject.hpp"
+#include "CK2/ObjImpls/CKGroup.hpp"
+#include "CK2/ObjImpls/CKRenderObject.hpp"
+#include "CK2/ObjImpls/CK3dEntity.hpp"
+#include "CK2/ObjImpls/CK3dObject.hpp"
+#include "CK2/ObjImpls/CKTexture.hpp"
+#include "CK2/ObjImpls/CKMaterial.hpp"
+#include "CK2/ObjImpls/CKMesh.hpp"
+
+// Managers
+#include "CK2/MgrImpls/CKBaseManager.hpp"
+#include "CK2/MgrImpls/CKObjectManager.hpp"
+#include "CK2/MgrImpls/CKPathManager.hpp"
diff --git a/Tools/MeshConv.py b/Tools/MeshConv.py
index 6aff1a8..cced666 100644
--- a/Tools/MeshConv.py
+++ b/Tools/MeshConv.py
@@ -2,7 +2,10 @@ import argparse, io, math, struct
# setup parser
parser = argparse.ArgumentParser(description='The Mesh Converter.')
-parser.add_argument('-b', '--in-bin', required=True, type=str, action='store', dest='in_bin', metavar='mesh.bin')
+parser.add_argument('-p', '--in-vpos', required=True, type=str, action='store', dest='in_vpos', metavar='vpos.bin')
+parser.add_argument('-n', '--in-vbml', required=True, type=str, action='store', dest='in_vnml', metavar='vnml.bin')
+parser.add_argument('-u', '--in-vuv', required=True, type=str, action='store', dest='in_vuv', metavar='vuv.bin')
+parser.add_argument('-i', '--in-findices', required=True, type=str, action='store', dest='in_findices', metavar='findices.bin')
parser.add_argument('-o', '--out-obj', required=True, type=str, action='store', dest='out_obj', metavar='mesh.obj')
parser.add_argument('-m', '--out-mtl', required=True, type=str, action='store', dest='out_mtl', metavar='mesh.mtl')
@@ -24,6 +27,14 @@ def EvaluateVertexCount(filename: str) -> int:
raise Exception("invalid file length")
return count
+def EvaluateFaceCount(filename: str) -> int:
+ with open(filename, 'rb') as fs:
+ filesize = GetFileLength(fs)
+ count, modrem = divmod(filesize, 3 * 2) # 3 WORD(2 byte)
+ if modrem != 0:
+ raise Exception("invalid file length")
+ return count
+
def AssertFileSize(fs: io.BufferedReader, expected_size: int):
if expected_size != GetFileLength(fs):
raise Exception("invalid file length")
@@ -72,17 +83,16 @@ if __name__ == '__main__':
input("Prepare VertexPositions please.")
vertexcount = EvaluateVertexCount(args.in_bin)
print(f'Vertex Count Evaluated: {vertexcount}')
- vpos = RecoupleTuple(ReadFloats(3 * vertexcount), 3)
+ vpos = RecoupleTuple(ReadFloats(args.in_bin, 3 * vertexcount), 3)
input("Prepare VertexNormals please.")
- vnml = RecoupleTuple(ReadFloats(3 * vertexcount), 3)
+ vnml = RecoupleTuple(ReadFloats(args.in_bin, 3 * vertexcount), 3)
input("Prepare VertexUVs please.")
- vuv = RecoupleTuple(ReadFloats(2 * vertexcount), 2)
+ vuv = RecoupleTuple(ReadFloats(args.in_bin, 2 * vertexcount), 2)
input("Prepare FaceIndices please.")
- findices = RecoupleTuple(ReadShorts(3 * vertexcount), 3)
+ findices = RecoupleTuple(ReadShorts(args.in_bin, 3 * vertexcount), 3)
GenerateObj(args.out_obj, vpos, vnml, vuv, findices)
print('Done')
-
\ No newline at end of file
diff --git a/Unvirt/StructFormatter.cpp b/Unvirt/StructFormatter.cpp
index 472bee0..91a4636 100644
--- a/Unvirt/StructFormatter.cpp
+++ b/Unvirt/StructFormatter.cpp
@@ -1,5 +1,4 @@
-#include
-#include
+#include
#include "StructFormatter.hpp"
#include "AccessibleValue.hpp"
#include "TerminalHelper.hpp"
@@ -60,6 +59,66 @@ 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);
+ fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
+ }
+
+ static void PrintCKSceneObjectDetail(LibCmo::CK2::ObjImpls::CKSceneObject* obj) {
+ PrintCKObjectDetail(obj);
+ fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKSceneObject\n")), stdout);
+ fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
+ }
+
+ static void PrintCKBeObjectDetail(LibCmo::CK2::ObjImpls::CKBeObject* obj) {
+ PrintCKSceneObjectDetail(obj);
+ fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKBeObject\n")), stdout);
+ fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
+ }
+
+ static void PrintCKMeshDetail(LibCmo::CK2::ObjImpls::CKMesh* obj) {
+ PrintCKBeObjectDetail(obj);
+ fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKMesh\n")), stdout);
+
+ fputs("Vertex:\n", stdout);
+ fprintf(stdout, "Vertex Count: %" PRIuCKDWORD "\n", obj->GetVertexCount());
+
+ fputs("VertexPositions: ", stdout);
+ PrintPointer(obj->GetVertexPositions());
+ fputc('\n', stdout);
+ fputs("VertexNormals: ", stdout);
+ PrintPointer(obj->GetVertexNormals());
+ fputc('\n', stdout);
+ fputs("VertexUVs: ", stdout);
+ PrintPointer(obj->GetVertexUVs());
+ fputc('\n', stdout);
+ fputs("VertexColors: ", stdout);
+ PrintPointer(obj->GetVertexColors());
+ fputc('\n', stdout);
+ fputs("VertexSpecularColors: ", stdout);
+ PrintPointer(obj->GetVertexSpecularColors());
+ fputc('\n', stdout);
+ fputs("VertexWeights: ", stdout);
+ PrintPointer(obj->GetVertexWeights());
+ fputc('\n', stdout);
+
+ fputs("Face:\n", stdout);
+ fprintf(stdout, "Face Count: %" PRIuCKDWORD "\n", obj->GetFaceCount());
+
+ fputs("FaceIndices: ", stdout);
+ PrintPointer(obj->GetFaceIndices());
+ fputc('\n', stdout);
+ fputs("FaceMaterialSlotIndexs: ", stdout);
+ PrintPointer(obj->GetFaceMaterialSlotIndexs());
+ fputc('\n', stdout);
+
+ }
+
+#pragma endregion
+
+
void PrintCKFileInfo(const LibCmo::CK2::CKFileInfo& fileinfo) {
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKFileInfo\n")), stdout);
@@ -166,13 +225,21 @@ namespace Unvirt::StructFormatter {
}
void PrintCKObject(const LibCmo::CK2::ObjImpls::CKObject* obj) {
- fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKObject\n")), stdout);
if (obj == nullptr) {
- fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
+ fputs(UNVIRT_TERMCOL_LIGHT_RED(("Null Object\n")), stdout);
return;
}
- fputs(UNVIRT_TERMCOL_LIGHT_RED(("Not Implemented.\n")), stdout);
+ LibCmo::CK2::ObjImpls::CKObject* mobj = const_cast(obj);
+ switch (mobj->GetClassID()) {
+ case LibCmo::CK2::CK_CLASSID::CKCID_MESH:
+ PrintCKMeshDetail(static_cast(mobj));
+ break;
+ default:
+ fputs(UNVIRT_TERMCOL_LIGHT_RED(("Not Implemented.\n")), stdout);
+ break;
+ }
+
}
void PrintCKBaseManager(const LibCmo::CK2::MgrImpls::CKBaseManager* mgr) {
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKBaseManager\n")), stdout);