Add a new Lua function to create debug axes for the current focus node

This commit is contained in:
Alexander Bock
2024-07-16 12:46:15 +02:00
parent acab685178
commit f10a2b1a22
2 changed files with 41 additions and 2 deletions

View File

@@ -37,6 +37,7 @@
#include <openspace/scripting/scriptengine.h>
#include <openspace/scripting/lualibrary.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/templatefactory.h>
@@ -63,13 +64,16 @@ std::vector<documentation::Documentation> 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")
}
};
}

View File

@@ -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