mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-01 16:29:43 -05:00
beginning to work on sequencing
This commit is contained in:
+1
-1
Submodule ext/ghoul updated: f33aef8eca...58abe3e023
@@ -28,6 +28,7 @@
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/imagesequencer.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
@@ -60,13 +61,17 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
|
||||
void loadTexture();
|
||||
void loadProjectionTexture();
|
||||
bool auxiliaryRendertarget();
|
||||
glm::mat4 computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up);
|
||||
|
||||
private:
|
||||
void imageProjectGPU();
|
||||
|
||||
ImageSequencer* _sequencer;
|
||||
|
||||
properties::StringProperty _colorTexturePath;
|
||||
properties::StringProperty _projectionTexturePath;
|
||||
properties::TriggerProperty _imageTrigger;
|
||||
@@ -102,6 +107,8 @@ private:
|
||||
|
||||
std::string _target;
|
||||
|
||||
std::string _oldPath = "";
|
||||
|
||||
// FBO stuff
|
||||
GLuint _fboID;
|
||||
GLuint _quad;
|
||||
|
||||
@@ -45,14 +45,13 @@ public:
|
||||
bool initialize(RenderablePlanet* parent) override;
|
||||
void deinitialize() override;
|
||||
void render() override;
|
||||
PowerScaledSphere* _planet;
|
||||
|
||||
private:
|
||||
void createSphere();
|
||||
|
||||
properties::Vec2Property _radius;
|
||||
properties::IntProperty _segments;
|
||||
|
||||
PowerScaledSphere* _planet;
|
||||
};
|
||||
|
||||
} // namespace planetgeometry
|
||||
|
||||
@@ -52,6 +52,11 @@ private:
|
||||
properties::Vec2Property _radius;
|
||||
properties::IntProperty _segments;
|
||||
|
||||
|
||||
properties::IntProperty _vaoID;
|
||||
properties::IntProperty _vBufferID;
|
||||
properties::IntProperty _iBufferID;
|
||||
|
||||
PowerScaledSphere* _planet;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __IMAGESEQUENCER_H__
|
||||
#define __IMAGESEQUENCER_H__
|
||||
|
||||
// open space includes
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ImageSequencer {
|
||||
public:
|
||||
// initializers
|
||||
ImageSequencer(const std::string dir);
|
||||
~ImageSequencer();
|
||||
|
||||
bool loadSequence(const std::string dir);
|
||||
|
||||
void testStartTimeMap();
|
||||
|
||||
bool initialize();
|
||||
|
||||
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);
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __IMAGESEQUENCER_H__
|
||||
@@ -43,7 +43,8 @@ public:
|
||||
|
||||
void render();
|
||||
|
||||
private:
|
||||
|
||||
//private:
|
||||
typedef struct {
|
||||
GLfloat location[4];
|
||||
GLfloat tex[2];
|
||||
@@ -51,9 +52,9 @@ private:
|
||||
GLubyte padding[28]; // Pads the struct out to 64 bytes for performance increase
|
||||
} Vertex;
|
||||
|
||||
GLuint _vaoID;
|
||||
GLuint _vBufferID;
|
||||
GLuint _iBufferID;
|
||||
GLuint _vaoID;
|
||||
GLuint _vBufferID;
|
||||
GLuint _iBufferID;
|
||||
|
||||
unsigned int _isize;
|
||||
unsigned int _vsize;
|
||||
|
||||
+1
-1
Submodule openspace-data updated: 820a067f7f...3a1f4e2e41
@@ -1,11 +1,11 @@
|
||||
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
|
||||
openspace.time.setTime("2007-02-26T17:30:00")
|
||||
openspace.time.setTime("2007-02-26T17:34:06.350")
|
||||
--openspace.time.setTime("2006-08-22T20:00:00")
|
||||
|
||||
--openspace.time.setDeltaTime(200000.0)
|
||||
--openspace.time.setDeltaTime(5000.00)
|
||||
--openspace.time.setDeltaTime(864000)
|
||||
openspace.time.setDeltaTime(500.0)
|
||||
openspace.time.setDeltaTime(0.01)
|
||||
-- print(openspace.time.currentTimeUTC())
|
||||
|
||||
|
||||
|
||||
+11
-8
@@ -61,24 +61,27 @@ bool inRange(float x, float a, float b){
|
||||
void main() {
|
||||
vec2 uv = vec2(0.5,0.5)*vs_position.xy+vec2(0.5,0.5);
|
||||
|
||||
// vec2 radius_expl = vec2(0.71492f, 8.f);
|
||||
vec4 vertex = uvToModel(uv.x, uv.y, radius, vs_segments);
|
||||
|
||||
vec4 raw_pos = psc_to_meter(vertex, _scaling);
|
||||
vec4 raw_pos = psc_to_meter(vertex, _scaling);
|
||||
vec4 projected = ProjectorMatrix * ModelTransform * raw_pos;
|
||||
|
||||
|
||||
projected.x /= projected.w;
|
||||
projected.y /= projected.w;
|
||||
|
||||
vec3 normal = normalize(ModelTransform * vec4(vertex.xyz,0)).xyz;
|
||||
|
||||
//"in range"
|
||||
vec3 normal = normalize((ModelTransform*vec4(vertex.xyz,0)).xyz);
|
||||
|
||||
vec3 v_b = normalize(vs_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(normal, vs_boresight) < 0){
|
||||
dot(v_b, normal) < 0 ) {
|
||||
color = texture(texture1, projected.xy);
|
||||
}else{
|
||||
color = vec4(1,0,0,0);
|
||||
//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
|
||||
}
|
||||
@@ -27,18 +27,21 @@ uniform mat4 ProjectorMatrix;
|
||||
uniform mat4 ModelTransform;
|
||||
uniform vec2 _scaling;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
layout(location = 1) in vec3 boresight;
|
||||
layout(location = 2) in int segments;
|
||||
layout(location = 3) in vec4 in_position;
|
||||
layout(location = 4) in vec3 boresight;
|
||||
layout(location = 5) in int segments;
|
||||
uniform vec2 radius;
|
||||
|
||||
out vec4 vs_position;
|
||||
out vec3 vs_boresight;
|
||||
flat out uint vs_segments;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vs_position = in_position;
|
||||
vs_boresight = boresight;
|
||||
vs_segments = segments;
|
||||
gl_Position = vec4(in_position.xy, 0.0, 1.0);
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ void main()
|
||||
//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 terminatorBright = 0.8;
|
||||
float intensity = min(max(5*dot(n,l_dir), terminatorBright), 1);
|
||||
|
||||
float shine = 0.0001;
|
||||
|
||||
@@ -78,7 +79,7 @@ void main()
|
||||
|
||||
// PROJECTIVE TEXTURE
|
||||
vec4 projTexColor = textureProj(texture2, ProjTexCoord);
|
||||
vec4 shaded = diffuse;//max(intensity * diffuse, ambient);
|
||||
vec4 shaded = max(intensity * diffuse, ambient);
|
||||
if (ProjTexCoord[0] > 0.0 ||
|
||||
ProjTexCoord[1] > 0.0 ||
|
||||
ProjTexCoord[0] < ProjTexCoord[2] ||
|
||||
|
||||
@@ -46,11 +46,8 @@ out float s;
|
||||
out vec3 vs_boresight;
|
||||
|
||||
out vec4 ProjTexCoord;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
void main(){
|
||||
// Radius = 0.71492 *10^8;
|
||||
vs_boresight = boresight;
|
||||
// set variables
|
||||
|
||||
@@ -37,10 +37,12 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <sgct.h>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderablePlanetProjection";
|
||||
const std::string keyProjObserver = "Projection.Observer";
|
||||
@@ -54,14 +56,18 @@ namespace {
|
||||
|
||||
const std::string _mainFrame = "GALACTIC";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
#ifdef WIN32
|
||||
const char pathSeparator = '\\';
|
||||
#else
|
||||
const char pathSeparator = '/';
|
||||
#endif
|
||||
RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _colorTexturePath("colorTexture", "Color Texture")
|
||||
, _projectionTexturePath("colorTexture", "Color Texture")
|
||||
, _colorTexturePath("planetTexture", "RGB Texture")
|
||||
, _projectionTexturePath("projectionTexture", "RGB Texture")
|
||||
, _imageTrigger("imageTrigger", "Image Trigger")
|
||||
, _sequencer(nullptr)
|
||||
, _programObject(nullptr)
|
||||
, _fboProgramObject(nullptr)
|
||||
, _texture(nullptr)
|
||||
@@ -69,13 +75,13 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
|
||||
, _geometry(nullptr)
|
||||
{
|
||||
bool b1 = dictionary.getValue(keyInstrument , _instrumentID);
|
||||
bool b2 = dictionary.getValue( keyProjObserver , _projectorID );
|
||||
bool b3 = dictionary.getValue( keyProjTarget , _projecteeID );
|
||||
bool b4 = dictionary.getValue( keyProjAberration , _aberration );
|
||||
bool b5 = dictionary.getValue(keyInstrumentFovy , _fovy);
|
||||
bool b6 = dictionary.getValue(keyInstrumentAspect, _aspectRatio);
|
||||
bool b7 = dictionary.getValue(keyInstrumentNear , _nearPlane);
|
||||
bool b8 = dictionary.getValue(keyInstrumentFar , _farPlane);
|
||||
bool b2 = dictionary.getValue(keyProjObserver , _projectorID );
|
||||
bool b3 = dictionary.getValue(keyProjTarget , _projecteeID );
|
||||
bool b4 = dictionary.getValue(keyProjAberration , _aberration );
|
||||
bool b5 = dictionary.getValue(keyInstrumentFovy , _fovy );
|
||||
bool b6 = dictionary.getValue(keyInstrumentAspect, _aspectRatio );
|
||||
bool b7 = dictionary.getValue(keyInstrumentNear , _nearPlane );
|
||||
bool b8 = dictionary.getValue(keyInstrumentFar , _farPlane );
|
||||
|
||||
assert(b1 == true);
|
||||
assert(b2 == true);
|
||||
@@ -124,7 +130,11 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
|
||||
addProperty(_colorTexturePath);
|
||||
_colorTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
|
||||
addProperty(_projectionTexturePath);
|
||||
_projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
|
||||
_projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadProjectionTexture, this));
|
||||
|
||||
std::string sPath = "C:/Users/michal/JupSequenceContrastCorrected";
|
||||
|
||||
_sequencer->loadSequence(sPath);
|
||||
}
|
||||
|
||||
RenderablePlanetProjection::~RenderablePlanetProjection(){
|
||||
@@ -142,6 +152,7 @@ bool RenderablePlanetProjection::initialize(){
|
||||
&= OsEng.ref().configurationManager().getValue("fboPassProgram", _fboProgramObject);
|
||||
|
||||
loadTexture();
|
||||
loadProjectionTexture();
|
||||
completeSuccess &= (_texture != nullptr);
|
||||
completeSuccess &= (_textureProj != nullptr);
|
||||
|
||||
@@ -182,10 +193,11 @@ bool RenderablePlanetProjection::auxiliaryRendertarget(){
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
glEnableVertexAttribArray(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glEnableVertexAttribArray(4);
|
||||
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
@@ -212,14 +224,25 @@ void RenderablePlanetProjection::imageProjectGPU(){
|
||||
GLint m_viewport[4];
|
||||
glGetIntegerv(GL_VIEWPORT, m_viewport);
|
||||
|
||||
static int counter = 0;
|
||||
if (counter > 50){ // every something frame for now..
|
||||
counter = 0;
|
||||
bool newImg = false;
|
||||
std::string tmpProj = "C:/Users/michal/openspace/openspace-data/scene/jupiterprojection/textures/lor_0034817584_0x630_sci_1.fit.jpg";
|
||||
|
||||
boost::any s = _projectionTexturePath.get();
|
||||
std::string *str;
|
||||
str = boost::any_cast<std::string>(&s);
|
||||
|
||||
std::string newPath = tmpProj;
|
||||
newImg = _sequencer->getImagePath(_time, newPath);
|
||||
|
||||
if (str[0] != newPath){ // every something frame for now..
|
||||
_projectionTexturePath = newPath;
|
||||
//counter = 0;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _fboID);
|
||||
// set blend eq
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ZERO);
|
||||
|
||||
glViewport(0, 0, _texture->width(), _texture->height());
|
||||
_fboProgramObject->activate();
|
||||
|
||||
@@ -251,6 +274,28 @@ void RenderablePlanetProjection::imageProjectGPU(){
|
||||
LERROR("Geometry object needs to provide segment count");
|
||||
}
|
||||
|
||||
/*
|
||||
if (_geometry->hasProperty("vaoID") &&
|
||||
_geometry->hasProperty("vboID") &&
|
||||
_geometry->hasProperty("iboID") ){
|
||||
|
||||
//int* vaoID, vboID, iboID;
|
||||
boost::any id1 = _geometry->property("vaoID")->get();
|
||||
boost::any id2 = _geometry->property("vboID")->get();
|
||||
boost::any id3 = _geometry->property("iboID")->get();
|
||||
if (GLuint vaoID = ((GLuint*)boost::any_cast<int>(&id1))[0]){
|
||||
if (GLuint vboID = ((GLuint*)boost::any_cast<int>(&id2))[0]){
|
||||
if (GLuint iboID = ((GLuint*)boost::any_cast<int>(&id3))[0]){
|
||||
|
||||
glBindVertexArray(vaoID); // select first VAO
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID);
|
||||
glDrawElements(GL_TRIANGLES, 240000, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
_fboProgramObject->deactivate();
|
||||
@@ -261,7 +306,8 @@ void RenderablePlanetProjection::imageProjectGPU(){
|
||||
glViewport(m_viewport[0], m_viewport[1],
|
||||
m_viewport[2], m_viewport[3]);
|
||||
}
|
||||
counter++;
|
||||
|
||||
//counter++;
|
||||
}
|
||||
|
||||
glm::mat4 RenderablePlanetProjection::computeProjectorMatrix(const glm::vec3 loc, glm::dvec3 aim, const glm::vec3 up){
|
||||
@@ -323,11 +369,12 @@ void RenderablePlanetProjection::render(const RenderData& data){
|
||||
#ifdef SEQUENCING
|
||||
imageProjectGPU();
|
||||
#endif
|
||||
|
||||
// Main renderpass
|
||||
_programObject->activate();
|
||||
// setup the data to the shader
|
||||
_programObject->setUniform("ProjectorMatrix", _projectorMatrix);
|
||||
_programObject->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform" , _transform);
|
||||
_programObject->setAttribute("boresight" , _boresight);
|
||||
setPscUniforms(_programObject, &data.camera, data.position);
|
||||
@@ -353,19 +400,7 @@ void RenderablePlanetProjection::update(const UpdateData& data){
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _mainFrame, data.time, _instrumentMatrix);
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadTexture(){
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadProjectionTexture(){
|
||||
delete _textureProj;
|
||||
_textureProj = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
@@ -382,4 +417,18 @@ void RenderablePlanetProjection::loadTexture(){
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadTexture(){
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
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
|
||||
|
||||
@@ -104,8 +104,7 @@ void SimpleSphereGeometry::render()
|
||||
_planet->render();
|
||||
}
|
||||
|
||||
void SimpleSphereGeometry::createSphere()
|
||||
{
|
||||
void SimpleSphereGeometry::createSphere(){
|
||||
//create the power scaled scalar
|
||||
|
||||
PowerScaledScalar planetSize(_radius);
|
||||
|
||||
@@ -45,6 +45,9 @@ SimpleSphereGeometryProjection::SimpleSphereGeometryProjection(const ghoul::Dict
|
||||
, _radius("radius", "Radius", glm::vec2(1.f, 0.f), glm::vec2(-10.f, -20.f),
|
||||
glm::vec2(10.f, 20.f))
|
||||
, _segments("segments", "Segments", 20, 1, 1000)
|
||||
, _vaoID("vaoID", "Vao", 1, 1, 1)
|
||||
, _vBufferID("vboID", "Vbo", 1, 1, 1)
|
||||
, _iBufferID("iboID", "Ibo", 1, 1, 1)
|
||||
, _planet(nullptr)
|
||||
{
|
||||
using constants::scenegraphnode::keyName;
|
||||
@@ -88,6 +91,14 @@ bool SimpleSphereGeometryProjection::initialize(RenderablePlanetProjection* pare
|
||||
{
|
||||
bool success = PlanetGeometryProjection::initialize(parent);
|
||||
createSphere();
|
||||
|
||||
//need to have this accessible in planetgeometryprojection for now -- Michal
|
||||
_vaoID = static_cast<int>(_planet->_vaoID);
|
||||
_vBufferID = static_cast<int>(_planet->_vBufferID);
|
||||
_iBufferID = static_cast<int>(_planet->_iBufferID);
|
||||
addProperty(_vaoID);
|
||||
addProperty(_vBufferID);
|
||||
addProperty(_iBufferID);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
// open space includes
|
||||
#include <openspace/util/imagesequencer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ImageSequencer";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct ImageParams{
|
||||
double startTime;
|
||||
double stopTime;
|
||||
std::string path;
|
||||
};
|
||||
std::vector<ImageParams> _timeStamps;
|
||||
|
||||
|
||||
ImageSequencer::ImageSequencer(const std::string root){
|
||||
|
||||
}
|
||||
|
||||
ImageSequencer::~ImageSequencer(){
|
||||
|
||||
}
|
||||
|
||||
bool ImageSequencer::initialize(){
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImageSequencer::createImage(double t1, double t2, std::string path){
|
||||
// insert
|
||||
ImageParams image;
|
||||
image.startTime = t1;
|
||||
image.stopTime = t2;
|
||||
image.path = path;
|
||||
|
||||
_timeStamps.push_back(image);
|
||||
// sort
|
||||
auto cmp = [](const ImageParams &a, const ImageParams &b)->bool{
|
||||
return a.startTime < b.startTime;
|
||||
};
|
||||
|
||||
std::sort(_timeStamps.begin(), _timeStamps.end(), cmp);
|
||||
}
|
||||
|
||||
bool ImageSequencer::getImagePath(std::string _currentTime, std::string& path){
|
||||
double currentEt = 0;
|
||||
openspace::SpiceManager::ref().getETfromDate(_currentTime, currentEt);
|
||||
bool success = getImagePath(currentEt, path);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ImageSequencer::getImagePath(double _currentTime, std::string& path){
|
||||
auto cmp = [](const ImageParams &a, const ImageParams &b)->bool{
|
||||
return a.startTime < b.startTime;
|
||||
};
|
||||
|
||||
auto binary_find = [](std::vector<ImageParams>::iterator begin,
|
||||
std::vector<ImageParams>::iterator end,
|
||||
const ImageParams &val,
|
||||
bool(*cmp)(const ImageParams &a, const ImageParams &b))->std::vector<ImageParams>::iterator{
|
||||
// Finds the lower bound in at most log(last - first) + 1 comparisons
|
||||
std::vector<ImageParams>::iterator it = std::lower_bound(begin, end, val, cmp);
|
||||
if (it != begin){
|
||||
return std::prev(it);
|
||||
}
|
||||
return end;
|
||||
};
|
||||
|
||||
auto it = binary_find(_timeStamps.begin(), _timeStamps.end(), { _currentTime, 0, "" }, cmp);
|
||||
//do this if check against [start, stop] intervals
|
||||
/*
|
||||
if (it == _timeStamps.end() || it->stopTime < _currentTime){
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
//do this if check against [start,) intervals
|
||||
if (it == _timeStamps.end()){
|
||||
return false;
|
||||
}
|
||||
|
||||
path = it->path;
|
||||
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
|
||||
int count = 0;
|
||||
std::cout.precision(15);
|
||||
|
||||
for (auto path : sequencePaths){
|
||||
if (size_t position = path.find_last_of(".") + 1){
|
||||
if (position != std::string::npos){
|
||||
ghoul::filesystem::File currentFile(path);
|
||||
std::string extension = currentFile.fileExtension();
|
||||
|
||||
if (extension == "lbl"){ // discovered header file
|
||||
std::ifstream file(currentFile.path());
|
||||
|
||||
if (!file.good()) LERROR("Failed to open label file '" << currentFile.path() << "'");
|
||||
|
||||
// open up label files
|
||||
std::string line = "";
|
||||
|
||||
std::string specsOfInterest[2] = { "START_TIME", "STOP_TIME" };
|
||||
double timestamps[2] = { 0.0, 0.0 };
|
||||
bool found = false;
|
||||
do {
|
||||
std::getline(file, line);
|
||||
for (int i = 0; i < 2; i++){
|
||||
auto pos = line.find(specsOfInterest[i]);
|
||||
if (pos != std::string::npos){
|
||||
std::string time = line.substr(line.find("=") + 2);
|
||||
time.erase(std::remove(time.begin(), time.end(), ' '), time.end());
|
||||
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]);
|
||||
}
|
||||
}
|
||||
if (timestamps[0] != 0.0 && timestamps[1] != 0.0){
|
||||
found = true;
|
||||
std::string ext = "jpg";
|
||||
path.replace(path.begin() + position, path.end(), ext);
|
||||
std::vector<std::string>::const_iterator it = std::find(sequencePaths.begin(), sequencePaths.end(), path);
|
||||
if ( it != sequencePaths.end()){
|
||||
// std::cout << "Creating image with time: " << timestamps[0] << "\ne_t: " << timestamps[1] << "\npath: " << path << std::endl;
|
||||
createImage(timestamps[0], timestamps[1], path);
|
||||
}
|
||||
}
|
||||
} while (!file.eof() && found == false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// testing _timeStamps
|
||||
/*double currentEt = 0;
|
||||
std::string currentTime = "2007-02-26T17:43:26.362";
|
||||
|
||||
openspace::SpiceManager::ref().getETfromDate(currentTime, currentEt);
|
||||
|
||||
std::cout << "\n Searching for s_t: " << currentEt << std::endl;
|
||||
|
||||
std::string storedpath = "";
|
||||
currentEt -= 1;
|
||||
|
||||
for (int i = 0; i < 10000; i++){
|
||||
bool success = getImagePath(currentEt, storedpath);
|
||||
currentEt += ((float)i)/10000.f;
|
||||
|
||||
if (success) std::cout << "FOUND AT : "<< currentEt << " PATH "<< storedpath << std::endl;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
Reference in New Issue
Block a user