mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-18 09:58:59 -05:00
Added accessors for rendering control points, for debugging
This commit is contained in:
@@ -240,6 +240,8 @@ void AutoNavigationHandler::stopPath() {
|
||||
_isPlaying = false;
|
||||
}
|
||||
|
||||
// TODO: remove when not needed
|
||||
// Created for debugging
|
||||
std::vector<glm::dvec3> AutoNavigationHandler::getCurvePositions(int nPerSegment) {
|
||||
std::vector<glm::dvec3> positions;
|
||||
|
||||
@@ -260,6 +262,24 @@ std::vector<glm::dvec3> AutoNavigationHandler::getCurvePositions(int nPerSegment
|
||||
return positions;
|
||||
}
|
||||
|
||||
// TODO: remove when not needed
|
||||
// Created for debugging
|
||||
std::vector<glm::dvec3> AutoNavigationHandler::getControlPoints() {
|
||||
std::vector<glm::dvec3> points;
|
||||
|
||||
if (_pathSegments.empty()) {
|
||||
LERROR("There is no current path to sample points from.");
|
||||
return points;
|
||||
}
|
||||
|
||||
for (PathSegment &p : _pathSegments) {
|
||||
std::vector<glm::dvec3> curvePoints = p.getControlPoints();
|
||||
points.insert(points.end(), curvePoints.begin(), curvePoints.end());
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
bool AutoNavigationHandler::handleInstruction(const Instruction& instruction, int index) {
|
||||
bool success = true;
|
||||
switch (instruction.type)
|
||||
|
||||
@@ -64,7 +64,9 @@ public:
|
||||
void continuePath();
|
||||
void stopPath();
|
||||
|
||||
std::vector<glm::dvec3> getCurvePositions(int nPerSegment);
|
||||
// TODO: remove functions for debugging
|
||||
std::vector<glm::dvec3> getCurvePositions(int nPerSegment); //debug
|
||||
std::vector<glm::dvec3> getControlPoints(); //debug
|
||||
|
||||
private:
|
||||
bool handleInstruction(const Instruction& instruction, int index);
|
||||
|
||||
@@ -93,6 +93,13 @@ scripting::LuaLibrary AutoNavigationModule::luaLibrary() const {
|
||||
{},
|
||||
"number",
|
||||
"TODO: "
|
||||
},
|
||||
{
|
||||
"getControlPoints",
|
||||
&autonavigation::luascriptfunctions::getControlPoints,
|
||||
{},
|
||||
"",
|
||||
"FOR DEBUG. Get control point positions from all pathsegments"
|
||||
}
|
||||
};
|
||||
return res;
|
||||
|
||||
@@ -168,6 +168,8 @@ namespace openspace::autonavigation::luascriptfunctions {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO: remove when not needed
|
||||
// Created for debugging. Access info for rendereable path
|
||||
int getPathPositions(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::getPathPositions");
|
||||
|
||||
@@ -201,4 +203,37 @@ namespace openspace::autonavigation::luascriptfunctions {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// TODO: remove when not needed
|
||||
// Created for debugging. Access info for rendering of control points
|
||||
int getControlPoints(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::getControlPoints");
|
||||
|
||||
// Get sample positions from the current curve
|
||||
AutoNavigationModule* module = global::moduleEngine.module<AutoNavigationModule>();
|
||||
AutoNavigationHandler& handler = module->AutoNavigationHandler();
|
||||
std::vector<glm::dvec3> points = handler.getControlPoints();
|
||||
|
||||
// Push the points to the Lua stack:
|
||||
lua_settop(L, 0);
|
||||
const auto pushVector = [](lua_State* L, const glm::dvec3& v) {
|
||||
lua_newtable(L);
|
||||
ghoul::lua::push(L, 1, v.x);
|
||||
lua_rawset(L, -3);
|
||||
ghoul::lua::push(L, 2, v.y);
|
||||
lua_rawset(L, -3);
|
||||
ghoul::lua::push(L, 3, v.z);
|
||||
lua_rawset(L, -3);
|
||||
};
|
||||
|
||||
lua_newtable(L);
|
||||
for (int i = 0; i < points.size(); ++i) {
|
||||
ghoul::lua::push(L, i);
|
||||
pushVector(L, points[i]);
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack");
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace openspace::autonavigation::luascriptfunctions
|
||||
|
||||
@@ -49,6 +49,12 @@ double PathCurve::arcLength(double tLimit) {
|
||||
return sum;
|
||||
}
|
||||
|
||||
// TODO: remove when not needed
|
||||
// Created for debugging
|
||||
std::vector<glm::dvec3> PathCurve::getPoints() {
|
||||
return _points;
|
||||
}
|
||||
|
||||
BezierCurve::BezierCurve(CameraState& start, CameraState& end) {
|
||||
glm::dvec3 startNodePos = sceneGraphNode(start.referenceNode)->worldPosition();
|
||||
glm::dvec3 endNodePos = sceneGraphNode(start.referenceNode)->worldPosition();
|
||||
|
||||
@@ -36,6 +36,7 @@ class PathCurve {
|
||||
public:
|
||||
virtual ~PathCurve() = 0;
|
||||
virtual glm::dvec3 valueAt(double t) = 0;
|
||||
std::vector<glm::dvec3> getPoints(); // for debugging
|
||||
|
||||
double arcLength(double tLimit = 1.0);
|
||||
protected:
|
||||
|
||||
@@ -69,6 +69,11 @@ const double PathSegment::duration() const { return _duration; }
|
||||
|
||||
const double PathSegment::startTime() const { return _startTime; }
|
||||
|
||||
// TODO: remove function for debugging
|
||||
const std::vector<glm::dvec3> PathSegment::getControlPoints() const {
|
||||
return _curve->getPoints();
|
||||
}
|
||||
|
||||
const glm::vec3 PathSegment::getPositionAt(double t) const {
|
||||
t = easingfunctions::cubicEaseInOut(t);
|
||||
return _curve->valueAt(t);
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
const double duration() const;
|
||||
const double startTime() const;
|
||||
|
||||
const std::vector<glm::dvec3> getControlPoints() const; // TODO: remove this debugging function
|
||||
const glm::vec3 getPositionAt(double t) const;
|
||||
const glm::dquat getRotationAt(double t) const;
|
||||
const glm::dquat getLookAtRotation(double t, glm::dvec3 currentPos, glm::dvec3 up) const;
|
||||
|
||||
Reference in New Issue
Block a user