finish mesh reading test (only core mesh data)
This commit is contained in:
parent
f60ee5058a
commit
be6cbc5692
|
@ -19,18 +19,10 @@ def GetFileLength(fs: io.BufferedReader) -> int:
|
||||||
fs.seek(pos, io.SEEK_SET)
|
fs.seek(pos, io.SEEK_SET)
|
||||||
return fsize
|
return fsize
|
||||||
|
|
||||||
def EvaluateVertexCount(filename: str) -> int:
|
def EvaluateCount(filename: str, unit_size: int) -> int:
|
||||||
with open(filename, 'rb') as fs:
|
with open(filename, 'rb') as fs:
|
||||||
filesize = GetFileLength(fs)
|
filesize = GetFileLength(fs)
|
||||||
count, modrem = divmod(filesize, 3 * 4) # 3 float(4 byte)
|
count, modrem = divmod(filesize, unit_size)
|
||||||
if modrem != 0:
|
|
||||||
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:
|
if modrem != 0:
|
||||||
raise Exception("invalid file length")
|
raise Exception("invalid file length")
|
||||||
return count
|
return count
|
||||||
|
@ -80,19 +72,21 @@ if __name__ == '__main__':
|
||||||
# parse arg
|
# parse arg
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
input("Prepare VertexPositions please.")
|
#input("Prepare VertexPositions please.")
|
||||||
vertexcount = EvaluateVertexCount(args.in_bin)
|
vertexcount = EvaluateCount(args.in_vpos, 3 * 4) # 3 float(4 bytes)
|
||||||
print(f'Vertex Count Evaluated: {vertexcount}')
|
print(f'Vertex Count Evaluated: {vertexcount}')
|
||||||
vpos = RecoupleTuple(ReadFloats(args.in_bin, 3 * vertexcount), 3)
|
vpos = RecoupleTuple(ReadFloats(args.in_vpos, 3 * vertexcount), 3)
|
||||||
|
|
||||||
input("Prepare VertexNormals please.")
|
#input("Prepare VertexNormals please.")
|
||||||
vnml = RecoupleTuple(ReadFloats(args.in_bin, 3 * vertexcount), 3)
|
vnml = RecoupleTuple(ReadFloats(args.in_vnml, 3 * vertexcount), 3)
|
||||||
|
|
||||||
input("Prepare VertexUVs please.")
|
#input("Prepare VertexUVs please.")
|
||||||
vuv = RecoupleTuple(ReadFloats(args.in_bin, 2 * vertexcount), 2)
|
vuv = RecoupleTuple(ReadFloats(args.in_vuv, 2 * vertexcount), 2)
|
||||||
|
|
||||||
input("Prepare FaceIndices please.")
|
#input("Prepare FaceIndices please.")
|
||||||
findices = RecoupleTuple(ReadShorts(args.in_bin, 3 * vertexcount), 3)
|
facecount = EvaluateCount(args.in_findices, 3 * 2) # 3 WORD(2 bytes)
|
||||||
|
print(f'Face Count Evaluated: {facecount}')
|
||||||
|
findices = RecoupleTuple(ReadShorts(args.in_findices, 3 * facecount), 3)
|
||||||
|
|
||||||
GenerateObj(args.out_obj, vpos, vnml, vuv, findices)
|
GenerateObj(args.out_obj, vpos, vnml, vuv, findices)
|
||||||
print('Done')
|
print('Done')
|
||||||
|
|
|
@ -78,6 +78,42 @@ namespace Unvirt::StructFormatter {
|
||||||
fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
|
fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PrintCKGroupDetail(LibCmo::CK2::ObjImpls::CKGroup* obj) {
|
||||||
|
PrintCKBeObjectDetail(obj);
|
||||||
|
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKGroup\n")), stdout);
|
||||||
|
fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
static void PrintCKMeshDetail(LibCmo::CK2::ObjImpls::CKMesh* obj) {
|
static void PrintCKMeshDetail(LibCmo::CK2::ObjImpls::CKMesh* obj) {
|
||||||
PrintCKBeObjectDetail(obj);
|
PrintCKBeObjectDetail(obj);
|
||||||
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKMesh\n")), stdout);
|
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKMesh\n")), stdout);
|
||||||
|
@ -232,6 +268,33 @@ namespace Unvirt::StructFormatter {
|
||||||
|
|
||||||
LibCmo::CK2::ObjImpls::CKObject* mobj = const_cast<LibCmo::CK2::ObjImpls::CKObject*>(obj);
|
LibCmo::CK2::ObjImpls::CKObject* mobj = const_cast<LibCmo::CK2::ObjImpls::CKObject*>(obj);
|
||||||
switch (mobj->GetClassID()) {
|
switch (mobj->GetClassID()) {
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_OBJECT:
|
||||||
|
PrintCKObjectDetail(static_cast<LibCmo::CK2::ObjImpls::CKObject*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_SCENEOBJECT:
|
||||||
|
PrintCKSceneObjectDetail(static_cast<LibCmo::CK2::ObjImpls::CKSceneObject*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_BEOBJECT:
|
||||||
|
PrintCKBeObjectDetail(static_cast<LibCmo::CK2::ObjImpls::CKBeObject*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_GROUP:
|
||||||
|
PrintCKGroupDetail(static_cast<LibCmo::CK2::ObjImpls::CKGroup*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_RENDEROBJECT:
|
||||||
|
PrintCKRenderObjectDetail(static_cast<LibCmo::CK2::ObjImpls::CKRenderObject*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY:
|
||||||
|
PrintCK3dEntityDetail(static_cast<LibCmo::CK2::ObjImpls::CK3dEntity*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT:
|
||||||
|
PrintCK3dObjectDetail(static_cast<LibCmo::CK2::ObjImpls::CK3dObject*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE:
|
||||||
|
PrintCKTextureDetail(static_cast<LibCmo::CK2::ObjImpls::CKTexture*>(mobj));
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL:
|
||||||
|
PrintCKMaterialDetail(static_cast<LibCmo::CK2::ObjImpls::CKMaterial*>(mobj));
|
||||||
|
break;
|
||||||
case LibCmo::CK2::CK_CLASSID::CKCID_MESH:
|
case LibCmo::CK2::CK_CLASSID::CKCID_MESH:
|
||||||
PrintCKMeshDetail(static_cast<LibCmo::CK2::ObjImpls::CKMesh*>(mobj));
|
PrintCKMeshDetail(static_cast<LibCmo::CK2::ObjImpls::CKMesh*>(mobj));
|
||||||
break;
|
break;
|
||||||
|
@ -244,7 +307,7 @@ namespace Unvirt::StructFormatter {
|
||||||
void PrintCKBaseManager(const LibCmo::CK2::MgrImpls::CKBaseManager* mgr) {
|
void PrintCKBaseManager(const LibCmo::CK2::MgrImpls::CKBaseManager* mgr) {
|
||||||
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKBaseManager\n")), stdout);
|
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKBaseManager\n")), stdout);
|
||||||
if (mgr == nullptr) {
|
if (mgr == nullptr) {
|
||||||
fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
|
fputs(UNVIRT_TERMCOL_LIGHT_RED(("Null Manager\n")), stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +316,7 @@ namespace Unvirt::StructFormatter {
|
||||||
void PrintCKStateChunk(const LibCmo::CK2::CKStateChunk* chunk) {
|
void PrintCKStateChunk(const LibCmo::CK2::CKStateChunk* chunk) {
|
||||||
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKStateChunk\n")), stdout);
|
fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKStateChunk\n")), stdout);
|
||||||
if (chunk == nullptr) {
|
if (chunk == nullptr) {
|
||||||
fputs(UNVIRT_TERMCOL_LIGHT_RED(("No Data\n")), stdout);
|
fputs(UNVIRT_TERMCOL_LIGHT_RED(("Null Chunk\n")), stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user