From 00c05aa80b2a5adb19fa17b6f767c2d32f10dc18 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 4 Mar 2024 12:54:25 -0500 Subject: [PATCH] Implement/match remaining Lego3DView functions (#623) --- LEGO1/lego/sources/3dmanager/lego3dview.cpp | 140 +++++--------------- LEGO1/lego/sources/3dmanager/lego3dview.h | 1 - LEGO1/realtime/orientableroi.cpp | 6 + LEGO1/realtime/orientableroi.h | 1 + LEGO1/viewmanager/viewmanager.cpp | 13 ++ LEGO1/viewmanager/viewmanager.h | 2 + 6 files changed, 58 insertions(+), 105 deletions(-) diff --git a/LEGO1/lego/sources/3dmanager/lego3dview.cpp b/LEGO1/lego/sources/3dmanager/lego3dview.cpp index 34f699d8..e895e378 100644 --- a/LEGO1/lego/sources/3dmanager/lego3dview.cpp +++ b/LEGO1/lego/sources/3dmanager/lego3dview.cpp @@ -73,68 +73,69 @@ void Lego3DView::Destroy() LegoView1::Destroy(); } -// STUB: LEGO1 0x100ab100 +// FUNCTION: LEGO1 0x100ab100 BOOL Lego3DView::Add(ViewROI& rROI) { - // assert(m_pViewManager); + assert(m_pViewManager); - // m_pViewManager->Add(rROI); + m_pViewManager->Add(&rROI); return TRUE; } -// STUB: LEGO1 0x100ab170 +// FUNCTION: LEGO1 0x100ab170 BOOL Lego3DView::Remove(ViewROI& rROI) { - // assert(m_pViewManager); + assert(m_pViewManager); - // m_pViewManager->Remove(rROI); + m_pViewManager->Remove(&rROI); - // if (m_pPointOfView == &rROI) { - // m_pPointOfView = 0; - // m_pViewManager->SetPOVSource(0); - // } + if (m_pPointOfView == &rROI) { + m_pPointOfView = 0; + m_pViewManager->SetPOVSource(0); + } return TRUE; } -// STUB: LEGO1 0x100ab1b0 +// FUNCTION: LEGO1 0x100ab1b0 BOOL Lego3DView::SetPointOfView(ViewROI& rROI) { - // Tgl::DoubleMatrix4 transformation; - // Tgl::Result result; + Tgl::FloatMatrix4 transformation; + Matrix4 mat(transformation); + Tgl::Result result; - // m_pPointOfView = &rROI; + m_pPointOfView = &rROI; - // assert(m_pViewManager); - // m_pViewManager->SetPOVSource(m_pPointOfView); + assert(m_pViewManager); + m_pViewManager->SetPOVSource(m_pPointOfView); - // assert(GetCamera()); - // SETMAT4(transformation, rROI.GetLocalTransform()); - // result = GetCamera()->SetTransformation(transformation); - // assert(Tgl::Succeeded(result)); + assert(GetCamera()); + rROI.GetLocalTransform(mat); + result = GetCamera()->SetTransformation(transformation); + assert(Tgl::Succeeded(result)); return TRUE; } -// STUB: LEGO1 0x100ab210 +// FUNCTION: LEGO1 0x100ab210 BOOL Lego3DView::Moved(ViewROI& rROI) { - // assert(m_pViewManager); + assert(m_pViewManager); - // m_pViewManager->Moved(rROI); + if (m_pPointOfView == &rROI) { + // move the camera + Tgl::FloatMatrix4 transformation; + Matrix4 mat(transformation); + Tgl::Result result; - // if (m_pPointOfView == &rROI) { - // // move the camera - // Tgl::DoubleMatrix4 transformation; - // Tgl::Result result; + assert(GetCamera()); - // assert(GetCamera()); - - // SETMAT4(transformation, rROI.GetLocalTransform()); - // result = GetCamera()->SetTransformation(transformation); - // assert(Tgl::Succeeded(result)); - // } + rROI.GetLocalTransform(mat); + result = GetCamera()->SetTransformation(transformation); + assert(Tgl::Succeeded(result)); + m_pViewManager->SetPOVSource(&rROI); + } return TRUE; } @@ -148,77 +149,8 @@ double Lego3DView::Render(double p_und) return m_previousRenderTime; } -/* -virtual Tgl::Result Tgl::View::Pick(unsigned long x, - unsigned long y, - const Tgl::Group** ppGroupsToPickFrom, - int groupsToPickFromCount, - const Tgl::Group**& rppPickedGroups, - int& rPickedGroupCount) = 0; -*/ - -// typedef std::map> Group2ROI; - -// STUB: LEGO1 0x100ab2b0 +// FUNCTION: LEGO1 0x100ab2b0 ViewROI* Lego3DView::Pick(unsigned long x, unsigned long y) { - // const ROIList& visible_rois = m_pViewManager->GetVisibleROIs(); - // int n_in = 0, n_out; - // const Tgl::Group** groups_in = new const Tgl::Group*[visible_rois.size()]; - // const Tgl::Group** groups_out = NULL; - // Group2ROI roi_map; - // ViewROI* viewROI = NULL; - - // // generate the list of groups to pick from which is all the geometry - // // groups of all the currently visible ROIs in the view manager. - // // Also, construct a mapping from each group back to it's ROI since that's - // // what we need to return. - // // - // WALK_STL_OBJECT(visible_rois, ROIList, vi) - // { - // ViewROI* vroi = (ViewROI*) (*vi); - // Tgl::Group* g = vroi->GetGeometry(); - // assert(g); - // groups_in[n_in++] = g; - // roi_map[g] = *vi; - // } - - // // perform the pick on our TglView passing the visible groups - // // - // Tgl::View* tglview = GetView(); - // assert(tglview); - // tglview->Pick(x, y, groups_in, n_in, groups_out, n_out); - - // // search the returned group hierarchy from the bottom for the - // // first group which was in groups_in. - // // - // for (int i = n_out - 1; i >= 0; i--) { - // const Tgl::Group* g = (const Tgl::Group*) (groups_out[i]); - // if (!g) // null entries means group node wasn't in groups_in - // continue; - // Group2ROI::iterator gi = roi_map.find(g); - // if (gi != roi_map.end()) { - // viewROI = (ViewROI*) ((*gi).second); - // break; - // } - // } - - // // delete the heap allocated arrays. - // // - // delete[] groups_in; - // if (groups_out) - // delete[] groups_out; - - return NULL; + return m_pViewManager->Pick(GetView(), x, y); } - -// double Lego3DView::GetTargetRenderingRate() const -// { -// double secondsAllowed; - -// assert(m_pViewManager); - -// secondsAllowed = m_pViewManager->GetSecondsAllowed(); - -// return (secondsAllowed ? (1 / secondsAllowed) : HUGE_VAL); -// } diff --git a/LEGO1/lego/sources/3dmanager/lego3dview.h b/LEGO1/lego/sources/3dmanager/lego3dview.h index cbbde4a8..74a9eb1c 100644 --- a/LEGO1/lego/sources/3dmanager/lego3dview.h +++ b/LEGO1/lego/sources/3dmanager/lego3dview.h @@ -29,7 +29,6 @@ class Lego3DView : public LegoView1 { ViewROI* GetPointOfView(); ViewManager* GetViewManager(); - // double GetTargetRenderingRate() const; private: ViewManager* m_pViewManager; // 0x88 diff --git a/LEGO1/realtime/orientableroi.cpp b/LEGO1/realtime/orientableroi.cpp index 62595da0..2acdb72d 100644 --- a/LEGO1/realtime/orientableroi.cpp +++ b/LEGO1/realtime/orientableroi.cpp @@ -40,6 +40,12 @@ void OrientableROI::WrappedVTable0x24(const Matrix4& p_transform) VTable0x24(p_transform); } +// STUB: LEGO1 0x100a50a0 +void OrientableROI::GetLocalTransform(Matrix4& p_transform) +{ + // TODO +} + // FUNCTION: LEGO1 0x100a58f0 void OrientableROI::FUN_100a58f0(const Matrix4& p_transform) { diff --git a/LEGO1/realtime/orientableroi.h b/LEGO1/realtime/orientableroi.h index 98c127d0..70db67cb 100644 --- a/LEGO1/realtime/orientableroi.h +++ b/LEGO1/realtime/orientableroi.h @@ -35,6 +35,7 @@ class OrientableROI : public ROI { void WrappedSetLocalTransform(const Matrix4& p_transform); void FUN_100a46b0(Matrix4& p_transform); void WrappedVTable0x24(const Matrix4& p_transform); + void GetLocalTransform(Matrix4& p_transform); void FUN_100a58f0(const Matrix4& p_transform); void FUN_100a5a30(const Vector3& p_world_velocity); diff --git a/LEGO1/viewmanager/viewmanager.cpp b/LEGO1/viewmanager/viewmanager.cpp index 6c10dc5c..93462bb9 100644 --- a/LEGO1/viewmanager/viewmanager.cpp +++ b/LEGO1/viewmanager/viewmanager.cpp @@ -32,6 +32,12 @@ ViewManager::~ViewManager() SetPOVSource(NULL); } +// STUB: LEGO1 0x100a6410 +void ViewManager::Remove(ViewROI* p_roi) +{ + // TODO +} + // FUNCTION: LEGO1 0x100a64d0 void ViewManager::RemoveAll(ViewROI* p_roi) { @@ -101,6 +107,13 @@ void ViewManager::SetPOVSource(const OrientableROI* point_of_view) } } +// STUB: LEGO1 0x100a6e00 +ViewROI* ViewManager::Pick(Tgl::View* p_view, unsigned long x, unsigned long y) +{ + // TODO + return NULL; +} + inline undefined4 SetD3DRM(IDirect3DRM2*& d3drm, Tgl::Renderer* pRenderer) { d3drm = ((TglImpl::RendererImpl*) pRenderer)->ImplementationData(); diff --git a/LEGO1/viewmanager/viewmanager.h b/LEGO1/viewmanager/viewmanager.h index 67f3df79..1d9103d3 100644 --- a/LEGO1/viewmanager/viewmanager.h +++ b/LEGO1/viewmanager/viewmanager.h @@ -21,9 +21,11 @@ class ViewManager { ViewManager(Tgl::Renderer* pRenderer, Tgl::Group* scene, const OrientableROI* point_of_view); virtual ~ViewManager(); + void Remove(ViewROI* p_roi); void RemoveAll(ViewROI* p_roi); void FUN_100a66a0(ViewROI* p_roi); void SetPOVSource(const OrientableROI* point_of_view); + ViewROI* Pick(Tgl::View* p_view, unsigned long x, unsigned long y); void SetResolution(int width, int height); void SetFrustrum(float fov, float front, float back); void Update(float p_previousRenderTime, float p_und2);