mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 18:51:17 -06:00
fixing stupid git mistake.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -27,3 +27,6 @@ html/
|
||||
latex/
|
||||
shaders/ABuffer/constants.hglsl
|
||||
*.OpenSpaceGenerated.glsl
|
||||
shaders/writeToTexture_fs.glsl
|
||||
shaders/writeToTexture_vs.glsl
|
||||
src/rendering/planets/writeToTexture.cpp
|
||||
|
||||
@@ -67,7 +67,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__
|
||||
@@ -0,0 +1,82 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.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;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
void loadTexture();
|
||||
|
||||
private:
|
||||
properties::StringProperty _colorTexturePath;
|
||||
properties::StringProperty _projectionTexturePath;
|
||||
|
||||
ghoul::opengl::ProgramObject* _programObject;
|
||||
|
||||
ghoul::opengl::Texture* _texture;
|
||||
ghoul::opengl::Texture* _textureProj;
|
||||
planetgeometryprojection::PlanetGeometryProjection* _geometry;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
glm::dmat3 _instrumentMatrix;
|
||||
|
||||
double _time;
|
||||
openspace::SceneGraphNode* _targetNode;
|
||||
|
||||
std::string _target;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __RENDERABLEPLANETPROJECTION_H__
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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;
|
||||
|
||||
PowerScaledSphere* _planet;
|
||||
};
|
||||
|
||||
} // namespace planetgeometry
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __SIMPLESPHEREGEOMETRY_H__
|
||||
71
include/openspace/rendering/planets/writeToTexture.h
Normal file
71
include/openspace/rendering/planets/writeToTexture.h
Normal file
@@ -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__
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/query/query.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
@@ -50,55 +51,123 @@ 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);
|
||||
|
||||
double distanceBetweenPoints(psc p1, psc p2);
|
||||
// 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;
|
||||
|
||||
GLenum _mode;
|
||||
unsigned int _isize;
|
||||
unsigned int _vsize;
|
||||
unsigned int _vtotal;
|
||||
unsigned int _stride;
|
||||
|
||||
double _startTrail;
|
||||
|
||||
//Vertex* _varray;
|
||||
std::vector<float> _varray;
|
||||
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;
|
||||
};
|
||||
}
|
||||
#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;
|
||||
}
|
||||
*/
|
||||
@@ -62,6 +62,11 @@ protected:
|
||||
glm::mat4 _gridMatrix;
|
||||
int _segments;
|
||||
|
||||
bool staticGrid;
|
||||
std::string _parentsRotation;
|
||||
glm::dmat3 _parentMatrix;
|
||||
PowerScaledScalar _radius;
|
||||
|
||||
GLuint _vaoID = 3;
|
||||
GLuint _vBufferID = 4;
|
||||
GLuint _iBufferID = 5;
|
||||
|
||||
@@ -107,6 +107,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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __SPICEMANAGER_H__
|
||||
|
||||
#include "SpiceUsr.h"
|
||||
#include "SpiceZpr.h"
|
||||
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
@@ -250,6 +251,24 @@ public:
|
||||
bool getDateFromET(double ephemerisTime, std::string& date,
|
||||
const std::string& format = "YYYY MON DDTHR:MN:SC.### ::RND");
|
||||
|
||||
/**
|
||||
* This helper method converts a 3 dimensional vector from one reference frame to another.
|
||||
* \param v The vector to be converted
|
||||
* \param from The frame to be converted from
|
||||
* \param to The frame to be converted to
|
||||
* \param ephemerisTime Time at which to get rotational matrix that transforms vector
|
||||
*/
|
||||
void frameConversion(glm::dvec3& v, const std::string from, const std::string to, double ephemerisTime) const;
|
||||
|
||||
/**
|
||||
* Finds the projection of one vector onto another vector.
|
||||
* All vectors are 3-dimensional.
|
||||
* \param v1 The vector to be projected.
|
||||
* \param v2 The vector onto which v1 is to be projected.
|
||||
* \return The projection of v1 onto v2.
|
||||
*/
|
||||
glm::dvec3 orthogonalProjection(glm::dvec3& v1, glm::dvec3& v2);
|
||||
|
||||
/**
|
||||
* Returns the <code>position</code> of a <code>target</code> body relative to an
|
||||
* <code>observer</code> in a specific <code>referenceFrame</code>, optionally
|
||||
@@ -290,7 +309,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 +458,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,
|
||||
@@ -523,34 +625,6 @@ public:
|
||||
glm::dvec3& subObserverPoint,
|
||||
double& targetEphemerisTime,
|
||||
glm::dvec3& vectorToSurfacePoint) const;
|
||||
|
||||
/**
|
||||
* Computes the rectangular coordinates of the sub-solar point on
|
||||
* a target body at a specified epoch, optionally corrected for
|
||||
* light time and stellar aberration.
|
||||
* For further details, please refer to 'subslr_c ' in SPICE Docummentation
|
||||
*
|
||||
* \param computationMethod Computation method.
|
||||
* \param target Name of target body.
|
||||
* \param ephemeris Epoch in ephemeris seconds past J2000 TDB.
|
||||
* \param bodyFixedFrame Body-fixed, body-centered target body frame.
|
||||
* \param aberrationCorrection Aberration correction.
|
||||
* \param observer Name of observing body.
|
||||
* \param subObserverPoint Sub-observer point on the target body.
|
||||
* \param targetEpoch Sub-observer point epoch.
|
||||
* \param observerToSubObserverVec Vector from observer to sub-observer point.
|
||||
* \return Whether the function succeeded or not
|
||||
*/
|
||||
//bool getSubSolarPoint(std::string target,
|
||||
// std::string computationMethod,
|
||||
//
|
||||
// double ephemeris,
|
||||
// std::string bodyFixedFrame,
|
||||
// std::string aberrationCorrection,
|
||||
//
|
||||
// glm::dvec3& subSolarPoint,
|
||||
// double& targetEpoch,
|
||||
// glm::dvec3& vectorToSurfacePoint) const;
|
||||
|
||||
/**
|
||||
* This method checks if one of the previous SPICE methods has failed. If it has, the
|
||||
|
||||
98
shaders/projectiveTexture_fs.glsl
Normal file
98
shaders/projectiveTexture_fs.glsl
Normal file
@@ -0,0 +1,98 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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;
|
||||
in vec3 vs_boresight;
|
||||
|
||||
#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 = vec3(0.0); // sun.
|
||||
vec3 l_dir = normalize(l_pos-objpos.xyz);
|
||||
float intensity = min(max(5*dot(n,l_dir), 0.0), 1);
|
||||
|
||||
float shine = 0.0001;
|
||||
|
||||
vec4 specular = vec4(0.5);
|
||||
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 = diffuse;//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,vs_boresight) < 0 ){
|
||||
diffuse = projTexColor;
|
||||
}else{
|
||||
diffuse = shaded;
|
||||
}
|
||||
|
||||
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
|
||||
addToBuffer(frag);
|
||||
|
||||
discard;
|
||||
}
|
||||
|
||||
75
shaders/projectiveTexture_vs.glsl
Normal file
75
shaders/projectiveTexture_vs.glsl
Normal file
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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;
|
||||
|
||||
layout(location = 3) in vec3 boresight;
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_normal;
|
||||
out vec4 vs_position;
|
||||
out float s;
|
||||
|
||||
out vec3 vs_boresight;
|
||||
|
||||
out vec4 ProjTexCoord;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
// Radius = 0.71492 *10^8;
|
||||
vs_boresight = boresight;
|
||||
// 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);
|
||||
}
|
||||
@@ -70,7 +70,10 @@ void main()
|
||||
spec = specular * pow(intSpec, shine);
|
||||
}
|
||||
*/
|
||||
vec4 tmpdiff = diffuse;
|
||||
tmpdiff[3] = 1;
|
||||
diffuse = max(intensity * diffuse, ambient);
|
||||
//diffuse[3] = 0.6f;
|
||||
//diffuse = vec4(1);
|
||||
|
||||
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
|
||||
|
||||
@@ -752,22 +752,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);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
if (success)
|
||||
_colorTexturePath = path + "/" + texturePath;
|
||||
|
||||
if (_geometry != nullptr)
|
||||
addPropertySubOwner(_geometry);
|
||||
|
||||
addProperty(_colorTexturePath);
|
||||
@@ -102,15 +103,20 @@ bool RenderableModel::initialize(){
|
||||
|
||||
loadTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
|
||||
if (_geometry != nullptr)
|
||||
completeSuccess &= _geometry->initialize(this);
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
bool RenderableModel::deinitialize(){
|
||||
_geometry->deinitialize();
|
||||
delete _geometry;
|
||||
_geometry = nullptr;
|
||||
|
||||
if (_geometry != nullptr){
|
||||
_geometry->deinitialize();
|
||||
delete _geometry;
|
||||
_geometry = nullptr;
|
||||
}
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
return true;
|
||||
@@ -127,6 +133,8 @@ void RenderableModel::render(const RenderData& data)
|
||||
|
||||
// scale the planet to appropriate size since the planet is a unit sphere
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
glm::mat4 roty = glm::rotate(transform, 90.f, glm::vec3(0, 1, 0));
|
||||
glm::mat4 scale = glm::scale(transform, glm::vec3(1, -1, 1));
|
||||
|
||||
glm::mat4 tmp = glm::mat4(1);
|
||||
for (int i = 0; i < 3; i++){
|
||||
@@ -134,7 +142,6 @@ void RenderableModel::render(const RenderData& data)
|
||||
tmp[i][j] = _stateMatrix[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
transform *= tmp;
|
||||
|
||||
//glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
|
||||
@@ -151,7 +158,8 @@ void RenderableModel::render(const RenderData& data)
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
_programObject->setUniform("texture1", unit);
|
||||
|
||||
|
||||
if (_geometry != nullptr)
|
||||
_geometry->render();
|
||||
|
||||
// disable shader
|
||||
|
||||
80
src/rendering/planets/planetgeometryprojection.cpp
Normal file
80
src/rendering/planets/planetgeometryprojection.cpp
Normal file
@@ -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
|
||||
@@ -128,6 +128,10 @@ void RenderablePlanet::render(const RenderData& data)
|
||||
}
|
||||
}
|
||||
transform = transform* rot;
|
||||
if (_target == "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;
|
||||
|
||||
341
src/rendering/planets/renderableplanetprojection.cpp
Normal file
341
src/rendering/planets/renderableplanetprojection.cpp
Normal file
@@ -0,0 +1,341 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 <ghoul/opengl/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 <sgct.h>
|
||||
#include <iomanip>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderablePlanetProjection";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath("colorTexture", "Color Texture")
|
||||
, _projectionTexturePath("colorTexture", "Color Texture")
|
||||
, _programObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _textureProj(nullptr)
|
||||
, _geometry(nullptr)
|
||||
{
|
||||
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);
|
||||
|
||||
ghoul::Dictionary geometryDictionary;
|
||||
success = dictionary.getValue(
|
||||
constants::renderableplanet::keyGeometry, geometryDictionary);
|
||||
if (success) {
|
||||
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
|
||||
geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
|
||||
_geometry = planetgeometryprojection::PlanetGeometryProjection::createFromDictionary(geometryDictionary);
|
||||
}
|
||||
|
||||
dictionary.getValue(constants::renderableplanet::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(_colorTexturePath);
|
||||
_colorTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
|
||||
addProperty(_projectionTexturePath);
|
||||
_projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
|
||||
}
|
||||
|
||||
RenderablePlanetProjection::~RenderablePlanetProjection(){
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool RenderablePlanetProjection::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess
|
||||
&= OsEng.ref().configurationManager().getValue("projectiveProgram", _programObject);
|
||||
|
||||
loadTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
completeSuccess &= (_textureProj != nullptr);
|
||||
|
||||
completeSuccess &= _geometry->initialize(this);
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
bool RenderablePlanetProjection::deinitialize(){
|
||||
_geometry->deinitialize();
|
||||
delete _geometry;
|
||||
_geometry = nullptr;
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
delete _textureProj;
|
||||
_textureProj = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::render(const RenderData& data)
|
||||
{
|
||||
if (!_programObject) return;
|
||||
if (!_textureProj) return;
|
||||
|
||||
// activate shader
|
||||
_programObject->activate();
|
||||
|
||||
// scale the planet to appropriate size since the planet is a unit sphere
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
|
||||
//earth needs to be rotated for that to work.
|
||||
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 scale of jupiterx = 0.935126
|
||||
transform *= glm::scale(glm::mat4(1), glm::vec3(1, 0.935126, 1));
|
||||
}
|
||||
|
||||
// PROJECTIVE TEXTURING----------------------------------------------------------
|
||||
// get fov
|
||||
std::string shape, instrument;
|
||||
std::vector<glm::dvec3> bounds;
|
||||
glm::dvec3 boresight;
|
||||
bool found = openspace::SpiceManager::ref().getFieldOfView("NH_LORRI", shape, instrument, boresight, bounds);
|
||||
if (!found) LERROR("Could not locate instrument");
|
||||
|
||||
psc position;
|
||||
double lightTime = 0.0;
|
||||
SpiceManager::ref().getTargetPosition("NEW HORIZONS", "JUPITER BARYCENTER","GALACTIC", "NONE", _time, position, lightTime);
|
||||
position[3] += 3;
|
||||
glm::vec3 nh_pos = position.vec3();
|
||||
|
||||
//get up-vecto
|
||||
//rotate boresight into correct alignment
|
||||
glm::vec3 bsight(_instrumentMatrix*boresight); // lookat must be vec3
|
||||
glm::vec3 uptmp(_instrumentMatrix*glm::dvec3(data.camera.lookUpVector()));
|
||||
|
||||
//create view matrix
|
||||
glm::vec3 e3 = glm::normalize(bsight);
|
||||
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, nh_pos), -glm::dot(e2, nh_pos), -glm::dot(e3, nh_pos), 1.f);
|
||||
//create perspective projection matrix
|
||||
glm::mat4 projProjectionMatrix = glm::perspective(0.2907f, 1.f, 0.2f, 1000000.0f);
|
||||
//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 );
|
||||
|
||||
glm::mat4 m = projNormalizationMatrix*projProjectionMatrix*projViewMatrix;
|
||||
// setup the data to the shader
|
||||
_programObject->setUniform("ProjectorMatrix", m);
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
_programObject->setAttribute("boresight", bsight);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
// Bind texture
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
_programObject->setUniform("texture1", unit); // jupiter
|
||||
|
||||
ghoul::opengl::TextureUnit unit2;
|
||||
unit2.activate();
|
||||
_textureProj->bind();
|
||||
_programObject->setUniform("texture2", unit2); // proj
|
||||
|
||||
// render
|
||||
_geometry->render();
|
||||
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
/*
|
||||
static int callCount = 0;
|
||||
callCount++;
|
||||
|
||||
if (callCount > 1000){
|
||||
callCount = 0;
|
||||
|
||||
_textureProj->downloadTexture();
|
||||
_texture->downloadTexture();
|
||||
|
||||
auto uvToModel = [](float u, float v, float radius[2], float fsegments)->glm::vec4{
|
||||
|
||||
const float fj = u * fsegments;
|
||||
const float fi = v * fsegments;
|
||||
|
||||
const float theta = fi * float(M_PI) / fsegments; // 0 -> PI
|
||||
const float phi = fj * float(M_PI) * 2.0f / fsegments;
|
||||
|
||||
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 glm::vec4(x, y, z, radius[1]);
|
||||
};
|
||||
|
||||
auto uvToIndex = [](const glm::vec2 &uv, int w, int h, int &i, int &j){
|
||||
i = static_cast<int>(uv.x * float(w));
|
||||
j = static_cast<int>(uv.y * float(h));
|
||||
};
|
||||
|
||||
auto inRange = [](int x, int a, int b)->bool{
|
||||
return (x >= a && x <= b);
|
||||
};
|
||||
|
||||
auto pscToMeter = [](glm::vec4 v1, glm::vec2 v2)->glm::vec4{
|
||||
float factor = v2.x * pow(10, v2.y + v1.w);
|
||||
return glm::vec4(v1.xyz * factor, 1.0);
|
||||
};
|
||||
|
||||
const float w = _texture->width();
|
||||
const float h = _texture->height();
|
||||
for (int i = 0; i < _texture->width(); ++i) {
|
||||
for (int j = 0; j < _texture->height(); ++j) {
|
||||
// "Shader code"
|
||||
|
||||
// Texture coordinates
|
||||
float u = float(i) / w;
|
||||
float v = float(j) / h;
|
||||
|
||||
// Psc scaling
|
||||
glm::vec2 scaling = data.camera.scaling();
|
||||
|
||||
// Convert texture coordinates to model coordinates
|
||||
float radius[2] = { 0.71492f, 8.f };
|
||||
glm::vec4 in_position = uvToModel(u, v, radius, 200);
|
||||
|
||||
// Convert psc to meters
|
||||
glm::vec4 raw_pos = pscToMeter(in_position, scaling);
|
||||
|
||||
// Transform model coordinates to world coordinates
|
||||
glm::vec4 projected = m * transform * raw_pos;
|
||||
|
||||
// To do : use bilinear interpolation
|
||||
int x, y;
|
||||
glm::vec2 uv;
|
||||
uv.x = projected.x / projected.w;
|
||||
uv.y = projected.y / projected.w;
|
||||
uvToIndex(uv, _textureProj->width(), _textureProj->height(), x, y);
|
||||
|
||||
if (inRange(x, 0, _textureProj->width() - 1) && inRange(y, 0, _textureProj->height() - 1)){
|
||||
|
||||
_texture->texel<glm::detail::tvec3<glm::detail::uint8> >(i, j) = _textureProj->texel<glm::detail::tvec3<glm::detail::uint8>>(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Upload textures
|
||||
//_textureProj->uploadTexture();
|
||||
_texture->uploadTexture();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::update(const UpdateData& data){
|
||||
// set spice-orientation in accordance to timestamp
|
||||
_time = data.time;
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_target, "GALACTIC", data.time, _stateMatrix);
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix("NH_LORRI", "GALACTIC", data.time, _instrumentMatrix);
|
||||
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadTexture()
|
||||
{
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
|
||||
if (_texture) {
|
||||
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
|
||||
_texture->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
delete _textureProj;
|
||||
_textureProj = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
_textureProj = ghoul::opengl::loadTexture(absPath(_projectionTexturePath));
|
||||
if (_textureProj) {
|
||||
LDEBUG("Loaded texture from '" << absPath(_projectionTexturePath) << "'");
|
||||
_textureProj->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
_textureProj->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_textureProj->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
/*
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_BORDER);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP_TO_BORDER);
|
||||
*/
|
||||
118
src/rendering/planets/simplespheregeometryprojection.cpp
Normal file
118
src/rendering/planets/simplespheregeometryprojection.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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)
|
||||
, _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();
|
||||
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
|
||||
@@ -29,107 +29,93 @@
|
||||
#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";
|
||||
//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{
|
||||
// colors, move later
|
||||
glm::vec4 origin(0);
|
||||
glm::vec4 col_gray(0.3, 0.3, 0.3, 1);
|
||||
glm::vec4 col_start(1.00, 0.89, 0.00, 1);
|
||||
glm::vec4 col_end(1.00, 0.29, 0.00, 1);
|
||||
glm::vec4 col_sq(1.00, 0.29, 0.00, 1);
|
||||
|
||||
glm::vec4 col_proj(1, 1, 1, 1);
|
||||
|
||||
RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath("colorTexture", "Color Texture")
|
||||
, _programObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _vaoID(0)
|
||||
, _vBufferID(0)
|
||||
, _iBufferID(0)
|
||||
, _mode(GL_LINE_STRIP){
|
||||
, _mode(GL_LINES){
|
||||
|
||||
bool b1 = dictionary.getValue(keyBody, _target);
|
||||
bool b2 = dictionary.getValue(keyObserver, _observer);
|
||||
bool b3 = dictionary.getValue(keyFrame, _frame);
|
||||
assert(b1 == true);
|
||||
assert(b2 == true);
|
||||
assert(b3 == true);
|
||||
|
||||
if (!dictionary.getValue(keyColor, _c)){
|
||||
_c = glm::vec3(0.0);
|
||||
}else{
|
||||
_r = 1 / _c[0];
|
||||
_g = 1 / _c[1];
|
||||
_b = 1 / _c[2];
|
||||
}
|
||||
assert(dictionary.getValue(keyBody , _spacecraft));
|
||||
assert(dictionary.getValue(keyFrame , _frame));
|
||||
assert(dictionary.getValue(keyInstrument , _instrumentID));
|
||||
assert(dictionary.getValue(keyInstrumentMethod , _method));
|
||||
assert(dictionary.getValue(keyInstrumentAberration , _aberrationCorrection));
|
||||
}
|
||||
void RenderableFov::fullYearSweep(){
|
||||
|
||||
void RenderableFov::allocateData(){
|
||||
int points = 8;
|
||||
_stride = 8;
|
||||
_isize = points;
|
||||
_iarray = new int[_isize];
|
||||
|
||||
_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[i] = i;
|
||||
_iarray1[0][i] = i;
|
||||
}
|
||||
|
||||
_stride = 8;
|
||||
_vsize = _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 = 5;
|
||||
}
|
||||
|
||||
RenderableFov::~RenderableFov(){
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
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, GL_STATIC_DRAW);
|
||||
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
||||
bool RenderableFov::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
|
||||
|
||||
_startTrail;
|
||||
SpiceManager::ref().getETfromDate("2007 feb 26 20:00:00", _startTrail);
|
||||
|
||||
fullYearSweep();
|
||||
sendToGPU();
|
||||
allocateData();
|
||||
sendToGPU();
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
@@ -139,85 +125,360 @@ bool RenderableFov::deinitialize(){
|
||||
_texture = nullptr;
|
||||
return true;
|
||||
}
|
||||
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_STREAM_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_STREAM_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++;
|
||||
}
|
||||
double RenderableFov::distanceBetweenPoints(psc p1, psc p2){
|
||||
PowerScaledScalar dist = (p1 - p2).length();
|
||||
return dist[0] * pow(10, dist[1]);
|
||||
}
|
||||
|
||||
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_STREAM_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::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] = _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" };
|
||||
_fovTarget = potential[0]; //default
|
||||
for (int i = 0; i < 5; i++){
|
||||
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i],
|
||||
_spacecraft, _method,
|
||||
_aberrationCorrection, _time);
|
||||
if (_withinFOV){
|
||||
_fovTarget = potential[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//somehow get target in there.
|
||||
//_targetNode = sceneGraphNode(_fovTarget);
|
||||
/*std::vector<PropertyOwner*> properties = _targetNode->subOwners();
|
||||
for (auto & element : properties) {
|
||||
std::cout << element->name() << std::endl;
|
||||
}*/
|
||||
//std::cout << _targetNode->renderable.hasProperty("PlanetGeometry") << std::endl;
|
||||
|
||||
float size = 4 * sizeof(float);
|
||||
float *begin = &_varray[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);
|
||||
// for each FOV vector
|
||||
for (int i = 0; i < 4; i++){
|
||||
double targetEpoch;
|
||||
// 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]);
|
||||
|
||||
|
||||
float sc = 2.2;
|
||||
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(_mode, 0, _vtotal);
|
||||
// VBO1 : draw vectors representing outer points of FOV.
|
||||
if (_interceptTag[i]){
|
||||
_interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
|
||||
_interceptVector[3] += 3;
|
||||
// INTERCEPTIONS
|
||||
memcpy(&_varray1[indx], glm::value_ptr(origin), 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 LARGER THAN OBJECT
|
||||
memcpy(&_varray1[indx], glm::value_ptr(origin), 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(glm::vec4(0, 0.5, 0.7, 1)), size);
|
||||
indx += 4;
|
||||
}else{
|
||||
glm::vec4 corner(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3]);
|
||||
corner = tmp*corner;
|
||||
// "INFINITE" FOV
|
||||
memcpy(&_varray1[indx], glm::value_ptr(origin), 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();
|
||||
}
|
||||
|
||||
@@ -225,8 +486,7 @@ void RenderableFov::update(const UpdateData& data){
|
||||
double lightTime;
|
||||
_time = data.time;
|
||||
_delta = data.delta;
|
||||
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix("NH_SPACECRAFT", "GALACTIC", data.time, _stateMatrix);
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _frame, data.time, _stateMatrix);
|
||||
}
|
||||
|
||||
void RenderableFov::loadTexture()
|
||||
|
||||
@@ -55,12 +55,9 @@ namespace openspace{
|
||||
, _iBufferID(0)
|
||||
, _mode(GL_LINE_STRIP){
|
||||
|
||||
bool b1 = dictionary.getValue(keyBody, _target);
|
||||
bool b2 = dictionary.getValue(keyObserver, _observer);
|
||||
bool b3 = dictionary.getValue(keyFrame, _frame);
|
||||
assert(b1 == true);
|
||||
assert(b2 == true);
|
||||
assert(b3 == true);
|
||||
assert(dictionary.getValue(keyBody, _target));
|
||||
assert(dictionary.getValue(keyObserver, _observer));
|
||||
assert(dictionary.getValue(keyFrame, _frame));
|
||||
/*assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
|
||||
assert(dictionary.getValue(keyEarthOrbitRatio, _ratio));
|
||||
assert(dictionary.getValue(keyDayLength, _day));//not used now, will be though.
|
||||
@@ -78,162 +75,159 @@ namespace openspace{
|
||||
}
|
||||
}
|
||||
void RenderablePath::fullYearSweep(){
|
||||
double lightTime = 0.0;
|
||||
SpiceManager::ref().getETfromDate("2006 jan 20 19:00:00", _time);
|
||||
double lightTime = 0.0;
|
||||
SpiceManager::ref().getETfromDate("2006 jan 20 19:00:00", _time);
|
||||
|
||||
std::cout << _time << std::endl;
|
||||
// -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
|
||||
double et2 = 0;
|
||||
//SpiceManager::ref().getETfromDate("2008 apr 01 00:00:00", et2);
|
||||
//psc nhpos, nhvel;
|
||||
//SpiceManager::ref().getTargetState("NEW HORIZONS", "SUN", "J2000", "LT+S", et2, _pscpos, _pscvel, lightTime);
|
||||
|
||||
// -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
|
||||
//SpiceManager::ref().getETfromDate("2008 apr 01 00:00:00", et2);
|
||||
//psc nhpos, nhvel;
|
||||
//SpiceManager::ref().getTargetState("NEW HORIZONS", "SUN", "J2000", "LT+S", et2, _pscpos, _pscvel, lightTime);
|
||||
double et = _time;
|
||||
int segments = 200000;
|
||||
_increment = 86400;
|
||||
|
||||
double et = _time;
|
||||
int segments = 200000;
|
||||
_increment = 86400;
|
||||
_isize = (segments + 2);
|
||||
_vsize = (segments + 2);
|
||||
_iarray = new int[_isize];
|
||||
|
||||
_isize = (segments + 2);
|
||||
_vsize = (segments + 2);
|
||||
_iarray = new int[_isize];
|
||||
|
||||
int indx = 0;
|
||||
for (int i = 0; i < segments + 1; i++){
|
||||
std::cout << i << std::endl;
|
||||
bool gotData = SpiceManager::ref().getTargetPosition(_target, _observer, _frame, "LT+S", et, _pscpos, lightTime);
|
||||
assert(gotData);
|
||||
if (_pscpos[0] != 0 && _pscpos[1] != 0 && _pscpos[2] != 0 && _pscpos[3] != 1){
|
||||
_pscpos[3] += 3;
|
||||
_varray.push_back(_pscpos[0]);
|
||||
_varray.push_back(_pscpos[1]);
|
||||
_varray.push_back(_pscpos[2]);
|
||||
_varray.push_back(_pscpos[3]);
|
||||
int indx = 0;
|
||||
for (int i = 0; i < segments + 1; i++){
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", et, _pscpos, _pscvel, lightTime);
|
||||
if (_pscpos[0] != 0 && _pscpos[1] != 0 && _pscpos[2] != 0 && _pscpos[3] != 1){
|
||||
_pscpos[3] += 3;
|
||||
_varray.push_back(_pscpos[0]);
|
||||
_varray.push_back(_pscpos[1]);
|
||||
_varray.push_back(_pscpos[2]);
|
||||
_varray.push_back(_pscpos[3]);
|
||||
|
||||
#ifndef DEBUG
|
||||
_varray.push_back(1.f - ((double)i / _tropic * _r));
|
||||
_varray.push_back(1.f - ((double)i / _tropic * _g));
|
||||
_varray.push_back(1.f - ((double)i / _tropic * _b));
|
||||
_varray.push_back(1.f - ((double)i / _tropic));
|
||||
_varray.push_back(1.f - ((double)i / _tropic * _r));
|
||||
_varray.push_back(1.f - ((double)i / _tropic * _g));
|
||||
_varray.push_back(1.f - ((double)i / _tropic * _b));
|
||||
_varray.push_back(1.f - ((double)i / _tropic));
|
||||
#else
|
||||
_varray.push_back(1.f);
|
||||
_varray.push_back(1.f);
|
||||
_varray.push_back(1.f);
|
||||
_varray.push_back(0.5f);
|
||||
_varray.push_back(1.f);
|
||||
_varray.push_back(1.f);
|
||||
_varray.push_back(1.f);
|
||||
_varray.push_back(0.5f);
|
||||
#endif
|
||||
indx++;
|
||||
_iarray[indx] = indx;
|
||||
indx++;
|
||||
_iarray[indx] = indx;
|
||||
}
|
||||
else{
|
||||
std::string date;
|
||||
SpiceManager::ref().getDateFromET(et, date);
|
||||
std::cout << "STOPPED AT: " << date << std::endl;
|
||||
break;
|
||||
}
|
||||
et += _increment;
|
||||
}
|
||||
else{
|
||||
std::string date;
|
||||
SpiceManager::ref().getDateFromET(et, date);
|
||||
std::cout << "STOPPED AT: " << date << std::endl;
|
||||
break;
|
||||
}
|
||||
et += _increment;
|
||||
_stride = 8;
|
||||
_vsize = _varray.size();
|
||||
_vtotal = static_cast<int>(_vsize / _stride);
|
||||
}
|
||||
_stride = 8;
|
||||
_vsize = _varray.size();
|
||||
_vtotal = static_cast<int>(_vsize / _stride);
|
||||
}
|
||||
|
||||
RenderablePath::~RenderablePath(){
|
||||
deinitialize();
|
||||
}
|
||||
RenderablePath::~RenderablePath(){
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool RenderablePath::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess
|
||||
&= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
|
||||
bool RenderablePath::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
completeSuccess
|
||||
&= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
|
||||
|
||||
//TEXTURES DISABLED FOR NOW
|
||||
//loadTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
//TEXTURES DISABLED FOR NOW
|
||||
//loadTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
|
||||
fullYearSweep();
|
||||
fullYearSweep();
|
||||
|
||||
// Initialize and upload to graphics card
|
||||
glGenVertexArrays(1, &_vaoID);
|
||||
glGenBuffers(1, &_vBufferID);
|
||||
glGenBuffers(1, &_iBufferID);
|
||||
// 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]);
|
||||
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;
|
||||
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)));
|
||||
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, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
bool RenderablePath::deinitialize(){
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
return true;
|
||||
}
|
||||
bool RenderablePath::deinitialize(){
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderablePath::render(const RenderData& data){
|
||||
assert(_programObject);
|
||||
_programObject->activate();
|
||||
void RenderablePath::render(const RenderData& data){
|
||||
assert(_programObject);
|
||||
_programObject->activate();
|
||||
|
||||
// fetch data
|
||||
psc currentPosition = data.position;
|
||||
psc campos = data.camera.position();
|
||||
glm::mat4 camrot = data.camera.viewRotationMatrix();
|
||||
// PowerScaledScalar scaling = camera->scaling();
|
||||
//PowerScaledScalar scaling = glm::vec2(1, -6);
|
||||
// fetch data
|
||||
psc currentPosition = data.position;
|
||||
psc campos = data.camera.position();
|
||||
glm::mat4 camrot = data.camera.viewRotationMatrix();
|
||||
// PowerScaledScalar scaling = camera->scaling();
|
||||
PowerScaledScalar scaling = glm::vec2(1, -6);
|
||||
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
|
||||
// setup the data to the shader
|
||||
//_programObject->setUniform("objectVelocity", pscvel.vec4());
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
// setup the data to the shader
|
||||
//_programObject->setUniform("objectVelocity", pscvel.vec4());
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
|
||||
/* glBindVertexArray(_vaoID);
|
||||
glDrawArrays(_mode, 0, _vtotal);
|
||||
glBindVertexArray(0);
|
||||
*/
|
||||
glPointSize(2.f);
|
||||
/* glBindVertexArray(_vaoID);
|
||||
glDrawArrays(_mode, 0, _vtotal);
|
||||
glBindVertexArray(0);
|
||||
*/
|
||||
glPointSize(2.f);
|
||||
|
||||
glBindVertexArray(_vaoID);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal);
|
||||
glBindVertexArray(0);
|
||||
|
||||
_programObject->deactivate();
|
||||
}
|
||||
glBindVertexArray(_vaoID);
|
||||
glDrawArrays(GL_POINTS, 0, _vtotal);
|
||||
glBindVertexArray(0);
|
||||
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
void RenderablePath::update(const UpdateData& data){
|
||||
double lightTime;
|
||||
void RenderablePath::update(const UpdateData& data){
|
||||
double lightTime;
|
||||
_time = data.time;
|
||||
_delta = data.delta;
|
||||
int newhorizons = 0;
|
||||
|
||||
_time = data.time;
|
||||
_delta = data.delta;
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", data.time, _pscpos, _pscvel, lightTime);
|
||||
}
|
||||
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", data.time, _pscpos, _pscvel, lightTime);
|
||||
}
|
||||
|
||||
void RenderablePath::loadTexture()
|
||||
{
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
|
||||
if (_texture) {
|
||||
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
|
||||
_texture->uploadTexture();
|
||||
void RenderablePath::loadTexture()
|
||||
{
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
|
||||
if (_texture) {
|
||||
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
|
||||
_texture->uploadTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,9 +56,18 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
|
||||
glm::vec2 s;
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridType , _gridType);
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridColor , _gridColor);
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridMatrix , _gridMatrix);
|
||||
|
||||
staticGrid = dictionary.getValue(constants::renderablesphericalgrid::gridMatrix, _gridMatrix);
|
||||
if (!staticGrid){
|
||||
staticGrid = dictionary.getValue(constants::renderablesphericalgrid::gridPatentsRotiation, _parentsRotation);
|
||||
}
|
||||
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridSegments, s);
|
||||
|
||||
|
||||
/*glm::vec2 radius;
|
||||
dictionary.getValue(constants::renderablesphericalgrid::gridRadius, radius);
|
||||
*/
|
||||
_segments = s[0];
|
||||
|
||||
_isize = int(6 * _segments * _segments);
|
||||
@@ -172,14 +181,22 @@ void RenderableSphericalGrid::render(const RenderData& data){
|
||||
assert(_gridProgram);
|
||||
_gridProgram->activate();
|
||||
|
||||
glm::mat4 transform;
|
||||
for (int i = 0; i < 3; i++){
|
||||
for (int j = 0; j < 3; j++){
|
||||
transform[i][j] = _parentMatrix[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// setup the data to the shader
|
||||
_gridProgram->setIgnoreUniformLocationError(true);
|
||||
_gridProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_gridProgram->setUniform("ModelTransform", glm::mat4(1));
|
||||
_gridProgram->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_gridProgram, &data.camera, data.position);
|
||||
_gridProgram->setUniform("gridColor", _gridColor);
|
||||
|
||||
//glLineWidth(1.0f);
|
||||
glLineWidth(0.5f);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
@@ -193,6 +210,8 @@ void RenderableSphericalGrid::render(const RenderData& data){
|
||||
|
||||
}
|
||||
void RenderableSphericalGrid::update(const UpdateData& data){
|
||||
}
|
||||
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix("IAU_JUPITER", "GALACTIC", data.time, _parentMatrix);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,6 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
#include <openspace/rendering/renderabletrail.h>
|
||||
|
||||
#include <sgct.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/constants.h>
|
||||
|
||||
@@ -65,26 +63,12 @@ namespace openspace{
|
||||
, _iBufferID(0)
|
||||
, _mode(GL_LINE_STRIP){
|
||||
|
||||
bool b1 = dictionary.getValue(keyBody, _target);
|
||||
bool b2 = dictionary.getValue(keyObserver, _observer);
|
||||
bool b3 = dictionary.getValue(keyFrame, _frame);
|
||||
bool b4 = dictionary.getValue(keyTropicalOrbitPeriod, _tropic);
|
||||
bool b5 = dictionary.getValue(keyEarthOrbitRatio, _ratio);
|
||||
bool b6 = dictionary.getValue(keyDayLength, _day);
|
||||
|
||||
assert(b1 == true);
|
||||
assert(b2 == true);
|
||||
assert(b3 == true);
|
||||
assert(b4 == true);
|
||||
assert(b5 == true);
|
||||
assert(b6 == true);
|
||||
|
||||
//assert(dictionary.getValue(keyBody , _target));
|
||||
//assert(dictionary.getValue(keyObserver, _observer));
|
||||
//assert(dictionary.getValue(keyFrame , _frame));
|
||||
//assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
|
||||
//assert(dictionary.getValue(keyEarthOrbitRatio , _ratio));
|
||||
//assert(dictionary.getValue(keyDayLength , _day));//not used now, will be though.
|
||||
assert(dictionary.getValue(keyBody , _target));
|
||||
assert(dictionary.getValue(keyObserver , _observer));
|
||||
assert(dictionary.getValue(keyFrame , _frame));
|
||||
assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
|
||||
assert(dictionary.getValue(keyEarthOrbitRatio , _ratio));
|
||||
assert(dictionary.getValue(keyDayLength , _day));//not used now, will be though.
|
||||
// values in modfiles set from here
|
||||
// http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
|
||||
|
||||
@@ -118,9 +102,14 @@ void RenderableTrail::fullYearSweep(){
|
||||
_isize = (segments + 2);
|
||||
_vsize = (segments + 2);
|
||||
_iarray = new int[_isize];
|
||||
|
||||
|
||||
for (int i = 0; i < segments+2; i++){
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", et, _pscpos, _pscvel, lightTime);
|
||||
/*if (_target == "NEW HORIZONS"){
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", _startTrail, _pscpos, _pscvel, lightTime);
|
||||
}
|
||||
else{*/
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", et, _pscpos, _pscvel, lightTime);
|
||||
//}
|
||||
_pscpos[3] += 3;
|
||||
|
||||
for (int k = 0; k < 4; k++)
|
||||
@@ -175,7 +164,6 @@ void RenderableTrail::sendToGPU(){
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
|
||||
bool RenderableTrail::initialize(){
|
||||
bool completeSuccess = true;
|
||||
if (_programObject == nullptr)
|
||||
@@ -186,8 +174,8 @@ bool RenderableTrail::initialize(){
|
||||
//loadTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
|
||||
// SpiceManager::ref().getETfromDate("2006 Aug 22 17:00:00", _startTrail);
|
||||
SpiceManager::ref().getETfromDate("2007 feb 26 17:30:00", _startTrail);
|
||||
_startTrail;
|
||||
SpiceManager::ref().getETfromDate("2007 feb 27 11:48:00.000", _startTrail);
|
||||
_dtEt = _startTrail;
|
||||
|
||||
fullYearSweep();
|
||||
@@ -202,27 +190,10 @@ bool RenderableTrail::deinitialize(){
|
||||
return true;
|
||||
}
|
||||
|
||||
// Tried interpolation but then realised this still gives straight lines (latenight thing).
|
||||
// Not allowed Splines so therefore - query spice for each point (bah...)
|
||||
// From psc paper:
|
||||
/*
|
||||
psc pscInterpolate(psc p0, psc p1, float t){
|
||||
assert(t >= 0 && t <= 1);
|
||||
|
||||
float s = (1.f - t)*p0[3] + t*p1[3];
|
||||
|
||||
float x = ((1.f - t)*p0[0] + t*p1[0]);
|
||||
float y = ((1.f - t)*p0[1] + t*p1[1]);
|
||||
float z = ((1.f - t)*p0[2] + t*p1[2]);
|
||||
|
||||
return PowerScaledCoordinate::PowerScaledCoordinate(x,y,z,s);
|
||||
}
|
||||
*/
|
||||
|
||||
void RenderableTrail::updateTrail(){
|
||||
int m = _stride;
|
||||
float *begin = &_varray[0];
|
||||
//float *end = &_varray[_vsize - 1] + 1;
|
||||
float *end = &_varray[_vsize - 1] + 1;
|
||||
|
||||
// update only when time progresses
|
||||
if (_oldTime != _time){
|
||||
@@ -230,7 +201,7 @@ void RenderableTrail::updateTrail(){
|
||||
while (_dtEt < _time){
|
||||
// get intermediary points
|
||||
psc dtPoint;
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", _dtEt, dtPoint, _pscvel, lightTime);
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", _dtEt, dtPoint, _pscvel, lightTime);
|
||||
dtPoint[3] += 3;
|
||||
|
||||
// overwrite the old position
|
||||
@@ -243,7 +214,7 @@ void RenderableTrail::updateTrail(){
|
||||
// keep track of progression
|
||||
_dtEt += _increment;
|
||||
}
|
||||
//add earths current position
|
||||
//add current position
|
||||
memcpy(&_varray[0], glm::value_ptr(_pscpos.vec4()), 4 * sizeof(float));
|
||||
_varray[4] = 1.f;
|
||||
_varray[5] = 1.f;
|
||||
@@ -296,7 +267,7 @@ void RenderableTrail::update(const UpdateData& data){
|
||||
_time = data.time;
|
||||
_delta = data.delta;
|
||||
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", data.time, _pscpos, _pscvel, lightTime);
|
||||
SpiceManager::ref().getTargetState(_target, _observer, _frame, "CN+S", data.time, _pscpos, _pscvel, lightTime);
|
||||
_pscpos[3] += 3; // KM to M
|
||||
|
||||
}
|
||||
|
||||
@@ -165,14 +165,32 @@ bool SceneGraph::initialize()
|
||||
typedef std::chrono::duration<double, std::ratio<1> > second_;
|
||||
std::chrono::time_point<clock_> beginning(clock_::now());
|
||||
|
||||
// pscstandard
|
||||
tmpProgram = ProgramObject::Build("writeToTextureProgram",
|
||||
"${SHADERS}/writeToTexture_vs.glsl",
|
||||
"${SHADERS}/writeToTexture_fs.glsl",
|
||||
cb);
|
||||
if (!tmpProgram) return false;
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("writeToTextureProgram", tmpProgram);
|
||||
|
||||
// pscstandard
|
||||
tmpProgram = ProgramObject::Build("projectiveProgram",
|
||||
"${SHADERS}/projectiveTexture_vs.glsl",
|
||||
"${SHADERS}/projectiveTexture_fs.glsl",
|
||||
cb);
|
||||
if( ! tmpProgram) return false;
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("projectiveProgram", tmpProgram);
|
||||
|
||||
// pscstandard
|
||||
tmpProgram = ProgramObject::Build("pscstandard",
|
||||
"${SHADERS}/pscstandard_vs.glsl",
|
||||
"${SHADERS}/pscstandard_fs.glsl",
|
||||
cb);
|
||||
if( ! tmpProgram) return false;
|
||||
if (!tmpProgram) return false;
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("pscShader", tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("pscShader", tmpProgram);
|
||||
|
||||
// pscstandard
|
||||
tmpProgram = ProgramObject::Build("EphemerisProgram",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
// renderables
|
||||
#include <openspace/rendering/model/renderablemodel.h>
|
||||
#include <openspace/rendering/stars/renderablestars.h>
|
||||
#include <openspace/rendering/renderableephemeris.h>
|
||||
#include <openspace/rendering/renderabletrail.h>
|
||||
#include <openspace/rendering/renderablepath.h>
|
||||
#include <openspace/rendering/renderablefov.h>
|
||||
@@ -48,6 +47,12 @@
|
||||
// std
|
||||
#include <cassert>
|
||||
|
||||
#include <openspace/rendering/planets/renderableplanetprojection.h>
|
||||
#include <openspace/rendering/planets/simplespheregeometryprojection.h>
|
||||
#include <openspace/rendering/planets/planetgeometryprojection.h>
|
||||
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
FactoryManager* FactoryManager::_manager = nullptr;
|
||||
@@ -62,12 +67,13 @@ void FactoryManager::initialize()
|
||||
// TODO: This has to be moved into a sort of module structure (ab)
|
||||
// Add Renderables
|
||||
_manager->addFactory(new ghoul::TemplateFactory<Renderable>);
|
||||
//TODELETE
|
||||
_manager->factory<Renderable>()->registerClass<RenderablePlanetProjection>(
|
||||
"RenderablePlanetProjection");
|
||||
_manager->factory<Renderable>()->registerClass<RenderablePlanet>(
|
||||
"RenderablePlanet");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableStars>(
|
||||
"RenderableStars");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableEphemeris>(
|
||||
"RenderableEphemeris");
|
||||
//will replace ephemeris class soon...
|
||||
_manager->factory<Renderable>()->registerClass<RenderablePath>(
|
||||
"RenderablePath");
|
||||
@@ -95,6 +101,12 @@ void FactoryManager::initialize()
|
||||
_manager->addFactory(new ghoul::TemplateFactory<planetgeometry::PlanetGeometry>);
|
||||
_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>);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -53,8 +53,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++) {
|
||||
@@ -87,7 +85,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;
|
||||
|
||||
@@ -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() {
|
||||
@@ -165,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);
|
||||
@@ -183,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;
|
||||
@@ -193,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 + "'");
|
||||
@@ -304,11 +300,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]);
|
||||
@@ -316,6 +313,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,
|
||||
@@ -356,14 +473,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,
|
||||
@@ -380,6 +493,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,
|
||||
@@ -412,6 +526,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