mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 04:31:08 -06:00
Only provide a single Lua function for creating debug axes
This commit is contained in:
@@ -161,8 +161,7 @@ scripting::LuaLibrary DebuggingModule::luaLibrary() const {
|
||||
codegen::lua::RenderCameraPath,
|
||||
codegen::lua::RemoveRenderedCameraPath,
|
||||
codegen::lua::RenderPathControlPoints,
|
||||
codegen::lua::RemovePathControlPoints,
|
||||
codegen::lua::AddCartesianAxes
|
||||
codegen::lua::RemovePathControlPoints
|
||||
},
|
||||
.scripts = {
|
||||
absPath("${MODULE_DEBUGGING}/scripts/axes.lua")
|
||||
|
||||
@@ -247,61 +247,6 @@ constexpr glm::vec3 OrientationLineColor = glm::vec3(0.0, 1.0, 1.0);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a set of Cartesian axes to the scene graph node identified by the first string, to
|
||||
* illustrate its local coordinate system. The second (optional) argument is a scale
|
||||
* value, in meters.
|
||||
*/
|
||||
[[codegen::luawrap]] void addCartesianAxes(std::string nodeIdentifier,
|
||||
std::optional<double> scale)
|
||||
{
|
||||
using namespace openspace;
|
||||
SceneGraphNode* n = global::renderEngine->scene()->sceneGraphNode(nodeIdentifier);
|
||||
if (!n) {
|
||||
throw ghoul::lua::LuaError("Unknown scene graph node: " + nodeIdentifier);
|
||||
}
|
||||
|
||||
if (!scale.has_value()) {
|
||||
scale = 2.0 * n->boundingSphere();
|
||||
if (n->boundingSphere() <= 0.0) {
|
||||
LWARNINGC(
|
||||
"Debugging: Cartesian Axes",
|
||||
"Using zero bounding sphere for scale of created axes. You need to set "
|
||||
"the scale manually for them to be visible"
|
||||
);
|
||||
scale = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string identifier = makeIdentifier(nodeIdentifier + "_AxesXYZ");
|
||||
const std::string& axes = "{"
|
||||
"Identifier = '" + identifier + "',"
|
||||
"Parent = '" + nodeIdentifier + "',"
|
||||
"Transform = { "
|
||||
"Scale = {"
|
||||
"Type = 'StaticScale',"
|
||||
"Scale = " + std::to_string(*scale) + ""
|
||||
"}"
|
||||
"},"
|
||||
"Renderable = {"
|
||||
"Type = 'RenderableCartesianAxes',"
|
||||
"Enabled = true,"
|
||||
"XColor = { 1.0, 0.0, 0.0 },"
|
||||
"YColor = { 0.0, 1.0, 0.0 },"
|
||||
"ZColor = { 0.0, 0.0, 1.0 }"
|
||||
"},"
|
||||
"GUI = {"
|
||||
"Name = '" + identifier + "',"
|
||||
"Path = '" + DebuggingGuiPath + "/Coordiante Systems'"
|
||||
"}"
|
||||
"}";
|
||||
|
||||
global::scriptEngine->queueScript(
|
||||
std::format("openspace.addSceneGraphNode({});", axes),
|
||||
scripting::ScriptEngine::ShouldBeSynchronized::Yes,
|
||||
scripting::ScriptEngine::ShouldSendToRemote::Yes
|
||||
);
|
||||
}
|
||||
|
||||
#include "debuggingmodule_lua_codegen.cpp"
|
||||
|
||||
|
||||
@@ -1,35 +1,47 @@
|
||||
openspace.debugging.documentation = {
|
||||
{
|
||||
Name = "createCoordinateAxes",
|
||||
Arguments = {},
|
||||
Arguments = {
|
||||
{ "nodeIdentifier", "String?" },
|
||||
{ "scale", "Number?" }
|
||||
},
|
||||
Documentation = [[
|
||||
Creates a new scene graph node that show the coordinate system used for the
|
||||
currently selected focus node.
|
||||
currently selected focus node. The first argument specifies the name of the
|
||||
scene graph node for which the axes should be added. If this parameter is
|
||||
not specified, the current focus node is used instead. The second argument
|
||||
provides the length of the coordinate axis in meters. If this value is not
|
||||
specified 2.5 times the interaction sphere of the selected node is used
|
||||
instead.
|
||||
]]
|
||||
}
|
||||
}
|
||||
|
||||
openspace.debugging.createCoordinateAxes = function ()
|
||||
local anchor = openspace.navigation.getNavigationState().Anchor
|
||||
local radius = openspace.propertyValue("Scene." .. anchor .. ".EvaluatedInteractionSphere")
|
||||
openspace.debugging.createCoordinateAxes = function (nodeIdentifier, scale)
|
||||
local node = nodeIdentifier or openspace.navigation.getNavigationState().Anchor
|
||||
local sphere = openspace.propertyValue("Scene." .. node .. ".EvaluatedInteractionSphere")
|
||||
if sphere == -1 then
|
||||
sphere = 1
|
||||
end
|
||||
local size = scale or sphere * 2.5
|
||||
|
||||
local node = {
|
||||
Identifier = anchor .. "_DebugAxes",
|
||||
Parent = anchor,
|
||||
local nodespec = {
|
||||
Identifier = node .. "_DebugAxes",
|
||||
Parent = node,
|
||||
Transform = {
|
||||
Scale = {
|
||||
Type = "StaticScale",
|
||||
Scale = radius * 2.5
|
||||
Scale = size
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableCartesianAxes"
|
||||
},
|
||||
GUI = {
|
||||
Name = anchor .. " (Debug Axes)",
|
||||
Path = openspace.propertyValue("Scene." .. anchor .. ".GuiPath")
|
||||
Name = node .. " (Debug Axes)",
|
||||
Path = openspace.propertyValue("Scene." .. node .. ".GuiPath")
|
||||
}
|
||||
}
|
||||
|
||||
openspace.addSceneGraphNode(node)
|
||||
openspace.addSceneGraphNode(nodespec)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user