Boston Posted December 21, 2023 Report Share Posted December 21, 2023 I am attempting to add a button to the Actor Viewer that will toggle between 2d and 3d projection: camera.SetPerspectiveProjection(2.f, 512.f, DEGTORAD(20.f)); found in source/tools/atlas/GameInterface/View.cpp sets the Field Of View, IE how strongly things are effected by perspective. float m_Distance; found on line 38 of source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ActorViewerTool.cpp sets the distance from the object being viewed to the camera, IE how large the object appears on screen. I want to modify both of these at the same time, but I can't for the life of me find a way to send data from source/tools/atlas/GameInterface/View.cpp to source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ActorViewerTool.cpp Any advice would be appreciated. Boston. 3 Quote Link to comment Share on other sites More sharing options...
Boston Posted December 22, 2023 Author Report Share Posted December 22, 2023 I might have to include more headers in view.cpp Then would I have to modify the makefile? I don't know what the system is with makefiles in 0 A.D. but I will have to learn it eventually. Boston Quote Link to comment Share on other sites More sharing options...
Boston Posted December 26, 2023 Author Report Share Posted December 26, 2023 m_ScenarioEditor.GetToolManager().GetCurrentToolName(); (added to Object.cpp) returns "ActorViewerTool", but m_ScenarioEditor.GetToolManager().GetCurrentTool(); returns type ObservablePtr<ITool>& and I cant get it to cast as ActorViewerTool& to modify it's variables. I tried passing data via a global variable, but the program wouldn't link. Boston. Quote Link to comment Share on other sites More sharing options...
Stan` Posted December 27, 2023 Report Share Posted December 27, 2023 Since it's a pointer (Ptr suffix) maybe you just need to dereference it ? Quote Link to comment Share on other sites More sharing options...
Boston Posted December 28, 2023 Author Report Share Posted December 28, 2023 The correct syntax is ObservablePtr<ITool>& Tool = p->m_ScenarioEditor.GetToolManager().GetCurrentTool(); ActorViewerTool *Tool1 = static_cast<ActorViewerTool*>(*Tool); Tool1->Toggle_3d(m_ViewerToggle3d); I get the same problem with the linker as I did trying to share a global variable. Quote Link to comment Share on other sites More sharing options...
Boston Posted December 28, 2023 Author Report Share Posted December 28, 2023 I don't know why passing the value by a global variable didn't work last time, but this time it did! Boston. 1 Quote Link to comment Share on other sites More sharing options...
Boston Posted December 28, 2023 Author Report Share Posted December 28, 2023 I've been fooling around with an orthogonal camera. It would be nice if it was more consistent with the perspective camera. This is as good a result as I can get, at least for today: Boston 1 Quote Link to comment Share on other sites More sharing options...
Boston Posted December 29, 2023 Author Report Share Posted December 29, 2023 I cant get the orthographic camera to work. Does anyone have code that works with the orthographic camera? Delenda Est, the mod for 0 A.D, uses a perspective camera with a narrow field of view. With a narrow field of view you have to place the camera further away to achieve the same level of "zoom" If the distance from the camera is too far, details like shadows are no longer drawn. Will look into fixing this, tomorrow. Boston 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted December 29, 2023 Report Share Posted December 29, 2023 8 hours ago, Boston said: If the distance from the camera is too far, details like shadows are no longer drawn. You just have to enable the whole map option for the shadows. The main problem with the narrow FOV/far zoom approach is that sound effects are now no longer the correct volume. The emitters are "far away", so that there needs to be a custom sound schema for such an approach. 1 Quote Link to comment Share on other sites More sharing options...
Boston Posted December 30, 2023 Author Report Share Posted December 30, 2023 They talk a bit about isometric projection in this topic: For future reference, this works: camera.SetOrthoProjection(-2.f, -512.f, 24.0f); And this doesn't work: camera.SetOrthoProjection(2.f, 512.f, 24.0f); Quote Link to comment Share on other sites More sharing options...
Boston Posted December 30, 2023 Author Report Share Posted December 30, 2023 (edited) I changed line 511 of source/graphics/CameraController.cpp from: m_Camera.SetPerspectiveProjection(m_ViewNear, m_ViewFar, m_ViewFOV); to: m_Camera.SetOrthoProjection(-m_ViewNear, -m_ViewFar, 256.f); this is the result: Sound works perfectly but I couldn't capture it with the screen capture software. Edited December 30, 2023 by Boston Typo 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted December 30, 2023 Report Share Posted December 30, 2023 Oh that's cool! @vladislavbelov You think this is the direction to go to add an orthographic option? 1 Quote Link to comment Share on other sites More sharing options...
vladislavbelov Posted December 30, 2023 Report Share Posted December 30, 2023 4 hours ago, Boston said: m_Camera.SetOrthoProjection(-m_ViewNear, -m_ViewFar, 256.f); m_Camera.SetOrthoProjection(m_ViewFar, m_ViewNear, 256.f); might also work. 3 hours ago, wowgetoffyourcellphone said: @vladislavbelov You think this is the direction to go to add an orthographic option? Yes, it's a start. Then we need: Add a separate camera controller to be able to configure the orthogonal mode properly Add an option in GUI Adjust zooming code with visible bounds to fit/to be similar to the perspective mode Choose camera position to have proper sounds on all zooms Check reflections and refractions Check shadows (w/ and w/o cover the whole map mode) Test regular and big screenshots and adjust their code if it doesn't work Think what do we need to do in Atlas (autoswitch to the perspective mode or something else) Test for z-fighting for all backends (OpenGL, OpenGL ARB, Vulcan) 2 Quote Link to comment Share on other sites More sharing options...
Boston Posted December 31, 2023 Author Report Share Posted December 31, 2023 15 minutes ago, vladislavbelov said: m_Camera.SetOrthoProjection(m_ViewFar, m_ViewNear, 256.f); might also work. No, I tried that when I was fooling around with the code. I don't know why the values have to be negated. Boston. Quote Link to comment Share on other sites More sharing options...
vladislavbelov Posted December 31, 2023 Report Share Posted December 31, 2023 30 minutes ago, Boston said: I don't know why the values have to be negated. Because we use it for GUI where the Z axis is inverted (and never thought to use it somewhere else before refactorings). 1 Quote Link to comment Share on other sites More sharing options...
Boston Posted December 31, 2023 Author Report Share Posted December 31, 2023 I can share data between: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ActorViewerTool.cpp and: source/tools/atlas/GameInterface/View.cpp fairly easily by declaring global variables in ActorViewerTool.cpp (and I know this is an ugly hack) But I cannot figure out how to trigger a call to ActorViewerTool::PostLookAt() from View.cpp, to update the display after modifying parameters. I cannot figure out how to trigger a call to camera.SetOrthoProjection(-2.f, -512.f, XXX); from ActorViewerTool.cpp (in order to change the scale of the image by clicking and dragging on it) 2 Quote Link to comment Share on other sites More sharing options...
Boston Posted January 2 Author Report Share Posted January 2 (edited) 2: is solved by making a call such as: POST_MESSAGE(SetViewParamI, (AtlasMessage::eRenderView::ACTOR, L"Set 2d scale", 512)); from within ActorViewerTool.cpp P.S. 1: might have to create the file ActorViewerTool.h Edited January 2 by Boston P.S. 1 Quote Link to comment Share on other sites More sharing options...
Boston Posted January 2 Author Report Share Posted January 2 I tried to declare a C like function in ActorViewerTool.cpp and call it from within View.cpp unfortunately, build/workspaces/gcc/atlas.make "includes" View.cpp and not ActorViewerTool.cpp I guess this is why I can't try to run code in ActorViewerTool.cpp from View.cpp without getting a linking error 1 Quote Link to comment Share on other sites More sharing options...
Boston Posted January 4 Author Report Share Posted January 4 I was able to implement POST_MESSAGE(SetViewParamF, (AtlasMessage::eRenderView::ACTOR, L"Set 2d scale", obj->m_Distance / 5)); instead of POST_MESSAGE(SetViewParamI, (AtlasMessage::eRenderView::ACTOR, L"Set 2d scale", obj->m_Distance / 5)); for smoother scrolling. I need to implement POST_MESSAGE(SetViewParamB, (ActorViewerTool, L"Set Toggle 3d", m_Toggle3d)); Then everything else should fall into place Boston 2 Quote Link to comment Share on other sites More sharing options...
Boston Posted January 4 Author Report Share Posted January 4 I was able to implement a C like function in source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ActorViewerTool.cpp and call it from source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp I'm pretty happy with the functionality but not so sure about coding this up "correctly" 2 Quote Link to comment Share on other sites More sharing options...
Boston Posted January 5 Author Report Share Posted January 5 I'd like to split ActorViewerTool.cpp into header and source and include ActorViewerTool.h in Object.cpp That would create a new dependency, so would I have to much around with Premake? I'm not sure what to do with lines 94 to 169 of ActorViewerTool.cpp, any advice? I'll soon be ready to submit a patch to Phabricator. What is the best place to download the current source for modifying and creating a patch? Boston. Quote Link to comment Share on other sites More sharing options...
hyperion Posted January 5 Report Share Posted January 5 33 minutes ago, Boston said: That would create a new dependency, so would I have to much around with Premake? Globbing is used for almost all of 0ad, so rerunning premake or update-workspace.sh should be all you need to do. 1 Quote Link to comment Share on other sites More sharing options...
Boston Posted January 9 Author Report Share Posted January 9 I implemented this code in Object.cpp: if (m_ViewerToggle3d == true) { p->m_ScenarioEditor.GetToolManager().GetCurrentTool()->OnCommand(_T("Set 3d"), NULL); } else { p->m_ScenarioEditor.GetToolManager().GetCurrentTool()->OnCommand(_T("Set 2d"), NULL); } I believe this is the "correct" solution. I've read that the best place to download the latest source is on SVN but I've also read that you have transitioned to hosting the latest source on GitHub, so which is it? Boston Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted January 9 Report Share Posted January 9 Each is a mirror of the other as far as I know. @Stan`? Quote Link to comment Share on other sites More sharing options...
vladislavbelov Posted January 9 Report Share Posted January 9 3 hours ago, Boston said: I've read that the best place to download the latest source is on SVN You can get the latest SVN here: https://svn.wildfiregames.com/public/ps/trunk/ 3 hours ago, Boston said: I've also read that you have transitioned to hosting the latest source on GitHub, so which is it? We haven't done transitioning yet, only mirror and test repositories. GitHub mirror is https://github.com/0ad/0ad. 2 hours ago, wowgetoffyourcellphone said: Each is a mirror of the other as far as I know. @Stan`? Yeah, currently all repositories except the SVN one are mirrors (or test mirrors). 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.