diff --git a/apps/SceneViewer3D/_DSceneViewerMain.cpp b/apps/SceneViewer3D/_DSceneViewerMain.cpp index 4e65081369..0e571cad18 100644 --- a/apps/SceneViewer3D/_DSceneViewerMain.cpp +++ b/apps/SceneViewer3D/_DSceneViewerMain.cpp @@ -320,6 +320,7 @@ const long _DSceneViewerFrame::ID_BUTTON5 = wxNewId(); const long _DSceneViewerFrame::ID_STATICLINE2 = wxNewId(); const long _DSceneViewerFrame::ID_BUTTON6 = wxNewId(); const long _DSceneViewerFrame::ID_BUTTON7 = wxNewId(); +const long _DSceneViewerFrame::ID_BUTTON_SHADOWS = wxNewId(); const long _DSceneViewerFrame::ID_BUTTON8 = wxNewId(); const long _DSceneViewerFrame::ID_BUTTON9 = wxNewId(); const long _DSceneViewerFrame::ID_STATICLINE3 = wxNewId(); @@ -480,6 +481,17 @@ _DSceneViewerFrame::_DSceneViewerFrame(wxWindow* parent, wxWindowID id) : maxv(0 wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_TICK_MARK")), wxART_TOOLBAR)); btnOrtho->SetMargins(wxSize(5, 5)); FlexGridSizer2->Add(btnOrtho, 1, wxEXPAND, 1); + + btnShadows = new wxCustomButton( + this, ID_BUTTON_SHADOWS, _(" Shadows "), + wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_TICK_MARK")), wxART_TOOLBAR), + wxDefaultPosition, wxDefaultSize, wxCUSTBUT_TOGGLE | wxCUSTBUT_BOTTOM, wxDefaultValidator, + _T("ID_BUTTON_SHADOWS")); + btnShadows->SetBitmapDisabled( + wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_TICK_MARK")), wxART_TOOLBAR)); + btnShadows->SetMargins(wxSize(5, 5)); + FlexGridSizer2->Add(btnShadows, 1, wxEXPAND, 1); + btnAutoplay = new wxCustomButton( this, ID_BUTTON8, _(" Autoplay "), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_REMOVABLE")), wxART_TOOLBAR), @@ -657,6 +669,7 @@ _DSceneViewerFrame::_DSceneViewerFrame(wxWindow* parent, wxWindowID id) : maxv(0 Bind(wxEVT_BUTTON, &svf::OnReload, this, ID_BUTTON5); Bind(wxEVT_BUTTON, &svf::OnMenuOptions, this, ID_BUTTON6); Bind(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, &svf::OnbtnOrthoClicked, this, ID_BUTTON7); + Bind(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, &svf::OnbtnShadowsClicked, this, ID_BUTTON_SHADOWS); Bind(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, &svf::OnbtnAutoplayClicked, this, ID_BUTTON8); Bind(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, &svf::OnBtnRecordClicked, this, ID_BUTTON9); Bind(wxEVT_BUTTON, &svf::OnAbout, this, ID_BUTTON10); @@ -923,13 +936,7 @@ void _DSceneViewerFrame::OntimLoadFileCmdLineTrigger(wxTimerEvent&) } // Enable shadows? - if (0) - { - if (auto vw = m_canvas->getOpenGLSceneRef()->getViewport(); vw) - { - vw->enableShadowCasting(); - } - } + applyShadowsOptions(); } void _DSceneViewerFrame::OnbtnAutoplayClicked(wxCommandEvent& event) @@ -1048,6 +1055,24 @@ void _DSceneViewerFrame::OnbtnOrthoClicked(wxCommandEvent& event) m_canvas->Refresh(false); } +void _DSceneViewerFrame::OnbtnShadowsClicked(wxCommandEvent& event) +{ + applyShadowsOptions(); + m_canvas->Refresh(false); +} + +void _DSceneViewerFrame::applyShadowsOptions() +{ + bool shadowsEnabled = btnShadows->GetValue(); + auto scene = m_canvas->getOpenGLSceneRef(); + if (!scene) return; + + auto vw = scene->getViewport(); + if (!vw) return; + + vw->enableShadowCasting(shadowsEnabled); +} + void _DSceneViewerFrame::OnReload(wxCommandEvent& event) { if (fileExists(loadedFileName)) loadFromFile(loadedFileName); diff --git a/apps/SceneViewer3D/_DSceneViewerMain.h b/apps/SceneViewer3D/_DSceneViewerMain.h index 3fc110ab8a..23dfae6d9d 100644 --- a/apps/SceneViewer3D/_DSceneViewerMain.h +++ b/apps/SceneViewer3D/_DSceneViewerMain.h @@ -76,6 +76,7 @@ class _DSceneViewerFrame : public wxFrame void OnClose(wxCloseEvent& event); void OnBtnRecordClicked(wxCommandEvent& event); void OnbtnOrthoClicked(wxCommandEvent& event); + void OnbtnShadowsClicked(wxCommandEvent& event); void OnReload(wxCommandEvent& event); void OnInsert3DS(wxCommandEvent& event); void OnMenuSave(wxCommandEvent& event); @@ -104,6 +105,8 @@ class _DSceneViewerFrame : public wxFrame void OntimAutoplay(wxTimerEvent& event); + void applyShadowsOptions(); + //(*Identifiers(_DSceneViewerFrame) static const long ID_BUTTON1; static const long ID_BUTTON2; @@ -114,6 +117,7 @@ class _DSceneViewerFrame : public wxFrame static const long ID_STATICLINE2; static const long ID_BUTTON6; static const long ID_BUTTON7; + static const long ID_BUTTON_SHADOWS; static const long ID_BUTTON8; static const long ID_BUTTON9; static const long ID_STATICLINE3; @@ -187,6 +191,7 @@ class _DSceneViewerFrame : public wxFrame wxMenuItem* mnuSelectionScale; wxMenuItem* mnuImportLAS; wxCustomButton* btnOrtho; + wxCustomButton* btnShadows; wxStatusBar* StatusBar1; wxMenuItem* MenuItem6; wxStaticLine* StaticLine3; diff --git a/doc/source/doxygen-docs/changelog.md b/doc/source/doxygen-docs/changelog.md index 35c6c45efb..4c78c14b95 100644 --- a/doc/source/doxygen-docs/changelog.md +++ b/doc/source/doxygen-docs/changelog.md @@ -1,6 +1,8 @@ \page changelog Change Log # Version 2.14.1: UNRELEASED +- Changes in apps: + - SceneViewer3D: New button to enable shadow casting. - Changes in libraries: - \ref mrpt_opengl_grp: - New method mrpt::opengl::CAssimpModel::split_triangles_rendering_bbox() to enable a new feature in Assimp 3D models: splitting into smaller triangle sets for correct z-ordering of semitransparent objects; e.g. required for trees with masked leaves.