mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 22:39:04 -06:00
Add new Lua functions to get a list of all scene graph nodes, scene graph nodes by renderable type (closes #2558), and all screenspace renderables
This commit is contained in:
@@ -860,6 +860,9 @@ scripting::LuaLibrary Scene::luaLibrary() {
|
||||
codegen::lua::RemoveSceneGraphNode,
|
||||
codegen::lua::RemoveSceneGraphNodesFromRegex,
|
||||
codegen::lua::HasSceneGraphNode,
|
||||
codegen::lua::SceneGraphNodes,
|
||||
codegen::lua::NodeByRenderableType,
|
||||
codegen::lua::ScreenSpaceRenderables,
|
||||
codegen::lua::AddInterestingTime,
|
||||
codegen::lua::WorldPosition,
|
||||
codegen::lua::WorldRotation,
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
#include <openspace/properties/vector/vec2property.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
#include <openspace/properties/vector/vec4property.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
@@ -877,6 +879,51 @@ namespace {
|
||||
return node != nullptr;
|
||||
}
|
||||
|
||||
// Returns a list of all scene graph nodes in the scene
|
||||
[[codegen::luawrap]] std::vector<std::string> sceneGraphNodes() {
|
||||
using namespace openspace;
|
||||
|
||||
const std::vector<SceneGraphNode*>& nodes =
|
||||
global::renderEngine->scene()->allSceneGraphNodes();
|
||||
std::vector<std::string> res;
|
||||
res.reserve(nodes.size());
|
||||
for (SceneGraphNode* node : nodes) {
|
||||
res.push_back(node->identifier());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Returns a list of all scene graph nodes in the scene that have a renderable of the
|
||||
// specific type
|
||||
[[codegen::luawrap]] std::vector<std::string> nodeByRenderableType(std::string type) {
|
||||
using namespace openspace;
|
||||
|
||||
const std::vector<SceneGraphNode*>& nodes =
|
||||
global::renderEngine->scene()->allSceneGraphNodes();
|
||||
std::vector<std::string> res;
|
||||
for (SceneGraphNode* node : nodes) {
|
||||
Renderable* renderable = node->renderable();
|
||||
if (renderable && renderable->typeAsString() == type) {
|
||||
res.push_back(node->identifier());
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Returns a list of all screen-space renderables
|
||||
[[codegen::luawrap]] std::vector<std::string> screenSpaceRenderables() {
|
||||
using namespace openspace;
|
||||
|
||||
const std::vector<ScreenSpaceRenderable*>& ssrs =
|
||||
global::renderEngine->screenSpaceRenderables();
|
||||
std::vector<std::string> res;
|
||||
res.reserve(ssrs.size());
|
||||
for (ScreenSpaceRenderable* ssr : ssrs) {
|
||||
res.push_back(ssr->identifier());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an interesting time to the current scene. The first argument is the name of the
|
||||
* time and the second argument is the time itself in the format YYYY-MM-DDThh:mm:ss.uuu
|
||||
|
||||
Reference in New Issue
Block a user