mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Add Lua function that returns the worldPosition of a scenegraph node
This commit is contained in:
@@ -25,8 +25,8 @@
|
||||
#ifndef __OPENSPACE_MODULE_BASE___RENDERABLEPRISM___H__
|
||||
#define __OPENSPACE_MODULE_BASE___RENDERABLEPRISM___H__
|
||||
|
||||
#include <openspace/properties/scalar/floatProperty.h>
|
||||
#include <openspace/properties/scalar/intProperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/scalar/intproperty.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
@@ -706,6 +706,13 @@ scripting::LuaLibrary Scene::luaLibrary() {
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"worldPosition",
|
||||
&luascriptfunctions::worldPosition,
|
||||
{},
|
||||
"string",
|
||||
"Returns the worldPosition of the scene graph node with the given string as identifier"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -902,4 +902,16 @@ int addInterestingTime(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int worldPosition(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::worldPosition");
|
||||
|
||||
std::string identifier = ghoul::lua::value<std::string>(L, 1, ghoul::lua::PopValue::Yes);
|
||||
|
||||
glm::dvec3 pos = global::renderEngine->scene()->sceneGraphNode(identifier)->worldPosition();
|
||||
ghoul::lua::push(L, pos);
|
||||
|
||||
ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack");
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace openspace::luascriptfunctions
|
||||
|
||||
Reference in New Issue
Block a user