Update SceneGraphNode to contain rotation information and remove rotation definition from renderable model.

This commit is contained in:
Kalle Bladin
2016-08-12 12:28:56 -04:00
parent bc9befc970
commit bd867ec402
12 changed files with 122 additions and 57 deletions
+3 -14
View File
@@ -77,25 +77,14 @@ const glm::dvec3& SpiceEphemeris::position() const {
return _position;
}
const glm::dmat3& SpiceEphemeris::worldRotationMatrix() const {
return _worldRotationMatrix;
}
void SpiceEphemeris::update(const UpdateData& data) {
if (!_kernelsLoadedSuccessfully)
return;
double lightTime = 0.0;
glm::dvec3 position = SpiceManager::ref().targetPosition(_targetName, _originName, "GALACTIC", {}, data.time, lightTime);
std::string frame = SpiceManager::ref().frameFromBody(_targetName);
if (SpiceManager::ref().hasFrameId(frame))
{
_worldRotationMatrix = SpiceManager::ref().positionTransformMatrix(frame, "GALACTIC", data.time);
}
else
{
_worldRotationMatrix = glm::dmat3(1.0);
}
glm::dvec3 position = SpiceManager::ref().targetPosition(
_targetName, _originName, "GALACTIC", {}, data.time, lightTime);
//double interval = openspace::ImageSequencer::ref().getIntervalLength();
//if (_ghosting == "TRUE" && interval > 60){
// double _time = openspace::ImageSequencer::ref().getNextCaptureTime();
-2
View File
@@ -35,14 +35,12 @@ class SpiceEphemeris : public Ephemeris {
public:
SpiceEphemeris(const ghoul::Dictionary& dictionary);
virtual const glm::dvec3& position() const;
virtual const glm::dmat3& worldRotationMatrix() const;
void update(const UpdateData& data) override;
private:
std::string _targetName;
std::string _originName;
glm::dvec3 _position;
glm::dmat3 _worldRotationMatrix;
bool _kernelsLoadedSuccessfully;
//std::string _ghosting;
std::string _name;
@@ -47,10 +47,6 @@ const glm::dvec3& StaticEphemeris::position() const {
return _position;
}
const glm::dmat3& StaticEphemeris::worldRotationMatrix() const {
return glm::dmat3(1.0);
}
void StaticEphemeris::update(const UpdateData&) {}
} // namespace openspace
-1
View File
@@ -35,7 +35,6 @@ public:
= ghoul::Dictionary());
virtual ~StaticEphemeris();
virtual const glm::dvec3& position() const;
virtual const glm::dmat3& worldRotationMatrix() const;
virtual void update(const UpdateData& data) override;
private:
glm::dvec3 _position;
+12 -15
View File
@@ -46,8 +46,6 @@
namespace {
const std::string _loggerCat = "RenderableModel";
const std::string keySource = "Rotation.Source";
const std::string keyDestination = "Rotation.Destination";
const std::string keyGeometry = "Geometry";
const std::string keyBody = "Body";
const std::string keyStart = "StartTime";
@@ -61,12 +59,12 @@ namespace {
namespace openspace {
RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _performFade("performFading", "Perform Fading", false)
, _debugModelRotation("modelrotation", "Model Rotation", glm::vec3(0.f), glm::vec3(0.f), glm::vec3(360.f))
, _fading("fading", "Fade", 0)
, _debugModelRotation("modelrotation", "Model Rotation", glm::vec3(0.f), glm::vec3(0.f), glm::vec3(360.f))
, _programObject(nullptr)
, _texture(nullptr)
, _geometry(nullptr)
@@ -92,20 +90,21 @@ namespace openspace {
_colorTexturePath = absPath(texturePath);
addPropertySubOwner(_geometry);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this));
addProperty(_debugModelRotation);
dictionary.getValue(keySource, _source);
dictionary.getValue(keyDestination, _destination);
//dictionary.getValue(keySource, _source);
//dictionary.getValue(keyDestination, _destination);
if (dictionary.hasKeyAndValue<glm::dmat3>(keyModelTransform))
dictionary.getValue(keyModelTransform, _modelTransform);
else
_modelTransform = glm::dmat3(1.f);
dictionary.getValue(keyBody, _target);
openspace::SpiceManager::ref().addFrame(_target, _source);
//openspace::SpiceManager::ref().addFrame(_target, _source);
//setBoundingSphere(pss(1.f, 9.f));
addProperty(_performShading);
@@ -149,8 +148,8 @@ bool RenderableModel::initialize() {
completeSuccess &= (_texture != nullptr);
completeSuccess &= _geometry->initialize(this);
completeSuccess &= !_source.empty();
completeSuccess &= !_destination.empty();
//completeSuccess &= !_source.empty();
//completeSuccess &= !_destination.empty();
return completeSuccess;
}
@@ -200,8 +199,6 @@ void RenderableModel::render(const RenderData& data) {
}
// Calculate variables to be used as uniform variables in shader
glm::dvec3 bodyPosition = data.positionVec3;
@@ -216,7 +213,7 @@ void RenderableModel::render(const RenderData& data) {
// Model transform and view transform needs to be in double precision
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), bodyPosition) * // Translation
glm::dmat4(_stateMatrix) * // Spice rotation
glm::dmat4(data.rotation) * // Spice rotation
debugModelRotation; // debug model rotation controlled from GUI
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
glm::vec3 directionToSun = glm::normalize(_sunPosition.vec3() - glm::vec3(bodyPosition));
@@ -265,9 +262,9 @@ void RenderableModel::update(const UpdateData& data) {
//}
// set spice-orientation in accordance to timestamp
if (!_source.empty()) {
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, _time) * _modelTransform;
}
//if (!_source.empty()) {
// _stateMatrix = SpiceManager::ref().positionTransformMatrix(_source, _destination, _time) * _modelTransform;
//}
double lt;
glm::dvec3 p =
+3 -3
View File
@@ -67,10 +67,10 @@ private:
glm::dmat3 _modelTransform;
float _alpha;
glm::dmat3 _stateMatrix;
//glm::dmat3 _stateMatrix;
std::string _source;
std::string _destination;
//std::string _source;
//std::string _destination;
std::string _target;
//bool _isGhost;