mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-25 21:48:57 -05:00
field of view rendering. Intermediate commit.
Working on trying to get the fov-on-surface square to render.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<!-- <Res x="1920" y="1080" /> -->
|
||||
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="1280" y="720" />
|
||||
<Size x="1920" y="1080" />
|
||||
<!-- <Size x="960" y="540" /> -->
|
||||
<!-- <Size x="640" y="360" /> -->
|
||||
<!--<Size x="640" y="310" />-->
|
||||
|
||||
+1
-1
Submodule ext/spice updated: 38f7fe9fe4...e679c330e7
@@ -50,10 +50,18 @@ public:
|
||||
properties::StringProperty _colorTexturePath;
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
|
||||
void loadTexture();
|
||||
void fullYearSweep();
|
||||
void allocateData();
|
||||
double computeTargetLocalTime(PowerScaledScalar d);
|
||||
psc orthogonalProjection(glm::dvec3 camvec);
|
||||
int findIndx(unsigned int p1, unsigned int p2) const;
|
||||
|
||||
void insertBetween(int p1, int p2);
|
||||
void hasIntercept(bool tag[]);
|
||||
|
||||
psc pscInterpolate(psc p0, psc p1, float t);
|
||||
|
||||
// modfile reads
|
||||
// spice
|
||||
std::string _target;
|
||||
std::string _observer;
|
||||
@@ -61,31 +69,33 @@ public:
|
||||
// color
|
||||
glm::vec3 _c;
|
||||
double _r, _g, _b;
|
||||
// orbit relational data
|
||||
double _tropic;
|
||||
double _ratio;
|
||||
double _day;
|
||||
|
||||
GLuint _vaoID ;
|
||||
GLuint _vBufferID ;
|
||||
GLuint _iBufferID;
|
||||
|
||||
void updateData();
|
||||
void sendToGPU();
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
GLuint _vaoID1 ;
|
||||
GLuint _vboID1 ;
|
||||
GLuint _iboID1;
|
||||
GLenum _mode;
|
||||
unsigned int _isize;
|
||||
unsigned int _vsize;
|
||||
unsigned int _vtotal;
|
||||
unsigned int _stride;
|
||||
std::vector<float> _varray1;
|
||||
int* _iarray1;
|
||||
|
||||
//Vertex* _varray;
|
||||
std::vector<float> _varray;
|
||||
int* _iarray;
|
||||
// second vbo
|
||||
GLuint _vaoID2;
|
||||
GLuint _vboID2;
|
||||
GLuint _iboID2;
|
||||
unsigned int _isize2;
|
||||
unsigned int _vsize2;
|
||||
unsigned int _vtotal2;
|
||||
|
||||
bool _once = false;
|
||||
std::vector<float> _varray2;
|
||||
int* _iarray2;
|
||||
|
||||
void updateData();
|
||||
void sendToGPU();
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
//used for update of trail
|
||||
psc _pscpos, _pscvel;
|
||||
@@ -94,7 +104,22 @@ public:
|
||||
double _oldTime = 0;
|
||||
|
||||
int _delta = 0;
|
||||
int _dtprogress = 0;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* // idk how we will compute the aberrated state.
|
||||
double RenderableFov::computeTargetLocalTime(PowerScaledScalar d){
|
||||
double c = 299792456.075; // m/s
|
||||
double dt = ( (d[0]*pow(10, d[1])) / c );
|
||||
double t_local = _time - dt*86400;
|
||||
|
||||
std::string localTime;
|
||||
std::string currentTime;
|
||||
|
||||
openspace::SpiceManager::ref().getDateFromET(t_local, localTime);
|
||||
openspace::SpiceManager::ref().getDateFromET(_time , currentTime);
|
||||
|
||||
std::cout << "time at jupiter : " << localTime << "\time at NH" << currentTime << std::endl;
|
||||
return t_local;
|
||||
}*/
|
||||
|
||||
@@ -62,6 +62,11 @@ protected:
|
||||
glm::mat4 _gridMatrix;
|
||||
int _segments;
|
||||
|
||||
bool staticGrid;
|
||||
std::string _parentsRotation;
|
||||
glm::dmat3 _parentMatrix;
|
||||
PowerScaledScalar _radius;
|
||||
|
||||
GLuint _vaoID = 3;
|
||||
GLuint _vBufferID = 4;
|
||||
GLuint _iBufferID = 5;
|
||||
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
#define SRCLEN 128
|
||||
|
||||
const int nrMetaKernels = 9;
|
||||
int which, handle, count = 0;
|
||||
SpiceInt which, handle, count = 0;
|
||||
char file[FILLEN], filtyp[TYPLEN], source[SRCLEN];
|
||||
double abs_error = 0.00001;
|
||||
|
||||
@@ -353,8 +353,8 @@ TEST_F(SpiceManagerTest, getPositionTransformMatrix){
|
||||
TEST_F(SpiceManagerTest, getFieldOfView){
|
||||
loadMetaKernel();
|
||||
|
||||
int n;
|
||||
int cassini_ID;
|
||||
SpiceInt n;
|
||||
SpiceInt cassini_ID;
|
||||
double et;
|
||||
glm::dvec3 boresight;
|
||||
double bounds_ref[5][3];
|
||||
@@ -395,7 +395,7 @@ TEST_F(SpiceManagerTest, planetocentricToRectangular){
|
||||
double lat = -35.0; //initial values
|
||||
double lon = 100.0;
|
||||
double rectangular_ref[3];
|
||||
int naifId;
|
||||
SpiceInt naifId;
|
||||
SpiceBoolean foundSpice;
|
||||
|
||||
bodn2c_c("EARTH", &naifId, &foundSpice);
|
||||
|
||||
@@ -104,6 +104,8 @@ namespace renderablesphericalgrid {
|
||||
const std::string gridColor = "GridColor";
|
||||
const std::string gridMatrix = "GridMatrix";
|
||||
const std::string gridSegments = "GridSegments";
|
||||
const std::string gridRadius = "GridRadius";
|
||||
const std::string gridPatentsRotiation = "ParentsRotation";
|
||||
} // namespace renderablesphericalgrid
|
||||
|
||||
namespace ephemeris {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __SPICEMANAGER_H__
|
||||
|
||||
#include "SpiceUsr.h"
|
||||
#include "SpiceZpr.h"
|
||||
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
@@ -250,8 +251,24 @@ public:
|
||||
bool getDateFromET(double ephemerisTime, std::string& date,
|
||||
const std::string& format = "YYYY MON DDTHR:MN:SC.### ::RND");
|
||||
|
||||
/**
|
||||
* This helper method converts a 3 dimensional vector from one reference frame to another.
|
||||
* \param v The vector to be converted
|
||||
* \param from The frame to be converted from
|
||||
* \param to The frame to be converted to
|
||||
* \param ephemerisTime Time at which to get rotational matrix that transforms vector
|
||||
*/
|
||||
void frameConversion(glm::dvec3& v, const std::string from, const std::string to, double ephemerisTime) const;
|
||||
|
||||
/**
|
||||
* Finds the projection of one vector onto another vector.
|
||||
* All vectors are 3-dimensional.
|
||||
* \param v1 The vector to be projected.
|
||||
* \param v2 The vector onto which v1 is to be projected.
|
||||
* \return The projection of v1 onto v2.
|
||||
*/
|
||||
glm::dvec3 orthogonalProjection(glm::dvec3& v1, glm::dvec3& v2);
|
||||
|
||||
/**
|
||||
* Returns the <code>position</code> of a <code>target</code> body relative to an
|
||||
* <code>observer</code> in a specific <code>referenceFrame</code>, optionally
|
||||
@@ -320,9 +337,9 @@ public:
|
||||
const std::string& aberrationCorrection,
|
||||
double ephemerisTime,
|
||||
double& targetEpoch,
|
||||
psc& directionVector,
|
||||
psc& surfaceIntercept,
|
||||
psc& surfaceVector) const;
|
||||
glm::dvec3& directionVector,
|
||||
glm::dvec3& surfaceIntercept,
|
||||
glm::dvec3& surfaceVector) const;
|
||||
|
||||
/**
|
||||
* Returns the state vector (<code>position</code> and <code>velocity</code>) of a
|
||||
@@ -407,6 +424,25 @@ public:
|
||||
double ephemerisTime,
|
||||
glm::dmat3& transformationMatrix) const;
|
||||
|
||||
/**
|
||||
* The following overloaded function performs similar to its default - the exception being
|
||||
* that it computes <code>transformationMatrix</code> with respect to local time offset
|
||||
* between an observer and its target. This allows for the accountance of light travel of
|
||||
* photons, e.g to account for instrument pointing offsets due to said phenomenon.
|
||||
* \param sourceFrame The name of the source reference frame
|
||||
* \param destinationFrame The name of the destination reference frame
|
||||
* \param ephemerisTimeFrom Recorded/observed observation time
|
||||
* \param ephemerisTimeTo Emission local target-time
|
||||
* \param transformationMatrix The output containing the transformation matrix that
|
||||
*/
|
||||
|
||||
bool getPositionTransformMatrix(const std::string& sourceFrame,
|
||||
const std::string& destinationFrame,
|
||||
double ephemerisTimeFrom,
|
||||
double ephemerisTimeTo,
|
||||
glm::dmat3& transformationMatrix) const;
|
||||
|
||||
|
||||
bool getPositionPrimeMeridian(const std::string& sourceFrame,
|
||||
const std::string& destinationFrame,
|
||||
double ephemerisTime,
|
||||
|
||||
+1
-1
Submodule openspace-data updated: 1e51c5836e...eae409646a
@@ -1,10 +1,10 @@
|
||||
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
|
||||
openspace.time.setTime("2007-02-27T07:19:00")
|
||||
openspace.time.setTime("2007-02-26T17:30:41")
|
||||
--openspace.time.setTime("2006-08-22T20:00:00")
|
||||
|
||||
--openspace.time.setDeltaTime(200000.0)
|
||||
--openspace.time.setDeltaTime(5000.00)
|
||||
--openspace.time.setDeltaTime(84600.00)
|
||||
--openspace.time.setDeltaTime(3600)
|
||||
openspace.time.setDeltaTime(1000.0)
|
||||
openspace.time.setDeltaTime(100.0)
|
||||
-- print(openspace.time.currentTimeUTC())
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define SCREEN_WIDTH 1280
|
||||
#define SCREEN_HEIGHT 720
|
||||
#define SCREEN_WIDTH 1920
|
||||
#define SCREEN_HEIGHT 1080
|
||||
#define MAX_LAYERS 32
|
||||
#define ABUFFER_SINGLE_LINKED 1
|
||||
#define ABUFFER_FIXED 2
|
||||
|
||||
+221
-51
@@ -49,35 +49,117 @@ namespace openspace{
|
||||
, _colorTexturePath("colorTexture", "Color Texture")
|
||||
, _programObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _vaoID(0)
|
||||
, _vBufferID(0)
|
||||
, _iBufferID(0)
|
||||
, _vaoID1(0)
|
||||
, _vboID1(0)
|
||||
, _iboID1(0)
|
||||
, _vaoID2(0)
|
||||
, _vboID2(0)
|
||||
, _iboID2(0)
|
||||
, _mode(GL_LINES){
|
||||
|
||||
assert(dictionary.getValue(keyBody , _target));
|
||||
assert(dictionary.getValue(keyObserver , _observer));
|
||||
assert(dictionary.getValue(keyFrame , _frame));
|
||||
}
|
||||
void RenderableFov::fullYearSweep(){
|
||||
|
||||
void RenderableFov::allocateData(){
|
||||
int points = 8;
|
||||
_stride = 8;
|
||||
_isize = points;
|
||||
_iarray = new int[_isize];
|
||||
|
||||
_iarray1 = new int[_isize];
|
||||
for (int i = 0; i < points; i++){
|
||||
for (int j = 0; j < 4; j++){
|
||||
_varray.push_back(0); // pos
|
||||
_varray1.push_back(0); // pos
|
||||
|
||||
}
|
||||
for (int j = 0; j < 4; j++){
|
||||
_varray.push_back(0); // col
|
||||
_varray1.push_back(0); // col
|
||||
}
|
||||
_iarray[i] = i;
|
||||
_iarray1[i] = i;
|
||||
}
|
||||
|
||||
_stride = 8;
|
||||
_vsize = _varray.size();
|
||||
_vsize = _varray1.size();
|
||||
_vtotal = static_cast<int>(_vsize / _stride);
|
||||
|
||||
// allocate second vbo data
|
||||
int cornerPoints = 5;
|
||||
_isize2 = cornerPoints;
|
||||
_iarray2 = new int[_isize2];
|
||||
for (int i = 0; i < _isize2; i++){
|
||||
_iarray2[i] = i;
|
||||
}
|
||||
_varray2.resize(40);
|
||||
_vsize2 = 40;
|
||||
_vtotal2 = 5;
|
||||
|
||||
/*
|
||||
// TESTING INDEX ROTATION ALGORITHM
|
||||
for (int i = 0; i < 40; i++){
|
||||
_varray2[i] = i;
|
||||
}
|
||||
// 0 1 2 3 4
|
||||
// 0 1 2 3 | 4 5 6 7 | 8 9 10 11 | 12 13 14 15 | 16 17 18 19 | 20 21 22 23 | 24 25 26 27 | 28 29 30 31 | 32 33 34 35 | 36 37 38 39 |
|
||||
// 8 16 24 32
|
||||
insertBetween(1, 2);
|
||||
*/
|
||||
}
|
||||
|
||||
psc RenderableFov::pscInterpolate(psc p0, psc p1, float t){
|
||||
assert(t >= 0 && t <= 1);
|
||||
|
||||
float s = (1.f - t)*p0[3] + t*p1[3];
|
||||
|
||||
float x = ((1.f - t)*p0[0] + t*p1[0]);
|
||||
float y = ((1.f - t)*p0[1] + t*p1[1]);
|
||||
float z = ((1.f - t)*p0[2] + t*p1[2]);
|
||||
|
||||
return PowerScaledCoordinate::PowerScaledCoordinate(x,y,z,s);
|
||||
}
|
||||
|
||||
|
||||
void RenderableFov::hasIntercept(bool tag[]){
|
||||
for (int i = 0; i < 4; i++){
|
||||
if (tag[i] != tag[i + 1]){
|
||||
std::cout << "intercept between pt " << i << " and " << i + 1 << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void RenderableFov::insertBetween(int p1, int p2){
|
||||
int idx = findIndx(p1, p2);
|
||||
|
||||
std::rotate(_varray2.begin(), _varray2.begin() + idx, _varray2.end());
|
||||
std::reverse(_varray2.begin(), _varray2.end());
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
_varray2.push_back(0); // add new point
|
||||
|
||||
std::rotate(_varray2.begin(), _varray2.begin() + idx, _varray2.end());
|
||||
std::reverse(_varray2.begin(), _varray2.end());
|
||||
/*
|
||||
int tmp = 0;
|
||||
for (int i = 0; i < _varray2.size(); i++){
|
||||
std::cout << _varray2[i] << " ";
|
||||
tmp++;
|
||||
if (tmp == 4){
|
||||
std::cout << "| ";
|
||||
tmp = 0;
|
||||
}
|
||||
}
|
||||
std::cout << "\n";
|
||||
*/
|
||||
}
|
||||
|
||||
int RenderableFov::findIndx(unsigned int p1, unsigned int p2) const{
|
||||
assert(p1 != p2 && _stride > 0);
|
||||
int idx = (p1 > p2) ? p1*_stride : p2*_stride;
|
||||
if (idx > _varray2.size()-_stride){
|
||||
LERROR("Out of bounds for points " << p1 << " and " << p2
|
||||
<< " will return index 0");
|
||||
return 0;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
RenderableFov::~RenderableFov(){
|
||||
@@ -86,14 +168,14 @@ RenderableFov::~RenderableFov(){
|
||||
|
||||
void RenderableFov::sendToGPU(){
|
||||
// Initialize and upload to graphics card
|
||||
glGenVertexArrays(1, &_vaoID);
|
||||
glGenBuffers(1, &_vBufferID);
|
||||
glGenBuffers(1, &_iBufferID);
|
||||
glGenVertexArrays(1, &_vaoID1);
|
||||
glGenBuffers(1, &_vboID1);
|
||||
glGenBuffers(1, &_iboID1);
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
|
||||
glBindVertexArray(_vaoID1);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID1);
|
||||
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray1[0]);
|
||||
|
||||
GLsizei st = sizeof(GLfloat) * _stride;
|
||||
|
||||
@@ -102,9 +184,27 @@ void RenderableFov::sendToGPU(){
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iboID1);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray1, GL_STATIC_DRAW);
|
||||
glBindVertexArray(0);
|
||||
|
||||
// second vbo
|
||||
glGenVertexArrays(1, &_vaoID2);
|
||||
glGenBuffers(1, &_vboID2);
|
||||
glGenBuffers(1, &_iboID2);
|
||||
|
||||
glBindVertexArray(_vaoID2);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID2);
|
||||
glBufferData(GL_ARRAY_BUFFER, _vsize2 * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize2 * sizeof(GLfloat), &_varray2[0]);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
|
||||
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iboID2);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize2 * sizeof(int), _iarray2, GL_STATIC_DRAW);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
@@ -114,7 +214,7 @@ bool RenderableFov::initialize(){
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
|
||||
|
||||
fullYearSweep();
|
||||
allocateData();
|
||||
sendToGPU();
|
||||
|
||||
return completeSuccess;
|
||||
@@ -127,8 +227,27 @@ bool RenderableFov::deinitialize(){
|
||||
}
|
||||
|
||||
void RenderableFov::updateData(){
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID1);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray1[0]);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID2);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize2 * sizeof(GLfloat), &_varray2[0]);
|
||||
}
|
||||
|
||||
psc RenderableFov::orthogonalProjection(glm::dvec3 camvec){
|
||||
glm::dvec3 vecToTarget;
|
||||
double lt;
|
||||
SpiceManager::ref().getTargetPosition("JUPITER", "NEW HORIZONS", "GALACTIC", "XCN+S", _time, vecToTarget, lt);
|
||||
glm::dvec3 b(camvec);
|
||||
|
||||
//might need time-offset dependant variant
|
||||
openspace::SpiceManager::ref().frameConversion(b, "NH_LORRI", "GALACTIC", _time);
|
||||
glm::dvec3 p = openspace::SpiceManager::ref().orthogonalProjection(vecToTarget, b);
|
||||
|
||||
psc projection = PowerScaledCoordinate::CreatePowerScaledCoordinate(p[0], p[1], p[2]);
|
||||
projection[3] += 3;
|
||||
|
||||
return projection;
|
||||
}
|
||||
|
||||
void RenderableFov::render(const RenderData& data){
|
||||
@@ -139,11 +258,6 @@ void RenderableFov::render(const RenderData& data){
|
||||
glm::mat4 transform(1);
|
||||
|
||||
glm::mat4 tmp = glm::mat4(1);
|
||||
glm::mat4 roty = glm::rotate(transform, 90.f, glm::vec3(0, 1, 0));
|
||||
glm::mat4 rotx = glm::rotate(transform, -90.f, glm::vec3(1, 0, 0));
|
||||
|
||||
glm::mat4 scale = glm::scale(transform, glm::vec3(1, -1, 1));
|
||||
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
tmp[i][j] = _stateMatrix[i][j];
|
||||
@@ -165,64 +279,120 @@ void RenderableFov::render(const RenderData& data){
|
||||
if (!found) LERROR("Could not locate instrument"); // fixlater
|
||||
|
||||
float size = 4 * sizeof(float);
|
||||
float *begin = &_varray[0];
|
||||
|
||||
// just some colors to help with debugging
|
||||
glm::vec4 origin(0);
|
||||
glm::vec4 col_gray(0.3, 0.3, 0.3, 1);
|
||||
glm::vec4 col_start(1.00, 0.89, 0.00, 1);
|
||||
glm::vec4 col_end(1.00, 0.29, 0.00, 1);
|
||||
// glm::vec4 bsight_t(boresight[0], boresight[1], boresight[2], data.position[3] - 3);
|
||||
glm::vec4 col_proj(1, 1, 1, 1);
|
||||
|
||||
float sc = 2.4;
|
||||
int indx = 0;
|
||||
int indx2 = 0;
|
||||
|
||||
psc projectionBounds[4];
|
||||
bool tags[5];
|
||||
|
||||
/**
|
||||
* NOTE: THIS CLASS IS UNDER DEVELOPMENT AND THEREFORE NON-OPTIMIZED
|
||||
*/
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
// might as well take glm. Would be nice if we had just one type to deal with here...
|
||||
psc dir = PowerScaledCoordinate::PowerScaledCoordinate(bounds[i][0], bounds[i][1], bounds[i][2], 1);
|
||||
psc intercept, interceptVector;
|
||||
glm::dvec3 ip, iv;
|
||||
double targetEpoch;
|
||||
found = openspace::SpiceManager::ref().getSurfaceIntercept("JUPITER", _target, instrument,
|
||||
_frame, "ELLIPSOID", "XCN+S",
|
||||
_time, targetEpoch, dir, intercept, interceptVector);
|
||||
// need to keep it explicit to keep my mind from exploding.
|
||||
found = openspace::SpiceManager::ref().getSurfaceIntercept("JUPITER", "NEW HORIZONS", "NH_LORRI",
|
||||
"GALACTIC", "ELLIPSOID", "NONE", _time, targetEpoch, bounds[i], ip, iv);
|
||||
|
||||
psc interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(iv[0], iv[1], iv[2]);
|
||||
interceptVector[3] += 3;
|
||||
glm::vec4 corner(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3]);
|
||||
|
||||
corner = tmp*corner;
|
||||
corner = tmp*corner; // manual rotation is a must.
|
||||
|
||||
//cleanup later.
|
||||
if (found){
|
||||
memcpy(&_varray[indx], glm::value_ptr(origin), size);
|
||||
if (found){
|
||||
// INTERCEPTIONS
|
||||
tags[i] = true;
|
||||
|
||||
memcpy(&_varray1[indx], glm::value_ptr(origin), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray[indx], glm::value_ptr(col_start), size);
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_start), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray[indx], glm::value_ptr(interceptVector.vec4()), size);
|
||||
memcpy(&_varray1[indx], glm::value_ptr(interceptVector.vec4()), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray[indx], glm::value_ptr(col_end), size);
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_end), size);
|
||||
indx += 4;
|
||||
}else{
|
||||
memcpy(&_varray[indx], glm::value_ptr(origin), size);
|
||||
// "INFINITE" FOV
|
||||
tags[i] = false;
|
||||
|
||||
memcpy(&_varray1[indx], glm::value_ptr(origin), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray[indx], glm::value_ptr(col_gray), size);
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_gray), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray[indx], glm::value_ptr(corner), size);
|
||||
memcpy(&_varray1[indx], glm::value_ptr(corner), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
}
|
||||
|
||||
// COMPUTE ORTHOGONAL PROJECTION. -- have to make cosmetic changes to this later.
|
||||
projectionBounds[i] = orthogonalProjection(bounds[i]);
|
||||
|
||||
/* // failed attempt at aberrated state.
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix("NH_LORRI", "IAU_JUPITER", _time, targetEpoch, _stateMatrix);
|
||||
glm::vec4 corner2(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3]);
|
||||
|
||||
corner2 = tmp*corner2;
|
||||
*/
|
||||
}
|
||||
|
||||
tags[4] = tags[0]; // 0 & 5 same point
|
||||
|
||||
hasIntercept(tags);
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
memcpy(&_varray2[indx2], glm::value_ptr(projectionBounds[i].vec4()), size);
|
||||
indx2 += 4;
|
||||
memcpy(&_varray2[indx2], glm::value_ptr(col_proj), size);
|
||||
indx2 += 4;
|
||||
}
|
||||
|
||||
//last point, finish lineloop
|
||||
psc lastpoint = orthogonalProjection(bounds[0]);
|
||||
memcpy(&_varray2[indx2], glm::value_ptr(lastpoint.vec4()), size);
|
||||
indx2 += 4;
|
||||
memcpy(&_varray2[indx2], glm::value_ptr(col_proj), size);
|
||||
indx2 += 4;
|
||||
|
||||
//insert point between data
|
||||
|
||||
|
||||
updateData();
|
||||
}
|
||||
_oldTime = _time;
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
|
||||
glBindVertexArray(_vaoID1);
|
||||
glDrawArrays(_mode, 0, _vtotal);
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
glPointSize(3.f);
|
||||
glBindVertexArray(_vaoID);
|
||||
//render points
|
||||
glPointSize(10.f);
|
||||
glBindVertexArray(_vaoID1);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal);
|
||||
glBindVertexArray(0);
|
||||
|
||||
//second vbo
|
||||
glBindVertexArray(_vaoID2);
|
||||
glDrawArrays(GL_LINE_STRIP, 0, _vtotal2);
|
||||
glBindVertexArray(0);
|
||||
|
||||
glPointSize(4.f);
|
||||
glBindVertexArray(_vaoID2);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal2);
|
||||
glBindVertexArray(0);
|
||||
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
// needs to be set from dictionary - REMEMBER
|
||||
const PowerScaledScalar radius = PowerScaledScalar(1.f, 20.f);
|
||||
//const PowerScaledScalar radius = PowerScaledScalar(1.f, 20.f);
|
||||
|
||||
RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
@@ -56,9 +56,18 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
glm::vec2 s;
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridType , _gridType);
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridColor , _gridColor);
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridMatrix , _gridMatrix);
|
||||
|
||||
staticGrid = dictionary.getValue(constants::renderablesphericalgrid::gridMatrix, _gridMatrix);
|
||||
if (!staticGrid){
|
||||
staticGrid = dictionary.getValue(constants::renderablesphericalgrid::gridPatentsRotiation, _parentsRotation);
|
||||
}
|
||||
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridSegments, s);
|
||||
|
||||
|
||||
glm::vec2 radius;
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridRadius, radius);
|
||||
|
||||
_segments = s[0];
|
||||
|
||||
_isize = int(6 * _segments * _segments);
|
||||
@@ -172,14 +181,22 @@ void RenderableSphericalGrid::render(const RenderData& data){
|
||||
assert(_gridProgram);
|
||||
_gridProgram->activate();
|
||||
|
||||
glm::mat4 transform;
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
transform[i][j] = _parentMatrix[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// setup the data to the shader
|
||||
_gridProgram->setIgnoreUniformLocationError(true);
|
||||
_gridProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_gridProgram->setUniform("ModelTransform", glm::mat4(1));
|
||||
_gridProgram->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_gridProgram, &data.camera, data.position);
|
||||
_gridProgram->setUniform("gridColor", _gridColor);
|
||||
|
||||
//glLineWidth(1.0f);
|
||||
glLineWidth(0.5f);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
@@ -193,6 +210,8 @@ void RenderableSphericalGrid::render(const RenderData& data){
|
||||
|
||||
}
|
||||
void RenderableSphericalGrid::update(const UpdateData& data){
|
||||
}
|
||||
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix("IAU_JUPITER", "GALACTIC", data.time, _parentMatrix);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -171,8 +171,7 @@ bool RenderableTrail::initialize(){
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
|
||||
_startTrail;
|
||||
// SpiceManager::ref().getETfromDate("2006 Aug 22 17:00:00", _startTrail);
|
||||
SpiceManager::ref().getETfromDate("2007 feb 27 07:19:00", _startTrail);
|
||||
SpiceManager::ref().getETfromDate("2007 feb 26 17:42:00", _startTrail);
|
||||
_dtEt = _startTrail;
|
||||
|
||||
fullYearSweep();
|
||||
|
||||
+44
-12
@@ -167,7 +167,9 @@ bool SpiceManager::getNaifId(const std::string& body, int& id) const {
|
||||
}
|
||||
else {
|
||||
SpiceBoolean success;
|
||||
bods2c_c(body.c_str(), &id, &success);
|
||||
SpiceInt sid = id;
|
||||
bods2c_c(body.c_str(), &sid, &success);
|
||||
id = sid;
|
||||
if (success == SPICEFALSE)
|
||||
LERROR("Could not find NAIF ID of body '" + body + "'");
|
||||
return (success == SPICETRUE);
|
||||
@@ -177,6 +179,7 @@ bool SpiceManager::getNaifId(const std::string& body, int& id) const {
|
||||
bool getValueInternal(const std::string& body, const std::string& value, int S,
|
||||
double* v)
|
||||
{
|
||||
|
||||
if (body.empty()) {
|
||||
LERROR("No body was provided");
|
||||
return false;
|
||||
@@ -186,7 +189,7 @@ bool getValueInternal(const std::string& body, const std::string& value, int S,
|
||||
return false;
|
||||
}
|
||||
|
||||
int n;
|
||||
SpiceInt n;
|
||||
bodvrd_c(body.c_str(), value.c_str(), S, &n, v);
|
||||
|
||||
bool hasError = SpiceManager::checkForError("Error getting value '" + value +
|
||||
@@ -228,7 +231,7 @@ bool SpiceManager::getValue(const std::string& body, const std::string& value,
|
||||
return false;
|
||||
}
|
||||
|
||||
int n;
|
||||
SpiceInt n;
|
||||
bodvrd_c(body.c_str(), value.c_str(), static_cast<SpiceInt>(v.size()), &n, &v[0]);
|
||||
|
||||
bool hasError = checkForError("Error getting value '" + value + "' for body '" +
|
||||
@@ -310,12 +313,20 @@ bool SpiceManager::getTargetPosition(const std::string& target,
|
||||
return true;
|
||||
}
|
||||
|
||||
// do NOT remove this method.
|
||||
void SpiceManager::frameConversion(glm::dvec3& v, const std::string from, const std::string to, double ephemerisTime) const{
|
||||
glm::dmat3 transform;
|
||||
// get rotation matrix from frame A - frame B
|
||||
pxform_c(from.c_str(), to.c_str(), ephemerisTime, (double(*)[3])glm::value_ptr(transform));
|
||||
transform = glm::transpose(transform);
|
||||
// re-express vector in new frame
|
||||
mxv_c((double(*)[3])glm::value_ptr(transform), glm::value_ptr(v), glm::value_ptr(v));
|
||||
}
|
||||
|
||||
v = transform*v;
|
||||
glm::dvec3 SpiceManager::orthogonalProjection(glm::dvec3& v1, glm::dvec3& v2){
|
||||
glm::dvec3 projected;
|
||||
vproj_c(glm::value_ptr(v1), glm::value_ptr(v2), glm::value_ptr(projected));
|
||||
|
||||
return projected;
|
||||
}
|
||||
|
||||
bool SpiceManager::getSurfaceIntercept(const std::string& target,
|
||||
@@ -326,9 +337,9 @@ bool SpiceManager::getSurfaceIntercept(const std::string& target,
|
||||
const std::string& aberrationCorrection,
|
||||
double ephemerisTime,
|
||||
double& targetEpoch,
|
||||
psc& directionVector,
|
||||
psc& surfaceIntercept,
|
||||
psc& surfaceVector) const{
|
||||
glm::dvec3& directionVector,
|
||||
glm::dvec3& surfaceIntercept,
|
||||
glm::dvec3& surfaceVector) const{
|
||||
// make pretty latr
|
||||
double dvec[3], spoint[3], et;
|
||||
glm::dvec3 srfvec;
|
||||
@@ -369,9 +380,11 @@ bool SpiceManager::getSurfaceIntercept(const std::string& target,
|
||||
if (convert) frameConversion(srfvec, bodyfixed, referenceFrame, ephemerisTime);
|
||||
|
||||
if (!hasError && found){
|
||||
directionVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(dvec[0] , dvec[1] , dvec[2] );
|
||||
surfaceIntercept = PowerScaledCoordinate::CreatePowerScaledCoordinate(spoint[0], spoint[1], spoint[2]);
|
||||
surfaceVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(srfvec[0], srfvec[1], srfvec[2]);
|
||||
|
||||
|
||||
memcpy(glm::value_ptr(directionVector), dvec, sizeof(dvec));
|
||||
memcpy(glm::value_ptr(surfaceIntercept), spoint, sizeof(spoint));
|
||||
surfaceVector = srfvec;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
@@ -436,6 +449,7 @@ bool SpiceManager::getStateTransformMatrix(const std::string& fromFrame,
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
// I honestly dont even think we need this, deprecatable relic from previous crunch time.
|
||||
bool SpiceManager::getPositionPrimeMeridian(const std::string& fromFrame,
|
||||
const std::string& body,
|
||||
double ephemerisTime,
|
||||
@@ -468,6 +482,24 @@ bool SpiceManager::getPositionTransformMatrix(const std::string& fromFrame,
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
|
||||
bool SpiceManager::getPositionTransformMatrix(const std::string& fromFrame,
|
||||
const std::string& toFrame,
|
||||
double ephemerisTimeFrom,
|
||||
double ephemerisTimeTo,
|
||||
glm::dmat3& positionMatrix) const{
|
||||
|
||||
pxfrm2_c(fromFrame.c_str(), toFrame.c_str(), ephemerisTimeFrom, ephemerisTimeTo, (double(*)[3])glm::value_ptr(positionMatrix));
|
||||
|
||||
bool hasError = checkForError("Error retrieving position transform matrix from "
|
||||
"frame '" + fromFrame + "' to frame '" + toFrame +
|
||||
"' at time '" + std::to_string(ephemerisTimeTo) + "'");
|
||||
positionMatrix = glm::transpose(positionMatrix);
|
||||
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
|
||||
bool SpiceManager::getFieldOfView(const std::string& instrument, std::string& fovShape,
|
||||
std::string& frameName, glm::dvec3& boresightVector,
|
||||
std::vector<glm::dvec3>& bounds) const
|
||||
@@ -492,7 +524,7 @@ bool SpiceManager::getFieldOfView(int instrument,
|
||||
static char fovShapeBuffer[bufferSize];
|
||||
static char frameNameBuffer[bufferSize];
|
||||
|
||||
int nrReturned;
|
||||
SpiceInt nrReturned;
|
||||
double boundsArr[maxBoundsSize][3];
|
||||
|
||||
getfov_c(instrument, // instrument id
|
||||
|
||||
Reference in New Issue
Block a user