mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 11:39:49 -06:00
Resolved merge conflict
This commit is contained in:
@@ -67,6 +67,7 @@ namespace openspace {
|
||||
{
|
||||
Vertex vv;
|
||||
memcpy(vv.location, v.location, sizeof(GLfloat) * 3);
|
||||
vv.location[3] = 0.0;
|
||||
memcpy(vv.tex, v.tex, sizeof(GLfloat) * 2);
|
||||
memcpy(vv.normal, v.normal, sizeof(GLfloat) * 3);
|
||||
_vertices.push_back(vv);
|
||||
|
||||
@@ -162,7 +162,7 @@ void RenderableConstellationBounds::render(const RenderData& data) {
|
||||
glm::mat4 viewMatrix = data.camera.viewMatrix();
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
|
||||
setPscUniforms(_program.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_program.get(), data.camera, data.position);
|
||||
|
||||
_program->setUniform("exponent", _distance);
|
||||
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
|
||||
@@ -200,7 +200,7 @@ void RenderableModel::render(const RenderData& data) {
|
||||
_programObject->setUniform("sun_pos", _sunPosition.vec3());
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
_programObject->setUniform("_performShading", _performShading);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ void RenderablePath::render(const RenderData& data) {
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
_programObject->setUniform("color", _lineColor);
|
||||
_programObject->setUniform("lastPosition", _lastPosition);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
if (_drawLine) {
|
||||
glLineWidth(_lineWidth);
|
||||
|
||||
@@ -206,7 +206,7 @@ void RenderablePlane::render(const RenderData& data) {
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_shader.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_shader.get(), data.camera, data.position);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
|
||||
@@ -213,7 +213,7 @@ void RenderablePlanet::render(const RenderData& data)
|
||||
_programObject->setUniform("transparency", _alpha);
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
_programObject->setUniform("_performShading", _performShading);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ void RenderableSphere::render(const RenderData& data) {
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
|
||||
setPscUniforms(_shader.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_shader.get(), data.camera, data.position);
|
||||
_shader->setUniform("alpha", _transparency);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
|
||||
@@ -212,7 +212,7 @@ void RenderableSphericalGrid::render(const RenderData& data){
|
||||
_gridProgram->setIgnoreUniformLocationError(IgnoreError::Yes);
|
||||
_gridProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_gridProgram->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_gridProgram, &data.camera, data.position);
|
||||
setPscUniforms(*_gridProgram, data.camera, data.position);
|
||||
_gridProgram->setUniform("gridColor", _gridColor);
|
||||
|
||||
glLineWidth(0.5f);
|
||||
|
||||
@@ -203,7 +203,7 @@ void RenderableStars::render(const RenderData& data) {
|
||||
_program->setUniform("scaleFactor", _scaleFactor);
|
||||
_program->setUniform("minBillboardSize", _minBillboardSize);
|
||||
|
||||
setPscUniforms(_program.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_program.get(), data.camera, data.position);
|
||||
_program->setUniform("scaling", scaling);
|
||||
|
||||
ghoul::opengl::TextureUnit psfUnit;
|
||||
|
||||
@@ -155,7 +155,7 @@ void RenderableTrail::render(const RenderData& data) {
|
||||
// setup the data to the shader
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
_programObject->setUniform("color", _lineColor);
|
||||
_programObject->setUniform("nVertices", static_cast<unsigned int>(_vertexArray.size()));
|
||||
|
||||
@@ -25,17 +25,22 @@
|
||||
include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
|
||||
|
||||
set(HEADER_FILES
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/distanceswitch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gridgeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/latlonpatch.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunklodglobe.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/util/converter.h
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/datastructures/chunknode.inl
|
||||
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableglobe.cpp
|
||||
@@ -43,13 +48,16 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/geometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/gridgeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/globemesh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/latlonpatch.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/clipmapglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/chunklodglobe.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/util/converter.cpp
|
||||
|
||||
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
set(SHADER_FILES
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/shaders/crawlingline_fs.glsl
|
||||
)
|
||||
source_group("Shader Files" FILES ${SHADER_FILES})
|
||||
|
||||
|
||||
105
modules/globebrowsing/rendering/clipmapglobe.cpp
Normal file
105
modules/globebrowsing/rendering/clipmapglobe.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/globebrowsing/rendering/clipmapglobe.h>
|
||||
|
||||
#include <modules/globebrowsing/util/converter.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 = "ClipMapGlobe";
|
||||
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
const std::string keyShading = "PerformShading";
|
||||
|
||||
const std::string keyBody = "Body";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
ClipMapGlobe::ClipMapGlobe(const ghoul::Dictionary& dictionary)
|
||||
: _patch(10, 10, 0, 0, M_PI / 6, M_PI / 6)
|
||||
, _rotation("rotation", "Rotation", 0, 0, 360)
|
||||
{
|
||||
std::string name;
|
||||
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
|
||||
ghoul_assert(success,
|
||||
"ClipMapGlobe need the '" << SceneGraphNode::KeyName << "' be specified");
|
||||
setName(name);
|
||||
|
||||
dictionary.getValue(keyFrame, _frame);
|
||||
dictionary.getValue(keyBody, _target);
|
||||
if (_target != "")
|
||||
setBody(_target);
|
||||
|
||||
// Mainly for debugging purposes @AA
|
||||
addProperty(_rotation);
|
||||
}
|
||||
|
||||
ClipMapGlobe::~ClipMapGlobe() {
|
||||
}
|
||||
|
||||
bool ClipMapGlobe::initialize() {
|
||||
_patch.initialize();
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool ClipMapGlobe::deinitialize() {
|
||||
_patch.deinitialize();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ClipMapGlobe::isReady() const {
|
||||
bool ready = true;
|
||||
ready &= _patch.isReady();
|
||||
return ready;
|
||||
}
|
||||
|
||||
void ClipMapGlobe::render(const RenderData& data)
|
||||
{
|
||||
// Set patch to follow camera
|
||||
_patch.setPositionLatLon(converter::cartesianToLatLon(data.camera.position().dvec3()));
|
||||
// render
|
||||
_patch.render(data);
|
||||
}
|
||||
|
||||
void ClipMapGlobe::update(const UpdateData& data) {
|
||||
_patch.update(data);
|
||||
// set spice-orientation in accordance to timestamp
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time);
|
||||
_time = data.time;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
72
modules/globebrowsing/rendering/clipmapglobe.h
Normal file
72
modules/globebrowsing/rendering/clipmapglobe.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __CLIPMAPGLOBE_H__
|
||||
#define __CLIPMAPGLOBE_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/geometry.h>
|
||||
#include <modules/globebrowsing/rendering/gridgeometry.h>
|
||||
#include <modules/globebrowsing/rendering/distanceswitch.h>
|
||||
#include <modules/globebrowsing/rendering/latlonpatch.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ClipMapGlobe : public Renderable {
|
||||
public:
|
||||
ClipMapGlobe(const ghoul::Dictionary& dictionary);
|
||||
~ClipMapGlobe();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
LatLonPatch _patch;
|
||||
|
||||
properties::IntProperty _rotation;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
std::string _frame;
|
||||
std::string _target;
|
||||
double _time;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __CLIPMAPGLOBE_H__
|
||||
@@ -48,8 +48,7 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
GlobeMesh::GlobeMesh(const ghoul::Dictionary& dictionary)
|
||||
: DistanceSwitch()
|
||||
, _programObject(nullptr)
|
||||
: _programObject(nullptr)
|
||||
, _grid(10, 10, Geometry::Positions::Yes, Geometry::TextureCoordinates::No, Geometry::Normals::No)
|
||||
, _rotation("rotation", "Rotation", 0, 0, 360)
|
||||
{
|
||||
@@ -75,7 +74,6 @@ namespace openspace {
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_programObject == nullptr) {
|
||||
// Night texture program
|
||||
_programObject = renderEngine.buildRenderProgram(
|
||||
"simpleTextureProgram",
|
||||
"${MODULE_GLOBEBROWSING}/shaders/simple_vs.glsl",
|
||||
@@ -130,10 +128,13 @@ namespace openspace {
|
||||
// _programObject->setUniform("camdir", camSpaceEye);
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
glm::dmat4 cameraTransform = data.camera.viewMatrix(); // TODO : NEEDS TO BE DOUBLE PRECISION
|
||||
glm::dmat4 cameraProjectionTransform = data.camera.viewProjectionMatrix(); // TODO : NEEDS TO BE DOUBLE PRECISION
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
//glCullFace(GL_BACK);
|
||||
|
||||
// render
|
||||
_grid.drawUsingActiveProgram();
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace ghoul {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class GlobeMesh : public DistanceSwitch {
|
||||
class GlobeMesh : public Renderable {
|
||||
public:
|
||||
GlobeMesh(const ghoul::Dictionary& dictionary);
|
||||
~GlobeMesh();
|
||||
|
||||
190
modules/globebrowsing/rendering/latlonpatch.cpp
Normal file
190
modules/globebrowsing/rendering/latlonpatch.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/globebrowsing/rendering/latlonpatch.h>
|
||||
|
||||
#include <modules/globebrowsing/util/converter.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
// ghoul includes
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "LatLonPatch";
|
||||
|
||||
const std::string keyFrame = "Frame";
|
||||
const std::string keyGeometry = "Geometry";
|
||||
const std::string keyShading = "PerformShading";
|
||||
|
||||
const std::string keyBody = "Body";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
LatLonPatch::LatLonPatch(
|
||||
unsigned int xRes,
|
||||
unsigned int yRes,
|
||||
double posLat,
|
||||
double posLon,
|
||||
double sizeLat,
|
||||
double sizeLon)
|
||||
: _grid(
|
||||
xRes,
|
||||
yRes,
|
||||
Geometry::Positions::No,
|
||||
Geometry::TextureCoordinates::Yes,
|
||||
Geometry::Normals::No)
|
||||
, _programObject(nullptr)
|
||||
, _posLatLon(posLat, posLon)
|
||||
, _sizeLatLon(sizeLat, sizeLon)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LatLonPatch::~LatLonPatch() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool LatLonPatch::initialize() {
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_programObject == nullptr) {
|
||||
_programObject = renderEngine.buildRenderProgram(
|
||||
"LatLonSphereMappingProgram",
|
||||
"${MODULE_GLOBEBROWSING}/shaders/latlonpatch_spheremapping_vs.glsl",
|
||||
"${MODULE_GLOBEBROWSING}/shaders/simple_fs.glsl");
|
||||
if (!_programObject) return false;
|
||||
}
|
||||
|
||||
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
|
||||
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool LatLonPatch::deinitialize() {
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_programObject) {
|
||||
renderEngine.removeRenderProgram(_programObject);
|
||||
_programObject = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LatLonPatch::isReady() const {
|
||||
bool ready = true;
|
||||
ready &= (_programObject != nullptr);
|
||||
return ready;
|
||||
}
|
||||
|
||||
void LatLonPatch::render(const RenderData& data) {
|
||||
// activate shader
|
||||
_programObject->activate();
|
||||
|
||||
// TODO : Not sure if double precision will be needed for all these calculations
|
||||
// Using doubles in case but might slow things down.
|
||||
// TODO : Need to get the radius of the globe
|
||||
double r = 6e6;
|
||||
|
||||
// Create control points (double)
|
||||
glm::dvec3 p00, p01, p10, p11;
|
||||
|
||||
// Calculate global positions of control points
|
||||
p00 = glm::dvec3(converter::latLonToCartesian(
|
||||
_posLatLon.x - _sizeLatLon.x,
|
||||
_posLatLon.y - _sizeLatLon.y,
|
||||
r));
|
||||
p10 = glm::dvec3(converter::latLonToCartesian(
|
||||
_posLatLon.x + _sizeLatLon.x,
|
||||
_posLatLon.y - _sizeLatLon.y,
|
||||
r));
|
||||
p01 = glm::dvec3(converter::latLonToCartesian(
|
||||
_posLatLon.x - _sizeLatLon.x,
|
||||
_posLatLon.y + _sizeLatLon.y,
|
||||
r));
|
||||
p11 = glm::dvec3(converter::latLonToCartesian(
|
||||
_posLatLon.x + _sizeLatLon.x,
|
||||
_posLatLon.y + _sizeLatLon.y,
|
||||
r));
|
||||
|
||||
// TODO : Transformation to world space from model space should also consider
|
||||
// rotations. Now it only uses translatation for simplicity. Should be done
|
||||
// With a matrix transform
|
||||
glm::dvec3 position = data.position.dvec3();
|
||||
p00 += position;
|
||||
p10 += position;
|
||||
p01 += position;
|
||||
p11 += position;
|
||||
|
||||
// Calculate global position of camera
|
||||
// TODO : Should only need to fetch the camera transform and use directly
|
||||
// Now the viewTransform is wrong due to the constant lookUpVector
|
||||
glm::dvec3 camPos = data.camera.position().dvec3();
|
||||
glm::dvec3 camDir = glm::normalize(position - camPos);
|
||||
glm::dvec3 camUp = glm::dvec3(0,1,0);// data.camera.lookUpVector();
|
||||
// Get camera transform matrix (double precision)
|
||||
glm::dmat4 viewTransform = glm::inverse(glm::translate(glm::dmat4(1.0), camPos));
|
||||
//glm::dmat4 viewTransform = glm::lookAt(camPos, camPos + camDir, camUp);
|
||||
viewTransform = glm::dmat4( data.camera.viewRotationMatrix()) * viewTransform;
|
||||
// Transform control points to camera space
|
||||
p00 = glm::dvec3(viewTransform * glm::dvec4(p00, 1.0));
|
||||
p10 = glm::dvec3(viewTransform * glm::dvec4(p10, 1.0));
|
||||
p01 = glm::dvec3(viewTransform * glm::dvec4(p01, 1.0));
|
||||
p11 = glm::dvec3(viewTransform * glm::dvec4(p11, 1.0));
|
||||
|
||||
// Send control points to GPU to be used in shader
|
||||
// TODO : Will need more control points or possibly normals to be able to
|
||||
// do better than linear interpolation
|
||||
_programObject->setUniform("p00", glm::vec3(p00));
|
||||
_programObject->setUniform("p10", glm::vec3(p10));
|
||||
_programObject->setUniform("p01", glm::vec3(p01));
|
||||
_programObject->setUniform("p11", glm::vec3(p11));
|
||||
|
||||
_programObject->setUniform("Projection", data.camera.projectionMatrix());
|
||||
|
||||
// Render triangles (use texture coordinates to interpolate to new positions)
|
||||
glDisable(GL_CULL_FACE);
|
||||
//glCullFace(GL_BACK);
|
||||
|
||||
// render
|
||||
_grid.drawUsingActiveProgram();
|
||||
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
}
|
||||
|
||||
void LatLonPatch::update(const UpdateData& data) {
|
||||
|
||||
}
|
||||
|
||||
void LatLonPatch::setPositionLatLon(glm::dvec2 posLatLon) {
|
||||
_posLatLon = posLatLon;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
73
modules/globebrowsing/rendering/latlonpatch.h
Normal file
73
modules/globebrowsing/rendering/latlonpatch.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __LATLONPATCH_H__
|
||||
#define __LATLONPATCH_H__
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/gridgeometry.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
class LatLonPatch : public Renderable
|
||||
{
|
||||
public:
|
||||
LatLonPatch(
|
||||
unsigned int xRes,
|
||||
unsigned int yRes,
|
||||
double posLat,
|
||||
double posLon,
|
||||
double sizeLat,
|
||||
double sizeLon);
|
||||
~LatLonPatch();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
void setPositionLatLon(glm::dvec2 posLatLon);
|
||||
|
||||
private:
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
|
||||
glm::dvec2 _posLatLon;
|
||||
glm::dvec2 _sizeLatLon;
|
||||
GridGeometry _grid;
|
||||
};
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __LATLONPATCH_H__
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <modules/globebrowsing/rendering/renderableglobe.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/globemesh.h>
|
||||
#include <modules/globebrowsing/rendering/clipmapglobe.h>
|
||||
|
||||
// open space includes
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
@@ -68,7 +69,8 @@ namespace openspace {
|
||||
// Mainly for debugging purposes @AA
|
||||
addProperty(_rotation);
|
||||
|
||||
addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh(dictionary)), 1000000000);
|
||||
addSwitchValue(std::shared_ptr<ClipMapGlobe>(new ClipMapGlobe(dictionary)), 1e9);
|
||||
addSwitchValue(std::shared_ptr<GlobeMesh>(new GlobeMesh(dictionary)), 1e10);
|
||||
}
|
||||
|
||||
RenderableGlobe::~RenderableGlobe() {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 Projection;
|
||||
|
||||
uniform vec3 p00;
|
||||
uniform vec3 p10;
|
||||
uniform vec3 p01;
|
||||
uniform vec3 p11;
|
||||
|
||||
layout(location = 1) in vec2 in_UV;
|
||||
|
||||
out vec4 vs_position;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
// Bilinear interpolation
|
||||
vec3 p0 = (1 - in_UV.x) * p00 + in_UV.x * p10;
|
||||
vec3 p1 = (1 - in_UV.x) * p01 + in_UV.x * p11;
|
||||
vec3 p = (1 - in_UV.y) * p0 + in_UV.y * p1;
|
||||
|
||||
vec4 position = Projection * vec4(p, 1);
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
@@ -36,8 +36,8 @@ out vec4 vs_position;
|
||||
void main()
|
||||
{
|
||||
// set variables
|
||||
vs_position = in_position;
|
||||
vec4 tmp = in_position;
|
||||
vs_position = vec4(in_position.xyz * 60000000.0f, 1);
|
||||
vec4 tmp = vec4(in_position.xyz * 60000000.0f, 1);
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
|
||||
52
modules/globebrowsing/util/converter.cpp
Normal file
52
modules/globebrowsing/util/converter.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/globebrowsing/util/converter.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace converter {
|
||||
|
||||
glm::dvec3 latLonToCartesian(double latitude, double longitude, double radius) {
|
||||
return radius * glm::dvec3(
|
||||
glm::cos(latitude) * glm::cos(longitude),
|
||||
glm::cos(latitude) * glm::sin(longitude),
|
||||
glm::sin(latitude));
|
||||
}
|
||||
|
||||
glm::dvec2 cartesianToLatLon(glm::dvec3 position) {
|
||||
double r = glm::length(position);
|
||||
double lat = glm::asin(position.z / r);
|
||||
double lon = atan2(position.y, position.x);
|
||||
return glm::vec2(lat, lon);
|
||||
}
|
||||
|
||||
} // namespace converter
|
||||
} // namespace openspace
|
||||
56
modules/globebrowsing/util/converter.h
Normal file
56
modules/globebrowsing/util/converter.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __CONVERTER_H__
|
||||
#define __CONVERTER_H__
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <modules/globebrowsing/rendering/geometry.h>
|
||||
#include <modules/globebrowsing/rendering/distanceswitch.h>
|
||||
#include <modules/globebrowsing/rendering/globemesh.h>
|
||||
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace converter {
|
||||
|
||||
glm::dvec3 latLonToCartesian(double latitude, double longitude, double radius);
|
||||
glm::dvec2 cartesianToLatLon(glm::dvec3 position);
|
||||
|
||||
} // namespace converter
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __CONVERTER_H__
|
||||
@@ -72,5 +72,7 @@ create_new_module(
|
||||
endif ()
|
||||
set_property(TARGET cdf PROPERTY FOLDER "External")
|
||||
endif ()
|
||||
|
||||
# Boost
|
||||
find_package(Boost REQUIRED)
|
||||
target_include_directories(openspace-module-kameleon SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
#include_external_library(${onscreengui_module} Imgui ${CMAKE_CURRENT_SOURCE_DIR}/ext/kameleon)
|
||||
|
||||
@@ -140,7 +140,7 @@ void RenderableCrawlingLine::render(const RenderData& data) {
|
||||
|
||||
_program->setUniform("_alpha", alpha);
|
||||
_program->setUniform("color", _lineColor);
|
||||
setPscUniforms(_program.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_program.get(), data.camera, data.position);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
|
||||
@@ -549,7 +549,7 @@ void RenderableFov::render(const RenderData& data) {
|
||||
// setup the data to the shader
|
||||
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform", glm::mat4(1));
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
if (openspace::ImageSequencer2::ref().isReady())
|
||||
_drawFOV = ImageSequencer2::ref().instrumentActive(_instrumentID);
|
||||
|
||||
@@ -331,7 +331,7 @@ void RenderableModelProjection::render(const RenderData& data) {
|
||||
_viewProjection = data.camera.viewProjectionMatrix();
|
||||
_programObject->setUniform("ViewProjection", _viewProjection);
|
||||
_programObject->setUniform("ModelTransform", _transform);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
textureBind();
|
||||
_geometry->render();
|
||||
|
||||
@@ -147,7 +147,7 @@ void RenderablePlaneProjection::render(const RenderData& data) {
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_shader.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_shader.get(), data.camera, data.position);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
|
||||
@@ -541,7 +541,7 @@ void RenderablePlanetProjection::render(const RenderData& data){
|
||||
_programObject->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
|
||||
_programObject->setUniform("ModelTransform" , _transform);
|
||||
_programObject->setUniform("boresight" , _boresight);
|
||||
setPscUniforms(_programObject.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
textureBind();
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ void RenderableShadowCylinder::render(const RenderData& data){
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", _transform);
|
||||
_shader->setUniform("shadowColor", _shadowColor);
|
||||
setPscUniforms(_shader.get(), &data.camera, data.position);
|
||||
setPscUniforms(*_shader.get(), data.camera, data.position);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, static_cast<GLsizei>(_vertices.size()));
|
||||
|
||||
43
modules/toyvolume/CMakeLists.txt
Normal file
43
modules/toyvolume/CMakeLists.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
#########################################################################################
|
||||
# #
|
||||
# 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(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
|
||||
|
||||
set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletoyvolume.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/toyvolumeraycaster.h
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletoyvolume.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/toyvolumeraycaster.cpp
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
create_new_module(
|
||||
"ToyVolume"
|
||||
toyvolume_module
|
||||
${HEADER_FILES} ${SOURCE_FILES}
|
||||
)
|
||||
1
modules/toyvolume/include.cmake
Normal file
1
modules/toyvolume/include.cmake
Normal file
@@ -0,0 +1 @@
|
||||
set (DEFAULT_MODULE ON)
|
||||
140
modules/toyvolume/rendering/renderabletoyvolume.cpp
Normal file
140
modules/toyvolume/rendering/renderabletoyvolume.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/toyvolume/rendering/renderabletoyvolume.h>
|
||||
#include <modules/toyvolume/rendering/toyvolumeraycaster.h>
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/rendering/raycastermanager.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string GlslRayCastPath = "${MODULES}/toyvolume/shaders/rayCast.glsl";
|
||||
const std::string GlslBoundsVsPath = "${MODULES}/toyvolume/shaders/boundsVs.glsl";
|
||||
const std::string GlslBoundsFsPath = "${MODULES}/toyvolume/shaders/boundsFs.glsl";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RenderableToyVolume::RenderableToyVolume(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _scalingExponent("scalingExponent", "Scaling Exponent", 1, -10, 20)
|
||||
, _stepSize("stepSize", "Step Size", 0.02, 0.01, 1)
|
||||
, _scaling("scaling", "Scaling", glm::vec3(1.0, 1.0, 1.0), glm::vec3(0.0), glm::vec3(10.0))
|
||||
, _translation("translation", "Translation", glm::vec3(0.0, 0.0, 0.0), glm::vec3(0.0), glm::vec3(10.0))
|
||||
, _rotation("rotation", "Euler rotation", glm::vec3(0.0, 0.0, 0.0), glm::vec3(0), glm::vec3(6.28))
|
||||
, _color("color", "Color", glm::vec4(1.0, 0.0, 0.0, 0.1), glm::vec4(0.0), glm::vec4(1.0)) {
|
||||
|
||||
float scalingExponent, stepSize;
|
||||
glm::vec3 scaling, translation, rotation;
|
||||
glm::vec4 color;
|
||||
if (dictionary.getValue("ScalingExponent", scalingExponent)) {
|
||||
_scalingExponent = scalingExponent;
|
||||
}
|
||||
if (dictionary.getValue("Scaling", scaling)) {
|
||||
_scaling = scaling;
|
||||
}
|
||||
if (dictionary.getValue("Translation", translation)) {
|
||||
_translation = translation;
|
||||
}
|
||||
if (dictionary.getValue("Rotation", rotation)) {
|
||||
_rotation = rotation;
|
||||
}
|
||||
if (dictionary.getValue("Color", color)) {
|
||||
_color = color;
|
||||
}
|
||||
if (dictionary.getValue("StepSize", stepSize)) {
|
||||
_stepSize = stepSize;
|
||||
}
|
||||
}
|
||||
|
||||
RenderableToyVolume::~RenderableToyVolume() {}
|
||||
|
||||
bool RenderableToyVolume::initialize() {
|
||||
_raycaster = std::make_unique<ToyVolumeRaycaster>(ToyVolumeRaycaster(_color));
|
||||
_raycaster->initialize();
|
||||
|
||||
OsEng.renderEngine().raycasterManager().attachRaycaster(*_raycaster.get());
|
||||
|
||||
std::function<void(bool)> onChange = [&](bool enabled) {
|
||||
if (enabled) {
|
||||
OsEng.renderEngine().raycasterManager().attachRaycaster(*_raycaster.get());
|
||||
}
|
||||
else {
|
||||
OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get());
|
||||
}
|
||||
};
|
||||
|
||||
onEnabledChange(onChange);
|
||||
|
||||
addProperty(_scaling);
|
||||
addProperty(_scalingExponent);
|
||||
addProperty(_stepSize);
|
||||
addProperty(_translation);
|
||||
addProperty(_rotation);
|
||||
addProperty(_color);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderableToyVolume::deinitialize() {
|
||||
if (_raycaster) {
|
||||
OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get());
|
||||
_raycaster = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderableToyVolume::isReady() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderableToyVolume::update(const UpdateData& data) {
|
||||
if (_raycaster) {
|
||||
|
||||
glm::mat4 transform = glm::translate(glm::mat4(1.0), static_cast<glm::vec3>(_translation) * std::pow(10.0f, static_cast<float>(_scalingExponent)));
|
||||
glm::vec3 eulerRotation = static_cast<glm::vec3>(_rotation);
|
||||
transform = glm::rotate(transform, eulerRotation.x, glm::vec3(1, 0, 0));
|
||||
transform = glm::rotate(transform, eulerRotation.y, glm::vec3(0, 1, 0));
|
||||
transform = glm::rotate(transform, eulerRotation.z, glm::vec3(0, 0, 1));
|
||||
transform = glm::scale(transform, static_cast<glm::vec3>(_scaling) * std::pow(10.0f, static_cast<float>(_scalingExponent)));
|
||||
|
||||
_raycaster->setColor(_color);
|
||||
_raycaster->setStepSize(_stepSize);
|
||||
_raycaster->setModelTransform(transform);
|
||||
_raycaster->setTime(data.time);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableToyVolume::render(const RenderData& data, RendererTasks& tasks) {
|
||||
RaycasterTask task{ _raycaster.get(), data };
|
||||
tasks.raycasterTasks.push_back(task);
|
||||
}
|
||||
|
||||
}
|
||||
62
modules/toyvolume/rendering/renderabletoyvolume.h
Normal file
62
modules/toyvolume/rendering/renderabletoyvolume.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __RENDERABLETOYVOLUME_H__
|
||||
#define __RENDERABLETOYVOLUME_H__
|
||||
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/util/boxgeometry.h>
|
||||
#include <openspace/util/blockplaneintersectiongeometry.h>
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <modules/toyvolume/rendering/toyvolumeraycaster.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct RenderData;
|
||||
|
||||
class RenderableToyVolume : public Renderable {
|
||||
public:
|
||||
RenderableToyVolume(const ghoul::Dictionary& dictionary);
|
||||
~RenderableToyVolume();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
void render(const RenderData& data, RendererTasks& tasks) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
properties::Vec3Property _scaling;
|
||||
properties::IntProperty _scalingExponent;
|
||||
properties::FloatProperty _stepSize;
|
||||
properties::Vec3Property _translation;
|
||||
properties::Vec3Property _rotation;
|
||||
properties::Vec4Property _color;
|
||||
|
||||
std::unique_ptr<ToyVolumeRaycaster> _raycaster;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __RENDERABLETOYVOLUME_H__
|
||||
131
modules/toyvolume/rendering/toyvolumeraycaster.cpp
Normal file
131
modules/toyvolume/rendering/toyvolumeraycaster.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/toyvolume/rendering/toyvolumeraycaster.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <sstream>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
namespace {
|
||||
const std::string GlslRaycastPath = "${MODULES}/toyvolume/shaders/raycast.glsl";
|
||||
const std::string GlslBoundsVsPath = "${MODULES}/toyvolume/shaders/boundsVs.glsl";
|
||||
const std::string GlslBoundsFsPath = "${MODULES}/toyvolume/shaders/boundsFs.glsl";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ToyVolumeRaycaster::ToyVolumeRaycaster(glm::vec4 color)
|
||||
: _boundingBox(glm::vec3(1.0))
|
||||
, _color(color) {}
|
||||
|
||||
ToyVolumeRaycaster::~ToyVolumeRaycaster() {}
|
||||
|
||||
void ToyVolumeRaycaster::initialize() {
|
||||
_boundingBox.initialize();
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::deinitialize() {
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
|
||||
Renderable::setPscUniforms(program, data.camera, data.position);
|
||||
|
||||
// Cull back face
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
// Render bounding geometry
|
||||
_boundingBox.render();
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
|
||||
// Uniforms
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
|
||||
Renderable::setPscUniforms(program, data.camera, data.position);
|
||||
|
||||
// Cull front face
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_FRONT);
|
||||
|
||||
// Render bounding geometry
|
||||
_boundingBox.render();
|
||||
|
||||
// Restore defaults
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
|
||||
std::string colorUniformName = "color" + std::to_string(data.id);
|
||||
std::string timeUniformName = "time" + std::to_string(data.id);
|
||||
std::string stepSizeUniformName = "maxStepSize" + std::to_string(data.id);
|
||||
program.setUniform(colorUniformName, _color);
|
||||
program.setUniform(stepSizeUniformName, _stepSize);
|
||||
program.setUniform(timeUniformName, static_cast<float>(std::fmod(_time, 3600.0)));
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
|
||||
// For example: release texture units
|
||||
}
|
||||
|
||||
std::string ToyVolumeRaycaster::getBoundsVsPath() const {
|
||||
return GlslBoundsVsPath;
|
||||
}
|
||||
|
||||
std::string ToyVolumeRaycaster::getBoundsFsPath() const {
|
||||
return GlslBoundsFsPath;
|
||||
}
|
||||
|
||||
std::string ToyVolumeRaycaster::getRaycastPath() const {
|
||||
return GlslRaycastPath;
|
||||
}
|
||||
|
||||
std::string ToyVolumeRaycaster::getHelperPath() const {
|
||||
return ""; // no helper file
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::setColor(glm::vec4 color) {
|
||||
_color = color;
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::setModelTransform(glm::mat4 transform) {
|
||||
_modelTransform = transform;
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::setTime(double time) {
|
||||
_time = time;
|
||||
}
|
||||
|
||||
void ToyVolumeRaycaster::setStepSize(float stepSize) {
|
||||
_stepSize = stepSize;
|
||||
}
|
||||
|
||||
}
|
||||
80
modules/toyvolume/rendering/toyvolumeraycaster.h
Normal file
80
modules/toyvolume/rendering/toyvolumeraycaster.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __TOYVOLUMERAYCASTER_H__
|
||||
#define __TOYVOLUMERAYCASTER_H__
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <openspace/rendering/volumeraycaster.h>
|
||||
#include <openspace/util/boxgeometry.h>
|
||||
#include <openspace/util/blockplaneintersectiongeometry.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class Texture;
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderData;
|
||||
class RaycastData;
|
||||
|
||||
class ToyVolumeRaycaster : public VolumeRaycaster {
|
||||
public:
|
||||
|
||||
ToyVolumeRaycaster(glm::vec4 color);
|
||||
|
||||
virtual ~ToyVolumeRaycaster();
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
void renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
void renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
void preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
void postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) override;
|
||||
|
||||
std::string getBoundsVsPath() const override;
|
||||
std::string getBoundsFsPath() const override;
|
||||
std::string getRaycastPath() const override;
|
||||
std::string getHelperPath() const override;
|
||||
|
||||
void setColor(glm::vec4 color);
|
||||
void setModelTransform(glm::mat4 transform);
|
||||
void setTime(double time);
|
||||
void setStepSize(float time);
|
||||
private:
|
||||
BoxGeometry _boundingBox;
|
||||
glm::vec4 _color;
|
||||
glm::mat4 _modelTransform;
|
||||
float _stepSize;
|
||||
double _time;
|
||||
|
||||
}; // ToyVolumeRaycaster
|
||||
|
||||
} // openspace
|
||||
|
||||
#endif // __TOYVOLUMERAYCASTER_H__
|
||||
40
modules/toyvolume/shaders/boundsFs.glsl
Normal file
40
modules/toyvolume/shaders/boundsFs.glsl
Normal file
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
in vec3 vPosition;
|
||||
in vec4 worldPosition;
|
||||
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
#include "fragment.glsl"
|
||||
|
||||
Fragment getFragment() {
|
||||
vec4 fragColor = vec4(vPosition+0.5, 1.0);
|
||||
vec4 position = worldPosition;
|
||||
float depth = pscDepth(position);
|
||||
|
||||
Fragment frag;
|
||||
frag.color = fragColor;
|
||||
frag.depth = depth;
|
||||
return frag;
|
||||
}
|
||||
47
modules/toyvolume/shaders/boundsVs.glsl
Normal file
47
modules/toyvolume/shaders/boundsVs.glsl
Normal file
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
layout(location = 0) in vec4 vertPosition;
|
||||
|
||||
uniform mat4 viewProjection;
|
||||
uniform mat4 modelTransform;
|
||||
|
||||
out vec3 vPosition;
|
||||
out vec4 worldPosition;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vPosition = vertPosition.xyz;
|
||||
worldPosition = modelTransform*vertPosition;
|
||||
|
||||
vec4 position = pscTransform(worldPosition, mat4(1.0));
|
||||
|
||||
// project the position to view space
|
||||
gl_Position = viewProjection * position;
|
||||
|
||||
gl_Position.z = 1.0;
|
||||
}
|
||||
58
modules/toyvolume/shaders/raycast.glsl
Normal file
58
modules/toyvolume/shaders/raycast.glsl
Normal file
@@ -0,0 +1,58 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
|
||||
uniform vec4 color#{id};
|
||||
uniform float time#{id};
|
||||
uniform float maxStepSize#{id} = 0.02;
|
||||
|
||||
vec4 sample#{id}(vec3 samplePos, vec3 dir, vec4 foregroundColor, inout float maxStepSize) {
|
||||
maxStepSize = maxStepSize#{id};
|
||||
|
||||
// Generate an arbitrary procedural volume.
|
||||
// In real situations, the sample function would sample a
|
||||
// 3D texture to retrieve the color contribution of a given point.
|
||||
|
||||
vec3 fromCenter = vec3(0.5, 0.5, 0.5) - samplePos;
|
||||
|
||||
vec4 c = color#{id};
|
||||
float r = length(fromCenter);
|
||||
c.a *= (1.0 - smoothstep(0.4, 0.45, r));
|
||||
c.a *= (1.0 - smoothstep(0.35, 0.3, r));
|
||||
c.a *= (1.0 - smoothstep(0.1, 0.2, abs(fromCenter.y)));
|
||||
|
||||
float theta = atan(fromCenter.x, fromCenter.z);
|
||||
float angularRatio = (theta + 3.1415) / 6.283;
|
||||
|
||||
angularRatio = mod(angularRatio + time#{id}*0.01, 1.0);
|
||||
|
||||
c.a *= smoothstep(0.0, 0.2, clamp(angularRatio, 0.0, 1.0));
|
||||
c.a *= smoothstep(1.0, 0.8, clamp(angularRatio, 0.0, 1.0));
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
float stepSize#{id}(vec3 samplePos, vec3 dir) {
|
||||
return maxStepSize#{id};
|
||||
}
|
||||
44
modules/toyvolume/toyvolumemodule.cpp
Normal file
44
modules/toyvolume/toyvolumemodule.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/toyvolume/toyvolumemodule.h>
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include <modules/toyvolume/rendering/renderabletoyvolume.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ToyVolumeModule::ToyVolumeModule() : OpenSpaceModule("ToyVolume") {}
|
||||
|
||||
void ToyVolumeModule::internalInitialize() {
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fRenderable, "No renderable factory existed");
|
||||
fRenderable->registerClass<RenderableToyVolume>("RenderableToyVolume");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
40
modules/toyvolume/toyvolumemodule.h
Normal file
40
modules/toyvolume/toyvolumemodule.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __TOYVOLUMEMODULE_H__
|
||||
#define __TOYVOLUMEMODULE_H__
|
||||
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class ToyVolumeModule : public OpenSpaceModule {
|
||||
public:
|
||||
ToyVolumeModule();
|
||||
void internalInitialize() override;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __TOYVOLUMEMODULE_H__
|
||||
Reference in New Issue
Block a user