mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 04:30:09 -05:00
Added class PlanetMesh and rendering it through Planet.
This commit is contained in:
@@ -55,6 +55,7 @@ public:
|
||||
static Renderable* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
|
||||
// constructors & destructor
|
||||
Renderable();
|
||||
Renderable(const ghoul::Dictionary& dictionary);
|
||||
virtual ~Renderable();
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
|
||||
const glm::vec2& vec2() const;
|
||||
float lengthf() const;
|
||||
double lengthd() const;
|
||||
|
||||
// operator overloading
|
||||
PowerScaledScalar& operator=(const PowerScaledScalar& rhs);
|
||||
|
||||
@@ -26,13 +26,17 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
|
||||
|
||||
set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planet.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetmesh.h
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetmesh.cpp
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <modules/planetbrowsing/planetbrowsingmodule.h>
|
||||
|
||||
#include <modules/planetbrowsing/rendering/planet.h>
|
||||
#include <modules/planetbrowsing/rendering/distanceswitch.h>
|
||||
#include <modules/planetbrowsing/rendering/planetmesh.h>
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
@@ -61,7 +63,8 @@ void PlanetBrowsingModule::internalInitialize() {
|
||||
ghoul_assert(fRenderable, "Renderable factory was not created");
|
||||
|
||||
fRenderable->registerClass<Planet>("Planet");
|
||||
|
||||
fRenderable->registerClass<PlanetMesh>("PlanetMesh");
|
||||
fRenderable->registerClass<DistanceSwitch>("DistanceSwitch");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 <modules/planetbrowsing/rendering/distanceswitch.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DistanceSwitch";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
DistanceSwitch::DistanceSwitch(){
|
||||
|
||||
}
|
||||
|
||||
DistanceSwitch::~DistanceSwitch() {
|
||||
|
||||
}
|
||||
|
||||
bool DistanceSwitch::initialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DistanceSwitch::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DistanceSwitch::isReady() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DistanceSwitch::render(const RenderData& data) {
|
||||
if (_maxDistances.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
pss pssDistanceToCamera = (data.camera.position() - data.position).length();
|
||||
double distanceToCamera = pssDistanceToCamera.lengthd();
|
||||
|
||||
if (distanceToCamera > _maxDistances.back()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// linear search through nodes to find which Renderable to render
|
||||
for (int i = 0; i < _renderables.size(); ++i) {
|
||||
if (distanceToCamera < _maxDistances[i]) {
|
||||
_renderables[i]->render(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DistanceSwitch::update(const UpdateData& data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DistanceSwitch::addSwitchValue(std::shared_ptr<Renderable> renderable, double maxDistance) {
|
||||
if (_maxDistances.size() > 0) {
|
||||
ghoul_assert(maxDistance > _maxDistances.back(),
|
||||
"Renderables must be inserted in ascending order wrt distance");
|
||||
}
|
||||
|
||||
_renderables.push_back(renderable);
|
||||
_maxDistances.push_back(maxDistance);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 __DISTANCESWITCH_H__
|
||||
#define __DISTANCESWITCH_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/powerscaledscalar.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
/**
|
||||
Selects a specific Renderable to be used for rendering, based on distance to the
|
||||
camera
|
||||
*/
|
||||
class DistanceSwitch : public Renderable {
|
||||
public:
|
||||
|
||||
DistanceSwitch();
|
||||
~DistanceSwitch();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
|
||||
/**
|
||||
Picks the first Renderable with the associated maxDistance greater than the
|
||||
current distance to the camera
|
||||
*/
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
/**
|
||||
Adds a new renderable (first argument) which may be rendered only if the distance
|
||||
to the camera is less than maxDistance (second argument)
|
||||
*/
|
||||
void addSwitchValue(std::shared_ptr<Renderable> renderable, double maxDistance);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
std::vector<std::shared_ptr<Renderable>> _renderables;
|
||||
std::vector <double> _maxDistances;
|
||||
|
||||
};
|
||||
} // openspace
|
||||
#endif //__DISTANCESWITCH_H__
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <modules/planetbrowsing/rendering/planet.h>
|
||||
|
||||
#include <modules/planetbrowsing/rendering/planetmesh.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
@@ -49,8 +51,9 @@ namespace {
|
||||
namespace openspace {
|
||||
|
||||
Planet::Planet(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _programObject(nullptr)
|
||||
: DistanceSwitch()
|
||||
//, _programObject(nullptr)
|
||||
, _planetMesh(dictionary)
|
||||
, _rotation("rotation", "Rotation", 0, 0, 360)
|
||||
{
|
||||
std::string name;
|
||||
@@ -71,7 +74,10 @@ namespace openspace {
|
||||
// Mainly for debugging purposes @AA
|
||||
addProperty(_rotation);
|
||||
|
||||
//addSwitchValue(std::shared_ptr<PlanetMesh>(new PlanetMesh(dictionary)), 10000000);
|
||||
|
||||
|
||||
/*
|
||||
// Create a simple triangle for testing the geometry
|
||||
std::vector<unsigned int> triangleElements;
|
||||
std::vector<glm::vec4> trianglePositions;
|
||||
@@ -92,6 +98,7 @@ namespace openspace {
|
||||
|
||||
_testGeometry->setPositionData(trianglePositions);
|
||||
_testGeometry->initialize();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -99,6 +106,7 @@ namespace openspace {
|
||||
}
|
||||
|
||||
bool Planet::initialize() {
|
||||
/*
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_programObject == nullptr) {
|
||||
// Night texture program
|
||||
@@ -111,28 +119,32 @@ namespace openspace {
|
||||
|
||||
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
|
||||
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
|
||||
|
||||
*/
|
||||
_planetMesh.initialize();
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool Planet::deinitialize() {
|
||||
/*
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_programObject) {
|
||||
renderEngine.removeRenderProgram(_programObject);
|
||||
_programObject = nullptr;
|
||||
}
|
||||
|
||||
*/
|
||||
_planetMesh.deinitialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Planet::isReady() const {
|
||||
bool ready = true;
|
||||
ready &= (_programObject != nullptr);
|
||||
//ready &= (_programObject != nullptr);
|
||||
return ready;
|
||||
}
|
||||
|
||||
|
||||
void Planet::render(const RenderData& data)
|
||||
{
|
||||
/*
|
||||
// activate shader
|
||||
_programObject->activate();
|
||||
|
||||
@@ -174,9 +186,12 @@ namespace openspace {
|
||||
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
*/
|
||||
_planetMesh.render(data);
|
||||
}
|
||||
|
||||
void Planet::update(const UpdateData& data) {
|
||||
_planetMesh.update(data);
|
||||
// set spice-orientation in accordance to timestamp
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time);
|
||||
_time = data.time;
|
||||
|
||||
@@ -32,17 +32,20 @@
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <modules/planetbrowsing/rendering/geometry.h>
|
||||
#include <modules/planetbrowsing/rendering/distanceswitch.h>
|
||||
#include <modules/planetbrowsing/rendering/planetmesh.h>
|
||||
|
||||
|
||||
// ghoul includes
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Planet : public Renderable {
|
||||
class Planet : public DistanceSwitch {
|
||||
public:
|
||||
Planet(const ghoul::Dictionary& dictionary);
|
||||
~Planet();
|
||||
@@ -55,9 +58,11 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
//std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
|
||||
std::unique_ptr<Geometry> _testGeometry;
|
||||
//std::unique_ptr<Geometry> _testGeometry;
|
||||
|
||||
PlanetMesh _planetMesh;
|
||||
|
||||
properties::IntProperty _rotation;
|
||||
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/planetbrowsing/rendering/planetmesh.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "PlanetMesh";
|
||||
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
const std::string keyShading = "PerformShading";
|
||||
|
||||
const std::string keyBody = "Body";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
PlanetMesh::PlanetMesh(const ghoul::Dictionary& dictionary)
|
||||
: DistanceSwitch()
|
||||
, _programObject(nullptr)
|
||||
, _rotation("rotation", "Rotation", 0, 0, 360)
|
||||
{
|
||||
std::string name;
|
||||
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
|
||||
ghoul_assert(success,
|
||||
"Planet need the '" << SceneGraphNode::KeyName << "' be specified");
|
||||
|
||||
//std::string path;
|
||||
//success = dictionary.getValue(constants::scenegraph::keyPathModule, path);
|
||||
//ghoul_assert(success,
|
||||
// "RenderablePlanet need the '"<<constants::scenegraph::keyPathModule<<"' be specified");
|
||||
|
||||
dictionary.getValue(keyFrame, _frame);
|
||||
dictionary.getValue(keyBody, _target);
|
||||
if (_target != "")
|
||||
setBody(_target);
|
||||
|
||||
// Mainly for debugging purposes @AA
|
||||
addProperty(_rotation);
|
||||
|
||||
//addSwitchValue(std::shared_ptr<PlanetMesh>(new PlanetMesh(dictionary)), 10000000);
|
||||
|
||||
|
||||
|
||||
// Create a simple triangle for testing the geometry
|
||||
std::vector<unsigned int> triangleElements;
|
||||
std::vector<glm::vec4> trianglePositions;
|
||||
|
||||
trianglePositions.push_back(glm::vec4(0, 0, 0, 1));
|
||||
trianglePositions.push_back(glm::vec4(10000000, 0, 0, 1));
|
||||
trianglePositions.push_back(glm::vec4(10000000, 10000000, 0, 1));
|
||||
|
||||
triangleElements.push_back(0);
|
||||
triangleElements.push_back(1);
|
||||
triangleElements.push_back(2);
|
||||
|
||||
_testGeometry = std::unique_ptr<Geometry>(new Geometry(
|
||||
triangleElements,
|
||||
Geometry::Positions::Yes,
|
||||
Geometry::Textures::No,
|
||||
Geometry::Normals::No));
|
||||
|
||||
_testGeometry->setPositionData(trianglePositions);
|
||||
_testGeometry->initialize();
|
||||
|
||||
|
||||
}
|
||||
|
||||
PlanetMesh::~PlanetMesh() {
|
||||
}
|
||||
|
||||
bool PlanetMesh::initialize() {
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_programObject == nullptr) {
|
||||
// Night texture program
|
||||
_programObject = renderEngine.buildRenderProgram(
|
||||
"simpleTextureProgram",
|
||||
"${MODULE_PLANETBROWSING}/shaders/simple_vs.glsl",
|
||||
"${MODULE_PLANETBROWSING}/shaders/simple_fs.glsl");
|
||||
if (!_programObject) return false;
|
||||
}
|
||||
|
||||
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
|
||||
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool PlanetMesh::deinitialize() {
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_programObject) {
|
||||
renderEngine.removeRenderProgram(_programObject);
|
||||
_programObject = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlanetMesh::isReady() const {
|
||||
bool ready = true;
|
||||
//ready &= (_programObject != nullptr);
|
||||
return ready;
|
||||
}
|
||||
|
||||
void PlanetMesh::render(const RenderData& data)
|
||||
{
|
||||
// activate shader
|
||||
_programObject->activate();
|
||||
|
||||
// scale the planet to appropriate size since the planet is a unit sphere. Ehm no?
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
|
||||
//earth needs to be rotated for that to work.
|
||||
glm::mat4 rot = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
|
||||
glm::mat4 roty = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, -1, 0));
|
||||
glm::mat4 rotProp = glm::rotate(transform, glm::radians(static_cast<float>(_rotation)), glm::vec3(0, 1, 0));
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
|
||||
}
|
||||
}
|
||||
transform = transform * rot * roty * rotProp;
|
||||
|
||||
//glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
|
||||
//glm::vec3 camSpaceEye = (-(modelview*data.position.vec4())).xyz;
|
||||
|
||||
|
||||
double lt;
|
||||
glm::dvec3 p =
|
||||
SpiceManager::ref().targetPosition("SUN", _target, "GALACTIC", {}, _time, lt);
|
||||
psc sun_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
|
||||
|
||||
// setup the data to the shader
|
||||
// _programObject->setUniform("camdir", camSpaceEye);
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
// render
|
||||
_testGeometry->render();
|
||||
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
void PlanetMesh::update(const UpdateData& data) {
|
||||
// set spice-orientation in accordance to timestamp
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time);
|
||||
_time = data.time;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 __PLANETMESH_H__
|
||||
#define __PLANETMESH_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <modules/planetbrowsing/rendering/geometry.h>
|
||||
#include <modules/planetbrowsing/rendering/distanceswitch.h>
|
||||
#include <modules/planetbrowsing/rendering/planetmesh.h>
|
||||
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class PlanetMesh : public DistanceSwitch {
|
||||
public:
|
||||
PlanetMesh(const ghoul::Dictionary& dictionary);
|
||||
~PlanetMesh();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
|
||||
std::unique_ptr<Geometry> _testGeometry;
|
||||
|
||||
properties::IntProperty _rotation;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
std::string _frame;
|
||||
std::string _target;
|
||||
double _time;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __PLANETMESH_H__
|
||||
@@ -69,6 +69,17 @@ Renderable* Renderable::createFromDictionary(const ghoul::Dictionary& dictionary
|
||||
return result;
|
||||
}
|
||||
|
||||
Renderable::Renderable()
|
||||
: _enabled("enabled", "Is Enabled", true)
|
||||
, _startTime("")
|
||||
, _endTime("")
|
||||
, _targetBody("")
|
||||
, _hasBody(false)
|
||||
, _hasTimeInterval(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Renderable::Renderable(const ghoul::Dictionary& dictionary)
|
||||
: _enabled("enabled", "Is Enabled", true)
|
||||
, _startTime("")
|
||||
|
||||
@@ -76,6 +76,10 @@ float PowerScaledScalar::lengthf() const {
|
||||
return static_cast<float>(_data[0] * pow(k,_data[1]));
|
||||
}
|
||||
|
||||
double PowerScaledScalar::lengthd() const {
|
||||
return static_cast<double>(_data[0]) * pow(k, static_cast<double>(_data[1]));
|
||||
}
|
||||
|
||||
PowerScaledScalar& PowerScaledScalar::operator=(const PowerScaledScalar &rhs) {
|
||||
if (this != &rhs){
|
||||
this->_data = rhs._data;
|
||||
|
||||
Reference in New Issue
Block a user