mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-24 05:18:59 -05:00
Merge branch 'updateSGCT' into develop
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<Window fullScreen="false">
|
||||
<Stereo type="none" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="512" y="512" />
|
||||
<Size x="1920" y="1920" />
|
||||
<!-- Frame buffer resolution
|
||||
<Res x="4096" y="4096" /> -->
|
||||
<!--
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
bool initializeGL();
|
||||
void preSynchronization();
|
||||
void postSynchronizationPreDraw();
|
||||
void render();
|
||||
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
|
||||
void postDraw();
|
||||
void keyboardCallback(int key, int action);
|
||||
void charCallback(unsigned int codepoint);
|
||||
|
||||
@@ -69,7 +69,6 @@ private:
|
||||
|
||||
std::string _source;
|
||||
std::string _destination;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __PlanetGeometryProjection_H__
|
||||
#define __PlanetGeometryProjection_H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/planets/RenderablePlanetProjection.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace planetgeometryprojection {
|
||||
|
||||
class PlanetGeometryProjection : public properties::PropertyOwner {
|
||||
public:
|
||||
static PlanetGeometryProjection* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
|
||||
PlanetGeometryProjection();
|
||||
virtual ~PlanetGeometryProjection();
|
||||
virtual bool initialize(RenderablePlanetProjection* parent);
|
||||
virtual void deinitialize();
|
||||
virtual void render() = 0;
|
||||
|
||||
protected:
|
||||
RenderablePlanetProjection* _parent;
|
||||
};
|
||||
|
||||
} // namespace planetgeometry
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __PLANETGEOMETRY_H__
|
||||
@@ -69,7 +69,9 @@ private:
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
std::string _frame;
|
||||
std::string _target;
|
||||
double _time;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __RENDERABLEPLANETPROJECTION_H__
|
||||
#define __RENDERABLEPLANETPROJECTION_H__
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/imagesequencer.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <ghoul/opengl/framebufferobject.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <openspace/query/query.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace planetgeometryprojection {
|
||||
class PlanetGeometryProjection;
|
||||
}
|
||||
|
||||
class RenderablePlanetProjection : public Renderable {
|
||||
public:
|
||||
RenderablePlanetProjection(const ghoul::Dictionary& dictionary);
|
||||
~RenderablePlanetProjection();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
|
||||
void loadTexture();
|
||||
void loadProjectionTexture();
|
||||
bool auxiliaryRendertarget();
|
||||
glm::mat4 computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up);
|
||||
void attitudeParameters(double time);
|
||||
|
||||
private:
|
||||
void imageProjectGPU();
|
||||
|
||||
properties::StringProperty _colorTexturePath;
|
||||
properties::StringProperty _projectionTexturePath;
|
||||
properties::TriggerProperty _imageTrigger;
|
||||
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
ghoul::opengl::ProgramObject* _fboProgramObject;
|
||||
|
||||
ghoul::opengl::Texture* _texture;
|
||||
ghoul::opengl::Texture* _textureProj;
|
||||
planetgeometryprojection::PlanetGeometryProjection* _geometry;
|
||||
|
||||
glm::vec2 _camScaling;
|
||||
glm::vec3 _up;
|
||||
glm::mat4 _transform;
|
||||
glm::mat4 _projectorMatrix;
|
||||
|
||||
// spice
|
||||
std::string _sequenceFile;
|
||||
std::string _instrumentID;
|
||||
std::string _projectorID;
|
||||
std::string _projecteeID;
|
||||
std::string _aberration;
|
||||
float _fovy;
|
||||
float _aspectRatio;
|
||||
float _nearPlane;
|
||||
float _farPlane;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
glm::dmat3 _instrumentMatrix;
|
||||
glm::vec3 _boresight;
|
||||
|
||||
double _time[2];
|
||||
double lightTime;
|
||||
|
||||
std::string _target;
|
||||
std::string _defaultProjImage;
|
||||
std::string _next;
|
||||
bool _capture;
|
||||
|
||||
// FBO stuff
|
||||
GLuint _fboID;
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
};
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __RENDERABLEPLANETPROJECTION_H__
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
bool initialize(RenderablePlanet* parent) override;
|
||||
void deinitialize() override;
|
||||
void render() override;
|
||||
PowerScaledSphere* _planet;
|
||||
|
||||
private:
|
||||
void createSphere();
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __SIMPLESPHEREGEOMETRYPROJECTION_H__
|
||||
#define __SIMPLESPHEREGEOMETRYPROJECTION_H__
|
||||
|
||||
#include <openspace/rendering/planets/planetgeometryprojection.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderablePlanet;
|
||||
|
||||
namespace planetgeometryprojection {
|
||||
|
||||
class SimpleSphereGeometryProjection : public PlanetGeometryProjection {
|
||||
public:
|
||||
SimpleSphereGeometryProjection(const ghoul::Dictionary& dictionary);
|
||||
~SimpleSphereGeometryProjection();
|
||||
|
||||
|
||||
bool initialize(RenderablePlanetProjection* parent) override;
|
||||
void deinitialize() override;
|
||||
void render() override;
|
||||
|
||||
private:
|
||||
void createSphere();
|
||||
|
||||
properties::Vec2Property _radius;
|
||||
properties::IntProperty _segments;
|
||||
|
||||
|
||||
properties::IntProperty _vaoID;
|
||||
properties::IntProperty _vBufferID;
|
||||
properties::IntProperty _iBufferID;
|
||||
|
||||
PowerScaledSphere* _planet;
|
||||
};
|
||||
|
||||
} // namespace planetgeometry
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __SIMPLESPHEREGEOMETRY_H__
|
||||
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __RENDERABLEPLANET_H__
|
||||
#define __RENDERABLEPLANET_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace planetgeometry {
|
||||
class PlanetGeometry;
|
||||
}
|
||||
|
||||
class RenderablePlanet : public Renderable {
|
||||
public:
|
||||
RenderablePlanet(const ghoul::Dictionary& dictionary);
|
||||
~RenderablePlanet();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
void loadTexture();
|
||||
|
||||
private:
|
||||
properties::StringProperty _colorTexturePath;
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
planetgeometry::PlanetGeometry* _geometry;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
std::string _target;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __RENDERABLEPLANET_H__
|
||||
@@ -22,14 +22,20 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __RENDERABLEFOV_H__
|
||||
#define __RENDERABLEFOV_H__
|
||||
#ifndef __RenderableFov_H__
|
||||
#define __RenderableFov_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/query/query.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
//#include <openspace/util/runtimedata.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
namespace openspace {
|
||||
class RenderableFov : public Renderable{
|
||||
@@ -48,54 +54,127 @@ public:
|
||||
properties::StringProperty _colorTexturePath;
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
void loadTexture();
|
||||
void fullYearSweep();
|
||||
openspace::SceneGraphNode* _targetNode;
|
||||
|
||||
void loadTexture();
|
||||
void allocateData();
|
||||
void insertPoint(std::vector<float>& arr, psc& p, glm::vec4& c);
|
||||
void fovProjection(bool H[], std::vector<glm::dvec3> bounds);
|
||||
|
||||
psc orthogonalProjection(glm::dvec3 camvec);
|
||||
psc checkForIntercept(glm::dvec3 ray);
|
||||
psc pscInterpolate(psc p0, psc p1, float t);
|
||||
psc sphericalInterpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
|
||||
|
||||
glm::dvec3 interpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
|
||||
glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance);
|
||||
|
||||
void computeColors();
|
||||
|
||||
// instance variables
|
||||
int _nrInserted = 0;
|
||||
int _isteps;
|
||||
bool _rebuild = false;
|
||||
bool _interceptTag[5];
|
||||
bool _withinFOV;
|
||||
psc _projectionBounds[4];
|
||||
psc _interceptVector;
|
||||
|
||||
// modfile reads
|
||||
// spice
|
||||
std::string _target;
|
||||
std::string _spacecraft;
|
||||
std::string _observer;
|
||||
std::string _frame;
|
||||
// color
|
||||
std::string _instrumentID;
|
||||
std::string _method;
|
||||
std::string _aberrationCorrection;
|
||||
std::string _fovTarget;
|
||||
|
||||
glm::dvec3 ipoint, ivec;
|
||||
glm::dvec3 _previousHalf;
|
||||
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...
|
||||
GLuint _vaoID ;
|
||||
GLuint _vBufferID ;
|
||||
GLuint _iBufferID;
|
||||
// GPU stuff
|
||||
GLuint _vaoID[2] ;
|
||||
GLuint _vboID[2] ;
|
||||
GLuint _iboID[2];
|
||||
GLenum _mode;
|
||||
unsigned int _isize[2];
|
||||
unsigned int _vsize[2];
|
||||
unsigned int _vtotal[2];
|
||||
unsigned int _stride[2];
|
||||
std::vector<float> _varray1;
|
||||
std::vector<float> _varray2;
|
||||
int* _iarray1[2];
|
||||
|
||||
void updateData();
|
||||
void sendToGPU();
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
unsigned int _isize;
|
||||
unsigned int _vsize;
|
||||
unsigned int _vtotal;
|
||||
unsigned int _stride;
|
||||
|
||||
double _startTrail;
|
||||
|
||||
//Vertex* _varray;
|
||||
std::vector<float> _varray;
|
||||
std::vector<int> _iarray;
|
||||
|
||||
bool _once = false;
|
||||
|
||||
//used for update of trail
|
||||
psc _pscpos, _pscvel;
|
||||
double _increment;
|
||||
// time
|
||||
double _time = 0;
|
||||
double _oldTime = 0;
|
||||
|
||||
int _delta = 0;
|
||||
int _dtprogress = 0;
|
||||
// capturetime
|
||||
double _timeInterval;
|
||||
double _nextCaptureTime;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// Scrap stuff i need to keep for now (michal)
|
||||
|
||||
|
||||
/* // 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;
|
||||
}*/
|
||||
|
||||
/*
|
||||
psc RenderableFov::sphericalInterpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
|
||||
double targetEt, lt;
|
||||
glm::dvec3 ip, iv;
|
||||
psc targetPos;
|
||||
SpiceManager::ref().getTargetPosition("JUPITER", _spacecraft, _frame, _aberrationCorrection, _time, targetPos, lt);
|
||||
|
||||
openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
|
||||
_frame, _method, _aberrationCorrection, _time, targetEt, p0, ip, iv);
|
||||
psc psc0 = PowerScaledCoordinate::CreatePowerScaledCoordinate(iv[0], iv[1], iv[2]);
|
||||
openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
|
||||
_frame, _method, _aberrationCorrection, _time, targetEt, p1, ip, iv);
|
||||
psc psc1 = PowerScaledCoordinate::CreatePowerScaledCoordinate(iv[0], iv[1], iv[2]);
|
||||
psc0[3] += 3;
|
||||
psc1[3] += 3;
|
||||
|
||||
psc0 -= targetPos;
|
||||
psc1 -= targetPos;
|
||||
|
||||
double angle = psc0.angle(psc1);
|
||||
|
||||
std::cout << angle << std::endl;
|
||||
|
||||
double sin_a = sin(angle); // opt
|
||||
double l[2] = { sin((1.f - t)*angle) / sin_a, sin((t)*angle) / sin_a };
|
||||
|
||||
std::cout << l[0] << " " << l[1] << std::endl;
|
||||
|
||||
float s = ((t-1)*psc0[3] + (t)*psc1[3]);
|
||||
float x = (l[0]*psc0[0] + l[1]*psc1[0]);
|
||||
float y = (l[0]*psc0[1] + l[1]*psc1[1]);
|
||||
float z = (l[0]*psc0[2] + l[1]*psc1[2]);
|
||||
|
||||
psc interpolated = PowerScaledCoordinate::PowerScaledCoordinate(x, y, z, 10);
|
||||
return interpolated;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -64,6 +64,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;
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
bool initializeGL();
|
||||
void postSynchronizationPreDraw();
|
||||
void preSynchronization();
|
||||
void render();
|
||||
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
|
||||
void postDraw();
|
||||
|
||||
void takeScreenshot();
|
||||
|
||||
@@ -96,6 +96,7 @@ private:
|
||||
//sync variables
|
||||
std::mutex _mutex;
|
||||
std::vector<std::string> _queuedScripts;
|
||||
std::vector<std::string> _receivedScripts;
|
||||
std::string _currentSyncedScript;
|
||||
};
|
||||
|
||||
|
||||
@@ -111,6 +111,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 {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __IMAGESEQUENCER_H__
|
||||
#define __IMAGESEQUENCER_H__
|
||||
|
||||
// open space includes
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ImageSequencer {
|
||||
public:
|
||||
static ImageSequencer& ref();
|
||||
bool loadSequence(const std::string dir);
|
||||
|
||||
bool parsePlaybook(const std::string& dir, const std::string& type, std::string year = "2015");
|
||||
bool parsePlaybookFile(const std::string& fileName, std::string year = "2015");
|
||||
|
||||
void testStartTimeMap();
|
||||
|
||||
static void initialize();
|
||||
static void deinitialize();
|
||||
bool sequenceReset();
|
||||
|
||||
bool getImagePath(double& _currentTime, std::string& path, bool closedInterval = false);
|
||||
bool getImagePath(std::string _currentTime, std::string& path, bool closedInterval = false);
|
||||
double getNextCaptureTime();
|
||||
double getIntervalLength(){ return _intervalLength; };
|
||||
|
||||
static ImageSequencer* _sequencer;
|
||||
|
||||
private:
|
||||
double nextCaptureTime(double _time);
|
||||
|
||||
void createImage(double t1, double t2, std::string path = "dummypath");
|
||||
|
||||
double _nextCapture;
|
||||
double _intervalLength;
|
||||
|
||||
std::string _defaultCaptureImage;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __IMAGESEQUENCER_H__
|
||||
@@ -60,6 +60,13 @@ public:
|
||||
|
||||
// returns the rescaled, "normal" coordinates
|
||||
glm::vec3 vec3() const;
|
||||
|
||||
// return the full psc as dvec4()
|
||||
glm::dvec4& dvec4() const;
|
||||
|
||||
// rescaled return as dvec3
|
||||
glm::dvec3 dvec3() const;
|
||||
|
||||
// length of the vector as a pss
|
||||
PowerScaledScalar length() const;
|
||||
glm::vec3 direction() const;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
#include <ghoul/opengl/vertexbufferobject.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -44,7 +43,8 @@ public:
|
||||
|
||||
void render();
|
||||
|
||||
private:
|
||||
|
||||
//private:
|
||||
typedef struct {
|
||||
GLfloat location[4];
|
||||
GLfloat tex[2];
|
||||
@@ -52,12 +52,14 @@ private:
|
||||
GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase
|
||||
} Vertex;
|
||||
|
||||
GLuint _vaoID;
|
||||
GLuint _vBufferID;
|
||||
GLuint _iBufferID;
|
||||
|
||||
unsigned int _isize;
|
||||
unsigned int _vsize;
|
||||
Vertex* _varray;
|
||||
int* _iarray;
|
||||
|
||||
ghoul::opengl::VertexBufferObject _vbo;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __SPICEMANAGER_H__
|
||||
|
||||
#include "SpiceUsr.h"
|
||||
#include "SpiceZpr.h"
|
||||
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
@@ -111,7 +112,7 @@ public:
|
||||
|
||||
/**
|
||||
* Determines whether values exist for some <code>item</code> for any
|
||||
* <code>body</code> in the kernel pool by passing it to the <code>bodfnd_c</code>
|
||||
* code>body</code> in the kernel pool by passing it to the <code>bodfnd_c</code>
|
||||
* function.
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/bodfnd_c.html
|
||||
* \param body The name of the body that should be sampled
|
||||
@@ -217,6 +218,9 @@ public:
|
||||
bool getValue(const std::string& body, const std::string& value,
|
||||
std::vector<double>& v) const;
|
||||
|
||||
|
||||
bool spacecraftClockToET(const std::string craftIdCode, double& craftTicks, double& et);
|
||||
|
||||
/**
|
||||
* Converts the <code>timeString</code> representing a date to a double precision
|
||||
* value representing the <code>ephemerisTime</code>; that is the number of TDB
|
||||
@@ -250,6 +254,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
|
||||
@@ -290,7 +312,71 @@ public:
|
||||
psc& position,
|
||||
double& lightTime) const;
|
||||
|
||||
void getPointingAttitude();
|
||||
/**
|
||||
* Given an observer and a direction vector defining a ray, compute
|
||||
* the surface intercept of the ray on a target body at a specified
|
||||
* epoch, optionally corrected for light time and stellar
|
||||
* aberration.
|
||||
* \param method Computation method.
|
||||
* \param target Name of target body.
|
||||
* \param et Epoch in ephemeris seconds past J2000 TDB.
|
||||
* \param fixref Body-fixed, body-centered target body frame.
|
||||
* \param abcorr Aberration correction.
|
||||
* \param obsrvr Name of observing body.
|
||||
* \param dref Reference frame of ray's direction vector.
|
||||
* \param dvec Ray's direction vector.
|
||||
* \param spoint Surface intercept point on the target body.
|
||||
* \param trgepc Intercept epoch.
|
||||
* \param srfvec Vector from observer to intercept point.
|
||||
* \param found Flag indicating whether intercept was found.
|
||||
* For further details, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/sincpt_c.html
|
||||
*/
|
||||
bool getSurfaceIntercept(const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& fovFrame,
|
||||
const std::string& bodyFixedFrame,
|
||||
const std::string& method,
|
||||
const std::string& aberrationCorrection,
|
||||
double ephemerisTime,
|
||||
double& targetEpoch,
|
||||
glm::dvec3& directionVector,
|
||||
glm::dvec3& surfaceIntercept,
|
||||
glm::dvec3& surfaceVector) const;
|
||||
|
||||
/**
|
||||
* Determine if a specified ephemeris object is within the
|
||||
* field-of-view (FOV) of a specified instrument at a given time.
|
||||
* \param Name or ID code string of the instrument.
|
||||
* \param Name or ID code string of the target.
|
||||
* \param Type of shape model used for the target.
|
||||
* \param Body-fixed, body-centered frame for target body.
|
||||
* \param Aberration correction method.
|
||||
* \param Name or ID code string of the observer.
|
||||
* \param Time of the observation (seconds past J2000).
|
||||
* \param Visibility flag (SPICETRUE/SPICEFALSE).
|
||||
* For further detail, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/fovtrg_c.html
|
||||
*/
|
||||
bool targetWithinFieldOfView(const std::string& instrument,
|
||||
const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& method,
|
||||
const std::string& referenceFrame,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const;
|
||||
/**
|
||||
* This method performs the same computation as the function its overloading
|
||||
* with the exception that in doing so it assumes the inertial bodyfixed frame
|
||||
* is that of 'IAU' type, allowing the client to omitt the
|
||||
* <code>referenceFrame</code> for planetary objects.
|
||||
*/
|
||||
bool targetWithinFieldOfView(const std::string& instrument,
|
||||
const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& method,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const;
|
||||
|
||||
/**
|
||||
* Returns the state vector (<code>position</code> and <code>velocity</code>) of a
|
||||
@@ -375,6 +461,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,
|
||||
@@ -465,9 +570,8 @@ public:
|
||||
* surface point on a body with the NAIF ID of <code>id</code> to rectangular
|
||||
* <code>coordinates</code>. For further details, refer to
|
||||
* http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/srfrec_c.html.
|
||||
* \param id The identifier of the body on which the <code>longitude</code> and
|
||||
* <code>latitude</code> are defined. This body needs to have a defined radius for
|
||||
* this function to work.
|
||||
* \param body The body on which the <code>longitude</code> and <code>latitude</code>
|
||||
* are defined. This body needs to have a defined radius for this function to work
|
||||
* \param longitude The longitude of the point on the <code>body</code> in radians
|
||||
* \param latitude The latitude of the point on the <code>body</code> in radians
|
||||
* \param coordinates The output containing the rectangular coordinates of the point
|
||||
@@ -524,7 +628,7 @@ public:
|
||||
glm::dvec3& subObserverPoint,
|
||||
double& targetEphemerisTime,
|
||||
glm::dvec3& vectorToSurfacePoint) const;
|
||||
|
||||
|
||||
/**
|
||||
* This method checks if one of the previous SPICE methods has failed. If it has, the
|
||||
* <code>errorMessage</code> is used to log an error along with the original SPICE
|
||||
|
||||
+1
-1
Submodule openspace-data updated: d8bc6ea847...1a280ed06a
+4
-2
@@ -8,7 +8,9 @@ return {
|
||||
TESTDIR = "${BASE_PATH}/src/tests",
|
||||
CONFIG = "${BASE_PATH}/config",
|
||||
CACHE = "${BASE_PATH}/cache",
|
||||
FONTS = "${OPENSPACE_DATA}/fonts"
|
||||
FONTS = "${OPENSPACE_DATA}/fonts",
|
||||
PLUTO_KERNELS = "${OPENSPACE_DATA}/spice/Pluto",
|
||||
JP_KERNELS = "${OPENSPACE_DATA}/spice/JP_KERNELS"
|
||||
},
|
||||
SpiceKernel = {
|
||||
Time = "${OPENSPACE_DATA}/spice/naif0010.tls",
|
||||
@@ -40,5 +42,5 @@ return {
|
||||
--SGCTConfig = "${SGCT}/single_fisheye.xml",
|
||||
--SGCTConfig = "${SGCT}/two_nodes.xml",
|
||||
--SGCTConfig = "${SGCT}/single_sbs_stereo.xml",
|
||||
Scene = "${OPENSPACE_DATA}/scene/default.scene",
|
||||
Scene = "${OPENSPACE_DATA}/scene/default_michal.scene",
|
||||
}
|
||||
@@ -18,7 +18,7 @@ openspace.bindKey("T", "openspace.distance(-interaction_speed * openspace.dt(),
|
||||
openspace.bindKey("G", "openspace.distance(interaction_speed * openspace.dt(), 6.0)")
|
||||
openspace.bindKey("Y", "openspace.distance(-interaction_speed * openspace.dt(), 10.0)")
|
||||
openspace.bindKey("H", "openspace.distance(interaction_speed * openspace.dt(), 10.0)")
|
||||
openspace.bindKey("U", "openspace.distance(-interaction_speed * openspace.dt(), 13.0)")
|
||||
openspace.bindKey("J", "openspace.distance(interaction_speed * openspace.dt(), 13.0)")
|
||||
openspace.bindKey("U", "openspace.distance(-interaction_speed * openspace.dt(), 10.0)")
|
||||
openspace.bindKey("J", "openspace.distance(interaction_speed * openspace.dt(), 10.0)")
|
||||
|
||||
openspace.bindKey("PRINT_SCREEN", "openspace.takeScreenshot()")
|
||||
@@ -0,0 +1,12 @@
|
||||
openspace.printInfo("Setting default values");
|
||||
openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false);
|
||||
|
||||
openspace.setPropertyValue("Stars.renderable.magnitudeClamp", {0.941, 3.824});
|
||||
openspace.setPropertyValue("Stars.renderable.exponentialOffset", 6.180);
|
||||
openspace.setPropertyValue("Stars.renderable.exponentialDampening", 0.838);
|
||||
openspace.setPropertyValue("Stars.renderable.scaleFactor", 0.563);
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.65);
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50);
|
||||
|
||||
openspace.printInfo("Done setting default values");
|
||||
@@ -1,11 +1,32 @@
|
||||
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
|
||||
openspace.time.setTime("2007-02-26T17:30:00")
|
||||
--openspace.time.setTime("2006-08-22T20:00:00")
|
||||
|
||||
--openspace.time.setDeltaTime(200000.0)
|
||||
--openspace.time.setDeltaTime(5000.00)
|
||||
--openspace.time.setDeltaTime(864000)
|
||||
openspace.time.setDeltaTime(100.0)
|
||||
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)
|
||||
|
||||
--openspace.time.setTime("2015-07-14T11:22:00.00") -- PLUTO
|
||||
--BEAUTIFUL SEQUENCE -- NH takes series of images (same as previous)
|
||||
-- Sequence ends at 2015 JUL 14T11:24:00:000, (recommended dt = 1)
|
||||
|
||||
--openspace.time.setTime("2015-07-14T11:36:40.00") -- PLUTO
|
||||
-- NH takes series of images (same as previous)
|
||||
-- Sequence ends at 2015 JUL 14T11:39:15:000, (recommended dt = 1)
|
||||
|
||||
--openspace.time.setTime("2015-07-14T11:48:43.00") -- CHARON
|
||||
--NH takes imagesequence across terminator
|
||||
-- Sequence ends at 2015 JUL 14T11:49:30:000, (recommended dt = 1)
|
||||
|
||||
--openspace.time.setTime("2015-07-14T12:04:35.00") -- PLUTO
|
||||
--NH takes imagesequence across Plutos north pole
|
||||
-- Sequence ends at 2015 JUL 14T12:05:48:000, (recommended dt = 1)
|
||||
|
||||
--openspace.time.setTime("2015-07-14T15:02:46.00") -- PLUTO DARKSIDE
|
||||
--From this point on NH takes a huge amount of images of the far side of
|
||||
-- CHARON and PLUTO - recommend run time from here and just let it run
|
||||
-- until audience tires (enough to fill 10-15 mins if run at dt = 100)
|
||||
|
||||
|
||||
openspace.time.setDeltaTime(10)
|
||||
-- print(openspace.time.currentTimeUTC())
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform mat4 ProjectorMatrix;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform vec2 _scaling;
|
||||
uniform vec2 radius;
|
||||
flat in uint vs_segments;
|
||||
|
||||
in vec4 vs_position;
|
||||
uniform vec3 boresight;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
|
||||
vec4 uvToModel( float u, float v, vec2 radius, float segments){
|
||||
const float fj = u * segments;
|
||||
const float fi = v * segments;
|
||||
|
||||
const float theta = fi * float(M_PI) / segments; // 0 -> PI
|
||||
const float phi = fj * float(M_PI) * 2.0f / segments;
|
||||
|
||||
const float x = radius[0] * sin(phi) * sin(theta); //
|
||||
const float y = radius[0] * cos(theta); // up
|
||||
const float z = radius[0] * cos(phi) * sin(theta); //
|
||||
|
||||
return vec4(x, y, z, radius[1]);
|
||||
}
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
bool inRange(float x, float a, float b){
|
||||
return (x >= a && x <= b);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = vec2(0.5,0.5)*vs_position.xy+vec2(0.5,0.5);
|
||||
|
||||
vec4 vertex = uvToModel(uv.x, uv.y, radius, vs_segments);
|
||||
|
||||
vec4 raw_pos = psc_to_meter(vertex, _scaling);
|
||||
vec4 projected = ProjectorMatrix * ModelTransform * raw_pos;
|
||||
|
||||
projected.x /= projected.w;
|
||||
projected.y /= projected.w;
|
||||
|
||||
vec3 normal = normalize((ModelTransform*vec4(vertex.xyz,0)).xyz);
|
||||
|
||||
vec3 v_b = normalize(boresight);
|
||||
|
||||
if((inRange(projected.x, 0, 1) &&
|
||||
inRange(projected.y, 0, 1)) &&
|
||||
dot(v_b, normal) < 0 ) {
|
||||
color = texture(texture1, projected.xy);
|
||||
}else{
|
||||
color = vec4(1,1,1,0);
|
||||
}
|
||||
// color.a = 0.1f;//1.f - abs(uv.x - 0.55) / (0.6 - 0.5); // blending
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430
|
||||
uniform mat4 ProjectorMatrix;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform vec2 _scaling;
|
||||
|
||||
layout(location = 3) in vec4 in_position;
|
||||
uniform vec3 boresight;
|
||||
layout(location = 5) in int segments;
|
||||
uniform vec2 radius;
|
||||
|
||||
out vec4 vs_position;
|
||||
flat out uint vs_segments;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vs_position = in_position;
|
||||
vs_segments = segments;
|
||||
gl_Position = vec4(in_position.xy, 0.0, 1.0);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
in vec4 vs_point_position;
|
||||
in vec4 vs_point_velocity;
|
||||
|
||||
|
||||
//out vec4 diffuse;
|
||||
|
||||
#include "ABuffer/abufferStruct.hglsl"
|
||||
#include "ABuffer/abufferAddToBuffer.hglsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec4 position = vs_point_position;
|
||||
float depth = pscDepth(position);
|
||||
|
||||
// set the depth
|
||||
//gl_FragDepth = depth;
|
||||
|
||||
//float l = length(vs_point_velocity);
|
||||
|
||||
vec4 diffuse = vs_point_velocity;
|
||||
|
||||
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
|
||||
addToBuffer(frag);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
//uniform vec4 etColor;
|
||||
uniform vec4 objectVelocity;
|
||||
|
||||
layout(location = 0) in vec4 in_point_position;
|
||||
layout(location = 1) in vec4 in_point_velocity;
|
||||
layout(location = 2) in vec2 in_point_timeindex;
|
||||
|
||||
|
||||
out vec4 vs_point_position;
|
||||
out vec4 vs_point_velocity;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vs_point_velocity = in_point_velocity;
|
||||
|
||||
vec4 tmp = in_point_position;
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_point_position = tmp;
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
/*
|
||||
//vs_point_position = objpos;
|
||||
|
||||
// rotate and scale vertex with model transform and add the translation
|
||||
vec3 local_vertex_pos = mat3(ModelTransform) * in_point_position.xyz;
|
||||
//vec4 lvp = ModelTransform * in_point_position;
|
||||
|
||||
// PSC addition; local vertex position and the object power scaled world position
|
||||
vs_point_position = psc_addition(vec4(local_vertex_pos,in_point_position.w),objpos);
|
||||
//vs_point_position = psc_addition(lvp,objpos);
|
||||
|
||||
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
|
||||
vs_point_position = psc_addition(vs_point_position,vec4(-campos.xyz,campos.w));
|
||||
|
||||
// rotate the camera
|
||||
local_vertex_pos = mat3(camrot) * vs_point_position.xyz;
|
||||
vs_point_position = vec4(local_vertex_pos, vs_point_position.w);
|
||||
//vs_point_position = camrot* vs_point_position;
|
||||
|
||||
// project using the rescaled coordinates,
|
||||
//vec4 vs_point_position_rescaled = psc_scaling(vs_point_position, scaling);
|
||||
vec4 vs_point_position_rescaled = psc_to_meter(vs_point_position, scaling);
|
||||
//vs_point_position = vs_point_position_rescaled;
|
||||
|
||||
// project the position to view space
|
||||
gl_Position = ViewProjection * vs_point_position_rescaled;
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430
|
||||
|
||||
uniform vec4 campos;
|
||||
uniform vec4 objpos;
|
||||
//uniform vec3 camdir; // add this for specular
|
||||
|
||||
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
uniform sampler2D texture2;
|
||||
|
||||
in vec2 vs_st;
|
||||
in vec4 vs_normal;
|
||||
in vec4 vs_position;
|
||||
|
||||
in vec4 ProjTexCoord;
|
||||
uniform vec3 boresight;
|
||||
uniform vec3 sun_pos;
|
||||
|
||||
#include "ABuffer/abufferStruct.hglsl"
|
||||
#include "ABuffer/abufferAddToBuffer.hglsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
//#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
void main()
|
||||
{
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
vec4 diffuse = texture(texture1, vs_st);
|
||||
|
||||
// directional lighting
|
||||
vec3 origin = vec3(0.0);
|
||||
vec4 spec = vec4(0.0);
|
||||
|
||||
vec3 n = normalize(vs_normal.xyz);
|
||||
//vec3 e = normalize(camdir);
|
||||
vec3 l_pos = sun_pos; // sun.
|
||||
vec3 l_dir = normalize(l_pos-objpos.xyz);
|
||||
float terminatorBright = 0.4;
|
||||
float intensity = min(max(5*dot(n,l_dir), terminatorBright), 1);
|
||||
|
||||
float shine = 0.0001;
|
||||
|
||||
vec4 specular = vec4(0.1);
|
||||
vec4 ambient = vec4(0.f,0.f,0.f,1);
|
||||
/* Specular
|
||||
if(intensity > 0.f){
|
||||
// halfway vector
|
||||
vec3 h = normalize(l_dir + e);
|
||||
// specular factor
|
||||
float intSpec = max(dot(h,n),0.0);
|
||||
spec = specular * pow(intSpec, shine);
|
||||
}
|
||||
*/
|
||||
//diffuse = max(intensity * diffuse, ambient);
|
||||
|
||||
// PROJECTIVE TEXTURE
|
||||
vec4 projTexColor = textureProj(texture2, ProjTexCoord);
|
||||
vec4 shaded = max(intensity * diffuse, ambient);
|
||||
if (ProjTexCoord[0] > 0.0 ||
|
||||
ProjTexCoord[1] > 0.0 ||
|
||||
ProjTexCoord[0] < ProjTexCoord[2] ||
|
||||
ProjTexCoord[1] < ProjTexCoord[2]){
|
||||
diffuse = shaded;
|
||||
}else if(dot(n,boresight) < 0 &&
|
||||
(projTexColor.w != 0)){// frontfacing
|
||||
diffuse = projTexColor;//*0.5f + 0.5f*shaded;
|
||||
}else{
|
||||
diffuse = shaded;
|
||||
}
|
||||
|
||||
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
|
||||
addToBuffer(frag);
|
||||
|
||||
discard;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version 430
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
//texture projection matrix
|
||||
|
||||
uniform mat4 ProjectorMatrix;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
//in vec3 in_position;
|
||||
layout(location = 1) in vec2 in_st;
|
||||
layout(location = 2) in vec3 in_normal;
|
||||
|
||||
uniform vec3 boresight;
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_normal;
|
||||
out vec4 vs_position;
|
||||
out float s;
|
||||
|
||||
|
||||
out vec4 ProjTexCoord;
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
void main(){
|
||||
// Radius = 0.71492 *10^8;
|
||||
// set variables
|
||||
vs_st = in_st;
|
||||
//vs_stp = in_position.xyz;
|
||||
vs_position = in_position;
|
||||
vec4 tmp = in_position;
|
||||
|
||||
// this is wrong for the normal.
|
||||
// The normal transform is the transposed inverse of the model transform
|
||||
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
|
||||
vec4 raw_pos = psc_to_meter(in_position, scaling);
|
||||
ProjTexCoord = ProjectorMatrix * ModelTransform * raw_pos;
|
||||
|
||||
position = ViewProjection * position;
|
||||
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
@@ -30,6 +30,8 @@ uniform vec4 objpos;
|
||||
|
||||
uniform bool _performShading = true;
|
||||
|
||||
uniform int shadows;
|
||||
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
#include <openspace/util/imagesequencer.h>
|
||||
|
||||
|
||||
#include <ghoul/cmdparser/commandlineparser.h>
|
||||
@@ -195,6 +196,8 @@ bool OpenSpaceEngine::create(int argc, char** argv,
|
||||
}
|
||||
}
|
||||
|
||||
ImageSequencer::initialize();
|
||||
|
||||
// Create the cachemanager
|
||||
FileSys.createCacheManager(absPath("${" + constants::configurationmanager::keyCache + "}"));
|
||||
_engine->_console->initialize();
|
||||
@@ -565,8 +568,8 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
}
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::render() {
|
||||
_renderEngine->render();
|
||||
void OpenSpaceEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix) {
|
||||
_renderEngine->render(projectionMatrix, viewMatrix);
|
||||
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
// If currently writing a command, render it to screen
|
||||
@@ -574,7 +577,7 @@ void OpenSpaceEngine::render() {
|
||||
if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _console->isVisible()) {
|
||||
_console->render();
|
||||
}
|
||||
|
||||
|
||||
if (_gui->isEnabled())
|
||||
_gui->endFrame();
|
||||
}
|
||||
|
||||
@@ -825,22 +825,22 @@ void InteractionHandler::keyboardCallback(int key, int action) {
|
||||
Time::ref().retreatTime(sgct::Engine::instance()->getDt());
|
||||
}
|
||||
if (key == 262) {
|
||||
glm::vec3 euler(0.0, speed * dt, 0.0);
|
||||
glm::vec3 euler(0.0, speed * dt*0.4, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotateDelta(rot);
|
||||
}
|
||||
if (key == 263) {
|
||||
glm::vec3 euler(0.0, -speed * dt, 0.0);
|
||||
glm::vec3 euler(0.0, -speed * dt*0.4, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotateDelta(rot);
|
||||
}
|
||||
if (key == 264) {
|
||||
glm::vec3 euler(speed * dt, 0.0, 0.0);
|
||||
glm::vec3 euler(speed * dt*0.4, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotateDelta(rot);
|
||||
}
|
||||
if (key == 265) {
|
||||
glm::vec3 euler(-speed * dt, 0.0, 0.0);
|
||||
glm::vec3 euler(-speed * dt*0.4, 0.0, 0.0);
|
||||
glm::quat rot = glm::quat(euler);
|
||||
rotateDelta(rot);
|
||||
}
|
||||
|
||||
+22
-25
@@ -42,13 +42,8 @@ void mainMousePosCallback(double x, double y);
|
||||
void mainMouseScrollCallback(double posX, double posY);
|
||||
void mainEncodeFun();
|
||||
void mainDecodeFun();
|
||||
|
||||
#if 0
|
||||
// @TODO Remove the ifdef hen the next SGCT version is available ---abock
|
||||
void mainExternalControlCallback(const char * receivedChars, int size);
|
||||
#else
|
||||
void mainExternalControlCallback(const char * receivedChars, int size, int clientId);
|
||||
#endif
|
||||
void mainLogCallback(const char* msg);
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "main";
|
||||
@@ -68,18 +63,11 @@ int main(int argc, char** argv)
|
||||
for (int i = 0; i < newArgc; ++i)
|
||||
newArgv[i] = const_cast<char*>(sgctArguments.at(i).c_str());
|
||||
|
||||
#if 0
|
||||
// @TODO Remove the ifdef (enabling the functions) when the next SGCT version is available
|
||||
// that enables the logging redirect ---abock
|
||||
sgct::MessageHandler::instance()->setLogToConsole(false);
|
||||
sgct::MessageHandler::instance()->setShowTime(false);
|
||||
sgct::MessageHandler::instance()->setLogToCallback(true);
|
||||
sgct::MessageHandler::instance()->setLogCallback([](const char* msg) {
|
||||
std::string message = msg;
|
||||
// Remove the trailing \n that is passed along
|
||||
LINFOC("SGCT", message.substr(0, message.size()-1));
|
||||
});
|
||||
#endif
|
||||
sgct::MessageHandler::instance()->setLogCallback(mainLogCallback);
|
||||
|
||||
|
||||
LDEBUG("Creating SGCT Engine");
|
||||
_sgctEngine = new sgct::Engine(newArgc, newArgv);
|
||||
@@ -162,7 +150,19 @@ void mainPostSyncPreDrawFunc()
|
||||
|
||||
void mainRenderFunc()
|
||||
{
|
||||
OsEng.render();
|
||||
//not the most efficient, but for clarity @JK
|
||||
|
||||
glm::mat4 userMatrix = glm::translate(glm::mat4(1.f), _sgctEngine->getDefaultUserPtr()->getPos());
|
||||
glm::mat4 sceneMatrix = _sgctEngine->getModelMatrix();
|
||||
glm::mat4 viewMatrix = _sgctEngine->getActiveViewMatrix() * userMatrix;
|
||||
|
||||
//dont shift nav-direction on master, makes it very tricky to navigate @JK
|
||||
if (!_sgctEngine->isMaster()){
|
||||
viewMatrix = viewMatrix * sceneMatrix;
|
||||
}
|
||||
|
||||
glm::mat4 projectionMatrix = _sgctEngine->getActiveProjectionMatrix();
|
||||
OsEng.render(projectionMatrix, viewMatrix);
|
||||
}
|
||||
|
||||
void mainPostDrawFunc()
|
||||
@@ -170,20 +170,11 @@ void mainPostDrawFunc()
|
||||
OsEng.postDraw();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// @TODO Remove the ifdef hen the next SGCT version is available ---abock
|
||||
void mainExternalControlCallback(const char* receivedChars, int size)
|
||||
{
|
||||
if (_sgctEngine->isMaster())
|
||||
OsEng.externalControlCallback(receivedChars, size, 0);
|
||||
}
|
||||
#else
|
||||
void mainExternalControlCallback(const char* receivedChars, int size, int clientId)
|
||||
{
|
||||
if (_sgctEngine->isMaster())
|
||||
OsEng.externalControlCallback(receivedChars, size, clientId);
|
||||
}
|
||||
#endif
|
||||
|
||||
void mainKeyboardCallback(int key, int action)
|
||||
{
|
||||
@@ -226,3 +217,9 @@ void mainDecodeFun()
|
||||
{
|
||||
OsEng.decode();
|
||||
}
|
||||
|
||||
void mainLogCallback(const char* msg){
|
||||
std::string message = msg;
|
||||
// Remove the trailing \n that is passed along
|
||||
LINFOC("SGCT", message.substr(0, std::max<size_t>(message.size() - 1, 0)));
|
||||
}
|
||||
@@ -201,7 +201,7 @@ void WavefrontGeometry::loadObj(const char *filename){
|
||||
vertexIndex = _iarray[m] * 3;
|
||||
_iarray[m] = m;
|
||||
|
||||
_varray[m].location[3] = 7; // I need to set this proper at some point.
|
||||
_varray[m].location[3] = 6; // I need to set this proper at some point.
|
||||
int q = 0;
|
||||
while (q < 3){
|
||||
_varray[m].location[q] = tempVertexArray[vertexIndex + q];
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/planets/PlanetGeometryProjection.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "PlanetGeometryProjection";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
namespace planetgeometryprojection {
|
||||
|
||||
PlanetGeometryProjection* PlanetGeometryProjection::createFromDictionary(const ghoul::Dictionary& dictionary)
|
||||
{
|
||||
std::string geometryType;
|
||||
const bool success = dictionary.getValue(
|
||||
constants::planetgeometry::keyType, geometryType);
|
||||
if (!success) {
|
||||
LERROR("PlanetGeometry did not contain a correct value of the key '"
|
||||
<< constants::planetgeometry::keyType << "'");
|
||||
return nullptr;
|
||||
}
|
||||
ghoul::TemplateFactory<PlanetGeometryProjection>* factory
|
||||
= FactoryManager::ref().factory<PlanetGeometryProjection>();
|
||||
|
||||
PlanetGeometryProjection* result = factory->create(geometryType, dictionary);
|
||||
if (result == nullptr) {
|
||||
LERROR("Failed to create a PlanetGeometry object of type '" << geometryType
|
||||
<< "'");
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PlanetGeometryProjection::PlanetGeometryProjection()
|
||||
: _parent(nullptr)
|
||||
{
|
||||
setName("PlanetGeometryProjection");
|
||||
}
|
||||
|
||||
PlanetGeometryProjection::~PlanetGeometryProjection()
|
||||
{
|
||||
}
|
||||
|
||||
bool PlanetGeometryProjection::initialize(RenderablePlanetProjection* parent)
|
||||
{
|
||||
_parent = parent;
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlanetGeometryProjection::deinitialize()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace planetgeometry
|
||||
} // namespace openspace
|
||||
@@ -47,6 +47,8 @@ namespace {
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
const std::string keyShading = "PerformShading";
|
||||
|
||||
const std::string keyBody = "Body";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -77,7 +79,10 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
|
||||
}
|
||||
|
||||
dictionary.getValue(keyFrame, _target);
|
||||
dictionary.getValue(keyFrame, _frame);
|
||||
|
||||
bool b1 = dictionary.getValue(keyBody, _target);
|
||||
assert(b1 == true);
|
||||
|
||||
// TODO: textures need to be replaced by a good system similar to the geometry as soon
|
||||
// as the requirements are fixed (ab)
|
||||
@@ -151,10 +156,18 @@ void RenderablePlanet::render(const RenderData& data)
|
||||
}
|
||||
}
|
||||
transform = transform* rot;
|
||||
if (_frame == "IAU_JUPITER"){ //x = 0.935126
|
||||
transform *= glm::scale(glm::mat4(1), glm::vec3(1, 0.93513, 1));
|
||||
}
|
||||
|
||||
|
||||
//glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
|
||||
//glm::vec3 camSpaceEye = (-(modelview*data.position.vec4())).xyz;
|
||||
|
||||
psc sun_pos;
|
||||
double lt;
|
||||
openspace::SpiceManager::ref().getTargetPosition("SUN", _target, "GALACTIC", "NONE", _time, sun_pos, lt);
|
||||
|
||||
// setup the data to the shader
|
||||
// _programObject->setUniform("camdir", camSpaceEye);
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
@@ -178,7 +191,8 @@ void RenderablePlanet::render(const RenderData& data)
|
||||
|
||||
void RenderablePlanet::update(const UpdateData& data){
|
||||
// set spice-orientation in accordance to timestamp
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_target, "GALACTIC", data.time, _stateMatrix);
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_frame, "GALACTIC", data.time, _stateMatrix);
|
||||
_time = data.time;
|
||||
}
|
||||
|
||||
void RenderablePlanet::loadTexture()
|
||||
|
||||
@@ -0,0 +1,435 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/planets/RenderablePlanetProjection.h>
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/rendering/planets/planetgeometryprojection.h>
|
||||
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
//#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
#include <sgct.h>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderablePlanetProjection";
|
||||
const std::string keyProjObserver = "Projection.Observer";
|
||||
const std::string keyProjTarget = "Projection.Target";
|
||||
const std::string keyProjAberration = "Projection.Aberration";
|
||||
const std::string keyInstrument = "Instrument.Name";
|
||||
const std::string keyInstrumentFovy = "Instrument.Fovy";
|
||||
const std::string keyInstrumentAspect = "Instrument.Aspect";
|
||||
const std::string keyInstrumentNear = "Instrument.Near";
|
||||
const std::string keyInstrumentFar = "Instrument.Far";
|
||||
const std::string keySequenceDir = "Projection.Sequence";
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
const std::string keyShading = "PerformShading";
|
||||
|
||||
const std::string keyBody = "Body";
|
||||
|
||||
const std::string _mainFrame = "GALACTIC";
|
||||
}
|
||||
namespace openspace {
|
||||
RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath("planetTexture", "RGB Texture")
|
||||
, _projectionTexturePath("projectionTexture", "RGB Texture")
|
||||
, _imageTrigger("clearProjections", "Clear Projections")
|
||||
//, _sequencer(nullptr)
|
||||
, _programObject(nullptr)
|
||||
, _fboProgramObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _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);
|
||||
|
||||
std::string path;
|
||||
success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
|
||||
assert(success);
|
||||
|
||||
_defaultProjImage = path + "/textures/defaultProj.png";
|
||||
|
||||
ghoul::Dictionary geometryDictionary;
|
||||
success = dictionary.getValue(
|
||||
keyGeometry, geometryDictionary);
|
||||
if (success) {
|
||||
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
|
||||
geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
|
||||
_geometry = planetgeometryprojection::PlanetGeometryProjection::createFromDictionary(geometryDictionary);
|
||||
}
|
||||
|
||||
dictionary.getValue(keyFrame, _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 = "";
|
||||
success = dictionary.getValue("Textures.Color", texturePath);
|
||||
if (success){
|
||||
_colorTexturePath = path + "/" + texturePath;
|
||||
}
|
||||
success = dictionary.getValue("Textures.Project", texturePath);
|
||||
if (success){
|
||||
_projectionTexturePath = path + "/" + texturePath;
|
||||
}
|
||||
addPropertySubOwner(_geometry);
|
||||
|
||||
addProperty(_imageTrigger);
|
||||
_imageTrigger.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
|
||||
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");
|
||||
}
|
||||
|
||||
RenderablePlanetProjection::~RenderablePlanetProjection(){
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool RenderablePlanetProjection::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess
|
||||
&= OsEng.ref().configurationManager()->getValue("projectiveProgram", _programObject);
|
||||
|
||||
if (_fboProgramObject == nullptr)
|
||||
completeSuccess
|
||||
&= OsEng.ref().configurationManager()->getValue("fboPassProgram", _fboProgramObject);
|
||||
|
||||
loadTexture();
|
||||
loadProjectionTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
completeSuccess &= (_textureProj != nullptr);
|
||||
|
||||
completeSuccess &= _geometry->initialize(this);
|
||||
|
||||
completeSuccess &= auxiliaryRendertarget();
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
bool RenderablePlanetProjection::auxiliaryRendertarget(){
|
||||
bool completeSuccess = false;
|
||||
// setup FBO
|
||||
glGenFramebuffers(1, &_fboID);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _fboID);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *_texture, 0);
|
||||
// check FBO status
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||
completeSuccess &= false;
|
||||
// switch back to window-system-provided framebuffer
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
// SCREEN-QUAD
|
||||
const GLfloat size = 1.0f;
|
||||
const GLfloat w = 1.0f;
|
||||
const GLfloat vertex_data[] = {
|
||||
-size, -size, 0.0f, w, 0, 1,
|
||||
size, size, 0.0f, w, 1, 0,
|
||||
-size, size, 0.0f, w, 0, 0,
|
||||
-size, -size, 0.0f, w, 0, 1,
|
||||
size, -size, 0.0f, w, 1, 1,
|
||||
size, size, 0.0f, w, 1, 0,
|
||||
};
|
||||
|
||||
glGenVertexArrays(1, &_quad); // generate array
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(4);
|
||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
bool RenderablePlanetProjection::deinitialize(){
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
delete _textureProj;
|
||||
_textureProj = nullptr;
|
||||
delete _geometry;
|
||||
_geometry = nullptr;
|
||||
return true;
|
||||
}
|
||||
bool RenderablePlanetProjection::isReady() const {
|
||||
return (_geometry != nullptr);
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::imageProjectGPU(){
|
||||
// keep handle to the current bound FBO
|
||||
GLint defaultFBO;
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
|
||||
|
||||
GLint m_viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, m_viewport);
|
||||
//counter = 0;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _fboID);
|
||||
// set blend eq
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ZERO);
|
||||
|
||||
glViewport(0, 0, _texture->width(), _texture->height());
|
||||
_fboProgramObject->activate();
|
||||
|
||||
ghoul::opengl::TextureUnit unitFbo;
|
||||
unitFbo.activate();
|
||||
_textureProj->bind();
|
||||
_fboProgramObject->setUniform("texture1" , unitFbo);
|
||||
_fboProgramObject->setUniform("ProjectorMatrix", _projectorMatrix);
|
||||
_fboProgramObject->setUniform("ModelTransform" , _transform);
|
||||
_fboProgramObject->setUniform("_scaling" , _camScaling);
|
||||
_fboProgramObject->setUniform("boresight" , _boresight);
|
||||
|
||||
//TODO - needs target switching.
|
||||
if (_geometry->hasProperty("radius")){
|
||||
boost::any r = _geometry->property("radius")->get();
|
||||
if (glm::vec2* radius = boost::any_cast<glm::vec2>(&r)){
|
||||
_fboProgramObject->setUniform("radius", radius[0]);
|
||||
}
|
||||
}else{
|
||||
LERROR("Geometry object needs to provide radius");
|
||||
}
|
||||
// pass nr of segments
|
||||
if (_geometry->hasProperty("segments")){
|
||||
boost::any s = _geometry->property("segments")->get();
|
||||
if (int* segments = boost::any_cast<int>(&s)){
|
||||
_fboProgramObject->setAttribute("segments", segments[0]);
|
||||
}
|
||||
}else{
|
||||
LERROR("Geometry object needs to provide segment count");
|
||||
}
|
||||
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
_fboProgramObject->deactivate();
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
//bind back to default
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
|
||||
glViewport(m_viewport[0], m_viewport[1],
|
||||
m_viewport[2], m_viewport[3]);
|
||||
|
||||
}
|
||||
|
||||
glm::mat4 RenderablePlanetProjection::computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up){
|
||||
//rotate boresight into correct alignment
|
||||
_boresight = _instrumentMatrix*aim;
|
||||
glm::vec3 uptmp(_instrumentMatrix*glm::dvec3(up));
|
||||
|
||||
// create view matrix
|
||||
glm::vec3 e3 = glm::normalize(_boresight);
|
||||
glm::vec3 e1 = glm::normalize(glm::cross(uptmp, e3));
|
||||
glm::vec3 e2 = glm::normalize(glm::cross(e3, e1));
|
||||
glm::mat4 projViewMatrix = glm::mat4(e1.x, e2.x, e3.x, 0.f,
|
||||
e1.y, e2.y, e3.y, 0.f,
|
||||
e1.z, e2.z, e3.z, 0.f,
|
||||
-glm::dot(e1, loc), -glm::dot(e2, loc), -glm::dot(e3, loc), 1.f);
|
||||
// create perspective projection matrix
|
||||
glm::mat4 projProjectionMatrix = glm::perspective(_fovy, _aspectRatio, _nearPlane, _farPlane);
|
||||
// bias matrix
|
||||
glm::mat4 projNormalizationMatrix = glm::mat4(0.5f, 0, 0, 0,
|
||||
0, 0.5f, 0, 0,
|
||||
0, 0, 0.5f, 0,
|
||||
0.5f, 0.5f, 0.5f, 1);
|
||||
return projNormalizationMatrix*projProjectionMatrix*projViewMatrix;
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::attitudeParameters(double time){
|
||||
// precomputations for shader
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_target, _mainFrame, time, _stateMatrix);
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _mainFrame, time, _instrumentMatrix);
|
||||
|
||||
_transform = glm::mat4(1);
|
||||
//90 deg rotation w.r.t spice req.
|
||||
glm::mat4 rot = glm::rotate(_transform, 90.f, glm::vec3(1, 0, 0));
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
_transform[i][j] = _stateMatrix[i][j];
|
||||
}
|
||||
}
|
||||
_transform = _transform* rot;
|
||||
/* if (_target == "IAU_JUPITER"){ // tmp solution scale of jupiterX = 0.935126
|
||||
_transform *= glm::scale(glm::mat4(1), glm::vec3(1, 0.935126, 1));
|
||||
}*/
|
||||
std::string shape, instrument;
|
||||
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");
|
||||
|
||||
psc position; //observer target
|
||||
found = SpiceManager::ref().getTargetPosition(_projectorID, _projecteeID, _mainFrame, _aberration, time, position, lightTime);
|
||||
if (!found) LERROR("Could not locate target position");
|
||||
position[3] += 3;
|
||||
glm::vec3 cpos = position.vec3();
|
||||
|
||||
_projectorMatrix = computeProjectorMatrix(cpos, bs, _up);
|
||||
}
|
||||
|
||||
#define GPU_PROJ
|
||||
void RenderablePlanetProjection::render(const RenderData& data){
|
||||
if (!_programObject) return;
|
||||
if (!_textureProj) return;
|
||||
|
||||
_camScaling = data.camera.scaling();
|
||||
_up = data.camera.lookUpVector();
|
||||
|
||||
#ifdef GPU_PROJ
|
||||
if (_capture){
|
||||
attitudeParameters(_time[0]);
|
||||
imageProjectGPU();
|
||||
}
|
||||
#endif
|
||||
attitudeParameters(_time[1]);
|
||||
|
||||
psc sun_pos;
|
||||
double lt;
|
||||
openspace::SpiceManager::ref().getTargetPosition("SUN", _projecteeID, "GALACTIC", "NONE", _time[1], sun_pos, lt);
|
||||
|
||||
// Main renderpass
|
||||
_programObject->activate();
|
||||
// setup the data to the shader
|
||||
_programObject->setUniform("sun_pos", sun_pos.vec3());
|
||||
_programObject->setUniform("ProjectorMatrix", _projectorMatrix);
|
||||
_programObject->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform" , _transform);
|
||||
_programObject->setUniform("boresight" , _boresight);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
// Bind texture
|
||||
ghoul::opengl::TextureUnit unit[2];
|
||||
unit[0].activate();
|
||||
_texture->bind();
|
||||
_programObject->setUniform("texture1", unit[0]);
|
||||
unit[1].activate();
|
||||
_textureProj->bind();
|
||||
_programObject->setUniform("texture2", unit[1]);
|
||||
// render geometry
|
||||
_geometry->render();
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::update(const UpdateData& data){
|
||||
// set spice-orientation in accordance to timestamp
|
||||
_time[0] = data.time;
|
||||
_time[1] = _time[0];
|
||||
_capture = false;
|
||||
|
||||
bool _withinFOV;
|
||||
/* -- TEMPORARY TARGETING SOLUTION -- */
|
||||
std::string potential[2] = { "PLUTO", "CHARON" }; // only possible to target these two for now.
|
||||
|
||||
std::string _fovTarget = "";
|
||||
for (int i = 0; i < 2; i++){
|
||||
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i], _projectorID, "ELLIPSOID", _aberration, _time[0]);
|
||||
if (_withinFOV){
|
||||
_fovTarget = potential[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_projecteeID == _fovTarget){
|
||||
_next = _defaultProjImage;
|
||||
if (_time[0] >= openspace::ImageSequencer::ref().getNextCaptureTime()){
|
||||
_capture = openspace::ImageSequencer::ref().getImagePath(_time[0], _next);
|
||||
}
|
||||
_projectionTexturePath = _next;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadProjectionTexture(){
|
||||
delete _textureProj;
|
||||
_textureProj = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
_textureProj = ghoul::io::TextureReader::ref().loadTexture(absPath(_projectionTexturePath));
|
||||
if (_textureProj) {
|
||||
_textureProj->uploadTexture();
|
||||
_textureProj->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
_textureProj->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder);
|
||||
}
|
||||
}
|
||||
//_sequencer->sequenceReset();
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadTexture(){
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
|
||||
if (_texture) {
|
||||
_texture->uploadTexture();
|
||||
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace openspace
|
||||
@@ -104,8 +104,7 @@ void SimpleSphereGeometry::render()
|
||||
_sphere->render();
|
||||
}
|
||||
|
||||
void SimpleSphereGeometry::createSphere()
|
||||
{
|
||||
void SimpleSphereGeometry::createSphere(){
|
||||
//create the power scaled scalar
|
||||
|
||||
PowerScaledScalar planetSize(_radius);
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/planets/SimpleSphereGeometryProjection.h>
|
||||
#include <openspace/util/constants.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "SimpleSphereGeometryProjection";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace constants {
|
||||
namespace simplespheregeometryprojection {
|
||||
const std::string keyRadius = "Radius";
|
||||
const std::string keySegments = "Segments";
|
||||
} // namespace simplespheregeometry
|
||||
}
|
||||
|
||||
namespace planetgeometryprojection {
|
||||
|
||||
SimpleSphereGeometryProjection::SimpleSphereGeometryProjection(const ghoul::Dictionary& dictionary)
|
||||
: PlanetGeometryProjection()
|
||||
, _radius("radius", "Radius", glm::vec2(1.f, 0.f), glm::vec2(-10.f, -20.f),
|
||||
glm::vec2(10.f, 20.f))
|
||||
, _segments("segments", "Segments", 20, 1, 1000)
|
||||
, _vaoID("vaoID", "Vao", 1, 1, 1)
|
||||
, _vBufferID("vboID", "Vbo", 1, 1, 1)
|
||||
, _iBufferID("iboID", "Ibo", 1, 1, 1)
|
||||
, _planet(nullptr)
|
||||
{
|
||||
using constants::scenegraphnode::keyName;
|
||||
using constants::simplespheregeometryprojection::keyRadius;
|
||||
using constants::simplespheregeometryprojection::keySegments;
|
||||
|
||||
// The name is passed down from the SceneGraphNode
|
||||
std::string name;
|
||||
bool success = dictionary.getValue(keyName, name);
|
||||
assert(success);
|
||||
|
||||
glm::vec2 radius;
|
||||
success = dictionary.getValue(keyRadius, radius);
|
||||
if (!success) {
|
||||
LERROR("SimpleSphereGeometry of '" << name << "' did not provide a key '"
|
||||
<< keyRadius << "'");
|
||||
}
|
||||
else
|
||||
_radius = radius;
|
||||
|
||||
double segments;
|
||||
success = dictionary.getValue(keySegments, segments);
|
||||
if (!success) {
|
||||
LERROR("SimpleSphereGeometry of '" << name << "' did not provide a key '"
|
||||
<< keySegments << "'");
|
||||
}
|
||||
else
|
||||
_segments = static_cast<int>(segments);
|
||||
|
||||
addProperty(_radius);
|
||||
_radius.onChange(std::bind(&SimpleSphereGeometryProjection::createSphere, this));
|
||||
addProperty(_segments);
|
||||
_segments.onChange(std::bind(&SimpleSphereGeometryProjection::createSphere, this));
|
||||
}
|
||||
|
||||
SimpleSphereGeometryProjection::~SimpleSphereGeometryProjection()
|
||||
{
|
||||
}
|
||||
|
||||
bool SimpleSphereGeometryProjection::initialize(RenderablePlanetProjection* parent)
|
||||
{
|
||||
bool success = PlanetGeometryProjection::initialize(parent);
|
||||
createSphere();
|
||||
|
||||
//need to have this accessible in planetgeometryprojection for now -- Michal
|
||||
_vaoID = static_cast<int>(_planet->_vaoID);
|
||||
_vBufferID = static_cast<int>(_planet->_vBufferID);
|
||||
_iBufferID = static_cast<int>(_planet->_iBufferID);
|
||||
addProperty(_vaoID);
|
||||
addProperty(_vBufferID);
|
||||
addProperty(_iBufferID);
|
||||
return success;
|
||||
}
|
||||
|
||||
void SimpleSphereGeometryProjection::deinitialize()
|
||||
{
|
||||
delete _planet;
|
||||
_planet = nullptr;
|
||||
}
|
||||
|
||||
void SimpleSphereGeometryProjection::render()
|
||||
{
|
||||
_planet->render();
|
||||
}
|
||||
|
||||
void SimpleSphereGeometryProjection::createSphere()
|
||||
{
|
||||
//create the power scaled scalar
|
||||
|
||||
PowerScaledScalar planetSize(_radius);
|
||||
_parent->setBoundingSphere(planetSize);
|
||||
|
||||
delete _planet;
|
||||
_planet = new PowerScaledSphere(planetSize, _segments);
|
||||
_planet->initialize();
|
||||
}
|
||||
|
||||
} // namespace planetgeometry
|
||||
} // namespace openspace
|
||||
+426
-140
@@ -29,215 +29,501 @@
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <openspace/util/imagesequencer.h>
|
||||
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
#include <openspace/query/query.h>
|
||||
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <iomanip>
|
||||
#include <utility>
|
||||
#include <utility>
|
||||
#include <chrono>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderableFov";
|
||||
const std::string _loggerCat = "RenderableFov";
|
||||
//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 keyBody = "Body";
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyPathModule = "ModulePath";
|
||||
const std::string keyColor = "RGB";
|
||||
const std::string keyInstrument = "Instrument.Name";
|
||||
const std::string keyInstrumentMethod = "Instrument.Method";
|
||||
const std::string keyInstrumentAberration = "Instrument.Aberration";
|
||||
}
|
||||
|
||||
//#define DEBUG
|
||||
namespace openspace{
|
||||
RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath("colorTexture", "Color Texture")
|
||||
, _programObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _vaoID(0)
|
||||
, _vBufferID(0)
|
||||
, _iBufferID(0)
|
||||
{
|
||||
// @TODO Uncomment when used again, do not depend on assert in constructor --jonasstrandstedt
|
||||
//dictionary.getValue(keyBody, _target);
|
||||
//dictionary.getValue(keyObserver, _observer);
|
||||
//dictionary.getValue(keyFrame, _frame);
|
||||
// colors, move later
|
||||
glm::vec4 col_sq;
|
||||
glm::vec4 c_project;
|
||||
glm::vec4 col_end;
|
||||
glm::vec4 blue;
|
||||
glm::vec4 col_gray;
|
||||
glm::vec4 col_start;
|
||||
|
||||
if (!dictionary.getValue(keyColor, _c)){
|
||||
_c = glm::vec3(0.0);
|
||||
}else{
|
||||
_r = 1 / _c[0];
|
||||
_g = 1 / _c[1];
|
||||
_b = 1 / _c[2];
|
||||
}
|
||||
RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath("colorTexture", "Color Texture")
|
||||
, _programObject(nullptr)
|
||||
, _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);
|
||||
|
||||
assert(b1 == true);
|
||||
assert(b2 == true);
|
||||
assert(b3 == true);
|
||||
assert(b4 == true);
|
||||
assert(b5 == true);
|
||||
}
|
||||
void RenderableFov::fullYearSweep(){
|
||||
|
||||
void RenderableFov::allocateData(){
|
||||
int points = 8;
|
||||
_stride = 8;
|
||||
_isize = points;
|
||||
_iarray.clear();
|
||||
|
||||
_stride[0] = points;
|
||||
_isize[0] = points;
|
||||
_iarray1[0] = new int[_isize[0]];
|
||||
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.push_back(i);
|
||||
_iarray1[0][i] = i;
|
||||
}
|
||||
|
||||
_stride = 8;
|
||||
_vsize = static_cast<unsigned int>(_varray.size());
|
||||
_vtotal = static_cast<int>(_vsize / _stride);
|
||||
_stride[0] = 8;
|
||||
_vsize[0] = _varray1.size();
|
||||
_vtotal[0] = static_cast<int>(_vsize[0] / _stride[0]);
|
||||
|
||||
// allocate second vbo data
|
||||
int cornerPoints = 5;
|
||||
_isize[1] = cornerPoints;
|
||||
_iarray1[1] = new int[_isize[1]];
|
||||
for (int i = 0; i < _isize[1]; i++){
|
||||
_iarray1[1][i] = i;
|
||||
}
|
||||
_varray2.resize(40);
|
||||
_vsize[1] = 40;
|
||||
_vtotal[1] = 5;
|
||||
_isteps = 10;
|
||||
}
|
||||
|
||||
RenderableFov::~RenderableFov(){
|
||||
}
|
||||
|
||||
bool RenderableFov::isReady() const {
|
||||
bool ready = true;
|
||||
ready &= (_programObject != nullptr);
|
||||
|
||||
return ready;
|
||||
}
|
||||
|
||||
void RenderableFov::sendToGPU(){
|
||||
// Initialize and upload to graphics card
|
||||
glGenVertexArrays(1, &_vaoID);
|
||||
glGenBuffers(1, &_vBufferID);
|
||||
glGenBuffers(1, &_iBufferID);
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
|
||||
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]);
|
||||
|
||||
GLsizei st = sizeof(GLfloat) * _stride;
|
||||
|
||||
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, _iBufferID);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray.data(), GL_STATIC_DRAW);
|
||||
|
||||
glBindVertexArray(0);
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
|
||||
bool RenderableFov::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess &= OsEng.ref().configurationManager()->getValue("FovProgram", _programObject);
|
||||
completeSuccess &= OsEng.ref().configurationManager()->getValue("EphemerisProgram", _programObject);
|
||||
|
||||
SpiceManager::ref().getETfromDate("2007 feb 26 20:00:00", _startTrail);
|
||||
|
||||
fullYearSweep();
|
||||
sendToGPU();
|
||||
allocateData();
|
||||
sendToGPU();
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
bool RenderableFov::deinitialize(){
|
||||
if (_texture)
|
||||
delete _texture;
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
|
||||
glDeleteVertexArrays(1, &_vaoID);
|
||||
glDeleteBuffers(1, &_vBufferID);
|
||||
glDeleteBuffers(1, &_iBufferID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderableFov::isReady() const {
|
||||
return _programObject != nullptr;
|
||||
}
|
||||
|
||||
void RenderableFov::sendToGPU(){
|
||||
// Initialize and upload to graphics card
|
||||
glGenVertexArrays(1, &_vaoID[0]);
|
||||
glGenBuffers(1, &_vboID[0]);
|
||||
glGenBuffers(1, &_iboID[0]);
|
||||
|
||||
glBindVertexArray(_vaoID[0]);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID[0]);
|
||||
glBufferData(GL_ARRAY_BUFFER, _vsize[0] * sizeof(GLfloat), NULL, GL_STATIC_DRAW); // orphaning the buffer, sending NULL data.
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[0] * sizeof(GLfloat), &_varray1[0]);
|
||||
|
||||
GLsizei st = sizeof(GLfloat) * _stride[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, _iboID[0]);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize[0] * sizeof(int), _iarray1, GL_STATIC_DRAW);
|
||||
glBindVertexArray(0);
|
||||
|
||||
// second vbo
|
||||
glGenVertexArrays(1, &_vaoID[1]);
|
||||
glGenBuffers(1, &_vboID[1]);
|
||||
glGenBuffers(1, &_iboID[1]);
|
||||
|
||||
glBindVertexArray(_vaoID[1]);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID[1]);
|
||||
glBufferData(GL_ARRAY_BUFFER, _vsize[1] * sizeof(GLfloat), NULL, GL_STATIC_DRAW); // orphaning the buffer, sending NULL data.
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[1] * 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, _iboID[1]);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize[1] * sizeof(int), _iarray1[1], GL_STATIC_DRAW);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
// various helper methods
|
||||
|
||||
void RenderableFov::insertPoint(std::vector<float>& arr, psc& p, glm::vec4& c){
|
||||
for (int i = 0; i < 4; i++){
|
||||
arr.push_back(p[i]);
|
||||
}
|
||||
for (int i = 0; i < 4; i++){
|
||||
arr.push_back(c[i]);
|
||||
}
|
||||
_nrInserted++;
|
||||
}
|
||||
|
||||
psc RenderableFov::pscInterpolate(psc p0, psc p1, float t){
|
||||
assert(t >= 0 && t <= 1);
|
||||
float t2 = (1.f - t);
|
||||
return PowerScaledCoordinate::PowerScaledCoordinate(t2*p0[0] + t*p1[0],
|
||||
t2*p0[1] + t*p1[1],
|
||||
t2*p0[2] + t*p1[2],
|
||||
t2*p0[3] + t*p1[3]);
|
||||
}
|
||||
glm::dvec3 RenderableFov::interpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
|
||||
assert(t >= 0 && t <= 1);
|
||||
float t2 = (1.f - t);
|
||||
return glm::dvec3(p0.x*t2 + p1.x*t, p0.y*t2 + p1.y*t, p0.z*t2 + p1.z*t);
|
||||
}
|
||||
// This method is the current bottleneck.
|
||||
psc RenderableFov::checkForIntercept(glm::dvec3 ray){
|
||||
double targetEt;
|
||||
bool intercepted = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
|
||||
_frame, _method, _aberrationCorrection,
|
||||
_time, targetEt, ray, ipoint, ivec);
|
||||
_interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
|
||||
_interceptVector[3] += 3;
|
||||
|
||||
return _interceptVector;
|
||||
}
|
||||
// Orthogonal projection next to planets surface, can also be optimized.
|
||||
psc RenderableFov::orthogonalProjection(glm::dvec3 vecFov){
|
||||
glm::dvec3 vecToTarget;
|
||||
double lt;
|
||||
SpiceManager::ref().getTargetPosition(_fovTarget, _spacecraft, _frame, _aberrationCorrection, _time, vecToTarget, lt);
|
||||
openspace::SpiceManager::ref().frameConversion(vecFov, _instrumentID, _frame, _time);
|
||||
glm::dvec3 p = openspace::SpiceManager::ref().orthogonalProjection(vecToTarget, vecFov);
|
||||
|
||||
psc projection = PowerScaledCoordinate::CreatePowerScaledCoordinate(p[0], p[1], p[2]);
|
||||
projection[3] += 3;
|
||||
|
||||
return projection;
|
||||
}
|
||||
// Bisection method, simple recurtion
|
||||
glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance){
|
||||
//check if point is on surface
|
||||
double targetEt;
|
||||
glm::dvec3 half = interpolate(p1, p2, 0.5f);
|
||||
bool intercepted = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
|
||||
_frame, _method, _aberrationCorrection,
|
||||
_time, targetEt, half, ipoint, ivec);
|
||||
if (glm::distance(_previousHalf, half) < tolerance){
|
||||
_previousHalf = glm::dvec3(0);
|
||||
return half;
|
||||
}
|
||||
_previousHalf = half;
|
||||
//recursive search
|
||||
if (intercepted == false){
|
||||
return bisection(p1, half, tolerance);
|
||||
}else{
|
||||
return bisection(half, p2, tolerance);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
README:
|
||||
There are 4 different cases as each boundary vector can either have detected
|
||||
an intercept or is outside of the planets surface. When no such intercepts are
|
||||
detected the algorithm performs an orthogonal projection to 'clip' the current
|
||||
fov vector next to the planets surface. If two or more intercepts are detected
|
||||
the algorithm continues with the bisection method O(logn) for points [Pn, Pn+1]
|
||||
to locate the point Pb where the orthogonal plane meets the planets surface
|
||||
(within ~20 iterations this will narrow down to centimeter resolution).
|
||||
Upon finding Pb a linear interpolation is performed for [Pn, Pb], at this stage
|
||||
the points are located on a straight line between the surface intercept and the
|
||||
surface-bound fov-corner. In order to correctly place these points on the
|
||||
targets surface, each consecutive point is queried for a surface intercept and
|
||||
thereby moved to the hull.
|
||||
*/
|
||||
void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
|
||||
_nrInserted = 0;
|
||||
_varray2.clear();// empty the array
|
||||
|
||||
double t;
|
||||
double tolerance = 0.0000001; // very low tolerance factor
|
||||
|
||||
glm::dvec3 mid;
|
||||
glm::dvec3 interpolated;
|
||||
glm::dvec3 current;
|
||||
glm::dvec3 next;
|
||||
|
||||
for (int i = 0; i < 4; i++){
|
||||
int k = (i + 1 > 3) ? 0 : i + 1;
|
||||
current = bounds[i];
|
||||
next = bounds[k];
|
||||
if (H[i] == false){ // If point is non-interceptive, project it.
|
||||
insertPoint(_varray2, orthogonalProjection(current), glm::vec4(1));
|
||||
}
|
||||
if (H[i] == true && H[i + 1] == false){ // current point is interceptive, next is not
|
||||
// find outer most point for interpolation
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (H[i] == false && H[i+1] == true){ // current point is non-interceptive, next is
|
||||
mid = bisection(next, current, tolerance);
|
||||
for (int j = 1; j <= _isteps; j++){
|
||||
t = ((double)j / _isteps);
|
||||
interpolated = interpolate(mid, next, t);
|
||||
_interceptVector = (j > 1) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
|
||||
insertPoint(_varray2, _interceptVector, col_sq);
|
||||
}
|
||||
}
|
||||
if (H[i] == true && H[i + 1] == true){ // both points intercept
|
||||
for (int j = 0; j <= _isteps; j++){
|
||||
t = ((double)j / _isteps);
|
||||
interpolated = interpolate(current, next, t);
|
||||
_interceptVector = checkForIntercept(interpolated);
|
||||
insertPoint(_varray2, _interceptVector, col_sq);
|
||||
}
|
||||
}
|
||||
}
|
||||
// only if new points are inserted are we interested in rebuilding the
|
||||
// vbo. Note that this can be optimized but is left as is for now.
|
||||
if (_nrInserted == 0){
|
||||
_rebuild = false;
|
||||
}else{
|
||||
_rebuild = true;
|
||||
//update size etc;
|
||||
_vtotal[1] = _nrInserted;
|
||||
_isize[1] = _nrInserted;
|
||||
_vsize[1] = _varray2.size();
|
||||
_iarray1[1] = new int[_isize[1]];
|
||||
for (int i = 0; i < _isize[1]; i++)
|
||||
_iarray1[1][i] = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RenderableFov::updateData(){
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID[0]);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[0] * sizeof(GLfloat), &_varray1[0]);
|
||||
|
||||
if (!_rebuild){
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID[1]);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[1] * sizeof(GLfloat), &_varray2[0]);
|
||||
}else{
|
||||
glBindVertexArray(_vaoID[1]);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboID[1]);
|
||||
glBufferData(GL_ARRAY_BUFFER, _vsize[1] * sizeof(GLfloat), NULL, GL_STATIC_DRAW); // orphaning the buffer, sending NULL data.
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[1] * sizeof(GLfloat), &_varray2[0]);
|
||||
|
||||
GLsizei st = sizeof(GLfloat) * _stride[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, _iboID[1]);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize[1] * sizeof(int), _iarray1[1], GL_STATIC_DRAW);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
}
|
||||
void RenderableFov::computeColors(){
|
||||
double t2 = openspace::ImageSequencer::ref().getNextCaptureTime();
|
||||
double diff = (t2 - _time);
|
||||
double t = 0.0;
|
||||
if (diff <= 7.0) t = 1.f - diff / 7.0;
|
||||
|
||||
if (diff < 0) t = 0.0;
|
||||
|
||||
c_project = glm::vec4(0.0, 1.0, 0.00,1);
|
||||
col_end = glm::vec4(1.00, 0.29, 0.00, 1);
|
||||
blue = glm::vec4(0, 0.5, 0.7, 1);
|
||||
col_gray = glm::vec4(0.3, 0.3, 0.3, 1);
|
||||
col_start = glm::vec4(1.00, 0.89, 0.00, 1);
|
||||
col_sq = glm::vec4(1.00, 0.29, 0.00, 1);
|
||||
|
||||
col_end.x = c_project.x*t + col_end.x*(1 - t);
|
||||
col_end.y = c_project.y*t + col_end.y*(1 - t);
|
||||
col_end.z = c_project.z*t + col_end.z*(1 - t);
|
||||
|
||||
blue.x = c_project.x*t + blue.x*(1 - t);
|
||||
blue.y = c_project.y*t + blue.y*(1 - t);
|
||||
blue.z = c_project.z*t + blue.z*(1 - t);
|
||||
|
||||
col_sq.x = c_project.x*t + col_sq.x*(1 - t);
|
||||
col_sq.y = c_project.y*t + col_sq.y*(1 - t);
|
||||
col_sq.z = c_project.z*t + col_sq.z*(1 - t);
|
||||
}
|
||||
|
||||
void RenderableFov::render(const RenderData& data){
|
||||
assert(_programObject);
|
||||
_programObject->activate();
|
||||
|
||||
// fetch data
|
||||
glm::mat4 tmat = glm::mat4(1);
|
||||
|
||||
glm::mat4 transform(1);
|
||||
|
||||
glm::mat4 tmp = glm::mat4(1);
|
||||
glm::mat4 rot = glm::rotate(transform, 90.f, glm::vec3(0, 1, 0));
|
||||
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
tmp[i][j] = static_cast<float>(_stateMatrix[i][j]);
|
||||
tmp[i][j] = _stateMatrix[i][j];
|
||||
}
|
||||
}
|
||||
transform = tmp*rot;
|
||||
|
||||
|
||||
// setup the data to the shader
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
// update only when time progresses.
|
||||
if (_oldTime != _time){
|
||||
std::string shape, instrument;
|
||||
std::vector<glm::dvec3> bounds;
|
||||
glm::dvec3 boresight;
|
||||
|
||||
// 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"); // fixlater
|
||||
|
||||
//boresight vector
|
||||
std::string shape, name;
|
||||
shape.resize(32);
|
||||
name.resize(32);
|
||||
std::vector<glm::dvec3> bounds;
|
||||
glm::dvec3 boresight;
|
||||
float size = 4 * sizeof(float);
|
||||
int indx = 0;
|
||||
|
||||
bool found = openspace::SpiceManager::ref().getFieldOfView("NH_LORRI", shape, name, boresight, bounds);
|
||||
// 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" };
|
||||
|
||||
size_t size = 4 * sizeof(float);
|
||||
float *begin = &_varray[0];
|
||||
_fovTarget = potential[0]; //default
|
||||
for (int i = 0; i < 2; i++){
|
||||
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
|
||||
_spacecraft, _method,
|
||||
_aberrationCorrection, _time);
|
||||
if (_withinFOV){
|
||||
_fovTarget = potential[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
computeColors();
|
||||
double t2 = openspace::ImageSequencer::ref().getNextCaptureTime();
|
||||
double diff = (t2 - _time);
|
||||
double t = 0.0;
|
||||
if (diff <= 30.0) t = 1.f - diff / 30.0;
|
||||
|
||||
glm::vec4 origin(0);
|
||||
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);
|
||||
|
||||
float sc = 2.2f;
|
||||
glm::vec4 corner1(bounds[0][0], bounds[0][1], bounds[0][2], data.position[3]-sc);
|
||||
memcpy(begin, glm::value_ptr(origin), size);
|
||||
memcpy(begin + 4, glm::value_ptr(col_start), size);
|
||||
memcpy(begin + 8, glm::value_ptr(corner1), size);
|
||||
memcpy(begin + 12, glm::value_ptr(col_end), size);
|
||||
|
||||
glm::vec4 corner2(bounds[1][0], bounds[1][1], bounds[1][2], data.position[3]-sc);
|
||||
memcpy(begin + 16, glm::value_ptr(origin), size);
|
||||
memcpy(begin + 20, glm::value_ptr(col_start), size);
|
||||
memcpy(begin + 24, glm::value_ptr(corner2), size);
|
||||
memcpy(begin + 28, glm::value_ptr(col_end), size);
|
||||
|
||||
glm::vec4 corner3(bounds[2][0], bounds[2][1], bounds[2][2], data.position[3]-sc);
|
||||
memcpy(begin + 32, glm::value_ptr(origin), size);
|
||||
memcpy(begin + 36, glm::value_ptr(col_start), size);
|
||||
memcpy(begin + 40, glm::value_ptr(corner3), size);
|
||||
memcpy(begin + 44, glm::value_ptr(col_end), size);
|
||||
|
||||
glm::vec4 corner4(bounds[3][0], bounds[3][1], bounds[3][2], data.position[3]-sc);
|
||||
memcpy(begin + 48, glm::value_ptr(origin), size);
|
||||
memcpy(begin + 52, glm::value_ptr(col_start), size);
|
||||
memcpy(begin + 56, glm::value_ptr(corner4), size);
|
||||
memcpy(begin + 60, glm::value_ptr(col_end), size);
|
||||
|
||||
updateData();
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
glDrawArrays(GL_LINE_STRIP, 0, _vtotal);
|
||||
double targetEpoch;
|
||||
// for each FOV vector
|
||||
for (int i = 0; i < 4; i++){
|
||||
// compute surface intercept
|
||||
_interceptTag[i] = openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
|
||||
_frame, _method, _aberrationCorrection,
|
||||
_time, targetEpoch, bounds[i], ipoint, ivec);
|
||||
// if not found, use the orthogonal projected point
|
||||
if (!_interceptTag[i]) _projectionBounds[i] = orthogonalProjection(bounds[i]);
|
||||
|
||||
// VBO1 : draw vectors representing outer points of FOV.
|
||||
if (_interceptTag[i]){
|
||||
_interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
|
||||
_interceptVector[3] += 3;
|
||||
//_interceptVector = pscInterpolate(_interceptVector, bsvec, t);
|
||||
// INTERCEPTIONS
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_start), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(_interceptVector.vec4()), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_end), size);
|
||||
indx += 4;
|
||||
}
|
||||
else if (_withinFOV){
|
||||
// FOV OUTSIDE OBJECT
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0,0,1,1)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(_projectionBounds[i].vec4()), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(blue), size);
|
||||
indx += 4;
|
||||
}else{
|
||||
glm::vec4 corner(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3]+1);
|
||||
corner = tmp*corner;
|
||||
// "INFINITE" FOV
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(col_gray), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(corner), size);
|
||||
indx += 4;
|
||||
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
|
||||
indx += 4;
|
||||
}
|
||||
}
|
||||
_interceptTag[4] = _interceptTag[0]; // 0 & 5 same point
|
||||
// Draw surface square!
|
||||
fovProjection(_interceptTag, bounds);
|
||||
updateData();
|
||||
}
|
||||
_oldTime = _time;
|
||||
|
||||
glLineWidth(1.f);
|
||||
glBindVertexArray(_vaoID[0]);
|
||||
glDrawArrays(_mode, 0, _vtotal[0]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
//render points
|
||||
glPointSize(2.f);
|
||||
glBindVertexArray(_vaoID[0]);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal[0]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
//second vbo
|
||||
glLineWidth(2.f);
|
||||
glBindVertexArray(_vaoID[1]);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, _vtotal[1]);
|
||||
glBindVertexArray(0);
|
||||
|
||||
/*glPointSize(5.f);
|
||||
glBindVertexArray(_vaoID2);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal2);
|
||||
glBindVertexArray(0);
|
||||
*/
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
void RenderableFov::update(const UpdateData& data){
|
||||
|
||||
double lightTime;
|
||||
_time = data.time;
|
||||
_delta = static_cast<int>(data.delta);
|
||||
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix("NH_SPACECRAFT", "GALACTIC", data.time, _stateMatrix);
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _frame, data.time, _stateMatrix);
|
||||
}
|
||||
|
||||
void RenderableFov::loadTexture()
|
||||
|
||||
@@ -112,7 +112,7 @@ bool RenderablePlane::initialize() {
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat size = _size[0];
|
||||
const GLfloat size = _size[0];
|
||||
const GLfloat w = _size[1];
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
@@ -159,11 +159,9 @@ bool RenderablePlane::deinitialize() {
|
||||
}
|
||||
|
||||
void RenderablePlane::render(const RenderData& data) {
|
||||
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
if (_billboard)
|
||||
transform = glm::inverse(data.camera.viewRotationMatrix());
|
||||
//transform = glm::scale(transform, glm::vec3(0.01));
|
||||
|
||||
// Activate shader
|
||||
_shader->activate();
|
||||
|
||||
@@ -53,10 +53,19 @@ 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);
|
||||
|
||||
_segments = static_cast<int>(s[0]);
|
||||
|
||||
/*glm::vec2 radius;
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridRadius, radius);
|
||||
*/
|
||||
_segments = s[0];
|
||||
|
||||
_isize = int(6 * _segments * _segments);
|
||||
_vsize = int((_segments + 1) * (_segments + 1));
|
||||
@@ -125,6 +134,8 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
}
|
||||
|
||||
RenderableSphericalGrid::~RenderableSphericalGrid(){
|
||||
deinitialize();
|
||||
|
||||
// Delete not done in deinitialize because new is done in constructor
|
||||
delete[] _varray;
|
||||
delete[] _iarray;
|
||||
@@ -185,14 +196,22 @@ bool RenderableSphericalGrid::initialize(){
|
||||
void RenderableSphericalGrid::render(const RenderData& data){
|
||||
_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);
|
||||
@@ -206,6 +225,8 @@ void RenderableSphericalGrid::render(const RenderData& data){
|
||||
}
|
||||
|
||||
void RenderableSphericalGrid::update(const UpdateData& data){
|
||||
}
|
||||
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix("IAU_JUPITER", "GALACTIC", data.time, _parentMatrix);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/renderabletrail.h>
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
@@ -112,6 +113,7 @@ bool RenderableTrail::deinitialize() {
|
||||
glDeleteVertexArrays(1, &_vaoID);
|
||||
glDeleteBuffers(1, &_vBufferID);
|
||||
return true;
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool RenderableTrail::isReady() const {
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <openspace/util/screenlog.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
#include <openspace/util/imagesequencer.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/lua/lua_helper.h>
|
||||
#include <ghoul/misc/sharedmemory.h>
|
||||
@@ -251,18 +252,19 @@ namespace openspace {
|
||||
const glm::vec3 center = (corners[0] + corners[1] + corners[2] + corners[3])
|
||||
/ 4.0f;
|
||||
|
||||
#if 0
|
||||
// @TODO Remove the ifdef when the next SGCT version is released that requests the
|
||||
// getUserPtr to get a name parameter ---abock
|
||||
|
||||
// set the eye position, useful during rendering
|
||||
const glm::vec3 eyePosition
|
||||
= sgct_core::ClusterManager::instance()->getUserPtr("")->getPos();
|
||||
#else
|
||||
const glm::vec3 eyePosition
|
||||
= sgct_core::ClusterManager::instance()->getUserPtr()->getPos();
|
||||
#endif
|
||||
|
||||
|
||||
//#if 0
|
||||
// // @TODO Remove the ifdef when the next SGCT version is released that requests the
|
||||
// // getUserPtr to get a name parameter ---abock
|
||||
//
|
||||
// // set the eye position, useful during rendering
|
||||
// const glm::vec3 eyePosition
|
||||
// = sgct_core::ClusterManager::instance()->getUserPtr("")->getPos();
|
||||
//#else
|
||||
// const glm::vec3 eyePosition
|
||||
// = sgct_core::ClusterManager::instance()->getUserPtr()->getPos();
|
||||
//#endif
|
||||
const glm::vec3 eyePosition = sgct_core::ClusterManager::instance()->getDefaultUserPtr()->getPos();
|
||||
// get viewdirection, stores the direction in the camera, used for culling
|
||||
const glm::vec3 viewdir = glm::normalize(eyePosition - center);
|
||||
_mainCamera->setCameraDirection(-viewdir);
|
||||
@@ -346,7 +348,7 @@ namespace openspace {
|
||||
|
||||
}
|
||||
|
||||
void RenderEngine::render()
|
||||
void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix)
|
||||
{
|
||||
// We need the window pointer
|
||||
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
|
||||
@@ -365,30 +367,12 @@ namespace openspace {
|
||||
#endif
|
||||
// setup the camera for the current frame
|
||||
|
||||
#if 0
|
||||
// @TODO: Use this as soon as the new SGCT version is available ---abock
|
||||
const glm::vec3 eyePosition
|
||||
= sgct_core::ClusterManager::instance()->getUserPtr("")->getPos();
|
||||
#else
|
||||
const glm::vec3 eyePosition
|
||||
= sgct_core::ClusterManager::instance()->getUserPtr()->getPos();
|
||||
#endif
|
||||
//@CHECK does the dome disparity disappear if this line disappears? ---abock
|
||||
const glm::mat4 view
|
||||
= glm::translate(glm::mat4(1.0),
|
||||
eyePosition); // make sure the eye is in the center
|
||||
_mainCamera->setViewProjectionMatrix(
|
||||
sgct::Engine::instance()->getActiveModelViewProjectionMatrix() * view);
|
||||
|
||||
_mainCamera->setModelMatrix(
|
||||
sgct::Engine::instance()->getModelMatrix());
|
||||
|
||||
_mainCamera->setViewMatrix(
|
||||
sgct::Engine::instance()->getActiveViewMatrix()* view);
|
||||
|
||||
viewMatrix );
|
||||
_mainCamera->setProjectionMatrix(
|
||||
sgct::Engine::instance()->getActiveProjectionMatrix());
|
||||
|
||||
projectionMatrix);
|
||||
//Is this really necessary to store? @JK
|
||||
_mainCamera->setViewProjectionMatrix(projectionMatrix * viewMatrix);
|
||||
|
||||
// render the scene starting from the root node
|
||||
if (!_visualizeABuffer) {
|
||||
@@ -435,8 +419,11 @@ namespace openspace {
|
||||
// GUI PRINT
|
||||
// Using a macro to shorten line length and increase readability
|
||||
#define PrintText(i, format, ...) Freetype::print(font, 10.f, static_cast<float>(startY - font_size_mono * i * 2), format, __VA_ARGS__);
|
||||
#define PrintColorText(i, format, size, color, ...) Freetype::print(font, size, static_cast<float>(startY - font_size_mono * i * 2), color, format, __VA_ARGS__);
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
PrintText(i++, "Date: %s", Time::ref().currentTimeUTC().c_str());
|
||||
PrintText(i++, "Avg. Frametime: %.5f", sgct::Engine::instance()->getAvgDt());
|
||||
PrintText(i++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime());
|
||||
@@ -446,6 +433,27 @@ namespace openspace {
|
||||
PrintText(i++, "View dir: (% .5f, % .5f, % .5f)", viewdirection[0], viewdirection[1], viewdirection[2]);
|
||||
PrintText(i++, "Cam->origin: (% .15f, % .4f)", pssl[0], pssl[1]);
|
||||
PrintText(i++, "Scaling: (% .5f, % .5f)", scaling[0], scaling[1]);
|
||||
|
||||
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - Time::ref().currentTime();
|
||||
double t = 0.0;
|
||||
t = 1.f - remaining / openspace::ImageSequencer::ref().getIntervalLength();
|
||||
std::string progress = "|";
|
||||
int g = ((t)* 20) + 1;
|
||||
for (int i = 0; i < g; i++) progress.append("-"); progress.append(">");
|
||||
for (int i = 0; i < 21 - g; i++) progress.append(" ");
|
||||
|
||||
std::string str = "";
|
||||
openspace::SpiceManager::ref().getDateFromET(openspace::ImageSequencer::ref().getNextCaptureTime(), str);
|
||||
|
||||
progress.append("|");
|
||||
if (remaining > 0){
|
||||
glm::vec4 g1(0, t, 0, 1);
|
||||
glm::vec4 g2(1 - t);
|
||||
PrintColorText(i++, "Next projection in | %.0f seconds", 10, g1 + g2, remaining);
|
||||
PrintColorText(i++, "%s %.1f %%", 10, g1 + g2, progress.c_str(), t * 100);
|
||||
}
|
||||
glm::vec4 w(1);
|
||||
PrintColorText(i++, "Ucoming : %s", 10, w, str.c_str());
|
||||
#undef PrintText
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary)
|
||||
|
||||
addProperty(_pointSpreadFunctionTexturePath);
|
||||
_pointSpreadFunctionTexturePath.onChange([&]{ _pointSpreadFunctionTextureIsDirty = true;});
|
||||
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange([&]{ _colorTextureIsDirty = true; });
|
||||
|
||||
@@ -179,7 +179,7 @@ void RenderableStars::render(const RenderData& data) {
|
||||
// is done twice? ---abock
|
||||
glm::vec2 scaling = glm::vec2(1, -19);
|
||||
|
||||
glm::mat4 modelMatrix = data.camera.modelMatrix();
|
||||
glm::mat4 modelMatrix = glm::mat4(1.0);
|
||||
glm::mat4 viewMatrix = data.camera.viewMatrix();
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
|
||||
|
||||
@@ -184,7 +184,6 @@ bool SceneGraph::initialize()
|
||||
tmpProgram->setProgramObjectCallback(cb);
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager()->setValue("fboPassProgram", tmpProgram);
|
||||
|
||||
// projection program
|
||||
tmpProgram = ProgramObject::Build("projectiveProgram",
|
||||
"${SHADERS}/projectiveTexture_vs.glsl",
|
||||
|
||||
@@ -75,8 +75,16 @@ void SpiceEphemeris::update(const UpdateData& data) {
|
||||
|
||||
glm::dvec3 position(0,0,0);
|
||||
double lightTime = 0.0;
|
||||
SpiceManager::ref().getTargetPosition(_targetName, _originName, "GALACTIC", "CN+S", data.time, position, lightTime);
|
||||
SpiceManager::ref().getTargetPosition(_targetName, _originName,
|
||||
"GALACTIC", "NONE", data.time, position, lightTime);
|
||||
|
||||
if (_targetName == "NEW HORIZONS"){
|
||||
// In order to properly draw the viewfrustrum, the craft might have to be
|
||||
// positioned using the X-variations of aberration methods (ongoing investigation).
|
||||
SpiceManager::ref().getTargetPosition(_targetName, _originName,
|
||||
"GALACTIC", "NONE", data.time, position, lightTime);
|
||||
}
|
||||
|
||||
_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
|
||||
_position[3] += 3;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace openspace {
|
||||
using namespace constants::staticephemeris;
|
||||
|
||||
StaticEphemeris::StaticEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: _position(0.f, 0.f, 0.f, 0.f)
|
||||
: _position(0.1f, 0.f, 0.f, 0.f)
|
||||
{
|
||||
const bool hasPosition = dictionary.hasKeyAndValue<glm::vec4>(keyPosition);
|
||||
if (hasPosition) {
|
||||
|
||||
@@ -612,13 +612,21 @@ void ScriptEngine::serialize(SyncBuffer* syncBuffer){
|
||||
|
||||
void ScriptEngine::deserialize(SyncBuffer* syncBuffer){
|
||||
syncBuffer->decode(_currentSyncedScript);
|
||||
|
||||
if (!_currentSyncedScript.empty()){
|
||||
_mutex.lock();
|
||||
_receivedScripts.push_back(_currentSyncedScript);
|
||||
_mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEngine::postSynchronizationPreDraw(){
|
||||
if (!_currentSyncedScript.empty()){
|
||||
runScript(_currentSyncedScript);
|
||||
_currentSyncedScript.clear();
|
||||
_mutex.lock();
|
||||
if (!_receivedScripts.empty()){
|
||||
runScript(_receivedScripts.back());
|
||||
_receivedScripts.pop_back();
|
||||
}
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void ScriptEngine::preSynchronization(){
|
||||
@@ -628,6 +636,9 @@ void ScriptEngine::preSynchronization(){
|
||||
if (!_queuedScripts.empty()){
|
||||
_currentSyncedScript = _queuedScripts.back();
|
||||
_queuedScripts.pop_back();
|
||||
|
||||
//Not really a received script but the master also needs to run the script...
|
||||
_receivedScripts.push_back(_currentSyncedScript);
|
||||
}
|
||||
|
||||
_mutex.unlock();
|
||||
|
||||
@@ -46,6 +46,12 @@
|
||||
#include <openspace/scenegraph/staticephemeris.h>
|
||||
#include <openspace/scenegraph/spiceephemeris.h>
|
||||
|
||||
// projection
|
||||
#include <openspace/rendering/planets/renderableplanetprojection.h>
|
||||
#include <openspace/rendering/planets/SimpleSphereGeometryProjection.h>
|
||||
#include <openspace/rendering/planets/PlanetGeometryProjection.h>
|
||||
|
||||
|
||||
// std
|
||||
#include <cassert>
|
||||
|
||||
@@ -64,6 +70,7 @@ void FactoryManager::initialize()
|
||||
// Add Renderables
|
||||
_manager->addFactory(new ghoul::TemplateFactory<Renderable>);
|
||||
_manager->factory<Renderable>()->registerClass<RenderablePlanet>("RenderablePlanet");
|
||||
_manager->factory<Renderable>()->registerClass<RenderablePlanetProjection>("RenderablePlanetProjection");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableStars>("RenderableStars");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableConstellationBounds>
|
||||
("RenderableConstellationBounds");
|
||||
@@ -97,6 +104,11 @@ void FactoryManager::initialize()
|
||||
_manager->factory<planetgeometry::PlanetGeometry>()
|
||||
->registerClass<planetgeometry::SimpleSphereGeometry>("SimpleSphere");
|
||||
|
||||
// Add PlanetGeometryProjection
|
||||
_manager->addFactory(new ghoul::TemplateFactory<planetgeometryprojection::PlanetGeometryProjection>);
|
||||
_manager->factory<planetgeometryprojection::PlanetGeometryProjection>()
|
||||
->registerClass<planetgeometryprojection::SimpleSphereGeometryProjection>("SimpleSphereProjection");
|
||||
|
||||
// Add ModelGeometry
|
||||
_manager->addFactory(new ghoul::TemplateFactory<modelgeometry::ModelGeometry>);
|
||||
_manager->factory<modelgeometry::ModelGeometry>()
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
// open space includes
|
||||
#include <openspace/util/imagesequencer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ImageSequencer";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ImageSequencer* ImageSequencer::_sequencer = nullptr;
|
||||
|
||||
struct ImageParams{
|
||||
double startTime;
|
||||
double stopTime;
|
||||
std::string path;
|
||||
bool projected;
|
||||
};
|
||||
|
||||
auto cmp = [](const ImageParams &a, const ImageParams &b)->bool{
|
||||
return a.startTime < b.startTime;
|
||||
};
|
||||
|
||||
std::vector<ImageParams> _timeStamps;
|
||||
|
||||
ImageSequencer& ImageSequencer::ref() {
|
||||
assert(_sequencer != nullptr);
|
||||
return *_sequencer;
|
||||
}
|
||||
void ImageSequencer::initialize(){
|
||||
assert(_sequencer == nullptr);
|
||||
_sequencer = new ImageSequencer;
|
||||
|
||||
_sequencer->_defaultCaptureImage = absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder.png");
|
||||
}
|
||||
|
||||
void ImageSequencer::deinitialize(){
|
||||
delete _sequencer;
|
||||
_sequencer = nullptr;
|
||||
}
|
||||
|
||||
void ImageSequencer::createImage(double t1, double t2, std::string path){
|
||||
// insert
|
||||
ImageParams image;
|
||||
image.startTime = t1;
|
||||
image.stopTime = t2;
|
||||
image.path = path;
|
||||
image.projected = false;
|
||||
|
||||
_timeStamps.push_back(image);
|
||||
// sort
|
||||
|
||||
}
|
||||
|
||||
double ImageSequencer::getNextCaptureTime(){
|
||||
return _nextCapture;
|
||||
}
|
||||
double ImageSequencer::nextCaptureTime(double _time){
|
||||
auto binary_find = [](std::vector<ImageParams>::iterator begin,
|
||||
std::vector<ImageParams>::iterator end,
|
||||
const ImageParams &val,
|
||||
bool(*cmp)(const ImageParams &a, const ImageParams &b))->std::vector<ImageParams>::iterator{
|
||||
// Finds the lower bound in at most log(last - first) + 1 comparisons
|
||||
std::vector<ImageParams>::iterator it = std::lower_bound(begin, end, val, cmp);
|
||||
if (it != begin){
|
||||
return it;
|
||||
}
|
||||
return end;
|
||||
};
|
||||
|
||||
auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { _time, 0, "", false }, cmp);
|
||||
|
||||
if (_time < _nextCapture) return _nextCapture;
|
||||
return it->startTime;
|
||||
}
|
||||
|
||||
bool ImageSequencer::getImagePath(std::string _currentTime, std::string& path, bool closedInterval){
|
||||
double currentEt = 0;
|
||||
openspace::SpiceManager::ref().getETfromDate(_currentTime, currentEt);
|
||||
bool success = getImagePath(currentEt, path, closedInterval);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ImageSequencer::getImagePath(double& _currentTime, std::string& path, bool closedInterval){
|
||||
auto binary_find = [](std::vector<ImageParams>::iterator begin,
|
||||
std::vector<ImageParams>::iterator end,
|
||||
const ImageParams &val,
|
||||
bool(*cmp)(const ImageParams &a, const ImageParams &b))->std::vector<ImageParams>::iterator{
|
||||
// Finds the lower bound in at most log(last - first) + 1 comparisons
|
||||
std::vector<ImageParams>::iterator it = std::lower_bound(begin, end, val, cmp);
|
||||
if (it != begin){
|
||||
return std::prev(it);
|
||||
}
|
||||
return end;
|
||||
};
|
||||
|
||||
auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { _currentTime, 0, "", false }, cmp);
|
||||
//check [start, stop]
|
||||
if (closedInterval && (it == _timeStamps.end() || it->stopTime < _currentTime || it->projected)){
|
||||
return false;
|
||||
}else if (!closedInterval && (it == _timeStamps.end() || it->projected)){
|
||||
return false;
|
||||
}
|
||||
double upcoming = nextCaptureTime(_currentTime);
|
||||
if (_nextCapture != upcoming){
|
||||
_nextCapture = upcoming;
|
||||
_intervalLength = upcoming - _currentTime;
|
||||
}
|
||||
|
||||
it->projected = true;
|
||||
path = it->path;
|
||||
_currentTime = it->startTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImageSequencer::sequenceReset(){
|
||||
for (auto image : _timeStamps){
|
||||
image.projected = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool replace(std::string& str, const std::string& from, const std::string& to) {
|
||||
size_t start_pos = str.find(from);
|
||||
if (start_pos == std::string::npos)
|
||||
return false;
|
||||
str.replace(start_pos, from.length(), to);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImageSequencer::parsePlaybook(const std::string& dir, const std::string& type, std::string year){
|
||||
ghoul::filesystem::Directory playbookDir(dir, true);
|
||||
std::vector<std::string> dirlist = playbookDir.read(true, false);
|
||||
for (auto path : dirlist) {
|
||||
bool success = parsePlaybookFile(path, year);
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
return true; // add check
|
||||
}
|
||||
|
||||
bool ImageSequencer::parsePlaybookFile(const std::string& fileName, std::string year) {
|
||||
if (size_t position = fileName.find_last_of(".") + 1){
|
||||
if (position != std::string::npos){
|
||||
std::string extension = ghoul::filesystem::File(fileName).fileExtension();
|
||||
|
||||
if (extension == "csv"){ // comma separated playbook
|
||||
std::cout << "USING COMMA SEPARATED TIMELINE V9F" << std::endl;
|
||||
|
||||
std::string cachedFile = "";
|
||||
FileSys.cacheManager()->getCachedFile(fileName, cachedFile, true);
|
||||
|
||||
bool hasCachedFile = FileSys.fileExists(cachedFile);
|
||||
if (hasCachedFile) {
|
||||
std::ifstream file(cachedFile);
|
||||
if (!file.good())
|
||||
LERROR("Error loading cached playbook '" << cachedFile << "'");
|
||||
else {
|
||||
do {
|
||||
std::string line;
|
||||
std::getline(file, line);
|
||||
|
||||
std::stringstream s(line);
|
||||
|
||||
double start, end;
|
||||
std::string path;
|
||||
|
||||
s >> start;
|
||||
s >> end;
|
||||
|
||||
std::getline(s, path);
|
||||
createImage(start, end, _defaultCaptureImage);
|
||||
} while (!file.eof());
|
||||
}
|
||||
} else {
|
||||
std::ifstream file(fileName);
|
||||
if (!file.good()) LERROR("Failed to open csv file '" << fileName << "'");
|
||||
|
||||
std::string timestr = "";
|
||||
double shutter = 0.01;
|
||||
double et;
|
||||
do{
|
||||
std::getline(file, timestr);
|
||||
auto pos = timestr.find("LORRI image started");
|
||||
if (pos != std::string::npos){
|
||||
timestr = timestr.substr(timestr.find_first_of(",") + 1);
|
||||
timestr = timestr.substr(0, timestr.find_first_of(","));
|
||||
|
||||
replace(timestr, " ", "::");
|
||||
timestr = year + " " + timestr;
|
||||
|
||||
openspace::SpiceManager::ref().getETfromDate(timestr, et);
|
||||
createImage(et, et + shutter, _defaultCaptureImage);
|
||||
}
|
||||
} while (!file.eof());
|
||||
|
||||
std::sort(_timeStamps.begin(), _timeStamps.end(), cmp);
|
||||
|
||||
std::ofstream cachedFileStream(cachedFile);
|
||||
cachedFileStream << std::setprecision(64);
|
||||
if (cachedFileStream.good()) {
|
||||
for (const ImageParams& i : _timeStamps)
|
||||
cachedFileStream << i.startTime << "\t" << i.stopTime << "\t" << i.path << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (extension == "txt"){// Hong Kang. pre-parsed playbook
|
||||
std::cout << "USING PREPARSED PLAYBOOK V9H" << std::endl;
|
||||
std::ifstream file(fileName);
|
||||
if (!file.good()) LERROR("Failed to open txt file '" << fileName << "'");
|
||||
|
||||
std::string timestr = "";
|
||||
double shutter = 0.01;
|
||||
double et;
|
||||
|
||||
double metRef = 299180517;
|
||||
do{
|
||||
std::getline(file, timestr);
|
||||
auto pos = timestr.find("LORRI Image Started");
|
||||
if (pos != std::string::npos){
|
||||
timestr = timestr.substr(24, 9);
|
||||
std::string::size_type sz; // alias of size_t
|
||||
|
||||
double met = std::stod(timestr, &sz);
|
||||
double diff;
|
||||
openspace::SpiceManager::ref().getETfromDate("2015-07-14T11:50:00.00", et);
|
||||
|
||||
diff = abs(met - metRef);
|
||||
if (met > metRef){
|
||||
et += diff;
|
||||
}
|
||||
else if (met < metRef){
|
||||
et -= diff;
|
||||
}
|
||||
/*
|
||||
std::string str;
|
||||
openspace::SpiceManager::ref().getDateFromET(et, str);
|
||||
std::cout << str << std::endl;
|
||||
*/
|
||||
createImage(et, et + shutter, _defaultCaptureImage);
|
||||
}
|
||||
} while (!file.eof());
|
||||
std::sort(_timeStamps.begin(), _timeStamps.end(), cmp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImageSequencer::loadSequence(const std::string dir){
|
||||
ghoul::filesystem::Directory sequenceDir(dir, true);
|
||||
std::vector<std::string> sequencePaths = sequenceDir.read(true, false); // check inputs
|
||||
for (auto path : sequencePaths){
|
||||
if (size_t position = path.find_last_of(".") + 1){
|
||||
if (position != std::string::npos){
|
||||
ghoul::filesystem::File currentFile(path);
|
||||
std::string extension = currentFile.fileExtension();
|
||||
|
||||
if (extension == "lbl"){ // discovered header file
|
||||
std::ifstream file(currentFile.path());
|
||||
|
||||
if (!file.good()) LERROR("Failed to open label file '" << currentFile.path() << "'");
|
||||
|
||||
// open up label files
|
||||
std::string line = "";
|
||||
std::string specsOfInterest[2] = { "START_TIME", "STOP_TIME" };
|
||||
double timestamps[2] = { 0.0, 0.0 };
|
||||
bool found = false;
|
||||
do {
|
||||
std::getline(file, line);
|
||||
for (int i = 0; i < 2; i++){
|
||||
auto pos = line.find(specsOfInterest[i]);
|
||||
if (pos != std::string::npos){
|
||||
std::string time = line.substr(line.find("=") + 2);
|
||||
time.erase(std::remove(time.begin(), time.end(), ' '), time.end());
|
||||
openspace::SpiceManager::ref().getETfromDate(time, timestamps[i]);
|
||||
}
|
||||
}
|
||||
if (timestamps[0] != 0.0 && timestamps[1] != 0.0){
|
||||
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()){
|
||||
createImage(timestamps[0], timestamps[1], path);
|
||||
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;
|
||||
}
|
||||
} while (!file.eof() && found == false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// NEED TO FIX THIS LATER ON
|
||||
|
||||
//_nextCapture = nextCaptureTime(Time::ref().currentTime()); // this is not really working 100%
|
||||
//_intervalLength = _timeStamps[1].startTime;
|
||||
return !sequencePaths.empty();
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
@@ -106,6 +106,18 @@ glm::vec3 PowerScaledCoordinate::vec3() const
|
||||
_vec[2] * pow(k, _vec[3]));
|
||||
}
|
||||
|
||||
glm::dvec4& PowerScaledCoordinate::dvec4() const
|
||||
{
|
||||
//return _vec;
|
||||
return glm::dvec4(_vec);
|
||||
}
|
||||
|
||||
glm::dvec3 PowerScaledCoordinate::dvec3() const
|
||||
{
|
||||
return glm::dvec3(_vec[0] * pow(k, _vec[3]), _vec[1] * pow(k, _vec[3]),
|
||||
_vec[2] * pow(k, _vec[3]));
|
||||
}
|
||||
|
||||
PowerScaledScalar PowerScaledCoordinate::length() const
|
||||
{
|
||||
return PowerScaledScalar(glm::length(glm::vec3(_vec[0], _vec[1], _vec[2])), _vec[3]);
|
||||
|
||||
@@ -37,7 +37,10 @@ const std::string _loggerCat = "PowerScaledSphere";
|
||||
namespace openspace {
|
||||
|
||||
PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segments)
|
||||
: _isize(6 * segments * segments)
|
||||
: _vaoID(0)
|
||||
, _vBufferID(0)
|
||||
, _iBufferID(0)
|
||||
, _isize(6 * segments * segments)
|
||||
, _vsize((segments + 1) * (segments + 1))
|
||||
, _varray(new Vertex[_vsize])
|
||||
, _iarray(new int[_isize])
|
||||
@@ -49,7 +52,6 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen
|
||||
const float fsegments = static_cast<float>(segments);
|
||||
const float r = static_cast<float>(radius[0]);
|
||||
|
||||
|
||||
for (int i = 0; i <= segments; i++) {
|
||||
// define an extra vertex around the y-axis due to texture mapping
|
||||
for (int j = 0; j <= segments; j++) {
|
||||
@@ -82,7 +84,6 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen
|
||||
_varray[nr].normal[1] = normal[1];
|
||||
_varray[nr].normal[2] = normal[2];
|
||||
|
||||
//std::cout << _varray[nr].location[0] << " " << _varray[nr].location[1] << " " << _varray[nr].location[2] << " " << _varray[nr].location[3] << std::endl;
|
||||
_varray[nr].tex[0] = t1;
|
||||
_varray[nr].tex[1] = t2;
|
||||
++nr;
|
||||
@@ -131,32 +132,68 @@ PowerScaledSphere::~PowerScaledSphere()
|
||||
if (_iarray)
|
||||
delete[] _iarray;
|
||||
|
||||
_vbo.deinitialize();
|
||||
_varray = 0;
|
||||
_iarray = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vBufferID);
|
||||
glDeleteBuffers(1, &_iBufferID);
|
||||
glDeleteVertexArrays(1, &_vaoID);
|
||||
}
|
||||
|
||||
bool PowerScaledSphere::initialize()
|
||||
{
|
||||
// Initialize and upload to graphics card
|
||||
GLuint errorID;
|
||||
if (_vaoID == 0)
|
||||
glGenVertexArrays(1, &_vaoID);
|
||||
|
||||
std::vector<Vertex> varray(_vsize);
|
||||
std::vector<int> iarray(_isize);
|
||||
for (size_t i = 0; i < _vsize; ++i) {
|
||||
varray.at(i) = _varray[i];
|
||||
}
|
||||
for (size_t i = 0; i < _isize; ++i) {
|
||||
iarray.at(i) = _iarray[i];
|
||||
}
|
||||
if (_vBufferID == 0) {
|
||||
glGenBuffers(1, &_vBufferID);
|
||||
|
||||
_vbo.initialize(varray, iarray);
|
||||
_vbo.vertexAttribPointer(0, 4, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, location));
|
||||
_vbo.vertexAttribPointer(1, 2, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, tex));
|
||||
_vbo.vertexAttribPointer(2, 3, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, normal));
|
||||
if (_vBufferID == 0) {
|
||||
LERROR("Could not create vertex buffer");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (_iBufferID == 0) {
|
||||
glGenBuffers(1, &_iBufferID);
|
||||
|
||||
if (_iBufferID == 0) {
|
||||
LERROR("Could not create index buffer");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// First VAO setup
|
||||
glBindVertexArray(_vaoID);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
|
||||
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), _varray, GL_STATIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glEnableVertexAttribArray(2);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
|
||||
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
|
||||
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
|
||||
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
|
||||
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
|
||||
|
||||
glBindVertexArray(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PowerScaledSphere::render()
|
||||
{
|
||||
_vbo.render();
|
||||
glBindVertexArray(_vaoID); // select first VAO
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
|
||||
glDrawElements(GL_TRIANGLES, _isize, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
+167
-27
@@ -45,13 +45,10 @@ void SpiceManager::initialize() {
|
||||
_manager = new SpiceManager;
|
||||
_manager->_lastAssignedKernel = 0;
|
||||
|
||||
char REPORT[]="REPORT";
|
||||
char NONE[]="NONE";
|
||||
|
||||
// Set the SPICE library to not exit the program if an error occurs
|
||||
erract_c("SET", 0, REPORT);
|
||||
erract_c("SET", 0, "REPORT");
|
||||
// But we do not want SPICE to print the errors, we will fetch them ourselves
|
||||
errprt_c("SET", 0, NONE);
|
||||
errprt_c("SET", 0, "NONE");
|
||||
}
|
||||
|
||||
void SpiceManager::deinitialize() {
|
||||
@@ -60,11 +57,10 @@ void SpiceManager::deinitialize() {
|
||||
|
||||
delete _manager;
|
||||
_manager = nullptr;
|
||||
char DEFAULT[]="DEFAULT";
|
||||
|
||||
// Set values back to default
|
||||
erract_c("SET", 0, DEFAULT);
|
||||
errprt_c("SET", 0, DEFAULT);
|
||||
erract_c("SET", 0, "DEFAULT");
|
||||
errprt_c("SET", 0, "DEFAULT");
|
||||
}
|
||||
|
||||
SpiceManager& SpiceManager::ref() {
|
||||
@@ -118,7 +114,8 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& fileP
|
||||
if (hasError)
|
||||
return KernelFailed;
|
||||
else {
|
||||
_loadedKernels.push_back({ path, std::move(kernelId) });
|
||||
KernelInformation&& info = { path, std::move(kernelId) };
|
||||
_loadedKernels.push_back(info);
|
||||
return kernelId;
|
||||
}
|
||||
}
|
||||
@@ -164,15 +161,15 @@ bool SpiceManager::hasValue(const std::string& body, const std::string& item) co
|
||||
}
|
||||
|
||||
bool SpiceManager::getNaifId(const std::string& body, int& id) const {
|
||||
|
||||
SpiceInt s_id = id;
|
||||
if (body.empty()) {
|
||||
LERROR("No body was provided");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
SpiceBoolean success;
|
||||
bods2c_c(body.c_str(), &s_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);
|
||||
@@ -182,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;
|
||||
@@ -192,8 +190,7 @@ bool getValueInternal(const std::string& body, const std::string& value, int S,
|
||||
}
|
||||
|
||||
SpiceInt n;
|
||||
SpiceInt _s = S;
|
||||
bodvrd_c(body.c_str(), value.c_str(), _s, &n, v);
|
||||
bodvrd_c(body.c_str(), value.c_str(), S, &n, v);
|
||||
|
||||
bool hasError = SpiceManager::checkForError("Error getting value '" + value +
|
||||
"' for body '" + body + "'");
|
||||
@@ -229,7 +226,7 @@ bool SpiceManager::getValue(const std::string& body, const std::string& value,
|
||||
LERROR("No value was provided");
|
||||
return false;
|
||||
}
|
||||
if (v.empty()) {
|
||||
if (v.size() == 0) {
|
||||
LERROR("Array for values has to be preallocaed");
|
||||
return false;
|
||||
}
|
||||
@@ -242,6 +239,13 @@ bool SpiceManager::getValue(const std::string& body, const std::string& value,
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
bool SpiceManager::spacecraftClockToET(const std::string craftIdCode, double& craftTicks, double& et){
|
||||
int craftID;
|
||||
getNaifId(craftIdCode, craftID);
|
||||
sct2e_c(craftID, craftTicks, &et);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SpiceManager::getETfromDate(const std::string& timeString,
|
||||
double& ephemerisTime) const
|
||||
{
|
||||
@@ -303,11 +307,12 @@ bool SpiceManager::getTargetPosition(const std::string& target,
|
||||
psc& position,
|
||||
double& lightTime) const
|
||||
{
|
||||
glm::dvec3 pos;
|
||||
bool success = getTargetPosition(target, observer, referenceFrame,
|
||||
aberrationCorrection, ephemerisTime, pos, lightTime);
|
||||
|
||||
if(!success)
|
||||
double pos[3] = { NULL, NULL, NULL };
|
||||
|
||||
spkpos_c(target.c_str(), ephemerisTime, referenceFrame.c_str(),
|
||||
aberrationCorrection.c_str(), observer.c_str(), pos, &lightTime);
|
||||
|
||||
if (pos[0] == NULL || pos[1] == NULL || pos[2] == NULL)
|
||||
return false;
|
||||
|
||||
position = PowerScaledCoordinate::CreatePowerScaledCoordinate(pos[0], pos[1], pos[2]);
|
||||
@@ -315,6 +320,126 @@ 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));
|
||||
// re-express vector in new frame
|
||||
mxv_c((double(*)[3])glm::value_ptr(transform), glm::value_ptr(v), glm::value_ptr(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::targetWithinFieldOfView(const std::string& instrument,
|
||||
const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& method,
|
||||
const std::string& referenceFrame,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const{
|
||||
|
||||
int visible ;
|
||||
fovtrg_c(instrument.c_str(),
|
||||
target.c_str(),
|
||||
method.c_str(),
|
||||
referenceFrame.c_str(),
|
||||
aberrationCorrection.c_str(),
|
||||
observer.c_str(),
|
||||
&targetEpoch,
|
||||
&visible);
|
||||
return visible;
|
||||
}
|
||||
|
||||
bool SpiceManager::targetWithinFieldOfView(const std::string& instrument,
|
||||
const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& method,
|
||||
const std::string& aberrationCorrection,
|
||||
double& targetEpoch) const{
|
||||
|
||||
int visible;
|
||||
|
||||
std::string bodyfixed = "IAU_";
|
||||
bodyfixed += target;
|
||||
|
||||
fovtrg_c(instrument.c_str(),
|
||||
target.c_str(),
|
||||
method.c_str(),
|
||||
bodyfixed.c_str(),
|
||||
aberrationCorrection.c_str(),
|
||||
observer.c_str(),
|
||||
&targetEpoch,
|
||||
&visible);
|
||||
return visible;
|
||||
}
|
||||
|
||||
|
||||
bool SpiceManager::getSurfaceIntercept(const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& fovInstrument,
|
||||
const std::string& referenceFrame,
|
||||
const std::string& method,
|
||||
const std::string& aberrationCorrection,
|
||||
double ephemerisTime,
|
||||
double& targetEpoch,
|
||||
glm::dvec3& directionVector,
|
||||
glm::dvec3& surfaceIntercept,
|
||||
glm::dvec3& surfaceVector) const{
|
||||
// make pretty latr
|
||||
double dvec[3], spoint[3], et;
|
||||
glm::dvec3 srfvec;
|
||||
int found;
|
||||
bool convert;
|
||||
|
||||
dvec[0] = directionVector[0];
|
||||
dvec[1] = directionVector[1];
|
||||
dvec[2] = directionVector[2];
|
||||
|
||||
// allow client specify non-inertial frame.
|
||||
std::string bodyfixed = "IAU_";
|
||||
convert = (referenceFrame.find(bodyfixed) == std::string::npos);
|
||||
if (convert){
|
||||
bodyfixed += target;
|
||||
}else{
|
||||
bodyfixed = referenceFrame;
|
||||
}
|
||||
|
||||
sincpt_c(method.c_str(),
|
||||
target.c_str(),
|
||||
ephemerisTime,
|
||||
bodyfixed.c_str(),
|
||||
aberrationCorrection.c_str(),
|
||||
observer.c_str(),
|
||||
fovInstrument.c_str(),
|
||||
dvec,
|
||||
spoint,
|
||||
&et,
|
||||
glm::value_ptr(srfvec),
|
||||
&found);
|
||||
|
||||
bool hasError = checkForError("Error retrieving surface intercept on target '" + target + "'" +
|
||||
"viewed from observer '" + observer + "' in " +
|
||||
"reference frame '" + bodyfixed + "' at time '" +
|
||||
std::to_string(ephemerisTime) + "'");
|
||||
|
||||
if (convert) frameConversion(srfvec, bodyfixed, referenceFrame, ephemerisTime);
|
||||
|
||||
if (!hasError && found){
|
||||
|
||||
|
||||
memcpy(glm::value_ptr(directionVector), dvec, sizeof(dvec));
|
||||
memcpy(glm::value_ptr(surfaceIntercept), spoint, sizeof(spoint));
|
||||
surfaceVector = srfvec;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
bool SpiceManager::getTargetState(const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& referenceFrame,
|
||||
@@ -355,14 +480,10 @@ bool SpiceManager::getTargetState(const std::string& target,
|
||||
spkezr_c(target.c_str(), ephemerisTime, referenceFrame.c_str(),
|
||||
aberrationCorrection.c_str(), observer.c_str(), state, &lightTime);
|
||||
|
||||
bool hasError = checkForError("Error getting position for '" +
|
||||
target + "' with observer '" + observer + "'");
|
||||
position = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[0], state[1], state[2]);
|
||||
velocity = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[3], state[4], state[5]);
|
||||
|
||||
if (!hasError) {
|
||||
position = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[0], state[1], state[2]);
|
||||
velocity = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[3], state[4], state[5]);
|
||||
}
|
||||
return !hasError;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SpiceManager::getStateTransformMatrix(const std::string& fromFrame,
|
||||
@@ -379,6 +500,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,
|
||||
@@ -411,6 +533,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
|
||||
|
||||
Reference in New Issue
Block a user