From a18bc67d2c34ade11b2e5f084a9f52d5ff5ce510 Mon Sep 17 00:00:00 2001 From: disinvite Date: Thu, 17 Apr 2025 16:15:07 -0400 Subject: [PATCH] SetShadingModel functions --- LEGO1/tgl/d3drm/device.cpp | 16 ++++++++++++---- LEGO1/tgl/d3drm/impl.h | 1 + LEGO1/tgl/d3drm/mesh.cpp | 31 ++++++++++++------------------- LEGO1/tgl/d3drm/meshbuilder.cpp | 19 +++++++++++++++---- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/LEGO1/tgl/d3drm/device.cpp b/LEGO1/tgl/d3drm/device.cpp index 82e96730..2d17a5c9 100644 --- a/LEGO1/tgl/d3drm/device.cpp +++ b/LEGO1/tgl/d3drm/device.cpp @@ -1,5 +1,6 @@ #include "impl.h" +#include #include using namespace TglImpl; @@ -29,13 +30,20 @@ Result DeviceImpl::SetColorModel(ColorModel) return Success; } +// FUNCTION: BETA10 0x1016e020 +inline Result DeviceSetShadingModel(IDirect3DRMDevice2* pDevice, ShadingModel model) +{ + D3DRMRENDERQUALITY renderQuality = Translate(model); + return ResultVal(pDevice->SetQuality(renderQuality)); +} + // FUNCTION: LEGO1 0x100a2c30 +// FUNCTION: BETA10 0x1016dfc0 Result DeviceImpl::SetShadingModel(ShadingModel model) { - // Doesn't match well even though we know this is exactly - // the original code thanks to the jump table. - D3DRMRENDERQUALITY renderQuality = Translate(model); - return ResultVal(m_data->SetQuality(renderQuality)); + assert(m_data); + + return DeviceSetShadingModel(m_data, model); } // FUNCTION: LEGO1 0x100a2ca0 diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index b1aa95dc..b7ab827e 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -603,6 +603,7 @@ void TextureImpl::Destroy() } // Translation helpers +// FUNCTION: BETA10 0x1016fc40 inline D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel) { D3DRMRENDERQUALITY renderQuality; diff --git a/LEGO1/tgl/d3drm/mesh.cpp b/LEGO1/tgl/d3drm/mesh.cpp index b5e66922..518ac921 100644 --- a/LEGO1/tgl/d3drm/mesh.cpp +++ b/LEGO1/tgl/d3drm/mesh.cpp @@ -1,5 +1,7 @@ #include "impl.h" +#include + using namespace TglImpl; DECOMP_SIZE_ASSERT(D3DRMVERTEX, 0x24); @@ -49,28 +51,19 @@ Result MeshImpl::SetTextureMappingMode(TextureMappingMode mode) } } +// FUNCTION: BETA10 0x10170750 +inline Result MeshSetShadingModel(MeshImpl::MeshData* pMesh, ShadingModel model) +{ + D3DRMRENDERQUALITY mode = Translate(model); + return ResultVal(pMesh->groupMesh->SetGroupQuality(pMesh->groupIndex, mode)); +} + // FUNCTION: LEGO1 0x100a3fc0 +// FUNCTION: BETA10 0x101706f0 Result MeshImpl::SetShadingModel(ShadingModel model) { - D3DRMRENDERQUALITY mode; - switch (model) { - case Wireframe: - mode = D3DRMRENDER_WIREFRAME; - break; - case UnlitFlat: - mode = D3DRMRENDER_UNLITFLAT; - break; - case Flat: - mode = D3DRMRENDER_FLAT; - break; - case Gouraud: - mode = D3DRMRENDER_GOURAUD; - break; - case Phong: - mode = D3DRMRENDER_PHONG; - break; - } - return ResultVal(m_data->groupMesh->SetGroupQuality(m_data->groupIndex, mode)); + assert(m_data); + return MeshSetShadingModel(m_data, model); } // FUNCTION: LEGO1 0x100a4030 diff --git a/LEGO1/tgl/d3drm/meshbuilder.cpp b/LEGO1/tgl/d3drm/meshbuilder.cpp index 4db21f0d..be7119f3 100644 --- a/LEGO1/tgl/d3drm/meshbuilder.cpp +++ b/LEGO1/tgl/d3drm/meshbuilder.cpp @@ -1,5 +1,7 @@ #include "impl.h" +#include + using namespace TglImpl; DECOMP_SIZE_ASSERT(MeshBuilder, 0x04); @@ -159,12 +161,12 @@ inline Result MeshBuilderImpl::CreateMeshImpl( ); } -// FUNCTION: LEGO1 0x100a3ae0 -Result MeshBuilderImpl::GetBoundingBox(float min[3], float max[3]) const +// FUNCTION: BETA10 0x1016e060 +inline Result MeshBuilderGetBoundingBox(IDirect3DRMMesh* pMesh, float min[3], float max[3]) { D3DRMBOX box; - Result result = ResultVal(m_data->GetBox(&box)); - if (result == Success) { + Result result = ResultVal(pMesh->GetBox(&box)); + if (Succeeded(result)) { min[0] = box.min.x; min[1] = box.min.y; min[2] = box.min.z; @@ -175,6 +177,15 @@ Result MeshBuilderImpl::GetBoundingBox(float min[3], float max[3]) const return result; } +// FUNCTION: LEGO1 0x100a3ae0 +// FUNCTION: BETA10 0x1016ce00 +Result MeshBuilderImpl::GetBoundingBox(float min[3], float max[3]) const +{ + assert(m_data); + + return MeshBuilderGetBoundingBox(m_data, min, max); +} + // FUNCTION: LEGO1 0x100a3b40 MeshBuilder* MeshBuilderImpl::Clone() {