From 283a55f4dea280a8574cdc61eed6103685ffeb06 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 5 May 2014 00:04:00 +0200 Subject: [PATCH] Included commented out version of new camera class adapted RenderableVolume to use ModulePath --- include/openspace/util/camera.h | 46 ++++++++++++++ src/rendering/renderableplanet.cpp | 2 +- src/rendering/renderablevolume.cpp | 7 ++- src/util/camera.cpp | 99 ++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 4 deletions(-) diff --git a/include/openspace/util/camera.h b/include/openspace/util/camera.h index 26273eb0bd..ef09ad5c18 100644 --- a/include/openspace/util/camera.h +++ b/include/openspace/util/camera.h @@ -36,6 +36,52 @@ namespace openspace { +//class Camera { +//public: +// Camera(); +// +// void setPosition(psc pos); +// const psc& position() const; +// +// void setFocus(psc focus); +// const psc& focus() const; +// +// void setUpVector(psc upVector); +// const psc& upVector() const; +// +// void setScaling(float scaling); +// float scaling() const; +// +// const glm::mat4& viewMatrix() const; +// +// void setProjectionMatrix(glm::mat4 projectionMatrix); +// const glm::mat4& projectionMatrix() const; +// +// void setMaxFox(float fov); +// float maxFov() const; +// +// +// // derived values +// psc lookVector() const; +// +//private: +// void invalidateViewMatrix(); +// void updateViewMatrix() const; // has to be constant to be called from getter methods +// +// psc _position; +// psc _focus; +// psc _upVector; +// +// glm::mat4 _projectionMatrix; +// mutable glm::mat4 _viewMatrix; +// float _scaling; +// +// float _maxFov; +// +// mutable bool _viewMatrixIsDirty; +//}; + + class Camera { public: Camera(); diff --git a/src/rendering/renderableplanet.cpp b/src/rendering/renderableplanet.cpp index 515e279128..69ece0e8c1 100644 --- a/src/rendering/renderableplanet.cpp +++ b/src/rendering/renderableplanet.cpp @@ -139,7 +139,7 @@ void RenderablePlanet::render(const Camera *camera, const psc &thisPosition) { // scale the planet to appropriate size since the planet is a unit sphere glm::mat4 transform = glm::mat4(1); -// transform = glm::rotate(transform, 4.1f*static_cast(sgct::Engine::instance()->getTime()), glm::vec3(0.0f, 1.0f, 0.0f)); + transform = glm::rotate(transform, 4.1f*static_cast(sgct::Engine::instance()->getTime()), glm::vec3(0.0f, 1.0f, 0.0f)); // setup the data to the shader _programObject->setUniform("ViewProjection", camera->viewProjectionMatrix()); diff --git a/src/rendering/renderablevolume.cpp b/src/rendering/renderablevolume.cpp index 08341364dc..c96b8ca7ae 100644 --- a/src/rendering/renderablevolume.cpp +++ b/src/rendering/renderablevolume.cpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -41,7 +42,7 @@ #include namespace { - std::string _loggerCat = "RenderableVolume"; + const std::string _loggerCat = "RenderableVolume"; bool hasExtension (std::string const &filepath, std::string const &extension) { @@ -77,8 +78,8 @@ RenderableVolume::RenderableVolume(const ghoul::Dictionary& dictionary) { // get path if available _relativePath = ""; - if(dictionary.hasKey("Path")) { - dictionary.getValue("Path", _relativePath); + if(dictionary.hasKey(constants::scenegraph::keyPathModule)) { + dictionary.getValue(constants::scenegraph::keyPathModule, _relativePath); _relativePath += "/"; } } diff --git a/src/util/camera.cpp b/src/util/camera.cpp index 2ef5d2fed4..b3957c6dc4 100644 --- a/src/util/camera.cpp +++ b/src/util/camera.cpp @@ -28,10 +28,12 @@ // sgct includes #include "sgct.h" +#include #include namespace openspace { + Camera::Camera() : _scaling(1.f, 0.f) , _viewRotation(glm::quat(glm::vec3(0.f, 0.f, 0.f))) @@ -145,4 +147,101 @@ const glm::vec3 Camera::lookUpVector() const return _lookUp; } + +// +//Camera::Camera() +// : _position(0.f, 0.f, 1.f, 0.f) +// , _focus(0.f, 0.f, 0.f, 0.f) +// , _upVector(0.f, 1.f, 0.f, 0.f) +// , _projectionMatrix(glm::mat4(1.f)) +// , _viewMatrix(glm::mat4(1.f)) +// , _scaling(0.f) +// , _maxFov(0.f) +// , _viewMatrixIsDirty(false) +//{ +// +//} +// +//void Camera::setPosition(psc pos) +//{ +// _position = std::move(pos); +//} +// +//const psc& Camera::position() const +//{ +// return _position; +//} +// +//void Camera::setFocus(psc focus) +//{ +// _focus = std::move(focus); +//} +// +//const psc& Camera::focus() const +//{ +// return _focus; +//} +// +//void Camera::setUpVector(psc upVector) +//{ +// _upVector = std::move(upVector); +//} +// +//const psc& Camera::upVector() const +//{ +// return _upVector; +//} +// +//void Camera::setScaling(float scaling) +//{ +// _scaling = scaling; +//} +// +//float Camera::scaling() const +//{ +// return _scaling; +//} +// +//const glm::mat4& Camera::viewMatrix() const +//{ +// +// return _viewMatrix; +//} +// +//void Camera::setProjectionMatrix(glm::mat4 projectionMatrix) +//{ +// _projectionMatrix = std::move(projectionMatrix); +//} +// +//const glm::mat4& Camera::projectionMatrix() const +//{ +// return _projectionMatrix; +//} +// +//void Camera::setMaxFox(float fov) +//{ +// _maxFov = fov; +//} +// +//float Camera::maxFov() const +//{ +// return _maxFov; +//} +// +//psc Camera::lookVector() const +//{ +// return _focus - _position; +//} +// +//void Camera::invalidateViewMatrix() { +// _viewMatrixIsDirty = true; +//} +// +//void Camera::updateViewMatrix() const { +// if (_viewMatrixIsDirty) { +// _viewMatrix = glm::lookAt(_position.getVec3f(), _focus.getVec3f(), _upVector.getVec3f()); +// _viewMatrixIsDirty = false; +// } +//} + } // namespace openspace