From 5f81dfecf69ed42722e8011c4a217bae789bc29a Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Thu, 29 May 2025 23:40:48 -0400 Subject: [PATCH 1/5] Small work on iModel --- src/SB/Core/gc/iModel.cpp | 56 +++++++++++++++++++++++++++++++++++++++ src/SB/Core/gc/iModel.h | 10 +++++++ 2 files changed, 66 insertions(+) diff --git a/src/SB/Core/gc/iModel.cpp b/src/SB/Core/gc/iModel.cpp index dd3e9b61c..7f1ba36c1 100644 --- a/src/SB/Core/gc/iModel.cpp +++ b/src/SB/Core/gc/iModel.cpp @@ -2,6 +2,62 @@ #include +RwFrame* GetChildFrameHierarchy(RwFrame* frame, void* data) +{ + RpHAnimHierarchy* hierarchy = RpHAnimFrameGetHierarchy(frame); + if (hierarchy == 0) + { + RwFrameForAllChildren(frame, GetChildFrameHierarchy, data); + } + else + { + data = hierarchy; + frame = 0; + } + return frame; +} + +void* GetHierarchy(RpAtomic* frame) +{ + void* unk_0[2]; + unk_0[0] = 0; + GetChildFrameHierarchy((RwFrame*)frame, unk_0); + return unk_0[0]; +} + +RpAtomic* iModelFileNew(void* buffer, U32 size) +{ + RwStream* rwmem; + S32 unk_0 = (S32)buffer; + RwStreamType type; + RwStreamAccessType accessType; + + type = (RwStreamType)3; + accessType = (RwStreamAccessType)1; + + rwmem = RwStreamOpen(type, accessType, buffer); + return iModelStreamRead(rwmem); +} + +void iModelUnload(RpAtomic* userdata) +{ + RpClump* clump; + RwFrame* frame = 0; + RwFrame* root; + + clump = (RpClump*)userdata + 0x3c; + if ((RpClump*)userdata != 0) + { + RwFrameGetRoot((RwFrame*)userdata); + RwFrameDestroyHierarchy(frame); + userdata = 0; + } + if (clump != 0) + { + RpClumpDestroy(clump); + } +} + void iModelCacheAtomic(RpAtomic*) { } diff --git a/src/SB/Core/gc/iModel.h b/src/SB/Core/gc/iModel.h index b9ddb99f4..a686a5148 100644 --- a/src/SB/Core/gc/iModel.h +++ b/src/SB/Core/gc/iModel.h @@ -6,14 +6,24 @@ #include #include +#include + +struct RwMemory +{ + char* start; + U32 length; +}; void iModelInit(); U32 iModelNumBones(RpAtomic* model); S32 iModelCull(RpAtomic* model, RwMatrixTag* mat); S32 iModelSphereCull(xSphere* sphere); +RpAtomic* iModelStreamRead(RwStream*); +RpAtomic* iModelFileNew(void* buffer, U32 size); RpAtomic* iModelFile_RWMultiAtomic(RpAtomic* model); void iModelSetMaterialTexture(RpAtomic* model, void* texture); void iModelResetMaterial(RpAtomic* model); +void iModelUnload(RpAtomic* userdata); S32 iModelCullPlusShadow(RpAtomic* model, RwMatrix* mat, xVec3* shadowVec, S32* shadowOutside); void iModelTagEval(RpAtomic* model, const xModelTag* tag, RwMatrixTag* mat, xVec3* dest); U32 iModelTagSetup(xModelTag* tag, RpAtomic* model, F32 x, F32 y, F32 z); From dcf5f3d080e6c8d9d29c3e353c657804972249eb Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Thu, 29 May 2025 23:43:04 -0400 Subject: [PATCH 2/5] build fix --- src/SB/Core/gc/iModel.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/SB/Core/gc/iModel.h b/src/SB/Core/gc/iModel.h index a686a5148..0279f0f16 100644 --- a/src/SB/Core/gc/iModel.h +++ b/src/SB/Core/gc/iModel.h @@ -7,12 +7,7 @@ #include #include #include - -struct RwMemory -{ - char* start; - U32 length; -}; +#include "zAssetTypes.h" void iModelInit(); U32 iModelNumBones(RpAtomic* model); From 25ef6ab561e644dcce3da37a047555619b110e75 Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Fri, 30 May 2025 09:29:15 -0400 Subject: [PATCH 3/5] True build fix --- src/SB/Core/gc/iModel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SB/Core/gc/iModel.h b/src/SB/Core/gc/iModel.h index 0279f0f16..4be240ae0 100644 --- a/src/SB/Core/gc/iModel.h +++ b/src/SB/Core/gc/iModel.h @@ -7,7 +7,6 @@ #include #include #include -#include "zAssetTypes.h" void iModelInit(); U32 iModelNumBones(RpAtomic* model); From 708c85b5804b230b934435b7e7b21ba9e3adfe34 Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Fri, 30 May 2025 20:13:57 -0400 Subject: [PATCH 4/5] Small work in iModel --- src/SB/Core/gc/iModel.cpp | 69 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/src/SB/Core/gc/iModel.cpp b/src/SB/Core/gc/iModel.cpp index 7f1ba36c1..ced252835 100644 --- a/src/SB/Core/gc/iModel.cpp +++ b/src/SB/Core/gc/iModel.cpp @@ -2,6 +2,9 @@ #include +RpLight* sEmptyDirectionalLight; +RpLight* sEmptyAmbientLight; + RwFrame* GetChildFrameHierarchy(RwFrame* frame, void* data) { RpHAnimHierarchy* hierarchy = RpHAnimFrameGetHierarchy(frame); @@ -25,6 +28,26 @@ void* GetHierarchy(RpAtomic* frame) return unk_0[0]; } +void iModelInit() +{ + RwFrame* frame; + RwRGBAReal black; + void* tempVoid = 0; + + for (S32 i = 0; i < 4; i++) + { + frame = (RwFrame*)RpLightCreate(i); + //black = frame; + RpLightSetColor(sEmptyDirectionalLight, &black); + frame = RwFrameCreate(); + _rwObjectHasFrameSetFrame(sEmptyDirectionalLight, frame); + + sEmptyAmbientLight = RpLightCreate(2); + + RpLightSetColor(sEmptyAmbientLight, &black); + } +} + RpAtomic* iModelFileNew(void* buffer, U32 size) { RwStream* rwmem; @@ -49,15 +72,59 @@ void iModelUnload(RpAtomic* userdata) if ((RpClump*)userdata != 0) { RwFrameGetRoot((RwFrame*)userdata); - RwFrameDestroyHierarchy(frame); userdata = 0; } + else + { + RwFrameDestroyHierarchy(frame); + } if (clump != 0) { RpClumpDestroy(clump); } } +RpAtomic* NextAtomicCallback(RpAtomic* atomic, void* data) +{ + // What? + + RpAtomic** nextModel; + + if (data != atomic) + { + atomic = 0; + return atomic; + } + if (data != 0) + { + return atomic; + } + + atomic = (RpAtomic*)data; + + return atomic; +} + +RpAtomic* iModelFile_RWMultiAtomic(RpAtomic* model) +{ + RpClump* clump; + RpAtomic* nextModel = 0; + RpAtomic* modelArray[2]; + + if (model == 0) + { + modelArray[0] = 0; + } + else + { + //modelArray[0] = (S32)model; + modelArray[0] = nextModel; + RpClumpForAllAtomics(model->clump, (RpAtomicCallBack)NextAtomicCallback(nextModel, NULL), + modelArray); + } + return model; +} + void iModelCacheAtomic(RpAtomic*) { } From ba4283d522e300df5c051cdc7d321bd528b68b41 Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Fri, 30 May 2025 23:13:25 -0400 Subject: [PATCH 5/5] VSCode cpp_properties update --- .vscode/c_cpp_properties.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 70f8d862b..ef5e1feb7 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,8 +9,9 @@ "includePath": [ "${workspaceFolder}/include", "${workspaceFolder}/include/bink", - "${workspaceFolder}/include/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include", - "${workspaceFolder}/include/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include", + "${workspaceFolder}/libs/PowerPC_EABI_Support/include", + "${workspaceFolder}/libs/PowerPC_EABI_Support/include/PowerPC_EABI_Support/MSL_C/MSL_Common", + "${workspaceFolder}/libs/PowerPC_EABI_Support/include/PowerPC_EABI_Support/MSL_C++", "${workspaceFolder}/include/inline", "${workspaceFolder}/include/rwsdk", "${workspaceFolder}/src/SB/Core/gc",