From c9e599050dfb699fc84d4c8d004f2be1038ec294 Mon Sep 17 00:00:00 2001 From: krystalgamer Date: Tue, 17 Sep 2024 18:43:01 +0200 Subject: [PATCH] PCGfx_RenderModelPreview --- PCGfx.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++---- camera.cpp | 2 +- camera.h | 1 + ps2m3d.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- ps2m3d.h | 12 ++++++++++++ 5 files changed, 110 insertions(+), 6 deletions(-) diff --git a/PCGfx.cpp b/PCGfx.cpp index 87c9fed..c6615cb 100644 --- a/PCGfx.cpp +++ b/PCGfx.cpp @@ -3,6 +3,10 @@ #include "DXsound.h" #include "SpideyDX.h" #include "DXinit.h" +#include "camera.h" +#include "mess.h" +#include "ps2m3d.h" +#include "pshell.h" #include @@ -108,7 +112,7 @@ void PCGfx_DrawTexture2D(i32,i32,i32,float,u32,u32,float) // @Ok // @Matching // @Note powerpc has fps counter here and fog level -void PCGfx_EndScene(i32 a1) +INLINE void PCGfx_EndScene(i32 a1) { if (gSceneRelated) { @@ -253,10 +257,47 @@ void PCGfx_RenderInit(float a1, float a2, float a3) gRenderInitTwo[1] = gRenderInitTwo[0] / 4096.0f; } -// @SMALLTODO -void PCGfx_RenderModelPreview(void *,char const *,i32) +// @NotOk +// third parameter of rendesetup seems to be useless but also DB related +void PCGfx_RenderModelPreview( + void* a1, + char const* a2, + i32 a3) { - printf("PCGfx_RenderModelPreview(void *,char const *,i32)"); + char v3[128]; + + M3dMaths_RotMatrixYXZ(&gMikeCamera[0].Angles, &gMikeCamera[0].Transform); + TransMatrix(&gMikeCamera[0].Transform, &gMikeCamera[0].Position); + PCGfx_BeginScene(1u, -1); + + // @FIXME: third param seems to be ignored + M3d_RenderSetup(&gMikeCamera[0], &gViewport, 0); + M3d_Render(a1); + M3d_RenderCleanup(); + Mess_SetSort(4095); + PShell_SmallFont(); + Mess_SetRGB(0xFFu, 0xFFu, 0xFFu, 0); + Mess_SetRGBBottom(0xFFu, 255, 255); + Mess_SetShadowRGB(0xFFu); + Mess_SetTextJustify(1); + + sprintf(v3, "PSX: %s", a2); + Mess_DrawText(20, 20, v3, 0, 0x1000u); + sprintf(v3, "IDX: %i", a3); + Mess_DrawText(220, 20, v3, 0, 0x1000u); + sprintf(v3, "CAM: %i %i %i", gMikeCamera[0].Position.vx, gMikeCamera[0].Position.vy, gMikeCamera[0].Position.vz); + Mess_DrawText(20, 45, v3, 0, 0x1000u); + + CItem* pItem = static_cast(a1); + sprintf( + v3, + "ITM: %i %i %i", + pItem->mPos.vx >> 12, + pItem->mPos.vy >> 12, + pItem->mPos.vz >> 12); + Mess_DrawText(220, 45, v3, 0, 0x1000u); + + PCGfx_EndScene(1); } EXPORT i8 gPcGfxBrightnessValues[256]; diff --git a/camera.cpp b/camera.cpp index 87888f0..5186eb2 100644 --- a/camera.cpp +++ b/camera.cpp @@ -7,7 +7,7 @@ SViewport gViewport; CCamera *CameraList; EXPORT i32 NumCameras; -EXPORT SCamera gMikeCamera[2]; +SCamera gMikeCamera[2]; // @Ok // @Test diff --git a/camera.h b/camera.h index f49c08c..d0e4a2a 100644 --- a/camera.h +++ b/camera.h @@ -208,6 +208,7 @@ public: EXPORT __int16 CalcTheta(__int16, __int16); EXPORT extern CCamera *CameraList; EXPORT extern SViewport gViewport; +EXPORT extern SCamera gMikeCamera[2]; void validate_CCamera(void); void validate_SCamera(void); diff --git a/ps2m3d.cpp b/ps2m3d.cpp index 4e078c3..1479aa0 100644 --- a/ps2m3d.cpp +++ b/ps2m3d.cpp @@ -8,4 +8,54 @@ void M3d_BuildTransform(CSuper* a){ // @BIGTODO void M3d_Render(void*) -{} +{ + printf("void M3d_Render(void*)"); +} + +// @MEDIUMTODO +void DCModel_RenderModel(SModel const *,DCModelData *,matrix4x4 const *,void const *) +{ + printf("DCModel_RenderModel(SModel const *,DCModelData *,matrix4x4 const *,void const *)"); +} + +// @MEDIUMTODO +void DC_PSXModel_RenderModel(SModel const *,matrix4x4 const *,void const *,DCModelData *) +{ + printf("DC_PSXModel_RenderModel(SModel const *,matrix4x4 const *,void const *,DCModelData *)"); +} + +// @MEDIUMTODO +void M3d_PreprocessPulsingColours(i32) +{ + printf("M3d_PreprocessPulsingColours(i32)"); +} + +// @MEDIUMTODO +void M3d_PreprocessWibblyTextures(i32) +{ + printf("M3d_PreprocessWibblyTextures(i32)"); +} + +// @MEDIUMTODO +void M3d_RenderBackground(void *) +{ + printf("M3d_RenderBackground(void *)"); +} + +// @MEDIUMTODO +void M3d_RenderCleanup(void) +{ + printf("M3d_RenderCleanup(void)"); +} + +// @MEDIUMTODO +void M3d_RenderSetup(SCamera *,SViewport *,u32 *) +{ + printf("M3d_RenderSetup(SCamera *,SViewport *,u32 *)"); +} + +// @MEDIUMTODO +void RenderSuperItem(CItem *,bool) +{ + printf("RenderSuperItem(CItem *,bool)"); +} diff --git a/ps2m3d.h b/ps2m3d.h index 080898d..ada36d8 100644 --- a/ps2m3d.h +++ b/ps2m3d.h @@ -5,8 +5,20 @@ #include "export.h" #include "ob.h" +#include "camera.h" +#include "dcmodel.h" + +struct matrix4x4; EXPORT void M3d_BuildTransform(CSuper*); EXPORT void M3d_Render(void*); +EXPORT void DCModel_RenderModel(SModel const *,DCModelData *,matrix4x4 const *,void const *); +EXPORT void DC_PSXModel_RenderModel(SModel const *,matrix4x4 const *,void const *,DCModelData *); +EXPORT void M3d_PreprocessPulsingColours(i32); +EXPORT void M3d_PreprocessWibblyTextures(i32); +EXPORT void M3d_RenderBackground(void *); +EXPORT void M3d_RenderCleanup(void); +EXPORT void M3d_RenderSetup(SCamera *,SViewport *,u32 *); +EXPORT void RenderSuperItem(CItem *,bool); #endif