mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-29 23:39:26 -05:00
Merge branch 'master' of github.com:OpenSpace/OpenSpace into feature/data-management
This commit is contained in:
@@ -42,6 +42,17 @@ template struct Vector4Verifier<bool>;
|
||||
template struct Vector4Verifier<int>;
|
||||
template struct Vector4Verifier<double>;
|
||||
|
||||
template struct Vector2ListVerifier<bool>;
|
||||
template struct Vector2ListVerifier<int>;
|
||||
template struct Vector2ListVerifier<double>;
|
||||
template struct Vector3ListVerifier<bool>;
|
||||
template struct Vector3ListVerifier<int>;
|
||||
template struct Vector3ListVerifier<double>;
|
||||
template struct Vector4ListVerifier<bool>;
|
||||
template struct Vector4ListVerifier<int>;
|
||||
template struct Vector4ListVerifier<double>;
|
||||
|
||||
|
||||
template struct Matrix2x2Verifier<double>;
|
||||
template struct Matrix2x3Verifier<double>;
|
||||
template struct Matrix2x4Verifier<double>;
|
||||
|
||||
@@ -1335,6 +1335,12 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
|
||||
{},
|
||||
"",
|
||||
"Remove all registered virtual properties"
|
||||
},
|
||||
{
|
||||
"addTag",
|
||||
&luascriptfunctions::addTag,
|
||||
"string, string",
|
||||
"Adds a tag (second argument) to a scene graph node (first argument)"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace luascriptfunctions {
|
||||
|
||||
@@ -144,7 +146,7 @@ int removeVirtualProperty(lua_State* L) {
|
||||
int removeAllVirtualProperties(lua_State* L) {
|
||||
const int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
}
|
||||
|
||||
std::vector<properties::Property*> ps = OsEng.virtualPropertyManager().properties();
|
||||
@@ -155,6 +157,30 @@ int removeAllVirtualProperties(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* addTag()
|
||||
* Adds a Tag to a SceneGraphNode
|
||||
*/
|
||||
int addTag(lua_State* L) {
|
||||
const int nArguments = lua_gettop(L);
|
||||
if (nArguments != 2) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
|
||||
}
|
||||
|
||||
const std::string uri = lua_tostring(L, -2);
|
||||
const std::string tag = lua_tostring(L, -1);
|
||||
|
||||
SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(uri);
|
||||
if (!node) {
|
||||
return luaL_error(L, "Unknown scene graph node type '%s'", uri.c_str());
|
||||
}
|
||||
|
||||
node->addTag(tag);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* downloadFile():
|
||||
|
||||
@@ -70,7 +70,13 @@ documentation::Documentation MissionPhase::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyPhases,
|
||||
new ReferencingVerifier("core_mission_mission"),
|
||||
new TableVerifier({
|
||||
{
|
||||
"*",
|
||||
new ReferencingVerifier("core_mission_mission"),
|
||||
Optional::Yes
|
||||
}
|
||||
}),
|
||||
Optional::Yes,
|
||||
"The phases into which this mission or mission phase is separated."
|
||||
}
|
||||
@@ -164,7 +170,7 @@ MissionPhase::Trace MissionPhase::phaseTrace(double time, int maxDepth) const {
|
||||
}
|
||||
|
||||
void MissionPhase::phaseTrace(double time, Trace& trace, int maxDepth) const {
|
||||
ghoul_assert(maxDepth >= 0, "maxDepth must not be negative");
|
||||
//ghoul_assert(maxDepth >= 0, "maxDepth must not be negative");
|
||||
|
||||
if (maxDepth == 0) {
|
||||
return;
|
||||
|
||||
@@ -372,7 +372,7 @@ void RenderEngine::initializeGL() {
|
||||
|
||||
// set the close clip plane and the far clip plane to extreme values while in
|
||||
// development
|
||||
OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 1000.f);
|
||||
OsEng.windowWrapper().setNearFarClippingPlane(0.001f, 10000.f);
|
||||
|
||||
try {
|
||||
const float fontSizeBig = 50.f;
|
||||
@@ -570,7 +570,7 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) {
|
||||
fontResolution().x - size.boundingBox.x - 10,
|
||||
fontResolution().y - size.boundingBox.y
|
||||
);
|
||||
penPosition.y -= _fontDate->height();
|
||||
// penPosition.y -= _fontDate->height();
|
||||
|
||||
RenderFontCr(
|
||||
*_fontDate,
|
||||
@@ -1043,81 +1043,81 @@ void RenderEngine::renderInformation() {
|
||||
bool hasNewHorizons = scene() && scene()->sceneGraphNode("NewHorizons");
|
||||
double currentTime = OsEng.timeManager().time().j2000Seconds();
|
||||
|
||||
if (MissionManager::ref().hasCurrentMission()) {
|
||||
//if (MissionManager::ref().hasCurrentMission()) {
|
||||
|
||||
const Mission& mission = MissionManager::ref().currentMission();
|
||||
// const Mission& mission = MissionManager::ref().currentMission();
|
||||
|
||||
if (mission.phases().size() > 0) {
|
||||
static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
|
||||
//static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
|
||||
static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
|
||||
static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
|
||||
// static const glm::vec4 currentLeafMissionColor = missionProgressColor;
|
||||
static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
|
||||
// if (mission.phases().size() > 0) {
|
||||
// static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
|
||||
// //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
|
||||
// static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
|
||||
// static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
|
||||
// // static const glm::vec4 currentLeafMissionColor = missionProgressColor;
|
||||
// static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
|
||||
|
||||
// Add spacing
|
||||
RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
|
||||
// // Add spacing
|
||||
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
|
||||
|
||||
auto phaseTrace = mission.phaseTrace(currentTime);
|
||||
// auto phaseTrace = mission.phaseTrace(currentTime);
|
||||
|
||||
if (phaseTrace.size()) {
|
||||
const MissionPhase& phase = phaseTrace.back().get();
|
||||
std::string title = "Current Mission Phase: " + phase.name();
|
||||
RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
|
||||
double remaining = phase.timeRange().end - currentTime;
|
||||
float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
|
||||
std::string progress = progressToStr(25, t);
|
||||
//RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
|
||||
// "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
|
||||
}
|
||||
else {
|
||||
RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
|
||||
double remaining = mission.timeRange().start - currentTime;
|
||||
RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
|
||||
"%.0f s", remaining);
|
||||
}
|
||||
// if (phaseTrace.size()) {
|
||||
// const MissionPhase& phase = phaseTrace.back().get();
|
||||
// std::string title = "Current Mission Phase: " + phase.name();
|
||||
// RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
|
||||
// double remaining = phase.timeRange().end - currentTime;
|
||||
// float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
|
||||
// std::string progress = progressToStr(25, t);
|
||||
// //RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
|
||||
// // "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
|
||||
// }
|
||||
// else {
|
||||
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
|
||||
// double remaining = mission.timeRange().start - currentTime;
|
||||
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
|
||||
// "%.0f s", remaining);
|
||||
// }
|
||||
|
||||
bool showAllPhases = false;
|
||||
// bool showAllPhases = false;
|
||||
|
||||
typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
|
||||
std::stack<PhaseWithDepth> S;
|
||||
int pixelIndentation = 20;
|
||||
S.push({ &mission, 0 });
|
||||
while (!S.empty()) {
|
||||
const MissionPhase* phase = S.top().first;
|
||||
int depth = S.top().second;
|
||||
S.pop();
|
||||
// typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
|
||||
// std::stack<PhaseWithDepth> S;
|
||||
// int pixelIndentation = 20;
|
||||
// S.push({ &mission, 0 });
|
||||
// while (!S.empty()) {
|
||||
// const MissionPhase* phase = S.top().first;
|
||||
// int depth = S.top().second;
|
||||
// S.pop();
|
||||
|
||||
bool isCurrentPhase = phase->timeRange().includes(currentTime);
|
||||
// bool isCurrentPhase = phase->timeRange().includes(currentTime);
|
||||
|
||||
penPosition.x += depth * pixelIndentation;
|
||||
if (isCurrentPhase) {
|
||||
double remaining = phase->timeRange().end - currentTime;
|
||||
float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
|
||||
std::string progress = progressToStr(25, t);
|
||||
RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
|
||||
"%s %s %.1f %%",
|
||||
phase->name().c_str(),
|
||||
progress.c_str(),
|
||||
t * 100
|
||||
);
|
||||
}
|
||||
else {
|
||||
RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
|
||||
}
|
||||
penPosition.x -= depth * pixelIndentation;
|
||||
// penPosition.x += depth * pixelIndentation;
|
||||
// if (isCurrentPhase) {
|
||||
// double remaining = phase->timeRange().end - currentTime;
|
||||
// float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
|
||||
// std::string progress = progressToStr(25, t);
|
||||
// RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
|
||||
// "%s %s %.1f %%",
|
||||
// phase->name().c_str(),
|
||||
// progress.c_str(),
|
||||
// t * 100
|
||||
// );
|
||||
// }
|
||||
// else {
|
||||
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
|
||||
// }
|
||||
// penPosition.x -= depth * pixelIndentation;
|
||||
|
||||
if (isCurrentPhase || showAllPhases) {
|
||||
// phases are sorted increasingly by start time, and will be popped
|
||||
// last-in-first-out from the stack, so add them in reversed order.
|
||||
int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
|
||||
for (int i = indexLastPhase; 0 <= i; --i) {
|
||||
S.push({ &phase->phases()[i], depth + 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (isCurrentPhase || showAllPhases) {
|
||||
// // phases are sorted increasingly by start time, and will be popped
|
||||
// // last-in-first-out from the stack, so add them in reversed order.
|
||||
// int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
|
||||
// for (int i = indexLastPhase; 0 <= i; --i) {
|
||||
// S.push({ &phase->phases()[i], depth + 1 });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
namespace {
|
||||
const char* _loggerCat = "SceneGraphNode";
|
||||
const char* KeyRenderable = "Renderable";
|
||||
const char* KeyGuiPath = "GuiPath";
|
||||
|
||||
const char* keyTransformTranslation = "Transform.Translation";
|
||||
const char* keyTransformRotation = "Transform.Rotation";
|
||||
@@ -159,6 +160,10 @@ std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(const ghoul
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(KeyGuiPath)) {
|
||||
result->_guiPath = dictionary.value<std::string>(KeyGuiPath);
|
||||
}
|
||||
|
||||
LDEBUG("Successfully created SceneGraphNode '"
|
||||
<< result->name() << "'");
|
||||
return result;
|
||||
@@ -497,28 +502,23 @@ const std::vector<SceneGraphNode*>& SceneGraphNode::dependentNodes() const {
|
||||
return _dependentNodes;
|
||||
}
|
||||
|
||||
glm::dvec3 SceneGraphNode::position() const
|
||||
{
|
||||
glm::dvec3 SceneGraphNode::position() const {
|
||||
return _transform.translation->position();
|
||||
}
|
||||
|
||||
const glm::dmat3& SceneGraphNode::rotationMatrix() const
|
||||
{
|
||||
const glm::dmat3& SceneGraphNode::rotationMatrix() const {
|
||||
return _transform.rotation->matrix();
|
||||
}
|
||||
|
||||
double SceneGraphNode::scale() const
|
||||
{
|
||||
double SceneGraphNode::scale() const {
|
||||
return _transform.scale->scaleValue();
|
||||
}
|
||||
|
||||
glm::dvec3 SceneGraphNode::worldPosition() const
|
||||
{
|
||||
glm::dvec3 SceneGraphNode::worldPosition() const {
|
||||
return _worldPositionCached;
|
||||
}
|
||||
|
||||
const glm::dmat3& SceneGraphNode::worldRotationMatrix() const
|
||||
{
|
||||
const glm::dmat3& SceneGraphNode::worldRotationMatrix() const {
|
||||
return _worldRotationCached;
|
||||
}
|
||||
|
||||
@@ -530,11 +530,14 @@ glm::dmat4 SceneGraphNode::inverseModelTransform() const {
|
||||
return _inverseModelTransformCached;
|
||||
}
|
||||
|
||||
double SceneGraphNode::worldScale() const
|
||||
{
|
||||
double SceneGraphNode::worldScale() const {
|
||||
return _worldScaleCached;
|
||||
}
|
||||
|
||||
const std::string& SceneGraphNode::guiPath() const {
|
||||
return _guiPath;
|
||||
}
|
||||
|
||||
glm::dvec3 SceneGraphNode::calculateWorldPosition() const {
|
||||
// recursive up the hierarchy if there are parents available
|
||||
if (_parent) {
|
||||
|
||||
@@ -98,6 +98,14 @@ documentation::Documentation SceneGraphNode::Documentation() {
|
||||
"node and all of its children. There are only three possible values "
|
||||
"corresponding to a 'Translation', a 'Rotation', and a 'Scale'."
|
||||
},
|
||||
{
|
||||
"GuiPath",
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
"If this value is specified, this '/' separated URI specifies the location "
|
||||
"of this scenegraph node in a GUI representation, for instance "
|
||||
"'/SolarSystem/Earth/Moon'."
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user