In short, this is new:

- ImageSequencer class added, requires planetary data service files (not added to openspace-data, too large)
   : Given current time returns path to specific image in dataset for projection.
- Changes to RenderablePlanetProjection class to accomodate sequencing
- Fixed normal computation in reverse-mapping stage
- Rudimental target recognition (will prob. become part of separate class at some point - since both fov & proj classes do similar things)

Next up:
- Redo pluto mockup visualization & begin spreadsheet reader for instrument-switching.
This commit is contained in:
Michal Marcinkowski
2015-01-16 13:06:52 -05:00
parent 3c2110e7e3
commit fa0f26c9da
13 changed files with 98 additions and 65 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<Window fullScreen="false">
<Stereo type="none" />
<!-- 16:9 aspect ratio -->
<Size x="512" y="512" />
<Size x="1920" y="1920" />
<!-- Frame buffer resolution
<Res x="4096" y="4096" /> -->
<!--
@@ -66,12 +66,11 @@ protected:
void loadProjectionTexture();
bool auxiliaryRendertarget();
glm::mat4 computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up);
void attitudeParameters(double time);
private:
void imageProjectGPU();
ImageSequencer* _sequencer;
properties::StringProperty _colorTexturePath;
properties::StringProperty _projectionTexturePath;
properties::TriggerProperty _imageTrigger;
@@ -84,7 +83,7 @@ private:
planetgeometryprojection::PlanetGeometryProjection* _geometry;
glm::vec2 _camScaling;
glm::vec3 _lookUp;
glm::vec3 _up;
glm::mat4 _transform;
glm::mat4 _projectorMatrix;
@@ -102,7 +101,7 @@ private:
glm::dmat3 _instrumentMatrix;
glm::vec3 _boresight;
double _time;
double _time[2];
double lightTime;
std::string _target;
+6 -5
View File
@@ -36,22 +36,23 @@ namespace openspace {
class ImageSequencer {
public:
// initializers
ImageSequencer(const std::string dir);
~ImageSequencer();
static ImageSequencer& ref();
bool loadSequence(const std::string dir);
void testStartTimeMap();
bool initialize();
static void initialize();
static void deinitialize();
bool sequenceReset();
public:
void createImage(double t1, double t2, std::string path = "dummypath");
bool getImagePath(double& _currentTime, std::string& path);
bool getImagePath(std::string _currentTime, std::string& path);
//double _previousTime; // not sure if i wanna use this yet.
static ImageSequencer* _sequencer;
};
} // namespace openspace
+1 -1
View File
@@ -33,7 +33,7 @@ return {
Type = "text",
File = "${BASE_PATH}/LuaScripting.txt"
},
SGCTConfig = "${SGCT}/single.xml",
SGCTConfig = "${SGCT}/single_fisheye.xml",
--SGCTConfig = "${SGCT}/two_nodes.xml",
--SGCTConfig = "${SGCT}/single_sbs_stereo.xml",
Scene = "${OPENSPACE_DATA}/scene/default.scene",
+3 -3
View File
@@ -1,11 +1,11 @@
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
openspace.time.setTime("2007-02-26T17:34:06.350")
--openspace.time.setTime("2006-08-22T20:00:00")
--openspace.time.setTime("2007-01-08T20:42:01.359") -- far
openspace.time.setTime("2007-02-27T16:30:00.000") -- close
--openspace.time.setDeltaTime(200000.0)
--openspace.time.setDeltaTime(5000.00)
--openspace.time.setDeltaTime(864000)
openspace.time.setDeltaTime(0.01)
openspace.time.setDeltaTime(0)
-- print(openspace.time.currentTimeUTC())
-3
View File
@@ -73,14 +73,11 @@ void main() {
vec3 v_b = normalize(boresight);
//color = 500*vec4(dot(v_b, normal),0,0,1);
// perspecitve division something with normals
if((inRange(projected.x, 0, 1) &&
inRange(projected.y, 0, 1)) &&
dot(v_b, normal) < 0 ) {
color = texture(texture1, projected.xy);
}else{
//color = 500*vec4(dot(v_b, normal),0,0,1);
color = vec4(1,1,1,0);
}
// color.a = 0.1f;//1.f - abs(uv.x - 0.55) / (0.6 - 0.5); // blending
+1 -1
View File
@@ -64,7 +64,7 @@ void main()
float shine = 0.0001;
vec4 specular = vec4(0.5);
vec4 specular = vec4(0.1);
vec4 ambient = vec4(0.f,0.f,0.f,1);
/* Specular
if(intensity > 0.f){
+3 -1
View File
@@ -38,6 +38,7 @@
#include <openspace/util/constants.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/syncbuffer.h>
#include <openspace/util/imagesequencer.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/cachemanager.h>
@@ -85,6 +86,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName)
, _syncBuffer(nullptr)
{
SpiceManager::initialize();
ImageSequencer::initialize();
Time::initialize();
FactoryManager::initialize();
ghoul::systemcapabilities::SystemCapabilities::initialize();
@@ -497,7 +499,7 @@ void OpenSpaceEngine::preSynchronization() {
_interactionHandler.update(dt);
_interactionHandler.lockControls();
//Time::ref().advanceTime(dt);
Time::ref().advanceTime(dt);
}
}
@@ -62,7 +62,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _colorTexturePath("planetTexture", "RGB Texture")
, _projectionTexturePath("projectionTexture", "RGB Texture")
, _imageTrigger("clearProjections", "Clear Projections")
, _sequencer(nullptr)
//, _sequencer(nullptr)
, _programObject(nullptr)
, _fboProgramObject(nullptr)
, _texture(nullptr)
@@ -130,9 +130,9 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
_projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadProjectionTexture, this));
//std::string sPath = "C:/Users/michal/JupSequenceCrosshair";
std::string sPath = "F:/JupiterFullSequence/data1/20070114_003110";
std::string sPath = "F:/JupiterFullSequence";
_sequencer->loadSequence(sPath);
openspace::ImageSequencer::ref().loadSequence(sPath);
}
RenderablePlanetProjection::~RenderablePlanetProjection(){
@@ -204,7 +204,7 @@ bool RenderablePlanetProjection::deinitialize(){
_geometry->deinitialize();
delete _geometry;
_geometry = nullptr;
delete _texture;
delete _texture;
_texture = nullptr;
delete _textureProj;
_textureProj = nullptr;
@@ -221,8 +221,6 @@ void RenderablePlanetProjection::imageProjectGPU(){
GLint m_viewport[4];
glGetIntegerv(GL_VIEWPORT, m_viewport);
if (_capture){ // every something frame for now..
//counter = 0;
glBindFramebuffer(GL_FRAMEBUFFER, _fboID);
// set blend eq
@@ -240,10 +238,10 @@ void RenderablePlanetProjection::imageProjectGPU(){
_fboProgramObject->setUniform("ProjectorMatrix", _projectorMatrix);
_fboProgramObject->setUniform("ModelTransform" , _transform);
_fboProgramObject->setUniform("_scaling" , _camScaling);
_fboProgramObject->setUniform("boresight" , _boresight);
_fboProgramObject->setUniform("boresight" , _boresight);
//TODO - needs target switching.
if (_geometry->hasProperty("radius")){
if (_geometry->hasProperty("radius")){
boost::any r = _geometry->property("radius")->get();
if (glm::vec2* radius = boost::any_cast<glm::vec2>(&r)){
_fboProgramObject->setUniform("radius", radius[0]);
@@ -270,7 +268,7 @@ void RenderablePlanetProjection::imageProjectGPU(){
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport(m_viewport[0], m_viewport[1],
m_viewport[2], m_viewport[3]);
}
}
glm::mat4 RenderablePlanetProjection::computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up){
@@ -296,13 +294,12 @@ glm::mat4 RenderablePlanetProjection::computeProjectorMatrix(const glm::vec3 loc
return projNormalizationMatrix*projProjectionMatrix*projViewMatrix;
}
#define SEQUENCING
void RenderablePlanetProjection::render(const RenderData& data){
if (!_programObject) return;
if (!_textureProj) return;
void RenderablePlanetProjection::attitudeParameters(double time){
// precomputations for shader
openspace::SpiceManager::ref().getPositionTransformMatrix(_target, _mainFrame, time, _stateMatrix);
openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _mainFrame, time, _instrumentMatrix);
_transform = glm::mat4(1);
//90 deg rotation w.r.t spice req.
glm::mat4 rot = glm::rotate(_transform, 90.f, glm::vec3(1, 0, 0));
for (int i = 0; i < 3; i++){
@@ -321,17 +318,31 @@ void RenderablePlanetProjection::render(const RenderData& data){
if (!found) LERROR("Could not locate instrument");
psc position;
SpiceManager::ref().getTargetPosition(_projectorID, _projecteeID, _mainFrame, _aberration, _time, position, lightTime);
found = SpiceManager::ref().getTargetPosition(_projectorID, _projecteeID, _mainFrame, _aberration, time, position, lightTime);
if (!found) LERROR("Could not locate target position");
position[3] += 3;
glm::vec3 cpos = position.vec3();
_projectorMatrix = computeProjectorMatrix(cpos, bs, data.camera.lookUpVector());
_projectorMatrix = computeProjectorMatrix(cpos, bs, _up);
}
#define GPU_PROJ
void RenderablePlanetProjection::render(const RenderData& data){
if (!_programObject) return;
if (!_textureProj) return;
_camScaling = data.camera.scaling();
_up = data.camera.lookUpVector();
#ifdef SEQUENCING
imageProjectGPU();
#ifdef GPU_PROJ
if (_capture){
attitudeParameters(_time[0]);
imageProjectGPU();
}
#endif
attitudeParameters(_time[1]);
// Main renderpass
_programObject->activate();
// setup the data to the shader
@@ -357,14 +368,30 @@ void RenderablePlanetProjection::render(const RenderData& data){
void RenderablePlanetProjection::update(const UpdateData& data){
// set spice-orientation in accordance to timestamp
_time = data.time;
_time[0] = data.time;
_time[1] = _time[0];
_capture = false;
bool _withinFOV;
std::string potential[5] = { "JUPITER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" };
std::string p2[5] = { "JUPITER BARYCENTER", "IO", "EUROPA", "GANYMEDE", "CALLISTO" };
_next = _defaultProjImage;
_capture = _sequencer->getImagePath(_time, _next);
_projectionTexturePath = _next;
openspace::SpiceManager::ref().getPositionTransformMatrix(_target, _mainFrame, _time, _stateMatrix);
openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _mainFrame, _time, _instrumentMatrix);
std::string _fovTarget = "";
for (int i = 0; i < 5; i++){
_withinFOV = openspace::SpiceManager::ref().targetWithinFieldOfView(_instrumentID, potential[i], _projectorID, "ELLIPSOID", _aberration, _time[0]);
if (_withinFOV){
_fovTarget = p2[i];
break;
}
}
if (_projecteeID == _fovTarget){
std::cout << _fovTarget << " " << _projecteeID << std::endl;
_next = _defaultProjImage;
_capture = openspace::ImageSequencer::ref().getImagePath(_time[0], _next);
if (_next != _defaultProjImage)
std::cout << _next << std::endl;
_projectionTexturePath = _next;
}
}
void RenderablePlanetProjection::loadProjectionTexture(){
@@ -373,14 +400,12 @@ void RenderablePlanetProjection::loadProjectionTexture(){
if (_colorTexturePath.value() != "") {
_textureProj = ghoul::io::TextureReader::ref().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::AnisotropicMipMap);
_textureProj->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder);
}
}
//_sequencer->sequenceReset();
}
void RenderablePlanetProjection::loadTexture(){
@@ -389,12 +414,9 @@ void RenderablePlanetProjection::loadTexture(){
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::ref().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);
}
}
}
} // namespace openspace
+3 -1
View File
@@ -22,6 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/rendering/renderabletrail.h>
#include <openspace/util/time.h>
#include <sgct.h>
#include <openspace/engine/openspaceengine.h>
@@ -196,7 +197,8 @@ bool RenderableTrail::initialize(){
completeSuccess &= (_texture != nullptr);
// SpiceManager::ref().getETfromDate("2006 Aug 22 17:00:00", _startTrail);
SpiceManager::ref().getETfromDate("2007 feb 26 17:30:00", _startTrail);
_startTrail = Time::ref().currentTime();
//SpiceManager::ref().getETfromDate("2007 feb 26 17:30:00", _startTrail);
_dtEt = _startTrail;
fullYearSweep();
+2
View File
@@ -417,7 +417,9 @@ void RenderEngine::render()
#define PrintText(i, format, ...) Freetype::print(font, 10.f, static_cast<float>(startY - font_size_mono * i * 2), format, __VA_ARGS__);
int i = 0;
PrintText(i++, "Date: %s", Time::ref().currentTimeUTC().c_str());
PrintText(i++, "DateD: %f", Time::ref().currentTime());
PrintText(i++, "Avg. Frametime: %.5f", sgct::Engine::instance()->getAvgDt());
PrintText(i++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime());
PrintText(i++, "Frametime: %.5f", sgct::Engine::instance()->getDt());
+21 -13
View File
@@ -38,6 +38,8 @@ const std::string _loggerCat = "ImageSequencer";
namespace openspace {
ImageSequencer* ImageSequencer::_sequencer = nullptr;
struct ImageParams{
double startTime;
double stopTime;
@@ -46,17 +48,17 @@ struct ImageParams{
};
std::vector<ImageParams> _timeStamps;
ImageSequencer::ImageSequencer(const std::string root){
ImageSequencer& ImageSequencer::ref() {
assert(_sequencer != nullptr);
return *_sequencer;
}
ImageSequencer::~ImageSequencer(){
void ImageSequencer::initialize(){
assert(_sequencer == nullptr);
_sequencer = new ImageSequencer;
}
bool ImageSequencer::initialize(){
return true;
void ImageSequencer::deinitialize(){
delete _sequencer;
_sequencer = nullptr;
}
void ImageSequencer::createImage(double t1, double t2, std::string path){
@@ -82,7 +84,7 @@ bool ImageSequencer::getImagePath(std::string _currentTime, std::string& path){
bool success = getImagePath(currentEt, path);
return success;
}
#define OPEN_INTERVAL
#define OPEN_INTERVAL // assign boolean value...
bool ImageSequencer::getImagePath(double& _currentTime, std::string& path){
auto cmp = [](const ImageParams &a, const ImageParams &b)->bool{
return a.startTime < b.startTime;
@@ -112,13 +114,19 @@ bool ImageSequencer::getImagePath(double& _currentTime, std::string& path){
return false;
}
#endif
it->projected = true;
path = it->path;
_currentTime = it->startTime;
return true;
}
bool ImageSequencer::sequenceReset(){
for (auto image : _timeStamps){
image.projected = false;
}
return true;
}
bool ImageSequencer::loadSequence(const std::string dir){
ghoul::filesystem::Directory sequenceDir(dir, true);
std::vector<std::string> sequencePaths = sequenceDir.read(true, false); // check inputs
@@ -148,8 +156,8 @@ bool ImageSequencer::loadSequence(const std::string dir){
if (pos != std::string::npos){
std::string time = line.substr(line.find("=") + 2);
time.erase(std::remove(time.begin(), time.end(), ' '), time.end());
if (i == 0) std::cout << "Creating image with startTime: " << time;
if (i == 1) std::cout << " ---> " << time << std::endl;
//if (i == 0) std::cout << "Creating image with startTime: " << time;
//if (i == 1) std::cout << " ---> " << time << std::endl;
openspace::SpiceManager::ref().getETfromDate(time, timestamps[i]);
}
}