Finished ephemeries for all 8 planets and fixed so that renderablewavefront object.

NOTE: Basically, added a whole bunch of mod files, I agre - its ugly but later we need to decide ownership of this class.

Ephemeries goes temporarily under the name "RenderableTrail"
It displays a fading ephemeries with nodes of equal time (planetary days for now, will make changable)
For each modfile one specifies all the usual spice stuff with the addition of:
 - Planets tropical orbit
 - Planet/Earth orbit ratio
 - Planets day length in earth hours
Pulled from NASAs webpage so its reliant data, got the link from Brian.
This commit is contained in:
michal
2014-10-07 23:06:21 -04:00
parent 262767ac4f
commit 36925cbde7
6 changed files with 44 additions and 33 deletions
@@ -53,11 +53,20 @@ public:
void loadTexture();
void fullYearSweep();
// modfile reads
// spice
std::string _target;
std::string _observer;
std::string _frame;
// color
glm::vec3 _c;
double _r, _g, _b;
// orbit relational data
double _tropic;
double _ratio;
double _day;
// need to write robust method for vbo id selection
// (right now galactic grid has to be present) (why though?) solve later...
@@ -73,7 +82,6 @@ public:
unsigned int _vtotal;
unsigned int _stride;
glm::vec3 _c;
//Vertex* _varray;
std::vector<float> _varray;
int* _iarray;
+2 -2
View File
@@ -268,7 +268,7 @@ void InteractionHandler::trackballRotate(int x, int y) {
glm::vec2 mousePos = glm::vec2((float)x/width, (float)y/height);
mousePos = glm::clamp(mousePos, -0.5, 1.5); // Ugly fix #1: Camera position becomes NaN on mouse values outside [-0.5, 1.5]
//mousePos[1] = 0.5; // Ugly fix #2: Tempoarily only allow rotation around y
mousePos[1] = 0.5; // Ugly fix #2: Tempoarily only allow rotation around y
glm::vec3 curTrackballPos = mapToTrackball(mousePos);
// LDEBUG(mousePos.x << ", " << mousePos.y << " = " << curTrackballPos.x << ", " << curTrackballPos.y << ", " << curTrackballPos.z);
@@ -360,7 +360,7 @@ void InteractionHandler::keyboardCallback(int key, int action) {
distance(dist);
}
if (key == SGCT_KEY_T) {
PowerScaledScalar dist(-speed * pow(10,8) * dt, 0.0);
PowerScaledScalar dist(-speed * pow(10, 8) * dt, 0.0);
distance(dist);
}
if (key == SGCT_KEY_G) {
+31 -25
View File
@@ -31,20 +31,21 @@
#include <openspace/util/spicemanager.h>
#include <iomanip>
#include <utility> // std::move
#include <utility>
namespace {
const std::string _loggerCat = "RenderableTrail";
//constants
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
const std::string keyPathModule = "ModulePath";
const std::string keyColor = "RGB";
const std::string keyTropicalOrbitPeriod = "TropicalOrbitPeriod";
const std::string keyEarthOrbitRatio = "EarthOrbitRatio";
const std::string keyDayLength = "DayLength";
const std::string keyColor = "RGB";
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
const std::string keyPathModule = "ModulePath";
}
//#define DEBUG
namespace openspace{
RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
@@ -56,11 +57,14 @@ namespace openspace{
, _iBufferID(0)
, _mode(GL_LINE_STRIP){
assert(dictionary.getValue(keyBody, _target));
assert(dictionary.getValue(keyObserver, _observer));
assert(dictionary.getValue(keyFrame, _frame));
assert(dictionary.getValue(keyBody , _target));
assert(dictionary.getValue(keyObserver , _observer));
assert(dictionary.getValue(keyFrame , _frame));
assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
assert(dictionary.getValue(keyEarthOrbitRatio , _ratio));
assert(dictionary.getValue(keyDayLength , _day));//not used now, will be though.
// values in modfiles set from here
// http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
//white is default col
if (!dictionary.getValue(keyColor, _c)){
@@ -77,17 +81,19 @@ void RenderableTrail::fullYearSweep(){
// -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
double et = _time;
// Need to pass in each planets individual year (w. local or earth time?)
double planetYear = 31536000;
int segments = 365;
_increment = planetYear / segments;
double planetYear = 31540000 * _ratio;
int segments = _tropic;
_increment = planetYear / _tropic;
_isize = (segments + 2);
_vsize = (segments + 2);
_iarray = new int[_isize];
double p = 1.0 / segments;
double p = 1.0 / _tropic;
for (int i = 0; i < segments + 1; i++){
SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", et, _pscpos, _pscvel, lightTime);
//std::cout << planetYear << " " << segments << " " << _increment << std::endl;
//psc tmppos = glm::vec4(i, i, i, 7);
_varray.push_back(_pscpos[0]);
@@ -96,10 +102,10 @@ void RenderableTrail::fullYearSweep(){
_varray.push_back(_pscpos[3]);
#ifndef DEBUG
_varray.push_back(1.f - ((double)i / 365 * _r));
_varray.push_back(1.f - ((double)i / 365 * _g));
_varray.push_back(1.f - ((double)i / 365 * _b));
_varray.push_back(1.f - ((double)i / 365));
_varray.push_back(1.f - ((double)i / _tropic * _r));
_varray.push_back(1.f - ((double)i / _tropic * _g));
_varray.push_back(1.f - ((double)i / _tropic * _b));
_varray.push_back(1.f - ((double)i / _tropic));
#elif
_varray.push_back(1.f );
_varray.push_back(1.f );
@@ -212,13 +218,13 @@ void RenderableTrail::render(const RenderData& data){
glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, _vtotal);
glBindVertexArray(0);
/*
glPointSize(2.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, _vtotal);
glBindVertexArray(0);
*/
_programObject->deactivate();
}
+1 -2
View File
@@ -232,7 +232,7 @@ void RenderableWavefrontObject::loadObj(const char *filename){
vertexIndex = _iarray[m] * 3;
_iarray[m] = m;
_varray[m].location[3] = 6;
_varray[m].location[3] = 8;
int q = 0;
while (q < 3){
_varray[m].location[q] = tempVertexArray[vertexIndex + q];
@@ -258,7 +258,6 @@ void RenderableWavefrontObject::loadObj(const char *filename){
free(tempTextureIndicesArray);
}
RenderableWavefrontObject::~RenderableWavefrontObject(){
deinitialize();
}
-2
View File
@@ -99,8 +99,6 @@ void SpiceEphemeris::update(const UpdateData& data) {
assert(_targetName != "JUPITER");
*/
_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
_position[3] -= 0.01;
//_position[3] += 1;
//_position[3] += 3;