diff --git a/LEGO1/tgl/d3drm/device.cpp b/LEGO1/tgl/d3drm/device.cpp index b991d41750..a1c7b0c880 100644 --- a/LEGO1/tgl/d3drm/device.cpp +++ b/LEGO1/tgl/d3drm/device.cpp @@ -49,28 +49,23 @@ Result DeviceImpl::SetDither(int dither) return ResultVal(m_data->SetDither(dither)); } -// Probably wrong, not sure what's going on in this method. // FUNCTION: LEGO1 0x100a2ce0 -void DeviceImpl::InitFromD3DDevice(Device*) +void DeviceImpl::HandleActivate(WORD wParam) { // Device argument is intentionally unused. IDirect3DRMWinDevice* winDevice; if (ResultVal(m_data->QueryInterface(IID_IDirect3DRMWinDevice, (LPVOID*) &winDevice))) { - m_data->InitFromD3D((LPDIRECT3D) &winDevice, (LPDIRECT3DDEVICE) m_data); + winDevice->HandleActivate(wParam); winDevice->Release(); } } -// Really don't know what's going on here. Seems it will call down to Init -// but the decomp suggests it otherwise looks the same as InitFromD3D but Init -// takes widly different parameters. // FUNCTION: LEGO1 0x100a2d20 -void DeviceImpl::InitFromWindowsDevice(Device*) +void DeviceImpl::HandlePaint(HDC p_dc) { - // Device argument is intentionally unused. IDirect3DRMWinDevice* winDevice; if (SUCCEEDED(m_data->QueryInterface(IID_IDirect3DRMWinDevice, (LPVOID*) &winDevice))) { - // m_data->Init(??); + winDevice->HandlePaint(p_dc); winDevice->Release(); } } @@ -80,3 +75,6 @@ Result DeviceImpl::Update() { return ResultVal(m_data->Update()); } + +// GLOBAL: LEGO1 0x100dd1d0 +// IID_IDirect3DRMWinDevice diff --git a/LEGO1/tgl/d3drm/group.cpp b/LEGO1/tgl/d3drm/group.cpp index 854788b8ba..912cc13766 100644 --- a/LEGO1/tgl/d3drm/group.cpp +++ b/LEGO1/tgl/d3drm/group.cpp @@ -128,8 +128,67 @@ Result GroupImpl::RemoveAll() return result; } -// STUB: LEGO1 0x100a3540 -Result GroupImpl::Unknown() +// FUNCTION: LEGO1 0x100a3540 +Result GroupImpl::Bounds(D3DVECTOR* p_min, D3DVECTOR* p_max) { - return Error; + D3DRMBOX size; + IDirect3DRMFrame2* frame = m_data; + + size.min.x = 88888.f; + size.min.y = 88888.f; + size.min.z = 88888.f; + size.max.x = -88888.f; + size.max.y = -88888.f; + size.max.z = -88888.f; + + IDirect3DRMVisualArray* visuals; + Result result = (Result) SUCCEEDED(frame->GetVisuals(&visuals)); + + if (result == Success) { + int i; + for (i = 0; i < (int) visuals->GetSize(); i++) { + IDirect3DRMVisual* visual; + visuals->GetElement(i, &visual); + IDirect3DRMMesh* mesh; + /* + * BUG: should be: + * visual->QueryInterface(IID_IDirect3DRMMesh, (void**)&mesh)); + */ + result = (Result) SUCCEEDED(visual->QueryInterface(IID_IDirect3DRMMeshBuilder, (void**) &mesh)); + + if (result == Success) { + D3DRMBOX box; + result = (Result) SUCCEEDED(mesh->GetBox(&box)); + + if (size.max.y < box.max.y) { + size.max.y = box.max.y; + } + if (size.max.z < box.max.z) { + size.max.z = box.max.z; + } + if (box.min.x < size.min.x) { + size.min.x = box.min.x; + } + if (box.min.y < size.min.y) { + size.min.y = box.min.y; + } + if (box.min.z < size.min.z) { + size.min.z = box.min.z; + } + if (size.max.x < box.max.x) { + size.max.x = box.max.x; + } + + mesh->Release(); + } + + visual->Release(); + } + + visuals->Release(); + } + + *p_min = size.min; + *p_max = size.max; + return result; } diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index 14acce2a4b..a2998c7ad3 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -145,8 +145,8 @@ class DeviceImpl : public Device { // vtable+0x20 Result Update() override; - void InitFromD3DDevice(Device*) override; - void InitFromWindowsDevice(Device*) override; + void HandleActivate(WORD) override; + void HandlePaint(HDC) override; IDirect3DRMDevice2* ImplementationData() const { return m_data; } void SetImplementationData(IDirect3DRMDevice2* device) { m_data = device; } @@ -335,7 +335,7 @@ class GroupImpl : public Group { Result RemoveAll() override; // vtable+0x30 - Result Unknown() override; + Result Bounds(D3DVECTOR* p_min, D3DVECTOR* p_max) override; IDirect3DRMFrame2* ImplementationData() const { return m_data; } @@ -545,4 +545,7 @@ inline D3DRMMATRIX4D* Translate(FloatMatrix4& tglMatrix4x4, D3DRMMATRIX4D& rD3DR // SYNTHETIC: LEGO1 0x100a3d80 // TglImpl::MeshImpl::`scalar deleting destructor' +// GLOBAL: LEGO1 0x100dd1e0 +// IID_IDirect3DRMMeshBuilder + } /* namespace TglImpl */ diff --git a/LEGO1/tgl/tgl.h b/LEGO1/tgl/tgl.h index 4c29ed1f65..34b1d5ee4b 100644 --- a/LEGO1/tgl/tgl.h +++ b/LEGO1/tgl/tgl.h @@ -171,8 +171,8 @@ class Device : public Object { // vtable+0x20 virtual Result Update() = 0; - virtual void InitFromD3DDevice(Device*) = 0; - virtual void InitFromWindowsDevice(Device*) = 0; + virtual void HandleActivate(WORD) = 0; + virtual void HandlePaint(HDC) = 0; // SYNTHETIC: LEGO1 0x100a2350 // Tgl::Device::~Device @@ -305,7 +305,7 @@ class Group : public Object { // This is TransformLocalToWorld in the leak, however it seems // to have been replaced by something else in the shipped code. - virtual Result Unknown() = 0; + virtual Result Bounds(D3DVECTOR*, D3DVECTOR*) = 0; // SYNTHETIC: LEGO1 0x100a2510 // Tgl::Group::~Group