Intermediate result to change viewpoint from Jupiter projection to Plutoprojection

This commit is contained in:
Alexander Bock
2015-02-24 17:52:40 +01:00
parent aa7e82eb7f
commit 43a3716afd
12 changed files with 150 additions and 63 deletions

View File

@@ -88,11 +88,11 @@ private:
glm::mat4 _projectorMatrix;
// spice
std::string _sequenceFile;
std::string _instrumentID;
std::string _projectorID;
std::string _projecteeID;
std::string _aberration;
std::vector<std::string> _potentialTargets; // @TODO copy-n-paste from renderablefov
float _fovy;
float _aspectRatio;
float _nearPlane;

View File

@@ -88,6 +88,7 @@ public:
std::string _method;
std::string _aberrationCorrection;
std::string _fovTarget;
std::vector<std::string> _potentialTargets;
glm::dvec3 ipoint, ivec;
glm::dvec3 _previousHalf;

View File

@@ -192,6 +192,7 @@ private:
double _time; ///< The time stored as the number of seconds past the J2000 epoch
double _dt;
bool _timeJumped;
bool _jockeHasToFixThisLater;
//shared copies
double _sharedTime;

View File

@@ -36,6 +36,7 @@ struct InitializeData {
struct UpdateData {
double time;
//bool isTimeJump;
double delta;
bool doPerformanceMeasurement;
};

View File

@@ -1,9 +1,9 @@
openspace.setInvertRoll(true);
-- openspace.time.setTime("2007 FEB 27 16:30:00")
openspace.time.setTime("2007 FEB 27 16:41:00")
-- openspace.time.setDeltaTime(50);
openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO
-- openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO
-- NH takes series of images from visible to dark side (across terminator)
-- Sequence lasts ~10 mins, (recommended dt = 10)

View File

@@ -57,6 +57,8 @@ namespace {
const std::string keyInstrumentNear = "Instrument.Near";
const std::string keyInstrumentFar = "Instrument.Far";
const std::string keySequenceDir = "Projection.Sequence";
const std::string keySequenceType = "Projection.SequenceType";
const std::string keyPotentialTargets = "PotentialTargets";
const std::string keyFrame = "Frame";
const std::string keyGeometry = "Geometry";
const std::string keyShading = "PerformShading";
@@ -64,8 +66,13 @@ namespace {
const std::string keyBody = "Body";
const std::string _mainFrame = "GALACTIC";
const std::string sequenceTypeImage = "image-sequence";
const std::string sequenceTypePlaybook = "playbook";
}
namespace openspace {
RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("planetTexture", "RGB Texture")
@@ -78,31 +85,13 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _textureProj(nullptr)
, _geometry(nullptr)
{
bool b1 = dictionary.getValue(keyInstrument , _instrumentID);
bool b2 = dictionary.getValue(keyProjObserver , _projectorID );
bool b3 = dictionary.getValue(keyProjTarget , _projecteeID );
bool b4 = dictionary.getValue(keyProjAberration , _aberration );
bool b5 = dictionary.getValue(keyInstrumentFovy , _fovy );
bool b6 = dictionary.getValue(keyInstrumentAspect, _aspectRatio );
bool b7 = dictionary.getValue(keyInstrumentNear , _nearPlane );
bool b8 = dictionary.getValue(keyInstrumentFar , _farPlane );
assert(b1 == true);
assert(b2 == true);
assert(b3 == true);
assert(b4 == true);
assert(b5 == true);
assert(b6 == true);
assert(b7 == true);
assert(b8 == true);
std::string name;
bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
assert(success);
ghoul_assert(success, "");
std::string path;
success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
assert(success);
ghoul_assert(success, "");
_defaultProjImage = path + "/textures/defaultProj.png";
@@ -117,6 +106,38 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
dictionary.getValue(keyFrame, _target);
bool b1 = dictionary.getValue(keyInstrument, _instrumentID);
bool b2 = dictionary.getValue(keyProjObserver, _projectorID);
bool b3 = dictionary.getValue(keyProjTarget, _projecteeID);
bool b4 = dictionary.getValue(keyProjAberration, _aberration);
bool b5 = dictionary.getValue(keyInstrumentFovy, _fovy);
bool b6 = dictionary.getValue(keyInstrumentAspect, _aspectRatio);
bool b7 = dictionary.getValue(keyInstrumentNear, _nearPlane);
bool b8 = dictionary.getValue(keyInstrumentFar, _farPlane);
ghoul_assert(b1, "");
ghoul_assert(b2, "");
ghoul_assert(b3, "");
ghoul_assert(b4, "");
ghoul_assert(b5, "");
ghoul_assert(b6, "");
ghoul_assert(b7, "");
ghoul_assert(b8, "");
// @TODO copy-n-paste from renderablefov ---abock
ghoul::Dictionary potentialTargets;
success = dictionary.getValue(keyPotentialTargets, potentialTargets);
ghoul_assert(success, "");
_potentialTargets.resize(potentialTargets.size());
for (int i = 0; i < potentialTargets.size(); ++i) {
std::string target;
potentialTargets.getValue(std::to_string(i + 1), target);
_potentialTargets[i] = target;
}
// TODO: textures need to be replaced by a good system similar to the geometry as soon
// as the requirements are fixed (ab)
std::string texturePath = "";
@@ -138,12 +159,27 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
addProperty(_projectionTexturePath);
_projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadProjectionTexture, this));
bool found = dictionary.getValue(keySequenceDir, _sequenceFile);
_sequenceFile = path + ghoul::filesystem::FileSystem::PathSeparator + _sequenceFile;
if (found)
openspace::ImageSequencer::ref().parsePlaybookFile(_sequenceFile);
else
LERROR("Sequence description file was not specified in module description");
std::string sequenceSource;
bool found = dictionary.getValue(keySequenceDir, sequenceSource);
if (found) {
//LERROR("RenderablePlanetProjection '" << name << "' did not contain a sequence source");
sequenceSource = absPath(sequenceSource);
//sequenceSource = path + ghoul::filesystem::FileSystem::PathSeparator + sequenceSource;
std::string sequenceType;
found = dictionary.getValue(keySequenceType, sequenceType);
if (found) {
if (sequenceType == sequenceTypeImage) {
openspace::ImageSequencer::ref().loadSequence(sequenceSource);
}
else if (sequenceType == sequenceTypePlaybook) {
openspace::ImageSequencer::ref().parsePlaybookFile(sequenceSource);
}
else {
LERROR("RenderablePlanetProjection '" << name << "' had unknown sequence type '" << sequenceType << "'");
}
}
}
}
RenderablePlanetProjection::~RenderablePlanetProjection(){
@@ -325,11 +361,15 @@ void RenderablePlanetProjection::attitudeParameters(double time){
std::vector<glm::dvec3> bounds;
glm::dvec3 bs;
bool found = openspace::SpiceManager::ref().getFieldOfView(_instrumentID, shape, instrument, bs, bounds);
if (!found) LERROR("Could not locate instrument");
//if (!found) LERROR("Could not locate instrument");
if (!found)
return ;
psc position; //observer target
found = SpiceManager::ref().getTargetPosition(_projectorID, _projecteeID, _mainFrame, _aberration, time, position, lightTime);
if (!found) LERROR("Could not locate target position");
//if (!found) LERROR("Could not locate target position");
if (!found)
return;
position[3] += 3;
glm::vec3 cpos = position.vec3();
@@ -388,13 +428,20 @@ void RenderablePlanetProjection::update(const UpdateData& data){
bool _withinFOV;
/* -- TEMPORARY TARGETING SOLUTION -- */
std::string potential[2] = { "PLUTO", "CHARON" }; // only possible to target these two for now.
//std::string potential2[2] = { "PLUTO", "CHARON" }; // only possible to target these two for now.
std::string _fovTarget = "";
for (int i = 0; i < 2; i++){
bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i], _projectorID, "ELLIPSOID", _aberration, _time[0], _withinFOV);
for (int i = 0; i < _potentialTargets.size(); i++){
bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(
_instrumentID,
_potentialTargets[i],
_projectorID,
"ELLIPSOID",
_aberration,
_time[0],
_withinFOV);
if (success && _withinFOV){
_fovTarget = potential[i];
_fovTarget = _potentialTargets[i];
break;
}
}

View File

@@ -52,6 +52,7 @@ namespace {
const std::string keyInstrument = "Instrument.Name";
const std::string keyInstrumentMethod = "Instrument.Method";
const std::string keyInstrumentAberration = "Instrument.Aberration";
const std::string keyPotentialTargets = "PotentialTargets";
}
//#define DEBUG
namespace openspace{
@@ -70,18 +71,33 @@ namespace openspace{
, _texture(nullptr)
, _mode(GL_LINES){
bool b1 = dictionary.getValue(keyBody , _spacecraft);
bool b2 = dictionary.getValue(keyFrame , _frame);
bool b3 = dictionary.getValue(keyInstrument , _instrumentID);
bool b4 = dictionary.getValue(keyInstrumentMethod , _method);
bool b5 = dictionary.getValue(keyInstrumentAberration , _aberrationCorrection);
bool success = dictionary.getValue(keyBody , _spacecraft);
ghoul_assert(success, "");
assert(b1 == true);
assert(b2 == true);
assert(b3 == true);
assert(b4 == true);
assert(b5 == true);
success = dictionary.getValue(keyFrame , _frame);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrument , _instrumentID);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrumentMethod , _method);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrumentAberration , _aberrationCorrection);
ghoul_assert(success, "");
ghoul::Dictionary potentialTargets;
success = dictionary.getValue(keyPotentialTargets, potentialTargets);
ghoul_assert(success, "");
_potentialTargets.resize(potentialTargets.size());
for (int i = 0; i < potentialTargets.size(); ++i) {
std::string target;
potentialTargets.getValue(std::to_string(i + 1), target);
_potentialTargets[i] = target;
}
}
void RenderableFov::allocateData(){
int points = 8;
_stride[0] = points;
@@ -433,23 +449,30 @@ void RenderableFov::render(const RenderData& data){
// fetch data for specific instrument (shape, boresight, bounds etc)
bool found = openspace::SpiceManager::ref().getFieldOfView(_instrumentID, shape, instrument, boresight, bounds);
if (!found) LERROR("Could not locate instrument");
if (!found) {
LERROR("Could not locate instrument");
return;
}
float size = 4 * sizeof(float);
int indx = 0;
// set target based on visibility to specific instrument,
// from here on the _fovTarget is the target for all spice functions.
//std::string potential[5] = { "Jupiter", "Io", "Europa", "Ganymede", "Callisto" };
std::string potential[2] = { "Pluto", "Charon" };
//std::string potential[2] = { "Pluto", "Charon" };
_fovTarget = potential[0]; //default
for (int i = 0; i < 2; i++){
bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
_spacecraft, _method,
_aberrationCorrection, _time, _withinFOV);
_fovTarget = _potentialTargets[0]; //default
for (int i = 0; i < _potentialTargets.size(); i++){
bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(
_instrumentID,
_potentialTargets[i],
_spacecraft,
_method,
_aberrationCorrection,
_time,
_withinFOV);
if (success && _withinFOV){
_fovTarget = potential[i];
_fovTarget = _potentialTargets[i];
break;
}
}

View File

@@ -145,7 +145,10 @@ void RenderableTrail::render(const RenderData& data) {
}
void RenderableTrail::update(const UpdateData& data) {
// needsSweep also needs to be done when the time has been changed abruptly ---abock
//if (data.isTimeJump)
//_needsSweep = true;
//return;
if (_needsSweep) {
fullYearSweep(data.time);
sendToGPU();

View File

@@ -427,10 +427,12 @@ namespace openspace {
// update and evaluate the scene starting from the root node
_sceneGraph->update({
Time::ref().currentTime(),
//Time::ref().timeJumped(),
Time::ref().deltaTime(),
_doPerformanceMeasurements
});
_sceneGraph->evaluate(_mainCamera);
// clear the abuffer before rendering the scene
@@ -629,6 +631,7 @@ namespace openspace {
}
void RenderEngine::postDraw() {
//Time::ref().setTimeJumped(false);
if (_takeScreenshot) {
sgct::Engine::instance()->takeScreenshot();
_takeScreenshot = false;

View File

@@ -246,7 +246,7 @@ bool ImageSequencer::parsePlaybookFile(const std::string& fileName, std::string
*/
if (extension == "txt"){// Hong Kang. pre-parsed playbook
std::cout << "USING PREPARSED PLAYBOOK V9H" << std::endl;
LINFO("Using Preparsed Playbook V9H");
std::ifstream file(fileName);
if (!file.good()) LERROR("Failed to open txt file '" << fileName << "'");
@@ -353,14 +353,14 @@ bool ImageSequencer::loadSequence(const std::string& dir) {
found = true;
std::string ext = "jpg";
path.replace(path.begin() + position, path.end(), ext);
std::vector<std::string>::const_iterator it = std::find(sequencePaths.begin(), sequencePaths.end(), path);
if ( it != sequencePaths.end()){
bool fileExists = FileSys.fileExists(path);
if (fileExists) {
createImage(timestamps[0], timestamps[1], "NH_LORRI", path); /// fix active instrument!
std::sort(_timeStamps.begin(), _timeStamps.end(), cmp);
}
std::string timestr;
openspace::SpiceManager::ref().getDateFromET(timestamps[0], timestr);
std::cout << "Found at time " << timestr << " " << path << std::endl;
//std::string timestr;
//openspace::SpiceManager::ref().getDateFromET(timestamps[0], timestr);
//std::cout << "Found at time " << timestr << " " << path << std::endl;
}
} while (!file.eof() && found == false);
}
@@ -371,7 +371,7 @@ bool ImageSequencer::loadSequence(const std::string& dir) {
//_nextCapture = nextCaptureTime(Time::ref().currentTime()); // this is not really working 100%
//_intervalLength = _timeStamps[1].startTime;
return !sequencePaths.empty();
return !_timeStamps.empty();
}

View File

@@ -239,6 +239,9 @@ void Time::deserialize(SyncBuffer* syncBuffer){
syncBuffer->decode(_sharedDt);
syncBuffer->decode(_sharedTimeJumped);
//if (_sharedTimeJumped)
// _jockeHasToFixThisLater = true;
_syncMutex.unlock();
}
@@ -249,6 +252,11 @@ void Time::postSynchronizationPreDraw(){
_syncedDt = _sharedDt;
_syncedTimeJumped = _sharedTimeJumped;
//if (_jockeHasToFixThisLater) {
// _syncedTimeJumped = true;
// _jockeHasToFixThisLater = false;
//}
_syncMutex.unlock();
}