Merge branch 'develop' into feature/parser

This commit is contained in:
Alexander Bock
2015-05-07 17:27:28 +02:00
5 changed files with 61 additions and 30 deletions

View File

@@ -53,6 +53,7 @@ namespace planetgeometryprojection {
class PlanetGeometryProjection;
}
class RenderablePlanetProjection : public Renderable {
public:
RenderablePlanetProjection(const ghoul::Dictionary& dictionary);
@@ -74,6 +75,9 @@ protected:
glm::mat4 computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up);
void attitudeParameters(double time);
void textureBind();
void project();
private:
void imageProjectGPU();
@@ -90,6 +94,7 @@ private:
ghoul::opengl::Texture* _texture;
ghoul::opengl::Texture* _textureOriginal;
ghoul::opengl::Texture* _textureProj;
ghoul::opengl::Texture* _textureWhiteSquare;
planetgeometryprojection::PlanetGeometryProjection* _geometry;
glm::vec2 _camScaling;

View File

@@ -7,23 +7,22 @@ openspace.setInvertRoll(true);
--openspace.time.setTime("2007 FEB 27 16:30:00") -- This is the start time for a Jupiter run of New Horizons
--openspace.time.setTime("2007 FEB 28 03:45:00") -- Io Capture!
--TESTING ALICE
--openspace.time.setTime("2015-07-13T00:00:00.00")
--openspace.time.setTime("2015-07-14T08:00:00.00")
--openspace.time.setTime("2011 AUG 6 07:15:00") -- Dawn @ Vestaprojection
--openspace.time.setTime("2014 AUG 28 03:45:00") -- Rosetta Travels 67p in triangular shape
openspace.time.setDeltaTime(10) -- How many seconds pass per second of realtime, changeable in the GUI
openspace.time.setDeltaTime(0) -- How many seconds pass per second of realtime, changeable in the GUI
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) -- Load the default keybindings
-- openspace.time.setDeltaTime(50);
openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO
--openspace.time.setTime("2015-07-14T12:00:00.00") -- PLUTO
-- NH takes series of images from visible to dark side (across terminator)
-- Sequence lasts ~10 mins, (recommended dt = 10)
--openspace.time.setTime("2015-07-14T11:22:00.00") -- PLUTO
openspace.time.setTime("2015-07-14T11:22:00.00") -- PLUTO
--BEAUTIFUL SEQUENCE -- NH takes series of images (same as previous)
-- Sequence ends at 2015 JUL 14T11:24:00:000, (recommended dt = 1)

View File

@@ -43,6 +43,7 @@
#include <sgct.h>
#include <iomanip>
#include <string>
#include <thread>
#define _USE_MATH_DEFINES
#include <math.h>
@@ -91,6 +92,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _texture(nullptr)
, _textureProj(nullptr)
, _textureOriginal(nullptr)
, _textureWhiteSquare(nullptr)
, _geometry(nullptr)
, _rotation("rotation", "Rotation", 0, 0, 360)
, _once(false)
@@ -219,7 +221,9 @@ bool RenderablePlanetProjection::initialize(){
loadTexture();
loadProjectionTexture();
completeSuccess &= (_texture != nullptr);
completeSuccess &= (_textureOriginal != nullptr);
completeSuccess &= (_textureProj != nullptr);
completeSuccess &= (_textureWhiteSquare != nullptr);
completeSuccess &= _geometry->initialize(this);
@@ -272,6 +276,10 @@ bool RenderablePlanetProjection::deinitialize(){
_texture = nullptr;
delete _textureProj;
_textureProj = nullptr;
delete _textureOriginal;
_textureOriginal = nullptr;
delete _textureWhiteSquare;
_textureWhiteSquare = nullptr;
delete _geometry;
_geometry = nullptr;
return true;
@@ -401,26 +409,43 @@ void RenderablePlanetProjection::attitudeParameters(double time){
_projectorMatrix = computeProjectorMatrix(cpos, bs, _up);
}
void RenderablePlanetProjection::textureBind(){
ghoul::opengl::TextureUnit unit[2];
unit[0].activate();
_texture->bind();
_programObject->setUniform("texture1", unit[0]);
unit[1].activate();
_textureWhiteSquare->bind();
_programObject->setUniform("texture2", unit[1]);
}
void RenderablePlanetProjection::project(){
for (auto img : _imageTimes){
std::thread t1(&RenderablePlanetProjection::attitudeParameters, this, img.startTime);
t1.join();
_projectionTexturePath = img.path; // path to current images
imageProjectGPU(); //fbopass
}
_capture = false;
}
#define GPU_PROJ
void RenderablePlanetProjection::render(const RenderData& data){
if (!_programObject) return;
if (!_textureProj) return;
_camScaling = data.camera.scaling();
_up = data.camera.lookUpVector();
double startTime, endTime;
#ifdef GPU_PROJ
if (_capture){
for (auto img : _imageTimes){
attitudeParameters(img.startTime); // compute projector viewmatrix
_projectionTexturePath = img.path; // path to current images
imageProjectGPU(); //fbopass
}
_capture = false;
}
if (_capture)
project();
#endif
attitudeParameters(_time);
_projectionTexturePath = _defaultProjImage;
psc sun_pos;
double lt;
@@ -435,20 +460,14 @@ void RenderablePlanetProjection::render(const RenderData& data){
_programObject->setUniform("ModelTransform" , _transform);
_programObject->setUniform("boresight" , _boresight);
setPscUniforms(_programObject, &data.camera, data.position);
// Bind texture
ghoul::opengl::TextureUnit unit[2];
unit[0].activate();
_texture->bind();
_programObject->setUniform("texture1", unit[0]);
unit[1].activate();
_textureProj->bind();
_programObject->setUniform("texture2", unit[1]);
textureBind();
// render geometry
_geometry->render();
// disable shader
_programObject->deactivate();
}
void RenderablePlanetProjection::update(const UpdateData& data){
@@ -461,7 +480,6 @@ void RenderablePlanetProjection::update(const UpdateData& data){
_capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID);
}
//floor fading to decimal
//_fadeProjection = floorf(_fadeProjection * 10) / 10;
}
void RenderablePlanetProjection::loadProjectionTexture(){
@@ -496,5 +514,14 @@ void RenderablePlanetProjection::loadTexture(){
_textureOriginal->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
delete _textureWhiteSquare;
_textureWhiteSquare = nullptr;
if (_colorTexturePath.value() != "") {
_textureWhiteSquare = ghoul::io::TextureReader::ref().loadTexture(absPath(_defaultProjImage));
if (_textureWhiteSquare) {
_textureWhiteSquare->uploadTexture();
_textureWhiteSquare->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
}
} // namespace openspace

View File

@@ -48,7 +48,7 @@ namespace openspace {
std::string spacecraft,
ghoul::Dictionary translationDictionary,
std::vector<std::string> potentialTargets) :
_defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder_blank.png"))
_defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder.png"))
{
_fileName = fileName;
_spacecraft = spacecraft;