mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Replaced RuntimeData with separate, temporary structs that are passed around
This commit is contained in:
@@ -25,6 +25,10 @@
|
||||
#ifndef __OPENSPACEENGINE_H__
|
||||
#define __OPENSPACEENGINE_H__
|
||||
|
||||
// sgct header has to be included before all others due to Windows header
|
||||
#define SGCT_WINDOWS_INCLUDE
|
||||
#include "sgct.h"
|
||||
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
#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>
|
||||
#include <openspace/util/runtimedata.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
void render(const Camera* camera, const psc& thisPosition, RuntimeData* runtimeData) override;
|
||||
void update() override;
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
void loadTexture();
|
||||
@@ -62,6 +62,8 @@ private:
|
||||
ghoul::opengl::Texture* _texture;
|
||||
planetgeometry::PlanetGeometry* _geometry;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
|
||||
std::string _target;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <openspace/util/camera.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/util/runtimedata.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
void setBoundingSphere(const PowerScaledScalar& boundingSphere);
|
||||
const PowerScaledScalar& getBoundingSphere();
|
||||
|
||||
virtual void render(const Camera* camera, const psc& thisPosition, RuntimeData* runtimeData) = 0;
|
||||
virtual void update();
|
||||
virtual void render(const RenderData& data) = 0;
|
||||
virtual void update(const UpdateData& data);
|
||||
|
||||
bool isVisible() const;
|
||||
|
||||
@@ -63,7 +63,6 @@ private:
|
||||
properties::BoolProperty _enabled;
|
||||
|
||||
PowerScaledScalar boundingSphere_;
|
||||
RuntimeData* _runtimeData;
|
||||
std::string _relativePath;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
@@ -43,8 +44,8 @@ public:
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
virtual void render(const Camera *camera, const psc& thisPosition, RuntimeData* runtimeData);
|
||||
virtual void update();
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
std::vector<std::vector<LinePoint> > getFieldlinesData(std::string filename, ghoul::Dictionary hintsDictionary);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
@@ -43,8 +44,8 @@ public:
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
void render(const Camera* camera, const psc& position, RuntimeData* runtimeData) override;
|
||||
void update() override;
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
private:
|
||||
protected:
|
||||
typedef struct {
|
||||
|
||||
@@ -44,8 +44,8 @@ public:
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
virtual void render(const Camera *camera, const psc& thisPosition, RuntimeData* runtimeData);
|
||||
virtual void update();
|
||||
virtual void render(const RenderData& data) override;
|
||||
virtual void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
ghoul::Dictionary _hintsDictionary;
|
||||
@@ -69,7 +69,6 @@ private:
|
||||
float _w;
|
||||
GLint _MVPLocation, _modelTransformLocation, _typeLocation;
|
||||
|
||||
RuntimeData* _runtimeData;
|
||||
bool _updateTransferfunction;
|
||||
int _id;
|
||||
};
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#define __RENDERENGINE_H__
|
||||
|
||||
#include <openspace/scenegraph/scenegraph.h>
|
||||
#include <openspace/util/runtimedata.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -44,7 +43,6 @@ public:
|
||||
|
||||
bool initialize();
|
||||
|
||||
void setRuntimeData(RuntimeData* runtimeData);
|
||||
void setSceneGraph(SceneGraph* sceneGraph);
|
||||
SceneGraph* sceneGraph();
|
||||
|
||||
@@ -63,7 +61,6 @@ public:
|
||||
private:
|
||||
Camera* _mainCamera;
|
||||
SceneGraph* _sceneGraph;
|
||||
RuntimeData* _runtimeData;
|
||||
ABuffer* _abuffer;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
@@ -43,8 +44,8 @@ public:
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
void render(const Camera* camera, const psc& position, RuntimeData* runtimeData) override;
|
||||
void update() override;
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
protected:
|
||||
void loadTexture();
|
||||
@@ -72,8 +73,6 @@ private:
|
||||
int v_size;
|
||||
int v_stride;
|
||||
int v_total;
|
||||
|
||||
RuntimeData* _runtimeData;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <openspace/util/runtimedata.h>
|
||||
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -40,14 +39,10 @@ public:
|
||||
virtual ~Ephemeris();
|
||||
virtual bool initialize();
|
||||
virtual const psc& position() const = 0;
|
||||
virtual void update(RuntimeData* runtimeData) = 0;
|
||||
virtual void update();
|
||||
virtual void update(const UpdateData& data);
|
||||
|
||||
protected:
|
||||
Ephemeris();
|
||||
|
||||
private:
|
||||
RuntimeData* _runtimeData;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -30,13 +30,12 @@
|
||||
#include <map>
|
||||
|
||||
#include <openspace/util/camera.h>
|
||||
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <openspace/util/runtimedata.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -49,8 +48,6 @@ public:
|
||||
SceneGraph();
|
||||
~SceneGraph();
|
||||
|
||||
void setRuntimeData(RuntimeData* runtimeData);
|
||||
|
||||
/**
|
||||
* Initalizes the SceneGraph by loading modules from the ${SCENEPATH} directory
|
||||
*/
|
||||
@@ -72,7 +69,7 @@ public:
|
||||
/*
|
||||
* Updates all SceneGraphNodes relative positions
|
||||
*/
|
||||
void update();
|
||||
void update(const UpdateData& data);
|
||||
|
||||
/*
|
||||
* Evaluates if the SceneGraphNodes are visible to the provided camera
|
||||
@@ -82,7 +79,7 @@ public:
|
||||
/*
|
||||
* Render visible SceneGraphNodes using the provided camera
|
||||
*/
|
||||
void render(Camera* camera);
|
||||
void render(const RenderData& data);
|
||||
|
||||
/*
|
||||
* Prints the SceneGraph tree. For debugging purposes
|
||||
@@ -119,7 +116,6 @@ private:
|
||||
SceneGraphNode* _root;
|
||||
std::vector<SceneGraphNode*> _nodes;
|
||||
std::map<std::string, SceneGraphNode*> _allNodes;
|
||||
RuntimeData* _runtimeData;
|
||||
|
||||
std::string _sceneGraphToLoad;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <openspace/scenegraph/scenegraph.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <openspace/util/runtimedata.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
// std includes
|
||||
#include <iostream>
|
||||
@@ -52,13 +52,13 @@ public:
|
||||
|
||||
static SceneGraphNode* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
|
||||
bool initialize(RuntimeData* runtimeData);
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
// essential
|
||||
void update();
|
||||
void update(const UpdateData& data);
|
||||
void evaluate(const Camera* camera, const psc& parentPosition = psc());
|
||||
void render(const Camera* camera, const psc& parentPosition = psc());
|
||||
void render(const RenderData& data);
|
||||
|
||||
// set & get
|
||||
void addNode(SceneGraphNode* child);
|
||||
@@ -88,7 +88,6 @@ private:
|
||||
std::vector<SceneGraphNode*> _children;
|
||||
SceneGraphNode* _parent;
|
||||
Ephemeris* _ephemeris;
|
||||
RuntimeData* _runtimeData;
|
||||
|
||||
// renderable
|
||||
Renderable* _renderable;
|
||||
|
||||
@@ -34,10 +34,10 @@ namespace openspace {
|
||||
class SpiceEphemeris : public Ephemeris {
|
||||
public:
|
||||
SpiceEphemeris(const ghoul::Dictionary& dictionary);
|
||||
virtual ~SpiceEphemeris();
|
||||
virtual bool initialize();
|
||||
virtual const psc& position() const;
|
||||
virtual void update(RuntimeData* runtimeData);
|
||||
~SpiceEphemeris();
|
||||
bool initialize();
|
||||
const psc& position() const;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
std::string _targetName;
|
||||
@@ -45,8 +45,6 @@ private:
|
||||
int _target;
|
||||
int _origin;
|
||||
psc _position;
|
||||
double _currentEphemerisTime = -1;
|
||||
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
= ghoul::Dictionary());
|
||||
virtual ~StaticEphemeris();
|
||||
virtual const psc& position() const;
|
||||
virtual void update(RuntimeData* runtimeData);
|
||||
virtual void update(const UpdateData& data) override;
|
||||
private:
|
||||
psc _position;
|
||||
};
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef __RUNTIMEDATA_H__
|
||||
#define __RUNTIMEDATA_H__
|
||||
|
||||
enum increment{
|
||||
YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND
|
||||
};
|
||||
|
||||
struct RuntimeData{
|
||||
public:
|
||||
RuntimeData() :_openspaceTime(0.0){
|
||||
};
|
||||
void setTime(double time) { _openspaceTime = time; }
|
||||
double getTime() { return _openspaceTime; }
|
||||
|
||||
// cant come up with proper user friendly-method, this will do.
|
||||
void advanceTimeBy(double nr, increment incr){
|
||||
switch (incr){
|
||||
case YEAR: _openspaceTime += (nr * year); break;
|
||||
case MONTH: _openspaceTime += (nr * month); break;
|
||||
case DAY: _openspaceTime += (nr * day); break;
|
||||
case HOUR: _openspaceTime += (nr * hour); break;
|
||||
case MINUTE: _openspaceTime += (nr * minute); break;
|
||||
case MILLISECOND: _openspaceTime += (nr * millisec); break;
|
||||
default : _openspaceTime += (nr);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
double _openspaceTime;
|
||||
|
||||
double year = 3.154*pow(10, 7);
|
||||
double month = 2.628*pow(10, 6);
|
||||
double day = 86400;
|
||||
double hour = 3600;
|
||||
double minute = 60;
|
||||
double millisec = 0.001;
|
||||
};
|
||||
|
||||
#endif // __RUNTIMEDATA_H__
|
||||
45
include/openspace/util/updatestructures.h
Normal file
45
include/openspace/util/updatestructures.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __UPDATESTRUCTURES_H__
|
||||
#define __UPDATESTRUCTURES_H__
|
||||
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct UpdateData {
|
||||
double time;
|
||||
};
|
||||
|
||||
struct RenderData {
|
||||
const Camera& camera;
|
||||
psc position;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __UPDATESTRUCTURES_H__
|
||||
@@ -24,10 +24,6 @@
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
// sgct header has to be included before all others due to Windows header
|
||||
#define SGCT_WINDOWS_INCLUDE
|
||||
#include "sgct.h"
|
||||
|
||||
#include <openspace/interaction/deviceidentifier.h>
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
@@ -37,7 +33,6 @@
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/runtimedata.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
@@ -329,9 +324,6 @@ bool OpenSpaceEngine::initialize()
|
||||
Spice::init();
|
||||
Spice::ref().loadDefaultKernels(); // changeto: instantiate spicemanager, load kernels.
|
||||
|
||||
RuntimeData* initialData = new RuntimeData;
|
||||
initialData->setTime(Time::ref().currentTime());
|
||||
|
||||
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/de430_1850-2150.bsp"), "SPK_EARTH");
|
||||
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/MAR063.bsp") , "SPK_MARS");
|
||||
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/pck00010.tpc") , "PCK");
|
||||
@@ -355,8 +347,6 @@ bool OpenSpaceEngine::initialize()
|
||||
|
||||
// initialize the RenderEngine, needs ${SCENEPATH} to be set
|
||||
_renderEngine->initialize();
|
||||
_renderEngine->setRuntimeData(initialData);
|
||||
sceneGraph->setRuntimeData(initialData);
|
||||
sceneGraph->initialize();
|
||||
|
||||
std::string sceneDescriptionPath;
|
||||
|
||||
@@ -113,7 +113,7 @@ bool RenderablePlanet::deinitialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderablePlanet::render(const Camera* camera, const psc& thisPosition, RuntimeData* runtimeData)
|
||||
void RenderablePlanet::render(const RenderData& data)
|
||||
{
|
||||
if (!_programObject)
|
||||
return;
|
||||
@@ -124,9 +124,9 @@ void RenderablePlanet::render(const Camera* camera, const psc& thisPosition, Run
|
||||
_programObject->activate();
|
||||
|
||||
// fetch data
|
||||
psc currentPosition = thisPosition;
|
||||
psc campos = camera->position();
|
||||
glm::mat4 camrot = camera->viewRotationMatrix();
|
||||
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);
|
||||
@@ -134,23 +134,19 @@ void RenderablePlanet::render(const Camera* camera, const psc& thisPosition, Run
|
||||
// scale the planet to appropriate size since the planet is a unit sphere
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
|
||||
// set spice-orientation in accordance to timestamp
|
||||
glm::dmat3 stateMatrix;
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrixGLM("GALACTIC", "IAU_EARTH", runtimeData->getTime(), stateMatrix);
|
||||
|
||||
//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[i][j] = _stateMatrix[i][j];
|
||||
}
|
||||
}
|
||||
transform = transform* rot;
|
||||
|
||||
|
||||
// setup the data to the shader
|
||||
_programObject->setUniform("ViewProjection", camera->viewProjectionMatrix());
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
_programObject->setUniform("campos", campos.vec4());
|
||||
_programObject->setUniform("objpos", currentPosition.vec4());
|
||||
@@ -171,8 +167,11 @@ void RenderablePlanet::render(const Camera* camera, const psc& thisPosition, Run
|
||||
|
||||
}
|
||||
|
||||
void RenderablePlanet::update()
|
||||
void RenderablePlanet::update(const UpdateData& data)
|
||||
{
|
||||
// set spice-orientation in accordance to timestamp
|
||||
openspace::SpiceManager::ref().getPositionTransformMatrixGLM("GALACTIC", "IAU_EARTH", data.time, _stateMatrix);
|
||||
|
||||
}
|
||||
|
||||
void RenderablePlanet::loadTexture()
|
||||
|
||||
@@ -88,7 +88,7 @@ const PowerScaledScalar& Renderable::getBoundingSphere()
|
||||
return boundingSphere_;
|
||||
}
|
||||
|
||||
void Renderable::update()
|
||||
void Renderable::update(const UpdateData&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -211,29 +211,29 @@ bool RenderableFieldlines::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderableFieldlines::render(const Camera* camera, const psc& thisPosition, RuntimeData* runtimeData) {
|
||||
void RenderableFieldlines::render(const RenderData& data) {
|
||||
if(_update) {
|
||||
_update = false;
|
||||
safeShaderCompilation();
|
||||
}
|
||||
|
||||
glm::mat4 transform = camera->viewProjectionMatrix();
|
||||
glm::mat4 camTransform = camera->viewRotationMatrix();
|
||||
psc relative = thisPosition-camera->position();
|
||||
glm::mat4 transform = data.camera.viewProjectionMatrix();
|
||||
glm::mat4 camTransform = data.camera.viewRotationMatrix();
|
||||
psc relative = data.position - data.camera.position();
|
||||
|
||||
transform = transform*camTransform;
|
||||
transform = glm::mat4(1.0);
|
||||
transform = glm::scale(transform, glm::vec3(0.01));
|
||||
|
||||
psc currentPosition = thisPosition;
|
||||
psc campos = camera->position();
|
||||
glm::mat4 camrot = camera->viewRotationMatrix();
|
||||
PowerScaledScalar scaling = camera->scaling();
|
||||
psc currentPosition = data.position;
|
||||
psc campos = data.camera.position();
|
||||
glm::mat4 camrot = data.camera.viewRotationMatrix();
|
||||
PowerScaledScalar scaling = data.camera.scaling();
|
||||
|
||||
// Activate shader
|
||||
_fieldlinesProgram->activate();
|
||||
|
||||
_fieldlinesProgram->setUniform("modelViewProjection", camera->viewProjectionMatrix());
|
||||
_fieldlinesProgram->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
|
||||
_fieldlinesProgram->setUniform("modelTransform", transform);
|
||||
_fieldlinesProgram->setUniform("campos", campos.vec4());
|
||||
_fieldlinesProgram->setUniform("objpos", currentPosition.vec4());
|
||||
@@ -253,7 +253,7 @@ void RenderableFieldlines::render(const Camera* camera, const psc& thisPosition,
|
||||
_fieldlinesProgram->deactivate();
|
||||
}
|
||||
|
||||
void RenderableFieldlines::update() {
|
||||
void RenderableFieldlines::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
void RenderableFieldlines::safeShaderCompilation() {
|
||||
|
||||
@@ -181,21 +181,21 @@ bool RenderableSphericalGrid::initialize(){
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
void RenderableSphericalGrid::render(const Camera* camera, const psc& thisPosition, RuntimeData* runtimeData){
|
||||
void RenderableSphericalGrid::render(const RenderData& data){
|
||||
assert(_gridProgram);
|
||||
_gridProgram->activate();
|
||||
|
||||
// fetch data
|
||||
psc currentPosition = thisPosition;
|
||||
psc campos = camera->position();
|
||||
glm::mat4 camrot = camera->viewRotationMatrix();
|
||||
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);
|
||||
|
||||
// setup the data to the shader
|
||||
_gridProgram->setUniform("ViewProjection", camera->viewProjectionMatrix());
|
||||
_gridProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_gridProgram->setUniform("ModelTransform", transform);
|
||||
_gridProgram->setUniform("campos", campos.vec4());
|
||||
_gridProgram->setUniform("objpos", currentPosition.vec4());
|
||||
@@ -216,7 +216,7 @@ void RenderableSphericalGrid::render(const Camera* camera, const psc& thisPositi
|
||||
_gridProgram->deactivate();
|
||||
|
||||
}
|
||||
void RenderableSphericalGrid::update(){
|
||||
|
||||
void RenderableSphericalGrid::update(const UpdateData& data){
|
||||
}
|
||||
|
||||
}
|
||||
@@ -228,7 +228,7 @@ bool RenderableVolumeGL::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition, RuntimeData* runtimeData) {
|
||||
void RenderableVolumeGL::render(const RenderData& data) {
|
||||
if(_updateTransferfunction) {
|
||||
_updateTransferfunction = false;
|
||||
ghoul::opengl::Texture* transferFunction = loadTransferFunction(_transferFunctionPath);
|
||||
@@ -248,10 +248,10 @@ void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition, R
|
||||
transform = glm::scale(transform, _boxScaling);
|
||||
|
||||
// fetch data
|
||||
psc currentPosition = thisPosition;
|
||||
psc campos = camera->position();
|
||||
glm::mat4 camrot = camera->viewRotationMatrix();
|
||||
PowerScaledScalar scaling = camera->scaling();
|
||||
psc currentPosition = data.position;
|
||||
psc campos = data.camera.position();
|
||||
glm::mat4 camrot = data.camera.viewRotationMatrix();
|
||||
PowerScaledScalar scaling = data.camera.scaling();
|
||||
|
||||
// psc addon(-1.1,0.0,0.0,0.0);
|
||||
// currentPosition += addon;
|
||||
@@ -262,7 +262,7 @@ void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition, R
|
||||
_boxProgram->activate();
|
||||
_boxProgram->setUniform(_typeLocation, _id);
|
||||
|
||||
_boxProgram->setUniform("modelViewProjection", camera->viewProjectionMatrix());
|
||||
_boxProgram->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
|
||||
_boxProgram->setUniform("modelTransform", transform);
|
||||
_boxProgram->setUniform("campos", campos.vec4());
|
||||
_boxProgram->setUniform("objpos", currentPosition.vec4());
|
||||
@@ -284,7 +284,7 @@ void RenderableVolumeGL::render(const Camera *camera, const psc &thisPosition, R
|
||||
_boxProgram->deactivate();
|
||||
}
|
||||
|
||||
void RenderableVolumeGL::update() {
|
||||
void RenderableVolumeGL::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -51,7 +51,6 @@ namespace openspace {
|
||||
RenderEngine::RenderEngine()
|
||||
: _mainCamera(nullptr)
|
||||
, _sceneGraph(nullptr)
|
||||
, _runtimeData(nullptr)
|
||||
, _abuffer(nullptr)
|
||||
{
|
||||
}
|
||||
@@ -82,10 +81,6 @@ bool RenderEngine::initialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderEngine::setRuntimeData(RuntimeData* runtimeData){
|
||||
_runtimeData = runtimeData;
|
||||
}
|
||||
|
||||
bool RenderEngine::initializeGL()
|
||||
{
|
||||
// LDEBUG("RenderEngine::initializeGL()");
|
||||
@@ -177,7 +172,7 @@ void RenderEngine::postSynchronizationPreDraw()
|
||||
_mainCamera->compileViewRotationMatrix();
|
||||
|
||||
// update and evaluate the scene starting from the root node
|
||||
_sceneGraph->update();
|
||||
_sceneGraph->update({Time::ref().currentTime()});
|
||||
_mainCamera->setCameraDirection(glm::vec3(0, 0, -1));
|
||||
_sceneGraph->evaluate(_mainCamera);
|
||||
}
|
||||
@@ -212,7 +207,7 @@ void RenderEngine::render()
|
||||
// render the scene starting from the root node
|
||||
_abuffer->clear();
|
||||
_abuffer->preRender();
|
||||
_sceneGraph->render(_mainCamera);
|
||||
_sceneGraph->render({*_mainCamera, psc()});
|
||||
_abuffer->postRender();
|
||||
_abuffer->resolve();
|
||||
|
||||
@@ -227,21 +222,15 @@ void RenderEngine::render()
|
||||
#endif
|
||||
|
||||
|
||||
std::string timeGUI = SpiceManager::ref().ephemerisTimeToString(_runtimeData->getTime());
|
||||
|
||||
if (timeGUI == "") _runtimeData->setTime(0); // if time ends -> reset time to julian date 0.
|
||||
|
||||
const glm::vec2 scaling = _mainCamera->scaling();
|
||||
const glm::vec3 viewdirection = _mainCamera->viewDirection();
|
||||
const psc position = _mainCamera->position();
|
||||
const psc origin = OsEng.interactionHandler().getOrigin();
|
||||
const PowerScaledScalar pssl = (position - origin).length();
|
||||
|
||||
/* GUI PRINT */
|
||||
|
||||
Freetype::print(
|
||||
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
|
||||
FONT_SIZE, FONT_SIZE * 20, "OpenSpace Time: (%s)", timeGUI.c_str());
|
||||
const std::string time = Time::ref().currentTimeUTC().c_str();
|
||||
std::string&& time = Time::ref().currentTimeUTC().c_str();
|
||||
Freetype::print(
|
||||
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
|
||||
FONT_SIZE, FONT_SIZE * 18, "Date: %s", time.c_str()
|
||||
|
||||
@@ -306,17 +306,17 @@ bool RenderableStars::deinitialize(){
|
||||
}
|
||||
|
||||
//#define TMAT
|
||||
void RenderableStars::render(const Camera* camera, const psc& thisPosition, RuntimeData* runtimeData){
|
||||
void RenderableStars::render(const RenderData& data){
|
||||
assert(_haloProgram);
|
||||
printOpenGLError();
|
||||
// activate shader
|
||||
_haloProgram->activate();
|
||||
|
||||
// fetch data
|
||||
psc currentPosition = thisPosition;
|
||||
psc campos = camera->position();
|
||||
glm::mat4 camrot = camera->viewRotationMatrix();
|
||||
PowerScaledScalar scaling = camera->scaling();
|
||||
psc currentPosition = data.position;
|
||||
psc campos = data.camera.position();
|
||||
glm::mat4 camrot = data.camera.viewRotationMatrix();
|
||||
PowerScaledScalar scaling = data.camera.scaling();
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
//scaling = glm::vec2(1, -22);
|
||||
scaling = glm::vec2(1, -19);
|
||||
@@ -332,9 +332,9 @@ void RenderableStars::render(const Camera* camera, const psc& thisPosition, Runt
|
||||
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
|
||||
|
||||
#ifdef GLSPRITES
|
||||
glm::mat4 modelMatrix = camera->modelMatrix();
|
||||
glm::mat4 viewMatrix = camera->viewMatrix();
|
||||
glm::mat4 projectionMatrix = camera->projectionMatrix();
|
||||
glm::mat4 modelMatrix = data.camera.modelMatrix();
|
||||
glm::mat4 viewMatrix = data.camera.viewMatrix();
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
|
||||
// ---------------------- RENDER HALOS -----------------------------
|
||||
_haloProgram->setUniform("model", modelMatrix);
|
||||
@@ -404,7 +404,7 @@ void RenderableStars::loadTexture(){
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableStars::update()
|
||||
void RenderableStars::update(const UpdateData& data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -68,6 +68,6 @@ bool Ephemeris::initialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ephemeris::update() {}
|
||||
void Ephemeris::update(const UpdateData& data) {}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/shadercreator.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
// ghoul includes
|
||||
#include "ghoul/opengl/programobject.h"
|
||||
@@ -196,7 +197,6 @@ SceneGraph::SceneGraph()
|
||||
: _focus(SceneGraphNode::RootNodeName)
|
||||
, _position(SceneGraphNode::RootNodeName)
|
||||
, _root(nullptr)
|
||||
, _runtimeData(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -205,10 +205,6 @@ SceneGraph::~SceneGraph()
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
void SceneGraph::setRuntimeData(RuntimeData* runtimeData){
|
||||
_runtimeData = runtimeData;
|
||||
}
|
||||
|
||||
bool SceneGraph::initialize()
|
||||
{
|
||||
LDEBUG("Initializing SceneGraph");
|
||||
@@ -457,7 +453,7 @@ bool SceneGraph::deinitialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void SceneGraph::update()
|
||||
void SceneGraph::update(const UpdateData& data)
|
||||
{
|
||||
if (!_sceneGraphToLoad.empty()) {
|
||||
OsEng.renderEngine().sceneGraph()->clearSceneGraph();
|
||||
@@ -468,7 +464,7 @@ void SceneGraph::update()
|
||||
}
|
||||
|
||||
for (auto node : _nodes)
|
||||
node->update();
|
||||
node->update(data);
|
||||
}
|
||||
|
||||
void SceneGraph::evaluate(Camera* camera)
|
||||
@@ -477,10 +473,10 @@ void SceneGraph::evaluate(Camera* camera)
|
||||
_root->evaluate(camera);
|
||||
}
|
||||
|
||||
void SceneGraph::render(Camera* camera)
|
||||
void SceneGraph::render(const RenderData& data)
|
||||
{
|
||||
if (_root)
|
||||
_root->render(camera);
|
||||
_root->render(data);
|
||||
}
|
||||
|
||||
void SceneGraph::scheduleLoadSceneFile(const std::string& sceneDescriptionFilePath) {
|
||||
@@ -588,7 +584,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
|
||||
|
||||
// Initialize all nodes
|
||||
for (auto node : _nodes) {
|
||||
bool success = node->initialize(_runtimeData);
|
||||
bool success = node->initialize();
|
||||
if (success)
|
||||
LDEBUG(node->name() << " initialized successfully!");
|
||||
else
|
||||
@@ -596,8 +592,9 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
|
||||
}
|
||||
|
||||
// update the position of all nodes
|
||||
// TODO need to check this; unnecessary? (ab)
|
||||
for (auto node : _nodes)
|
||||
node->update();
|
||||
node->update({Time::ref().currentTime()});
|
||||
|
||||
// Calculate the bounding sphere for the scenegraph
|
||||
_root->calculateBoundingSphere();
|
||||
|
||||
@@ -128,7 +128,6 @@ SceneGraphNode::SceneGraphNode()
|
||||
, _renderable(nullptr)
|
||||
, _renderableVisible(false)
|
||||
, _boundingSphereVisible(false)
|
||||
, _runtimeData(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ SceneGraphNode::~SceneGraphNode()
|
||||
deinitialize();
|
||||
}
|
||||
|
||||
bool SceneGraphNode::initialize(RuntimeData* runtimeData)
|
||||
bool SceneGraphNode::initialize()
|
||||
{
|
||||
if (_renderable != nullptr)
|
||||
_renderable->initialize();
|
||||
@@ -145,7 +144,6 @@ bool SceneGraphNode::initialize(RuntimeData* runtimeData)
|
||||
if (_ephemeris != nullptr)
|
||||
_ephemeris->initialize();
|
||||
|
||||
_runtimeData = runtimeData;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -173,9 +171,12 @@ bool SceneGraphNode::deinitialize()
|
||||
}
|
||||
|
||||
// essential
|
||||
void SceneGraphNode::update()
|
||||
void SceneGraphNode::update(const UpdateData& data)
|
||||
{
|
||||
_ephemeris->update(_runtimeData);
|
||||
if (_ephemeris)
|
||||
_ephemeris->update(data);
|
||||
if (_renderable)
|
||||
_renderable->update(data);
|
||||
}
|
||||
|
||||
void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition)
|
||||
@@ -220,9 +221,11 @@ void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition)
|
||||
}
|
||||
}
|
||||
|
||||
void SceneGraphNode::render(const Camera* camera, const psc& parentPosition)
|
||||
void SceneGraphNode::render(const RenderData& data)
|
||||
{
|
||||
const psc thisPosition = parentPosition + _ephemeris->position();
|
||||
const psc thisPosition = data.position + _ephemeris->position();
|
||||
|
||||
RenderData newData = {data.camera, thisPosition};
|
||||
|
||||
// check if camera is outside the node boundingsphere
|
||||
/*if (!_boundingSphereVisible) {
|
||||
@@ -231,13 +234,13 @@ void SceneGraphNode::render(const Camera* camera, const psc& parentPosition)
|
||||
|
||||
if (_renderableVisible && _renderable->isVisible()) {
|
||||
// LDEBUG("Render");
|
||||
_renderable->render(camera, thisPosition, _runtimeData);
|
||||
_renderable->render(newData);
|
||||
}
|
||||
|
||||
// evaluate all the children, tail-recursive function(?)
|
||||
|
||||
for (auto& child : _children) {
|
||||
child->render(camera, thisPosition);
|
||||
child->render(newData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +320,6 @@ PowerScaledScalar SceneGraphNode::boundingSphere() const{
|
||||
// renderable
|
||||
void SceneGraphNode::setRenderable(Renderable* renderable) {
|
||||
_renderable = renderable;
|
||||
update();
|
||||
}
|
||||
|
||||
const Renderable* SceneGraphNode::renderable() const
|
||||
|
||||
@@ -78,15 +78,13 @@ const psc& SpiceEphemeris::position() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void SpiceEphemeris::update(RuntimeData* runtimeData) {
|
||||
void SpiceEphemeris::update(const UpdateData& data) {
|
||||
double state[3];
|
||||
|
||||
_currentEphemerisTime = runtimeData->getTime();
|
||||
|
||||
glm::dvec3 position(0,0,0);
|
||||
|
||||
double lightTime = 0.0;
|
||||
SpiceManager::ref().getTargetPosition(_targetName, _currentEphemerisTime, "GALACTIC", "LT+S", _originName, position, lightTime);
|
||||
SpiceManager::ref().getTargetPosition(_targetName, data.time, "GALACTIC", "LT+S", _originName, position, lightTime);
|
||||
|
||||
/*
|
||||
std::cout << _targetName << " (";
|
||||
|
||||
@@ -47,7 +47,7 @@ const psc& StaticEphemeris::position() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void StaticEphemeris::update(RuntimeData* runtimeData) {
|
||||
void StaticEphemeris::update(const UpdateData&) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user