From f10a2b1a22866b386d9c15b0ee9a2c169031ed23 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 16 Jul 2024 12:46:15 +0200 Subject: [PATCH] Add a new Lua function to create debug axes for the current focus node --- modules/debugging/debuggingmodule.cpp | 8 ++++-- modules/debugging/scripts/axes.lua | 35 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 modules/debugging/scripts/axes.lua diff --git a/modules/debugging/debuggingmodule.cpp b/modules/debugging/debuggingmodule.cpp index 87d81a8663..93add8f04f 100644 --- a/modules/debugging/debuggingmodule.cpp +++ b/modules/debugging/debuggingmodule.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -63,13 +64,16 @@ std::vector DebuggingModule::documentations() cons scripting::LuaLibrary DebuggingModule::luaLibrary() const { return { - "debugging", - { + .name = "debugging", + .functions = { codegen::lua::RenderCameraPath, codegen::lua::RemoveRenderedCameraPath, codegen::lua::RenderPathControlPoints, codegen::lua::RemovePathControlPoints, codegen::lua::AddCartesianAxes + }, + .scripts = { + absPath("${MODULE_DEBUGGING}/scripts/axes.lua") } }; } diff --git a/modules/debugging/scripts/axes.lua b/modules/debugging/scripts/axes.lua new file mode 100644 index 0000000000..4fa5dac1f1 --- /dev/null +++ b/modules/debugging/scripts/axes.lua @@ -0,0 +1,35 @@ +openspace.debugging.documentation = { + { + Name = "createCoordinateAxes", + Arguments = {}, + Documentation = [[ + Creates a new scene graph node that show the coordinate system used for the + currently selected focus node. + ]] + } +} + +openspace.debugging.createCoordinateAxes = function () + local anchor = openspace.navigation.getNavigationState().Anchor + local radius = openspace.propertyValue("Scene." .. anchor .. ".EvaluatedInteractionSphere") + + local node = { + Identifier = anchor .. "_DebugAxes", + Parent = anchor, + Transform = { + Scale = { + Type = "StaticScale", + Scale = radius * 2.5 + } + }, + Renderable = { + Type = "RenderableCartesianAxes" + }, + GUI = { + Name = anchor .. " (Debug Axes)", + Path = openspace.propertyValue("Scene." .. anchor .. ".GuiPath") + } + } + + openspace.addSceneGraphNode(node) +end