Fixes to trails, fov and adding some keybindings

This commit is contained in:
Michal Marcinkowski
2015-05-04 20:15:34 -04:00
parent d3bf8eb7f7
commit 0a1c0164ef
15 changed files with 127 additions and 45 deletions
+1 -1
View File
@@ -31,6 +31,6 @@
</Window>
</Node>
<User eyeSeparation="0.065">
<Pos x="0.0" y="0.0" z="4.0" />
<Pos x="0.0" y="0.0" z="2.0" />
</User>
</Cluster>
@@ -71,6 +71,7 @@ private:
std::string _destination;
std::string _target;
bool _isGhost;
psc _sunPosition;
@@ -53,6 +53,7 @@ public:
private:
properties::FloatProperty _lineWidth;
properties::BoolProperty _drawSolid;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
openspace::SceneGraphNode* _targetNode;
+2
View File
@@ -42,6 +42,8 @@ private:
std::string _originName;
psc _position;
bool _kernelsLoadedSuccessfully;
std::string _ghosting;
std::string _name;
};
} // namespace openspace
+14
View File
@@ -36,5 +36,19 @@ openspace.bindKey("j", "local b = openspace.getPropertyValue('PlutoText.renderab
openspace.bindKey("l", "local b = openspace.getPropertyValue('Labels.renderable.performFading'); openspace.setPropertyValue('Labels.renderable.performFading', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_LORRI.renderable.solidDraw'); openspace.setPropertyValue('NH_LORRI.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_LEISA.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_LEISA.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_PAN1.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_PAN1.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_PAN2.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_PAN2.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_RED.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_RED.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_BLUE.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_BLUE.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_FT.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_FT.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_METHANE.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_METHANE.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_NIR.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_NIR.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_ALICE_AIRGLOW.renderable.solidDraw'); openspace.setPropertyValue('NH_ALICE_AIRGLOW.renderable.solidDraw', not b)")
openspace.bindKey("PAUSE", "openspace.printInfo('F5: Toogle to Sun, F6: Toggle to Jupiter, F7: Toggle to Pluto'); openspace.printInfo('Bookmarks: 1: Jupter, 2-7: Pluto');")
+3 -3
View File
@@ -68,9 +68,9 @@ void main()
float shine = 100;
vec4 specular = vec4(1.0);
vec4 ambient = vec4(0.0,0.0,0.0,transparency);//diffuse*0.4;
if(intensity > 0.0f){
vec4 ambient =diffuse*0.4;
ambient[3] = transparency;
if(intensity > 0.0f){
// halfway vector
vec3 h = normalize(l_dir + normalize(cam_dir));
// specular factor
+1 -1
View File
@@ -60,7 +60,7 @@ void main()
//vec3 e = normalize(camdir);
vec3 l_pos = sun_pos; // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
float terminatorBright = 0.4;
float terminatorBright = 0.1;
float intensity = min(max(5*dot(n,l_dir), terminatorBright), 1);
float shine = 0.0001;
+39 -8
View File
@@ -37,19 +37,21 @@
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/imagesequencer2.h>
#include <openspace/engine/openspaceengine.h>
#include <sgct.h>
#include "imgui.h"
namespace {
const std::string _loggerCat = "RenderableModel";
namespace {
const std::string _loggerCat = "RenderableModel";
const std::string keySource = "Rotation.Source";
const std::string keyDestination = "Rotation.Destination";
const std::string keyBody = "Body";
const std::string keyStart = "StartTime";
const std::string keyEnd = "EndTime";
const std::string keyFading = "Shading.Fadeable";
const std::string keyBody = "Body";
const std::string keyStart = "StartTime";
const std::string keyEnd = "EndTime";
const std::string keyFading = "Shading.Fadeable";
const std::string keyGhosting = "Shading.Ghosting";
}
@@ -61,6 +63,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
, _programObject(nullptr)
, _texture(nullptr)
, _geometry(nullptr)
, _isGhost(false)
, _performShading("performShading", "Perform Shading", true)
, _alpha(1.f)
, _fading("fading", "Fade", 0)
@@ -105,6 +108,12 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
_performFade = fading;
}
addProperty(_performFade);
if (dictionary.hasKeyAndValue<bool>(keyGhosting)) {
bool ghosting;
dictionary.getValue(keyGhosting, ghosting);
_isGhost = ghosting;
}
}
bool RenderableModel::isReady() const {
@@ -203,12 +212,34 @@ void RenderableModel::render(const RenderData& data) {
}
void RenderableModel::update(const UpdateData& data) {
double _time = data.time;
double futureTime;
if (_isGhost){
futureTime = openspace::ImageSequencer2::ref().getNextCaptureTime();
double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - data.time;
double interval = openspace::ImageSequencer2::ref().getIntervalLength();
double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength();
if (interval > 60){
if (t < 0.8){
_fading = t;
}
else if (t >= 0.95f){
_fading = _fading - 0.5f;
}
}
else{
_fading = 0.0f;
}
_time = futureTime;
}
// set spice-orientation in accordance to timestamp
if (!_source.empty())
openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _destination, data.time, _stateMatrix);
openspace::SpiceManager::ref().getPositionTransformMatrix(_source, _destination, _time, _stateMatrix);
double lt;
openspace::SpiceManager::ref().getTargetPosition("SUN", _target, "GALACTIC", "NONE", data.time, _sunPosition, lt);
openspace::SpiceManager::ref().getTargetPosition("SUN", _target, "GALACTIC", "NONE", _time, _sunPosition, lt);
}
void RenderableModel::loadTexture() {
@@ -341,7 +341,7 @@ void RenderablePlanetProjection::imageProjectGPU(){
m_viewport[2], m_viewport[3]);
}
#include <math.h>
glm::mat4 RenderablePlanetProjection::computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up){
//rotate boresight into correct alignment
_boresight = _instrumentMatrix*aim;
@@ -435,7 +435,7 @@ void RenderablePlanetProjection::render(const RenderData& data){
_programObject->setUniform("ModelTransform" , _transform);
_programObject->setUniform("boresight" , _boresight);
setPscUniforms(_programObject, &data.camera, data.position);
// Bind texture
ghoul::opengl::TextureUnit unit[2];
unit[0].activate();
@@ -444,6 +444,7 @@ void RenderablePlanetProjection::render(const RenderData& data){
unit[1].activate();
_textureProj->bind();
_programObject->setUniform("texture2", unit[1]);
// render geometry
_geometry->render();
// disable shader
@@ -460,7 +461,7 @@ void RenderablePlanetProjection::update(const UpdateData& data){
_capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID);
}
//floor fading to decimal
_fadeProjection = floorf(_fadeProjection * 10) / 10;
//_fadeProjection = floorf(_fadeProjection * 10) / 10;
}
void RenderablePlanetProjection::loadProjectionTexture(){
+27 -7
View File
@@ -71,6 +71,7 @@ namespace openspace{
, _lineWidth("lineWidth", "Line Width", 1.f, 1.f, 20.f)
, _programObject(nullptr)
, _texture(nullptr)
, _drawSolid("solidDraw", "Draw as Quads", false)
, _mode(GL_LINES){
bool success = dictionary.getValue(keyBody, _spacecraft);
@@ -100,6 +101,7 @@ namespace openspace{
}
addProperty(_lineWidth);
addProperty(_drawSolid);
}
void RenderableFov::allocateData(){
@@ -305,8 +307,6 @@ void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
mid = bisection(current, next, tolerance);
for (int j = 1; j <= _isteps; j++){
t = ((double)j / _isteps);
// TODO: change the interpolate scheme to place points not on a straight line but instead
// using either slerp or some other viable method (goal: eliminate checkForIntercept -method)
interpolated = interpolate(current, mid, t);
_interceptVector = (j < _isteps) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
insertPoint(_varray2, _interceptVector, col_sq);
@@ -426,6 +426,7 @@ void RenderableFov::render(const RenderData& data){
drawFOV = ImageSequencer2::ref().instumentActive(_instrumentID);
}
if (drawFOV){
// update only when time progresses.
if (_oldTime != _time){
@@ -463,8 +464,9 @@ void RenderableFov::render(const RenderData& data){
double targetEpoch;
// for each FOV vector
for (int i = 0; i <= bounds.size(); i++){
// compute surface intercept
int r = (i == bounds.size()) ? 0 : i;
// compute surface intercept
openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
_frame, _method, _aberrationCorrection,
_time, targetEpoch, bounds[r], ipoint, ivec, _interceptTag[r]);
@@ -512,17 +514,37 @@ void RenderableFov::render(const RenderData& data){
}
_interceptTag[bounds.size()] = _interceptTag[0];
if (!(_instrumentID == "NH_LORRI")) // image plane replaces fov square
fovProjection(_interceptTag, bounds);
updateData();
glm::vec3 aim = (spacecraftRot * glm::vec4(boresight, 1)).xyz;
psc position;
double lt;
SpiceManager::ref().getTargetPosition(_fovTarget,
_spacecraft,
_frame,
_aberrationCorrection,
_time,
position,
lt);
//if aimed 80 deg away from target, dont draw white square
if (glm::dot(glm::normalize(aim), glm::normalize(position.vec3())) < 0.2){
drawFOV = false;
}
}
_oldTime = _time;
if (!_drawSolid) _mode = GL_LINES;
else _mode = GL_TRIANGLE_STRIP;
glLineWidth(_lineWidth);
glBindVertexArray(_vaoID[0]);
glDrawArrays(GL_LINES, 0, _vtotal[0]);
glDrawArrays(_mode, 0, _vtotal[0]);
glBindVertexArray(0);
glLineWidth(_lineWidth);
@@ -530,8 +552,6 @@ void RenderableFov::render(const RenderData& data){
glDrawArrays(GL_LINES, 0, _vtotal[0]);
glBindVertexArray(0);
//second vbo
if (drawFOV){
glLineWidth(1.f);
glBindVertexArray(_vaoID[1]);
+3 -2
View File
@@ -194,9 +194,10 @@ void RenderablePlaneProjection::updatePlane(const Image* img, double currentTime
std::string target = "JUPITER"; //default
if (!_moving) {
target = findClosestTarget(currentTime);
// target = findClosestTarget(currentTime);
}
if (img != nullptr)
target = img->target;
setTarget(target);
+2 -2
View File
@@ -60,7 +60,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _lineColor("lineColor", "Line Color")
, _lineFade("lineFade", "Line Fade", 0.75f, 0.f, 5.f)
, _lineWidth("lineWidth", "Line Width", 1.f, 1.f, 20.f)
, _lineWidth("lineWidth", "Line Width", 2.f, 1.f, 20.f)
, _programObject(nullptr)
, _programIsDirty(true)
, _vaoID(0)
@@ -148,7 +148,7 @@ void RenderableTrail::render(const RenderData& data) {
const psc& origin = openspace::OpenSpaceEngine::ref().interactionHandler()->focusNode()->worldPosition();
const PowerScaledScalar& pssl = (position - origin).length();
if (pssl[0] < 0.00001){
if (pssl[0] < 0.000001){
if (_distanceFade > 0.0f) _distanceFade -= 0.05f;
_programObject->setUniform("forceFade", _distanceFade);
}
+21 -11
View File
@@ -976,7 +976,7 @@ void RenderEngine::changeViewPoint(std::string origin) {
SceneGraphNode* jupiterBarycenterNode = scene()->sceneGraphNode("JupiterBarycenter");
//SceneGraphNode* newHorizonsGhostNode = sceneGraph()->sceneGraphNode("NewHorizonsGhost");
SceneGraphNode* newHorizonsGhostNode = scene()->sceneGraphNode("NewHorizonsGhost");
//SceneGraphNode* dawnNode = scene()->sceneGraphNode("Dawn");
//SceneGraphNode* vestaNode = scene()->sceneGraphNode("Vesta");
@@ -995,6 +995,8 @@ void RenderEngine::changeViewPoint(std::string origin) {
solarSystemBarycenterNode->setParent(plutoBarycenterNode);
newHorizonsNode->setParent(plutoBarycenterNode);
newHorizonsGhostNode->setParent(plutoBarycenterNode);
//newHorizonsTrailNode->setParent(plutoBarycenterNode);
ghoul::Dictionary solarDictionary =
{
@@ -1049,17 +1051,18 @@ void RenderEngine::changeViewPoint(std::string origin) {
//};
//vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary));
/*
ghoul::Dictionary newHorizonsGhostDictionary =
{
{ std::string("Type"), std::string("Spice") },
{ std::string("Body"), std::string("NEW HORIZONS GHOST") },
{ std::string("Body"), std::string("NEW HORIZONS") },
{ std::string("EphmerisGhosting"), std::string("TRUE") },
{ std::string("Reference"), std::string("GALACTIC") },
{ std::string("Observer"), std::string("PLUTO BARYCENTER") },
{ std::string("Kernels"), ghoul::Dictionary() }
};
newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary));
*/
return;
}
if (origin == "Sun") {
@@ -1068,6 +1071,8 @@ void RenderEngine::changeViewPoint(std::string origin) {
plutoBarycenterNode->setParent(solarSystemBarycenterNode);
jupiterBarycenterNode->setParent(solarSystemBarycenterNode);
newHorizonsNode->setParent(solarSystemBarycenterNode);
newHorizonsGhostNode->setParent(solarSystemBarycenterNode);
//newHorizonsTrailNode->setParent(solarSystemBarycenterNode);
ghoul::Dictionary plutoDictionary =
@@ -1123,17 +1128,18 @@ void RenderEngine::changeViewPoint(std::string origin) {
//};
//vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary));
/*
ghoul::Dictionary newHorizonsGhostDictionary =
{
{ std::string("Type"), std::string("Spice") },
{ std::string("Body"), std::string("NEW HORIZONS GHOST") },
{ std::string("Body"), std::string("NEW HORIZONS") },
{ std::string("EphmerisGhosting"), std::string("TRUE") },
{ std::string("Reference"), std::string("GALACTIC") },
{ std::string("Observer"), std::string("JUPITER BARYCENTER") },
{ std::string("Kernels"), ghoul::Dictionary() }
};
newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary));
*/
return;
}
if (origin == "Jupiter") {
@@ -1172,7 +1178,8 @@ void RenderEngine::changeViewPoint(std::string origin) {
};
solarSystemBarycenterNode->setEphemeris(new SpiceEphemeris(solarDictionary));
plutoBarycenterNode->setEphemeris(new SpiceEphemeris(plutoDictionary));
//newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary));
newHorizonsNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary));
newHorizonsGhostNode->setParent(jupiterBarycenterNode);
//newHorizonsTrailNode->setEphemeris(new SpiceEphemeris(newHorizonsDictionary));
@@ -1197,17 +1204,20 @@ void RenderEngine::changeViewPoint(std::string origin) {
//vestaNode->setEphemeris(new SpiceEphemeris(vestaDictionary));
/*
ghoul::Dictionary newHorizonsGhostDictionary =
{
{ std::string("Type"), std::string("Spice") },
{ std::string("Body"), std::string("NEW HORIZONS GHOST") },
{ std::string("Body"), std::string("NEW HORIZONS") },
{ std::string("EphmerisGhosting"), std::string("TRUE") },
{ std::string("Reference"), std::string("GALACTIC") },
{ std::string("Observer"), std::string("JUPITER BARYCENTER") },
{ std::string("Kernels"), ghoul::Dictionary() }
};
newHorizonsGhostNode->setEphemeris(new SpiceEphemeris(newHorizonsGhostDictionary));
*/
newHorizonsGhostNode->setParent(jupiterBarycenterNode);
return;
}
//if (origin == "Vesta") {
+7 -6
View File
@@ -31,6 +31,7 @@
namespace {
const std::string _loggerCat = "SpiceEphemeris";
const std::string keyGhosting = "EphmerisGhosting";
}
namespace openspace {
@@ -51,6 +52,8 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
if (!hasObserver)
LERROR("SpiceEphemeris does not contain the key '" << keyOrigin << "'");
dictionary.getValue(keyGhosting, _ghosting);
ghoul::Dictionary kernels;
dictionary.getValue(keyKernels, kernels);
for (size_t i = 1; i <= kernels.size(); ++i) {
@@ -74,18 +77,16 @@ void SpiceEphemeris::update(const UpdateData& data) {
glm::dvec3 position(0,0,0);
double lightTime = 0.0;
//if (_targetName != "NEW HORIZONS GHOST")
SpiceManager::ref().getTargetPosition(_targetName, _originName,
"GALACTIC", "NONE", data.time, position, lightTime);
/*
double interval = openspace::ImageSequencer2::ref().getIntervalLength();
if (_targetName == "NEW HORIZONS GHOST" && interval > 60){
if (_ghosting == "TRUE" && interval > 60){
double _time = openspace::ImageSequencer2::ref().getNextCaptureTime();
SpiceManager::ref().getTargetPosition("NEW HORIZONS", _originName,
SpiceManager::ref().getTargetPosition(_targetName, _originName,
"GALACTIC", "NONE", _time, position, lightTime);
}
*/
_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
_position[3] += 3;
}