solve merge conflict with develop

This commit is contained in:
Michael Nilsson
2016-05-20 09:33:41 -04:00
47 changed files with 1562 additions and 131 deletions
+45
View File
@@ -0,0 +1,45 @@
#########################################################################################
# #
# 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. #
#########################################################################################
set(APPLICATION_NAME DataConverter)
set(APPLICATION_LINK_TO_OPENSPACE ON)
include (${GHOUL_BASE_DIR}/support/cmake/handle_external_library.cmake)
set(application_path ${OPENSPACE_APPS_DIR}/DataConverter)
set(SOURCE_FILES
${application_path}/main.cpp
${application_path}/milkywayconversiontask.cpp
)
set(HEADER_FILES
${application_path}/conversiontask.h
${application_path}/milkywayconversiontask.h
)
add_executable(${APPLICATION_NAME} MACOSX_BUNDLE
${SOURCE_FILES}
${HEADER_FILES}
)
+17
View File
@@ -0,0 +1,17 @@
#ifndef __CONVERSIONTASK_H__
#define __CONVERSIONTASK_H__
#include <functional>
namespace openspace {
namespace dataconverter {
class ConversionTask {
public:
virtual void perform(const std::function<void(float)>& onProgress) = 0;
};
}
}
#endif
+77
View File
@@ -0,0 +1,77 @@
/*****************************************************************************************
* *
* 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 <iostream>
#include <string>
#include <glm/glm.hpp>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/io/texture/texturereaderdevil.h>
#include <ghoul/io/texture/texturereaderfreeimage.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/ghoul.h>
#include <openspace/util/progressbar.h>
#include <apps/DataConverter/milkywayconversiontask.h>
int main(int argc, char** argv) {
using namespace openspace;
using namespace dataconverter;
ghoul::initialize();
#ifdef GHOUL_USE_DEVIL
ghoul::io::TextureReader::ref().addReader(std::make_shared<ghoul::io::TextureReaderDevIL>());
#endif // GHOUL_USE_DEVIL
#ifdef GHOUL_USE_FREEIMAGE
ghoul::io::TextureReader::ref().addReader(std::make_shared<ghoul::io::TextureReaderFreeImage>());
#endif // GHOUL_USE_FREEIMAGE
openspace::ProgressBar pb(100);
std::function<void(float)> onProgress = [&](float progress) {
pb.print(progress * 100);
};
// TODO: Make the converter configurable using either
// config files (json, lua dictionaries),
// lua scripts,
// or at the very least: a command line interface.
MilkyWayConversionTask mwConversionTask(
"F:/milky-way/cam2_main.",
".exr",
1385,
512,
"F:/milky-way/mw_512_512_64.rawvolume",
glm::vec3(512, 512, 64));
mwConversionTask.perform(onProgress);
std::cout << "Done." << std::endl;
std::cin.get();
return 0;
};
@@ -0,0 +1,50 @@
#include <apps/DataConverter/milkywayconversiontask.h>
#include <modules/volume/textureslicevolumereader.h>
#include <modules/volume/rawvolumewriter.h>
#include <modules/volume/volumesampler.h>
namespace openspace {
namespace dataconverter {
MilkyWayConversionTask::MilkyWayConversionTask(
const std::string& inFilenamePrefix,
const std::string& inFilenameSuffix,
size_t inFirstIndex,
size_t inNSlices,
const std::string& outFilename,
const glm::ivec3& outDimensions)
: _inFilenamePrefix(inFilenamePrefix)
, _inFilenameSuffix(inFilenameSuffix)
, _inFirstIndex(inFirstIndex)
, _inNSlices(inNSlices)
, _outFilename(outFilename)
, _outDimensions(outDimensions) {}
void MilkyWayConversionTask::perform(const std::function<void(float)>& onProgress) {
std::vector<std::string> filenames;
for (int i = 0; i < _inNSlices; i++) {
filenames.push_back(_inFilenamePrefix + std::to_string(i + _inFirstIndex) + _inFilenameSuffix);
}
TextureSliceVolumeReader<glm::tvec4<GLfloat>> sliceReader(filenames, _inNSlices, 10);
sliceReader.initialize();
RawVolumeWriter<glm::tvec4<GLfloat>> rawWriter(_outFilename);
rawWriter.setDimensions(_outDimensions);
glm::vec3 resolutionRatio =
static_cast<glm::vec3>(sliceReader.dimensions()) / static_cast<glm::vec3>(rawWriter.dimensions());
VolumeSampler<TextureSliceVolumeReader<glm::tvec4<GLfloat>>> sampler(sliceReader, resolutionRatio);
std::function<glm::tvec4<GLfloat>(glm::ivec3)> sampleFunction = [&](glm::ivec3 outCoord) {
glm::vec3 inCoord = ((glm::vec3(outCoord) + glm::vec3(0.5)) * resolutionRatio) - glm::vec3(0.5);
glm::tvec4<GLfloat> value = sampler.sample(inCoord);
return value;
};
rawWriter.write(sampleFunction, onProgress);
}
}
}
@@ -0,0 +1,41 @@
#ifndef __MILKYWAYCONVERSIONTASK_H__
#define __MILKYWAYCONVERSIONTASK_H__
#include <apps/DataConverter/conversiontask.h>
#include <string>
#include <glm/glm.hpp>
#include <functional>
#include <modules/volume/textureslicevolumereader.h>
#include <modules/volume/rawvolumewriter.h>
namespace openspace {
namespace dataconverter {
/**
* Converts a set of exr image slices to a raw volume
* with floating point RGBA data (32 bit per channel).
*/
class MilkyWayConversionTask : public ConversionTask {
public:
MilkyWayConversionTask(const std::string& inFilenamePrefix,
const std::string& inFilenameSuffix,
size_t inFirstIndex,
size_t inNSlices,
const std::string& outFilename,
const glm::ivec3& outDimensions);
void perform(const std::function<void(float)>& onProgress) override;
private:
std::string _inFilenamePrefix;
std::string _inFilenameSuffix;
size_t _inFirstIndex;
size_t _inNSlices;
std::string _outFilename;
glm::ivec3 _outDimensions;
};
}
}
#endif
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<Cluster masterAddress="localhost" externalControlPort="20500">
<Settings>
<Display swapInterval="1" />
<Display swapInterval="0" />
</Settings>
<Node address="localhost" port="20401">
<Window fullScreen="false" fxaa="false" numberOfSamples="8" name="OpenSpace">
+1 -1
View File
@@ -37,7 +37,7 @@ return {
Type = "simple",
Color = "textures/earth_bluemarble.jpg",
Night = "textures/earth_night.jpg",
-- Depth = "textures/earth_depth.png"
Height = "textures/earth_bluemarble_height.jpg"
},
Atmosphere = {
Type = "Nishita", -- for example, values missing etc etc
+1 -1
View File
@@ -16,7 +16,7 @@ function preInitialization()
-- openspace.time.setTime("2015-07-14T02:41:55.00")
openspace.time.setTime("2015-07-14T10:05:00.00")
openspace.time.setDeltaTime(0)
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
dofile(openspace.absPath('${SCRIPTS}/bind_keys_newhorizons.lua'))
end
function postInitialization()
+5 -3
View File
@@ -42,7 +42,9 @@ return {
-- Color = "textures/pluto_large.jpg",
-- Color = "textures/white.png",
Project = "textures/3.jpg",
Sequencing = "true",
-- Height = "textures/pluto_shenk_heightmap.jpg",
-- NormalMap = "textures/pluto_shenk_normalmap.png",
Sequencing = "true"
},
Atmosphere = {
Type = "Nishita", -- for example, values missing etc etc
@@ -50,8 +52,8 @@ return {
MieColor = {1.0, 1.0, 1.0}
},
Projection = {
Sequence = "${OPENSPACE_DATA}/scene/newhorizons/pluto/plutoprojection/all_images",
EventFile = "${OPENSPACE_DATA}/scene/newhorizons/pluto/plutoprojection/assets/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt",
Sequence = "${OPENSPACE_DATA}/scene/newhorizons/pluto/pluto/images",
EventFile = "${OPENSPACE_DATA}/scene/newhorizons/pluto/pluto/assets/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt",
SequenceType = "hybrid",
Observer = "NEW HORIZONS",
Target = "PLUTO",
+2 -1
View File
@@ -7,7 +7,8 @@ function preInitialization()
]]--
openspace.time.setTime("2014 AUG 21 18:00:00")
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
-- openspace.time.setTime("2015 SEP 10 19:39:00")
dofile(openspace.absPath('${SCRIPTS}/bind_keys_rosetta.lua'))
end
function postInitialization()
+1 -1
View File
@@ -1,6 +1,6 @@
return {
FileRequest = {
{ Identifier = "67p_textures", Destination = "textures", Version = 1 }
{ Identifier = "67p_textures", Destination = "textures", Version = 2 }
},
TorrentFiles = {
{ File = "67P_rotated_5_130.obj.torrent", Destination = "obj" },
+17 -5
View File
@@ -23,7 +23,7 @@ return {
Destination = "GALACTIC"
},
Projection = {
Sequence = "rosettaimages",
Sequence = "rosettaimages2",
SequenceType = "image-sequence",
Observer = "ROSETTA",
Target = "CHURYUMOV-GERASIMENKO",
@@ -78,28 +78,40 @@ return {
"${OPENSPACE_DATA}/spice/de430_1850-2150.bsp",
-- SPK
--long term orbits loaded first
'${OPENSPACE_DATA}/spice/RosettaKernels_New/SPK/LORL_DL_009_02____P__00268.BSP',
'${OPENSPACE_DATA}/spice/RosettaKernels_New/SPK/RORL_DL_009_02____P__00268.BSP',
'${OPENSPACE_DATA}/spice/RosettaKernels_New/SPK/CORL_DL_009_02____P__00268.BSP',
'${OPENSPACE_DATA}/spice/RosettaKernels/SPK/LORL_DL_006_01____H__00156.BSP',
'${OPENSPACE_DATA}/spice/RosettaKernels/SPK/RORL_DL_006_01____H__00156.BSP',
'${OPENSPACE_DATA}/spice/RosettaKernels/SPK/CORL_DL_006_01____H__00156.BSP',
--Jan 2014 - May 2015 (version match with 00162 ck files)
"${OPENSPACE_DATA}/spice/RosettaKernels_New/SPK/CORB_DV_211_01_______00288.BSP",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/SPK/RORB_DV_211_01_______00288.BSP",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/SPK/LORB_DV_211_01_______00288.BSP",
"${OPENSPACE_DATA}/spice/RosettaKernels/SPK/CORB_DV_097_01_______00162.BSP",
"${OPENSPACE_DATA}/spice/RosettaKernels/SPK/RORB_DV_097_01_______00162.BSP",
"${OPENSPACE_DATA}/spice/RosettaKernels/SPK/LORB_DV_097_01_______00162.BSP",
--SCLK
"${OPENSPACE_DATA}/spice/RosettaKernels/SCLK/ROS_150227_STEP.TSC",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/SCLK/ROS_150227_STEP.TSC",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/SCLK/ROS_160425_STEP.TSC",
-- FK
"${OPENSPACE_DATA}/spice/RosettaKernels/FK/ROS_CHURYUMOV_V01.TF",
"${OPENSPACE_DATA}/spice/RosettaKernels/FK/ROS_V24.TF",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/FK/ROS_CHURYUMOV_V01.TF",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/FK/ROS_V26.TF",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/FK/ROS_V24.TF",
-- CK
"${OPENSPACE_DATA}/spice/RosettaKernels_New/CK/RATT_DV_211_01_01____00288.BC",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/CK/CATT_DV_211_01_______00288.BC",
'${OPENSPACE_DATA}/spice/RosettaKernels/CK/RATT_DV_097_01_01____00162.BC',
"${OPENSPACE_DATA}/spice/RosettaKernels/CK/CATT_DV_097_01_______00162.BC",
-- PCK
"${OPENSPACE_DATA}/spice/RosettaKernels/PCK/ROS_CGS_RSOC_V03.TPC",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/PCK/ROS_CGS_RSOC_V03.TPC",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/PCK/ROS_CGS_RSOC_V03.TPC",
}
+16 -16
View File
@@ -30,31 +30,33 @@ return {
"${OPENSPACE_DATA}/spice/de430_1850-2150.bsp",
-- SPK
--long term orbits loaded first
'${OPENSPACE_DATA}/spice/RosettaKernels/SPK/LORL_DL_006_01____H__00156.BSP',
'${OPENSPACE_DATA}/spice/RosettaKernels/SPK/RORL_DL_006_01____H__00156.BSP',
'${OPENSPACE_DATA}/spice/RosettaKernels/SPK/CORL_DL_006_01____H__00156.BSP',
-- '${OPENSPACE_DATA}/spice/RosettaKernels/SPK/LORL_DL_006_01____H__00156.BSP',
-- '${OPENSPACE_DATA}/spice/RosettaKernels/SPK/RORL_DL_006_01____H__00156.BSP',
-- '${OPENSPACE_DATA}/spice/RosettaKernels/SPK/CORL_DL_006_01____H__00156.BSP',
--Jan 2014 - May 2015 (version match with 00162 ck files)
"${OPENSPACE_DATA}/spice/RosettaKernels/SPK/CORB_DV_097_01_______00162.BSP",
"${OPENSPACE_DATA}/spice/RosettaKernels/SPK/RORB_DV_097_01_______00162.BSP",
"${OPENSPACE_DATA}/spice/RosettaKernels/SPK/LORB_DV_097_01_______00162.BSP",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/SPK/CORB_DV_097_01_______00162.BSP",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/SPK/RORB_DV_097_01_______00162.BSP",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/SPK/LORB_DV_097_01_______00162.BSP",
--IK
"${OPENSPACE_DATA}/spice/RosettaKernels_New/IK/ROS_NAVCAM_V01.TI",
"${OPENSPACE_DATA}/spice/RosettaKernels/IK/ROS_NAVCAM_V00-20130102.TI",
--SCLK
"${OPENSPACE_DATA}/spice/RosettaKernels/SCLK/ROS_150227_STEP.TSC",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/SCLK/ROS_150227_STEP.TSC",
-- FK
"${OPENSPACE_DATA}/spice/RosettaKernels/FK/ROS_CHURYUMOV_V01.TF",
"${OPENSPACE_DATA}/spice/RosettaKernels/FK/ROS_V24.TF",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/FK/ROS_CHURYUMOV_V01.TF",
-- "${OPENSPACE_DATA}/spice/RosettaKernels/FK/ROS_V24.TF",
-- CK
'${OPENSPACE_DATA}/spice/RosettaKernels/CK/RATT_DV_097_01_01____00162.BC',
"${OPENSPACE_DATA}/spice/RosettaKernels/CK/CATT_DV_097_01_______00162.BC",
-- '${OPENSPACE_DATA}/spice/RosettaKernels/CK/RATT_DV_097_01_01____00162.BC',
-- "${OPENSPACE_DATA}/spice/RosettaKernels/CK/CATT_DV_097_01_______00162.BC",
"${OPENSPACE_DATA}/spice/RosettaKernels/CK/ROS_SA_2014_V0044.BC",
"${OPENSPACE_DATA}/spice/RosettaKernels/CK/ROS_SA_2015_V0009.BC",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/CK/ROS_SA_2014_V0047.BC",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/CK/ROS_SA_2015_V0042.BC",
"${OPENSPACE_DATA}/spice/RosettaKernels_New/CK/ROS_SA_2016_V0019.BC",
}
},
GuiName = "/Solar/Rosetta"
@@ -90,18 +92,16 @@ return {
Body = "ROSETTA",
Frame = "GALACTIC",
Observer = "CHURYUMOV-GERASIMENKO",
-- 3 Dummy values for compilation:
TropicalOrbitPeriod = 20000.0,
EarthOrbitRatio = 2,
DayLength = 25,
-- End of Dummy values
RGB = { 0.9, 0.2, 0.9 },
Textures = {
Type = "simple",
Color = "textures/glare.png"
},
StartTime = "2014 AUG 01 12:00:00",
EndTime = "2015 MAY 26 12:00:00"
EndTime = "2016 MAY 26 12:00:00"
},
GuiName = "RosettaCometTrail"
},
+50 -5
View File
@@ -58,15 +58,19 @@ namespace openspace {
RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _nightTexturePath("nightTexture", "Night Texture")
, _heightMapTexturePath("heightMap", "Heightmap Texture")
, _heightExaggeration("heightExaggeration", "Height Exaggeration", 1.f, 0.f, 10.f)
, _programObject(nullptr)
, _texture(nullptr)
, _nightTexture(nullptr)
, _heightMapTexture(nullptr)
, _geometry(nullptr)
, _performShading("performShading", "Perform Shading", true)
, _rotation("rotation", "Rotation", 0, 0, 360)
, _alpha(1.f)
, _nightTexturePath("")
, _hasNightTexture(false)
, _hasHeightTexture(false)
{
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
@@ -100,17 +104,31 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
std::string nightTexturePath = "";
dictionary.getValue("Textures.Night", nightTexturePath);
if (nightTexturePath != ""){
_hasNightTexture = true;
_nightTexturePath = absPath(nightTexturePath);
}
std::string heightMapTexturePath = "";
dictionary.getValue("Textures.Height", heightMapTexturePath);
if (heightMapTexturePath != "") {
_hasHeightTexture = true;
_heightMapTexturePath = absPath(heightMapTexturePath);
}
addPropertySubOwner(_geometry);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
addProperty(_nightTexturePath);
_nightTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
addProperty(_heightMapTexturePath);
_heightMapTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
addProperty(_heightExaggeration);
if (dictionary.hasKeyAndValue<bool>(keyShading)) {
bool shading;
dictionary.getValue(keyShading, shading);
@@ -142,11 +160,13 @@ bool RenderablePlanet::initialize() {
"pscstandard",
"${MODULE_BASE}/shaders/pscstandard_vs.glsl",
"${MODULE_BASE}/shaders/pscstandard_fs.glsl");
if (!_programObject) return false;
if (!_programObject)
return false;
}
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
_programObject->setIgnoreUniformLocationError(IgnoreError::Yes);
loadTexture();
_geometry->initialize(this);
@@ -218,20 +238,32 @@ void RenderablePlanet::render(const RenderData& data)
_programObject->setUniform("_performShading", _performShading);
_programObject->setUniform("_hasHeightMap", _hasHeightTexture);
_programObject->setUniform("_heightExaggeration", _heightExaggeration);
// Bind texture
ghoul::opengl::TextureUnit dayUnit;
ghoul::opengl::TextureUnit nightUnit;
ghoul::opengl::TextureUnit heightUnit;
dayUnit.activate();
_texture->bind();
_programObject->setUniform("texture1", dayUnit);
// Bind possible night texture
if (_hasNightTexture) {
ghoul::opengl::TextureUnit nightUnit;
nightUnit.activate();
_nightTexture->bind();
_programObject->setUniform("nightTex", nightUnit);
}
if (_hasHeightTexture) {
heightUnit.activate();
_heightMapTexture->bind();
_programObject->setUniform("heightTex", heightUnit);
}
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -264,7 +296,7 @@ void RenderablePlanet::loadTexture() {
}
if (_hasNightTexture) {
_nightTexture = nullptr;
if (_nightTexturePath != "") {
if (_nightTexturePath.value() != "") {
_nightTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_nightTexturePath)));
if (_nightTexture) {
LDEBUG("Loaded texture from '" << _nightTexturePath << "'");
@@ -274,6 +306,19 @@ void RenderablePlanet::loadTexture() {
}
}
}
if (_hasHeightTexture) {
_heightMapTexture = nullptr;
if (_heightMapTexturePath.value() != "") {
_heightMapTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_heightMapTexturePath)));
if (_heightMapTexture) {
LDEBUG("Loaded texture from '" << _heightMapTexturePath << "'");
_heightMapTexture->uploadTexture();
_heightMapTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
//_nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
}
}
}
}
} // namespace openspace
+8 -1
View File
@@ -62,19 +62,26 @@ protected:
private:
properties::StringProperty _colorTexturePath;
properties::StringProperty _nightTexturePath;
properties::StringProperty _heightMapTexturePath;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
std::unique_ptr<ghoul::opengl::Texture> _texture;
std::unique_ptr<ghoul::opengl::Texture> _nightTexture;
std::unique_ptr<ghoul::opengl::Texture> _heightMapTexture;
properties::FloatProperty _heightExaggeration;
planetgeometry::PlanetGeometry* _geometry;
properties::BoolProperty _performShading;
properties::IntProperty _rotation;
float _alpha;
glm::dmat3 _stateMatrix;
std::string _nightTexturePath;
std::string _frame;
std::string _target;
bool _hasNightTexture;
bool _hasHeightTexture;
double _time;
};
+6 -12
View File
@@ -231,19 +231,11 @@ void RenderableTrail::update(const UpdateData& data) {
psc pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
pscPos[3] += 3; // KM to M
_vertexArray[0] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
if (nValues != 0) {
// If we have new values to create, we do that here. nValues should always be
// close to 1
// But you never know
nValues = std::min(nValues, int(_vertexArray.size() - 1));
//LINFO(nValues);
std::vector<TrailVBOLayout> tmp = _vertexArray;
std::vector<TrailVBOLayout> tmp(nValues);
for (int i = nValues; i > 0; --i) {
double et = _oldTime + i * _increment;
if (start > et)
@@ -254,11 +246,13 @@ void RenderableTrail::update(const UpdateData& data) {
SpiceManager::ref().targetPosition(_target, _observer, _frame, {}, et, lightTime);
pscPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
pscPos[3] += 3;
_vertexArray[i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
tmp[nValues - i] = { pscPos[0], pscPos[1], pscPos[2], pscPos[3] };
}
for (size_t i = 0; i < tmp.size() - (nValues + 1); ++i)
_vertexArray[nValues + 1 + i] = tmp[i + 1];
size_t size = _vertexArray.size();
_vertexArray.insert(_vertexArray.begin() + 1, tmp.begin(), tmp.end());
_vertexArray.resize(size);
_oldTime += nValues * _increment;
}
@@ -45,7 +45,7 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
: PlanetGeometry()
, _realRadius("radius", "Radius", glm::vec4(1.f, 1.f, 1.f, 0.f), glm::vec4(-10.f, -10.f, -10.f, -20.f),
glm::vec4(10.f, 10.f, 10.f, 20.f))
, _segments("segments", "Segments", 20, 1, 50)
, _segments("segments", "Segments", 20, 1, 5000)
, _sphere(nullptr)
{
using constants::simplespheregeometry::keyRadius;
+2 -1
View File
@@ -39,6 +39,7 @@ in vec2 vs_st;
in vec2 vs_nightTex;
in vec4 vs_normal;
in vec4 vs_position;
in vec4 test;
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
@@ -68,7 +69,7 @@ Fragment getFragment() {
vec4 ambient = vec4(0.0,0.0,0.0,transparency);
vec4 daytex = max(intensity * diffuse, ambient);
vec4 mixtex = mix(diffuse, diffuse2, (1+dot(n,-l_dir))/2);
vec4 mixtex = mix(diffuse, diffuse2, (1+dot(n,-l_dir))/2);
diffuse = (daytex*2 + mixtex)/3;
}
+19 -5
View File
@@ -24,21 +24,25 @@
#version __CONTEXT__
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
#include "PowerScaling/powerScaling_vs.hglsl"
layout(location = 0) in vec4 in_position;
layout(location = 1) in vec2 in_st;
layout(location = 2) in vec3 in_normal;
//layout(location = 3) in vec2 in_nightTex;
out vec2 vs_st;
out vec4 vs_normal;
out vec4 vs_position;
out float s;
#include "PowerScaling/powerScaling_vs.hglsl"
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
uniform sampler2D heightTex;
uniform bool _hasHeightMap;
uniform float _heightExaggeration;
void main()
{
@@ -49,9 +53,19 @@ void main()
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
// vs_normal = vec4(in_normal, 0.0);
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
if (_hasHeightMap) {
float height = texture(heightTex, in_st).r;
vec3 displacementDirection = abs(normalize(in_normal.xyz));
float displacementFactor = height * _heightExaggeration;
position.xyz = position.xyz + displacementDirection * displacementFactor;
}
//
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
@@ -82,14 +82,16 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di
, _fboProgramObject(nullptr)
, _texture(nullptr)
, _geometry(nullptr)
, _textureOriginal(nullptr)
//, _textureOriginal(nullptr)
, _textureProj(nullptr)
, _textureWhiteSquare(nullptr)
, _alpha(1.f)
, _performShading("performShading", "Perform Shading", true)
, _performProjection("performProjection", "Perform Projections", true)
, _clearAllProjections("clearAllProjections", "Clear Projections", false)
, _frameCount(0)
, _programIsDirty(false)
, _clearingImage(absPath("${OPENSPACE_DATA}/scene/common/textures/clear.png"))
{
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
@@ -149,6 +151,7 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di
addProperty(_performShading);
addProperty(_performProjection);
addProperty(_clearAllProjections);
addProperty(_rotationX);
addProperty(_rotationY);
addProperty(_rotationZ);
@@ -195,6 +198,7 @@ bool RenderableModelProjection::initialize() {
"${MODULE_NEWHORIZONS}/shaders/modelShader_vs.glsl",
"${MODULE_NEWHORIZONS}/shaders/modelShader_fs.glsl");
if (!_programObject)
return false;
}
@@ -204,6 +208,7 @@ bool RenderableModelProjection::initialize() {
_fboProgramObject = ghoul::opengl::ProgramObject::Build("ProjectionPass",
"${MODULE_NEWHORIZONS}/shaders/projectionPass_vs.glsl",
"${MODULE_NEWHORIZONS}/shaders/projectionPass_fs.glsl");
_fboProgramObject->setIgnoreUniformLocationError(ghoul::opengl::ProgramObject::IgnoreError::Yes);
if (!_fboProgramObject)
return false;
}
@@ -213,7 +218,7 @@ bool RenderableModelProjection::initialize() {
loadProjectionTexture();
completeSuccess &= (_texture != nullptr);
completeSuccess &= (_textureOriginal != nullptr);
//completeSuccess &= (_textureOriginal != nullptr);
completeSuccess &= (_textureProj != nullptr);
completeSuccess &= (_textureWhiteSquare != nullptr);
@@ -286,7 +291,7 @@ bool RenderableModelProjection::deinitialize() {
_geometry = nullptr;
_texture = nullptr;
_textureProj = nullptr;
_textureOriginal = nullptr;
//_textureOriginal = nullptr;
_textureWhiteSquare = nullptr;
glDeleteBuffers(1, &_vbo);
@@ -300,12 +305,44 @@ bool RenderableModelProjection::deinitialize() {
return true;
}
void RenderableModelProjection::clearAllProjections() {
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath)));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
GLint defaultFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
glBindFramebuffer(GL_FRAMEBUFFER, _fboID);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *_texture, 0);
// check FBO status
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
// switch back to window-system-provided framebuffer
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
//float tmp = _fadeProjection;
//_fadeProjection = 1.f;
//_projectionTexturePath = _clearingImage;
//imageProjectGPU();
//_fadeProjection = tmp;
_clearAllProjections = false;
}
void RenderableModelProjection::render(const RenderData& data) {
if (!_programObject)
return;
if (!_textureProj)
return;
if (_clearAllProjections)
clearAllProjections();
_programObject->activate();
_frameCount++;
@@ -373,7 +410,8 @@ void RenderableModelProjection::update(const UpdateData& data) {
}
void RenderableModelProjection::imageProjectGPU() {
glDisable(GL_DEPTH_TEST);
// keep handle to the current bound FBO
GLint defaultFBO;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO);
@@ -403,18 +441,21 @@ void RenderableModelProjection::imageProjectGPU() {
_fboProgramObject->setUniform("_scaling", _camScaling);
_fboProgramObject->setUniform("boresight", _boresight);
_geometry->setUniforms(*_fboProgramObject);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(_geometryIndeces.size()), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
_fboProgramObject->deactivate();
glDisable(GL_BLEND);
//glDisable(GL_BLEND);
//bind back to default
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport(m_viewport[0], m_viewport[1],
m_viewport[2], m_viewport[3]);
glEnable(GL_DEPTH_TEST);
}
void RenderableModelProjection::attitudeParameters(double time) {
@@ -495,8 +536,9 @@ void RenderableModelProjection::textureBind() {
void RenderableModelProjection::project() {
for (auto img : _imageTimes) {
std::thread t1(&RenderableModelProjection::attitudeParameters, this, img.startTime);
t1.join();
//std::thread t1(&RenderableModelProjection::attitudeParameters, this, img.startTime);
//t1.join();
attitudeParameters(img.startTime);
_projectionTexturePath = img.path;
imageProjectGPU(); //fbopass
}
@@ -513,15 +555,15 @@ void RenderableModelProjection::loadTexture() {
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
_textureOriginal = nullptr;
if (_colorTexturePath.value() != "") {
_textureOriginal = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath)));
if (_textureOriginal) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_textureOriginal->uploadTexture();
_textureOriginal->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
//_textureOriginal = nullptr;
//if (_colorTexturePath.value() != "") {
// _textureOriginal = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath)));
// if (_textureOriginal) {
// LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
// _textureOriginal->uploadTexture();
// _textureOriginal->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
// }
//}
_textureWhiteSquare = nullptr;
if (_defaultProjImage != "") {
_textureWhiteSquare = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_defaultProjImage)));
@@ -30,6 +30,7 @@
#include <modules/newhorizons/util/imagesequencer.h>
#include <modules/newhorizons/util/labelparser.h>
#include <openspace/properties/numericalproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/util/updatestructures.h>
#include <modules/base/rendering/modelgeometry.h>
@@ -69,9 +70,11 @@ namespace openspace {
void textureBind();
void project();
void clearAllProjections();
properties::StringProperty _colorTexturePath;
properties::BoolProperty _performProjection;
properties::BoolProperty _clearAllProjections;
properties::IntProperty _rotationX;
properties::IntProperty _rotationY;
@@ -136,6 +139,8 @@ namespace openspace {
double _time;
bool _capture;
std::string _clearingImage;
psc _sunPosition;
@@ -87,19 +87,27 @@ namespace openspace {
RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("planetTexture", "RGB Texture")
, _heightMapTexturePath("heightMap", "Heightmap Texture")
, _normalMapTexturePath("normalMap", "Normalmap Texture")
, _projectionTexturePath("projectionTexture", "RGB Texture")
, _rotation("rotation", "Rotation", 0, 0, 360)
, _fadeProjection("fadeProjections", "Image Fading Factor", 0.f, 0.f, 1.f)
//, _fadeProjection("fadeProjections", "Image Fading Factor", 0.f, 0.f, 1.f)
, _performProjection("performProjection", "Perform Projections", true)
, _clearAllProjections("clearAllProjections", "Clear Projections", false)
, _heightExaggeration("heightExaggeration", "Height Exaggeration", 1.f, 0.f, 100.f)
, _enableNormalMapping("enableNormalMapping", "Enable Normal Mapping", true)
, _programObject(nullptr)
, _fboProgramObject(nullptr)
, _texture(nullptr)
, _textureOriginal(nullptr)
, _textureProj(nullptr)
, _textureWhiteSquare(nullptr)
, _heightMapTexture(nullptr)
, _normalMapTexture(nullptr)
, _geometry(nullptr)
, _capture(false)
, _hasHeightMap(false)
, _hasNormalMap(false)
, _clearingImage(absPath("${OPENSPACE_DATA}/scene/common/textures/clear.png"))
{
std::string name;
@@ -164,18 +172,43 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
if (success){
_projectionTexturePath = absPath(texturePath);
}
std::string heightMapPath = "";
success = dictionary.getValue("Textures.Height", heightMapPath);
if (success) {
_heightMapTexturePath = absPath(heightMapPath);
_hasHeightMap = true;
}
std::string normalMapPath = "";
success = dictionary.getValue("Textures.NormalMap", normalMapPath);
if (success) {
_normalMapTexturePath = absPath(normalMapPath);
_hasNormalMap = true;
}
addPropertySubOwner(_geometry);
addProperty(_rotation);
addProperty(_fadeProjection);
//addProperty(_fadeProjection);
addProperty(_performProjection);
addProperty(_clearAllProjections);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
addProperty(_heightMapTexturePath);
_heightMapTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
addProperty(_normalMapTexturePath);
_normalMapTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadTexture, this));
addProperty(_projectionTexturePath);
_projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadProjectionTexture, this));
addProperty(_heightExaggeration);
addProperty(_enableNormalMapping);
SequenceParser* parser;
// std::string sequenceSource;
@@ -366,7 +399,7 @@ void RenderablePlanetProjection::imageProjectGPU() {
unitFbo2.activate();
_textureOriginal->bind();
_fboProgramObject->setUniform("texture2", unitFbo2);
_fboProgramObject->setUniform("projectionFading", _fadeProjection);
//_fboProgramObject->setUniform("projectionFading", _fadeProjection);
_fboProgramObject->setUniform("ProjectorMatrix", _projectorMatrix);
_fboProgramObject->setUniform("ModelTransform" , _transform);
@@ -467,13 +500,27 @@ void RenderablePlanetProjection::attitudeParameters(double time) {
void RenderablePlanetProjection::textureBind() {
ghoul::opengl::TextureUnit unit[2];
ghoul::opengl::TextureUnit unit[4];
unit[0].activate();
_texture->bind();
_programObject->setUniform("texture1", unit[0]);
unit[1].activate();
_textureWhiteSquare->bind();
_programObject->setUniform("texture2", unit[1]);
if (_hasHeightMap) {
unit[2].activate();
_heightMapTexture->bind();
_programObject->setUniform("heightTex", unit[2]);
}
if (_hasNormalMap) {
unit[3].activate();
_normalMapTexture->bind();
_programObject->setUniform("normalTex", unit[3]);
}
}
void RenderablePlanetProjection::project(){
@@ -510,11 +557,11 @@ void RenderablePlanetProjection::project(){
}
void RenderablePlanetProjection::clearAllProjections() {
float tmp = _fadeProjection;
_fadeProjection = 1.f;
//float tmp = _fadeProjection;
//_fadeProjection = 1.f;
_projectionTexturePath = _clearingImage;
imageProjectGPU();
_fadeProjection = tmp;
//_fadeProjection = tmp;
_clearAllProjections = false;
}
@@ -548,6 +595,11 @@ void RenderablePlanetProjection::render(const RenderData& data) {
_programObject->setUniform("ViewProjection" , data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform" , _transform);
_programObject->setUniform("boresight" , _boresight);
_programObject->setUniform("_hasHeightMap", _hasHeightMap);
_programObject->setUniform("_heightExaggeration", _heightExaggeration);
_programObject->setUniform("_enableNormalMapping", _enableNormalMapping && _hasNormalMap);
setPscUniforms(*_programObject.get(), data.camera, data.position);
textureBind();
@@ -593,11 +645,10 @@ void RenderablePlanetProjection::update(const UpdateData& data) {
void RenderablePlanetProjection::loadProjectionTexture() {
_textureProj = nullptr;
if (_colorTexturePath.value() != "") {
if (_projectionTexturePath.value() != "") {
_textureProj = ghoul::io::TextureReader::ref().loadTexture(absPath(_projectionTexturePath));
if (_textureProj) {
if (_textureProj->format() == ghoul::opengl::Texture::Format::Red)
_textureProj->setSwizzleMask({ GL_RED, GL_RED, GL_RED, GL_ONE });
ghoul::opengl::convertTextureFormat(ghoul::opengl::Texture::Format::RGB, *_textureProj);
_textureProj->uploadTexture();
// TODO: AnisotropicMipMap crashes on ATI cards ---abock
//_textureProj->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
@@ -636,5 +687,25 @@ void RenderablePlanetProjection::loadTexture() {
_textureWhiteSquare->setFilter(Texture::FilterMode::Linear);
}
}
_heightMapTexture = nullptr;
if (_heightMapTexturePath.value() != "") {
_heightMapTexture = ghoul::io::TextureReader::ref().loadTexture(_heightMapTexturePath);
if (_heightMapTexture) {
ghoul::opengl::convertTextureFormat(Texture::Format::RGB, *_heightMapTexture);
_heightMapTexture->uploadTexture();
_heightMapTexture->setFilter(Texture::FilterMode::Linear);
}
}
_normalMapTexture = nullptr;
if (_normalMapTexturePath.value() != "") {
_normalMapTexture = ghoul::io::TextureReader::ref().loadTexture(_normalMapTexturePath);
if (_normalMapTexture) {
_normalMapTexture->uploadTexture();
_normalMapTexture->setFilter(Texture::FilterMode::Linear);
}
}
}
} // namespace openspace
@@ -89,9 +89,12 @@ private:
std::map<std::string, Decoder*> _fileTranslation;
properties::StringProperty _colorTexturePath;
properties::StringProperty _heightMapTexturePath;
properties::StringProperty _normalMapTexturePath;
properties::StringProperty _projectionTexturePath;
properties::IntProperty _rotation;
properties::FloatProperty _fadeProjection;
//properties::FloatProperty _fadeProjection;
properties::BoolProperty _performProjection;
properties::BoolProperty _clearAllProjections;
@@ -102,6 +105,12 @@ private:
std::unique_ptr<ghoul::opengl::Texture> _textureOriginal;
std::unique_ptr<ghoul::opengl::Texture> _textureProj;
std::unique_ptr<ghoul::opengl::Texture> _textureWhiteSquare;
std::unique_ptr<ghoul::opengl::Texture> _heightMapTexture;
std::unique_ptr<ghoul::opengl::Texture> _normalMapTexture;
properties::FloatProperty _heightExaggeration;
properties::BoolProperty _enableNormalMapping;
planetgeometry::PlanetGeometry* _geometry;
glm::vec2 _camScaling;
@@ -152,6 +161,9 @@ private:
GLuint _quad;
GLuint _vertexPositionBuffer;
bool _hasHeightMap;
bool _hasNormalMap;
std::queue<Image> imageQueue;
};
} // namespace openspace
@@ -57,7 +57,7 @@ void main() {
projected.y /= projected.w;
//invert gl coordinates
projected.x = 1 - projected.x;
projected.y = 1 - projected.y;
// projected.y = 1 - projected.y;
if((inRange(projected.x, 0, 1) && inRange(projected.y, 0, 1)) && (dot(n, boresight) < 0)) {
color = texture(projectTexture, projected.xy);
@@ -27,15 +27,20 @@ uniform vec4 objpos;
//uniform vec3 camdir; // add this for specular
uniform float time;
uniform float time;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D heightTex;
uniform sampler2D normalTex;
uniform bool _enableNormalMapping;
in vec2 vs_st;
in vec4 vs_normal;
in vec4 vs_position;
in vec4 ProjTexCoord;
uniform vec3 boresight;
uniform vec3 sun_pos;
@@ -46,12 +51,21 @@ Fragment getFragment() {
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse = texture(texture1, vs_st);
// vec4 diffuse = texture(heightTex, vs_st);
// directional lighting
vec3 origin = vec3(0.0);
vec4 spec = vec4(0.0);
// vec3 n = normalize(texture(normalTex, vs_st).xyz);
vec3 n = normalize(vs_normal.xyz);
// n = vec3(0);
// vec3 n = vec3(0);
if (_enableNormalMapping) {
n = n + normalize(texture(normalTex, vs_st).xyz);
}
//vec3 e = normalize(camdir);
vec3 l_pos = sun_pos; // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
@@ -90,6 +104,12 @@ Fragment getFragment() {
Fragment frag;
frag.color = diffuse;
// frag.color = vec4(normalize(vs_position.xyz), 1.0);
// frag.color = vec4(vec3(texture(heightTex, vs_st).r), 1.0);
// frag.color = texture(heightTex, vs_st);
// frag.color = vec4(n, 1.0);
// frag.color = test;
frag.depth = depth;
//frag.color = vec4(vs_st, 0.0, 1.0);
return frag;
@@ -24,12 +24,7 @@
#version __CONTEXT__
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
//texture projection matrix
uniform mat4 ProjectorMatrix;
#include "PowerScaling/powerScaling_vs.hglsl"
layout(location = 0) in vec4 in_position;
//in vec3 in_position;
@@ -42,11 +37,21 @@ out vec2 vs_st;
out vec4 vs_normal;
out vec4 vs_position;
out float s;
out vec4 ProjTexCoord;
#include "PowerScaling/powerScaling_vs.hglsl"
void main(){
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
//texture projection matrix
uniform mat4 ProjectorMatrix;
uniform bool _hasHeightMap;
uniform float _heightExaggeration;
uniform sampler2D heightTex;
void main() {
// Radius = 0.71492 *10^8;
// set variables
vs_st = in_st;
@@ -64,7 +69,15 @@ void main(){
vec4 raw_pos = psc_to_meter(in_position, scaling);
ProjTexCoord = ProjectorMatrix * ModelTransform * raw_pos;
if (_hasHeightMap) {
float height = texture(heightTex, in_st).r;
vec3 displacementDirection = (normalize(raw_pos.xzy));
float displacementFactor = height * _heightExaggeration * 2000;
position.xyz = position.xyz + displacementDirection * displacementFactor;
}
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
+14 -4
View File
@@ -25,14 +25,24 @@
include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
# ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablevolume.h
# ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablevolumegl.h
${CMAKE_CURRENT_SOURCE_DIR}/rawvolume.h
${CMAKE_CURRENT_SOURCE_DIR}/rawvolumereader.h
${CMAKE_CURRENT_SOURCE_DIR}/rawvolumewriter.h
${CMAKE_CURRENT_SOURCE_DIR}/textureslicevolumereader.h
${CMAKE_CURRENT_SOURCE_DIR}/lrucache.h
${CMAKE_CURRENT_SOURCE_DIR}/linearlrucache.h
${CMAKE_CURRENT_SOURCE_DIR}/volumesampler.h
${CMAKE_CURRENT_SOURCE_DIR}/volumeutils.h
)
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
# ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablevolume.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablevolumegl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rawvolume.inl
${CMAKE_CURRENT_SOURCE_DIR}/rawvolumereader.inl
${CMAKE_CURRENT_SOURCE_DIR}/rawvolumewriter.inl
${CMAKE_CURRENT_SOURCE_DIR}/textureslicevolumereader.inl
${CMAKE_CURRENT_SOURCE_DIR}/volumesampler.inl
${CMAKE_CURRENT_SOURCE_DIR}/volumeutils.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})
+91
View File
@@ -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. *
****************************************************************************************/
#ifndef __LRUCACHE_H__
#define __LRUCACHE_H__
#include <glm/glm.hpp>
#include <list>
#include <iterator>
namespace openspace {
template <typename ValueType>
class LinearLruCache {
public:
LinearLruCache(size_t capacity, size_t nIndices)
: _tracker()
, _cache(nIndices, std::make_pair(nullptr, _tracker.end()))
, _capacity(capacity) {};
bool has(size_t key) {
return _cache[key].first != nullptr;
};
void set(size_t key, ValueType value) {
auto prev = _cache[key];
if (prev.first != nullptr) {
prev.first = value;
std::list<size_t>::iterator trackerIter = prev.second;
_tracker.splice(_tracker.end(),
_tracker,
trackerIter);
}
else {
insert(key, value);
}
};
ValueType& use(size_t key) {
auto pair = _cache[key];
std::list<size_t>::iterator trackerIter = pair.second;
_tracker.splice(_tracker.end(),
_tracker,
trackerIter);
return pair.first;
};
ValueType& get(size_t key) {
return _cache[key].first;
};
void evict() {
_cache[_tracker.front()] = make_pair(nullptr, _tracker.end());
_tracker.pop_front();
};
size_t capacity() {
return _capacity;
};
private:
void insert(size_t key, const ValueType& value) {
if (_tracker.size() == _capacity) {
evict();
}
auto iter = _tracker.insert(_tracker.end(), key);
_cache[key] = std::make_pair(value, iter);
};
std::list<size_t> _tracker;
std::vector<std::pair<ValueType, typename std::list<size_t>::iterator>> _cache;
size_t _capacity;
};
}
#endif
+91
View File
@@ -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. *
****************************************************************************************/
#ifndef __LRUCACHE_H__
#define __LRUCACHE_H__
#include <glm/glm.hpp>
#include <list>
#include <iterator>
namespace openspace {
template <typename KeyType, typename ValueType, template<typename...> class ContainerType>
class LruCache {
typedef KeyType K;
public:
LruCache(size_t capacity) {
_capacity = capacity;
};
bool has(const KeyType& key) {
return (_cache.find(key) != _cache.end());
};
void set(const KeyType& key, ValueType value) {
auto prev = _cache.find(key);
if (prev != _cache.end()) {
prev->second.first = value;
std::list<KeyType>::iterator trackerIter = prev->second.second;
_tracker.splice(_tracker.end(),
_tracker,
trackerIter);
}
else {
insert(key, value);
}
};
ValueType& use(const KeyType& key) {
auto iter = _cache.find(key);
std::list<KeyType>::iterator trackerIter = iter->second.second;
_tracker.splice(_tracker.end(),
_tracker,
trackerIter);
return iter->second.first;
};
ValueType& get(const KeyType& key) {
auto iter = _cache.find(key);
return iter->second.first;
};
void evict() {
_cache.erase(_cache.find(_tracker.front()));
_tracker.pop_front();
};
size_t capacity() {
return _capacity;
};
private:
void insert(const KeyType& key, const ValueType& value) {
if (_cache.size() == _capacity) {
evict();
}
auto iter = _tracker.insert(_tracker.end(), key);
_cache[key] = std::make_pair(value, iter);
};
ContainerType<KeyType, std::pair<ValueType, typename std::list<KeyType>::iterator>> _cache;
std::list<KeyType> _tracker;
size_t _capacity;
};
}
#endif
+54
View File
@@ -0,0 +1,54 @@
/*****************************************************************************************
* *
* 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 __RAWVOLUME_H__
#define __RAWVOLUME_H__
namespace openspace {
template <typename Voxel>
class RawVolume {
public:
typedef Voxel VoxelType;
RawVolume(const glm::ivec3& dimensions);
glm::ivec3 dimensions() const;
void setDimensions(const glm::ivec3& dimensions);
VoxelType get(const glm::ivec3& coordinates) const;
VoxelType get(const size_t index) const;
void set(const glm::ivec3& coordinates, const VoxelType& value);
void set(size_t index, const VoxelType& value);
void forEachVoxel(const std::function<void(const glm::ivec3&, const VoxelType&)>& fn);
VoxelType* data();
private:
size_t coordsToIndex(const glm::ivec3& cartesian) const;
glm::ivec3 indexToCoords(size_t linear) const;
glm::ivec3 _dimensions;
std::vector<VoxelType> _data;
};
}
#include "rawvolume.inl"
#endif // __RAWVOLUME_H__
+100
View File
@@ -0,0 +1,100 @@
/*****************************************************************************************
* *
* 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/volume/volumeutils.h>
namespace openspace {
template <typename VoxelType>
RawVolume<VoxelType>::RawVolume(const glm::ivec3& dimensions)
: _dimensions(dimensions)
, _data(static_cast<size_t>(dimensions.x) *
static_cast<size_t>(dimensions.y) *
static_cast<size_t>(dimensions.z)) {}
template <typename VoxelType>
glm::ivec3 RawVolume<VoxelType>::dimensions() const {
return _dimensions;
}
template <typename VoxelType>
void RawVolume<VoxelType>::setDimensions(const glm::ivec3& dimensions) {
_dimensions = dimensions;
_data.resize(static_cast<size_t>(dimensions.x) *
static_cast<size_t>(dimensions.y) *
static_cast<size_t>(dimensions.z));
}
template <typename VoxelType>
VoxelType RawVolume<VoxelType>::get(const glm::ivec3& coordinates) const {
return get(coordsToIndex(coordinates, dimensions()));
}
template <typename VoxelType>
VoxelType RawVolume<VoxelType>::get(size_t index) const {
return _data[index];
}
template <typename VoxelType>
void RawVolume<VoxelType>::set(const glm::ivec3& coordinates, const VoxelType& value) {
return set(coordsToIndex(coordinates, dimensions()), value);
}
template <typename VoxelType>
void RawVolume<VoxelType>::set(size_t index, const VoxelType& value) {
_data[index] = value;
}
template <typename VoxelType>
void RawVolume<VoxelType>::forEachVoxel(
const std::function<void(const glm::ivec3&, const VoxelType&)>& fn)
{
glm::ivec3 dims = dimensions();
size_t nVals = static_cast<size_t>(dims.x) *
static_cast<size_t>(dims.y) *
static_cast<size_t>(dims.z);
for (size_t i = 0; i < nVals; i++) {
glm::ivec3 coords = indexToCoords(i);
fn(coords, _data[i]);
}
}
template <typename VoxelType>
size_t RawVolume<VoxelType>::coordsToIndex(const glm::ivec3& cartesian) const {
return volumeutils::coordsToIndex(cartesian, dimensions());
}
template <typename VoxelType>
glm::ivec3 RawVolume<VoxelType>::indexToCoords(size_t linear) const {
return volumeutils::indexToCoords(linear, dimensions());
}
template <typename VoxelType>
VoxelType* RawVolume<VoxelType>::data() {
return _data.data();
}
}
+56
View 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 __RAWVOLUMEREADER_H__
#define __RAWVOLUMEREADER_H__
#include <functional>
#include <modules/volume/rawvolume.h>
namespace openspace {
template <typename Voxel>
class RawVolumeReader {
public:
typedef Voxel VoxelType;
RawVolumeReader(const std::string& path, const glm::ivec3& dimensions);
glm::ivec3 dimensions() const;
std::string path() const;
void setPath(const std::string& path);
void setDimensions(const glm::ivec3& dimensions);
//VoxelType get(const glm::ivec3& coordinates) const; // TODO: Implement this
//VoxelType get(const size_t index) const; // TODO: Implement this
std::unique_ptr<RawVolume<VoxelType>> read();
private:
size_t coordsToIndex(const glm::ivec3& cartesian) const;
glm::ivec3 indexToCoords(size_t linear) const;
glm::ivec3 _dimensions;
std::string _path;
};
}
#include "rawvolumereader.inl"
#endif // __RAWVOLUMEREADER_H__
+73
View File
@@ -0,0 +1,73 @@
#include <fstream>
namespace openspace {
template <typename VoxelType>
RawVolumeReader<VoxelType>::RawVolumeReader(const std::string& path,
const glm::ivec3& dimensions)
: _path(path)
, _dimensions(dimensions) {}
template <typename VoxelType>
glm::ivec3 RawVolumeReader<VoxelType>::dimensions() const {
return _dimensions;
}
template <typename VoxelType>
void RawVolumeReader<VoxelType>::setDimensions(const glm::ivec3& dimensions) {
_dimensions = dimensions;
}
template <typename VoxelType>
std::string RawVolumeReader<VoxelType>::path() const {
return _path;
}
template <typename VoxelType>
void RawVolumeReader<VoxelType>::setPath(const std::string& path) {
_path = path;
}
/*
TODO: Implement these methods for random access in raw volume file
template <typename VoxelType>
VoxelType RawVolumeReader<VoxelType>::get(const glm::ivec3& coordinates) const {
return get(coordsToIndex(coordinates, dimensions()));
}
template <typename VoxelType>
VoxelType RawVolumeReader<VoxelType>::get(size_t index) const {
// TODO: read from specific position.
return VoxelType();
}*/
template <typename VoxelType>
size_t RawVolumeReader<VoxelType>::coordsToIndex(const glm::ivec3& cartesian) const {
return volumeutils::coordsToIndex(cartesian, dimensions());
}
template <typename VoxelType>
glm::ivec3 RawVolumeReader<VoxelType>::indexToCoords(size_t linear) const {
return volumeutils::indexToCoords(linear, dimensions());
}
template <typename VoxelType>
std::unique_ptr<RawVolume<VoxelType>> RawVolumeReader<VoxelType>::read() {
glm::ivec3 dims = dimensions();
std::unique_ptr<RawVolume<VoxelType>> volume =
std::make_unique<RawVolume<VoxelType>>(dims);
std::ifstream file(_path, std::ios::binary);
char *buffer = reinterpret_cast<char*>(volume->data());
size_t length = static_cast<size_t>(dims.x) *
static_cast<size_t>(dims.y) *
static_cast<size_t>(dims.z) *
sizeof(VoxelType);
file.read(buffer, length);
return volume;
}
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef __RAWVOLUMEWRITER_H__
#define __RAWVOLUMEWRITER_H__
#include <functional>
#include <string>
#include <modules/volume/rawvolume.h>
namespace openspace {
template <typename VoxelType>
class RawVolumeWriter {
public:
RawVolumeWriter(std::string path, size_t bufferSize = 1024);
void setPath(const std::string& path);
glm::ivec3 dimensions() const;
void setDimensions(const glm::ivec3& dimensions);
void write(const std::function<VoxelType(const glm::ivec3&)>& fn,
const std::function<void(float t)>& onProgress = [](float t) {});
void write(const RawVolume<VoxelType>& volume);
size_t coordsToIndex(const glm::ivec3& coords) const;
glm::ivec3 indexToCoords(size_t linear) const;
private:
glm::ivec3 _dimensions;
std::string _path;
size_t _bufferSize;
};
}
#include "rawvolumewriter.inl";
#endif
+80
View File
@@ -0,0 +1,80 @@
#include <fstream>
#include <modules/volume/volumeutils.h>
namespace openspace {
template <typename VoxelType>
RawVolumeWriter<VoxelType>::RawVolumeWriter(std::string path, size_t bufferSize)
: _path(path)
, _bufferSize(bufferSize) {}
template <typename VoxelType>
size_t RawVolumeWriter<VoxelType>::coordsToIndex(const glm::ivec3& cartesian) const {
return volumeutils::coordsToIndex(cartesian, dimensions());
}
template <typename VoxelType>
glm::ivec3 RawVolumeWriter<VoxelType>::indexToCoords(size_t linear) const {
return volumeutils::indexToCoords(linear, dimensions());
}
template <typename VoxelType>
void RawVolumeWriter<VoxelType>::setDimensions(const glm::ivec3& dimensions) {
_dimensions = dimensions;
}
template <typename VoxelType>
glm::ivec3 RawVolumeWriter<VoxelType>::dimensions() const {
return _dimensions;
}
template <typename VoxelType>
void RawVolumeWriter<VoxelType>::write(const std::function<VoxelType(const glm::ivec3&)>& fn,
const std::function<void(float t)>& onProgress)
{
glm::ivec3 dims = dimensions();
size_t size = static_cast<size_t>(dims.x) *
static_cast<size_t>(dims.y) *
static_cast<size_t>(dims.z);
std::vector<VoxelType> buffer(_bufferSize);
std::ofstream file(_path, std::ios::binary);
int nChunks = size / _bufferSize;
if (size % _bufferSize > 0) {
nChunks++;
}
size_t i = 0;
for (int c = 0; c < nChunks; c++) {
size_t bufferPos = 0;
size_t bufferSize = std::min(_bufferSize, size - i);
for (bufferPos = 0; bufferPos < bufferSize; bufferPos++, i++) {
buffer[bufferPos] = fn(indexToCoords(i));
}
file.write(reinterpret_cast<char*>(buffer.data()), bufferSize * sizeof(VoxelType));
onProgress(static_cast<float>(c + 1) / nChunks);
}
file.close();
}
template <typename VoxelType>
void RawVolumeWriter<VoxelType>::write(const RawVolume<VoxelType>& volume) {
glm::ivec3 dims = dimensions();
ghoul_assert(dims == volume.dims(), "Dimensions of input and output volume must agree");
const char* buffer = reinterpret_cast<char*>(volume.data());
size_t length = static_cast<size_t>(dims.x) *
static_cast<size_t>(dims.y) *
static_cast<size_t>(dims.z) *
sizeof(VoxelType);
std::ofstream file(_path, std::ios::binary);
file.write(buffer, length);
file.close();
}
}
+34
View File
@@ -0,0 +1,34 @@
#ifndef __TEXTURESLICEVOLUMEREADER_H__
#define __TEXTURESLICEVOLUMEREADER_H__
#include <vector>
#include <ghoul/opengl/texture.h>
#include <memory>
#include <modules/volume/linearlrucache.h>
#include <map>
#include <unordered_map>
namespace openspace {
template <typename Voxel>
class TextureSliceVolumeReader {
public:
typedef Voxel VoxelType;
TextureSliceVolumeReader(std::vector<std::string> paths, size_t sliceCacheMaxItems, size_t sliceCacheSize);
VoxelType get(const glm::ivec3& coordinates) const;
virtual glm::ivec3 dimensions() const;
void setPaths(const std::vector<std::string> paths);
void initialize();
private:
ghoul::opengl::Texture& getSlice(int sliceIndex) const;
std::vector<std::string> _paths;
mutable LinearLruCache<std::shared_ptr<ghoul::opengl::Texture>> _cache;
glm::ivec2 _sliceDimensions;
bool _initialized;
};
}
#include "textureslicevolumereader.inl"
#endif // __TEXTURESLICEVOLUME_H__
@@ -0,0 +1,58 @@
#include <ghoul/io/texture/texturereader.h>
namespace openspace {
template <typename VoxelType>
VoxelType TextureSliceVolumeReader<VoxelType>::get(const glm::ivec3& coordinates) const {
ghoul::opengl::Texture& slice = getSlice(coordinates.z);
return slice.texel<VoxelType>(coordinates.xy());
}
template <typename VoxelType>
glm::ivec3 TextureSliceVolumeReader<VoxelType>::dimensions() const {
return glm::ivec3(_sliceDimensions, _paths.size());
}
template <typename VoxelType>
TextureSliceVolumeReader<VoxelType>::TextureSliceVolumeReader(std::vector<std::string> paths,
size_t sliceCacheNIndices,
size_t sliceCacheCapacity)
: _initialized(false)
, _paths(paths)
, _cache(sliceCacheCapacity, sliceCacheNIndices) {}
template <typename VoxelType>
void TextureSliceVolumeReader<VoxelType>::initialize() {
ghoul_assert(_paths.size() > 0, "No paths to read slices from.");
std::shared_ptr<ghoul::opengl::Texture> firstSlice =
ghoul::io::TextureReader::ref().loadTexture(_paths[0]);
_sliceDimensions = firstSlice->dimensions().xy();
_initialized = true;
_cache.set(0, firstSlice);
}
template <typename VoxelType>
void TextureSliceVolumeReader<VoxelType>::setPaths(const std::vector<std::string> paths) {
_paths = paths;
}
template <typename VoxelType>
ghoul::opengl::Texture& TextureSliceVolumeReader<VoxelType>::getSlice(int sliceIndex) const {
ghoul_assert(_initialized, "Volume is not initialized");
ghoul_assert(sliceIndex >= 0 && sliceIndex < _paths.size(),
"Slice index " + std::to_string(sliceIndex) + "is outside the range.");
if (!_cache.has(sliceIndex)) {
std::shared_ptr<ghoul::opengl::Texture> texture =
ghoul::io::TextureReader::ref().loadTexture(_paths[sliceIndex]);
glm::ivec2 dims = texture->dimensions().xy();
ghoul_assert(dims == _sliceDimensions, "Slice dimensions do not agree.");
_cache.set(sliceIndex, std::move(texture));
}
return *_cache.get(sliceIndex).get();
}
}
-2
View File
@@ -40,8 +40,6 @@ VolumeModule::VolumeModule()
void VolumeModule::internalInitialize() {
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "No renderable factory existed");
//fRenderable->registerClass<RenderableVolumeGL>("RenderableVolumeGL");
}
} // namespace openspace
+20
View File
@@ -0,0 +1,20 @@
#ifndef __VOLUMESAMPLER_H__
#define __VOLUMESAMPLER_H__
namespace openspace {
template <typename VolumeType>
class VolumeSampler {
public:
VolumeSampler(const VolumeType& volume, const glm::vec3& filterSize);
typename VolumeType::VoxelType sample(const glm::vec3& position) const;
private:
glm::ivec3 _filterSize;
const VolumeType* _volume;
};
}
#include "volumesampler.inl"
#endif
+57
View File
@@ -0,0 +1,57 @@
namespace openspace {
template <typename VolumeType>
VolumeSampler<VolumeType>::VolumeSampler(const VolumeType& volume, const glm::vec3& filterSize) {
// Only accept filter sizes of size 1, 3, 5, 7...
// Round down to closest odd number.
_filterSize = static_cast<glm::ivec3>((filterSize - glm::vec3(1.0)) * glm::vec3(0.5)) *
glm::ivec3(2) + glm::ivec3(1);
_volume = &volume;
}
template <typename VolumeType>
typename VolumeType::VoxelType VolumeSampler<VolumeType>::sample(const glm::vec3& position) const {
glm::ivec3 flooredPos = static_cast<glm::ivec3>(glm::floor(position));
glm::vec3 t = glm::fract(position);
// t is now in interval [0, 1[ (never 1)
glm::ivec3 minCoords = flooredPos - _filterSize / 2; // min coord to sample from
glm::ivec3 maxCoords = minCoords + _filterSize; // max coords to sample from, including interpolation.
glm::ivec3 clampCeiling = _volume->dimensions() - glm::ivec3(1);
typename VolumeType::VoxelType value;
for (int z = minCoords.z; z <= maxCoords.z; z++) {
for (int y = minCoords.y; y <= maxCoords.y; y++) {
for (int x = minCoords.x; x <= maxCoords.x; x++) {
glm::ivec3 sampleCoords = glm::ivec3(x, y, z);
float filterCoefficient = 1.0;
if (x == minCoords.x) {
filterCoefficient *= (1.0 - t.x);
} else if (x == maxCoords.x) {
filterCoefficient *= t.x;
}
if (y == minCoords.y) {
filterCoefficient *= (1.0 - t.y);
} else if (y == maxCoords.y) {
filterCoefficient *= t.y;
}
if (z == minCoords.z) {
filterCoefficient *= (1.0 - t.z);
} else if (z == maxCoords.z) {
filterCoefficient *= t.z;
}
glm::ivec3 clampedCoords = glm::clamp(sampleCoords, glm::ivec3(0), clampCeiling);
value += filterCoefficient * _volume->get(clampedCoords);
}
}
}
value /= static_cast<float>(_filterSize.x * _filterSize.y * _filterSize.z);
return value;
}
}
+31
View File
@@ -0,0 +1,31 @@
#include "volumeutils.h"
namespace openspace {
namespace volumeutils {
size_t coordsToIndex(const glm::vec3& coords, const glm::ivec3& dims) {
size_t w = dims.x;
size_t h = dims.y;
size_t d = dims.z;
size_t x = coords.x;
size_t y = coords.y;
size_t z = coords.z;
return coords.z * (h * w) + coords.y * w + coords.x;
}
glm::vec3 indexToCoords(size_t index, const glm::ivec3& dims) {
size_t w = dims.x;
size_t h = dims.y;
size_t d = dims.z;
size_t x = index % w;
size_t y = (index / w) % h;
size_t z = index / w / h;
return glm::ivec3(x, y, z);
}
}
}
+39
View File
@@ -0,0 +1,39 @@
/*****************************************************************************************
* *
* 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 __VOLUMEUTILS_H__
#define __VOLUMEUTILS_H__
#include <glm/glm.hpp>
namespace openspace {
namespace volumeutils {
size_t coordsToIndex(const glm::vec3& coords, const glm::ivec3& dimensions);
glm::vec3 indexToCoords(size_t index, const glm::ivec3& dimensions);
}
}
#endif // __VOLUMEUTILS__
+91
View File
@@ -0,0 +1,91 @@
--[[ OpenSpace keybinding script ]]--
-- This script sets the default keybindings and is executed at startup
openspace.clearKeys()
openspace.bindKey("F1", "openspace.gui.toggle()")
openspace.bindKey("F2", "openspace.setPerformanceMeasurement(true)")
openspace.bindKey("F3", "openspace.setPerformanceMeasurement(false)")
openspace.bindKey("F5", "openspace.setPropertyValue('Interaction.coordinateSystem', 'Sun'); openspace.printInfo('Changing Viewpoint to Sun-in-center');");
openspace.bindKey("F6", "openspace.setPropertyValue('Interaction.coordinateSystem', 'Jupiter'); openspace.printInfo('Changing Viewpoint to Jupiter-in-center');");
openspace.bindKey("F7", "openspace.setPropertyValue('Interaction.coordinateSystem', 'Pluto'); openspace.printInfo('Changing Viewpoint to Pluto-in-center');");
openspace.bindKey("PRINT_SCREEN", "openspace.takeScreenshot()")
openspace.bindKey("SPACE", "openspace.time.togglePause()")
-- Bookmarks for the New Horizons encounter
openspace.bindKey("1", "openspace.time.setDeltaTime(1)")
openspace.bindKey("2", "openspace.time.setDeltaTime(5)")
openspace.bindKey("3", "openspace.time.setDeltaTime(10)")
openspace.bindKey("4", "openspace.time.setDeltaTime(20)")
openspace.bindKey("5", "openspace.time.setDeltaTime(40)")
openspace.bindKey("6", "openspace.time.setDeltaTime(60)")
openspace.bindKey("7", "openspace.time.setDeltaTime(120)")
openspace.bindKey("8", "openspace.time.setDeltaTime(360)")
openspace.bindKey("9", "openspace.time.setDeltaTime(540)")
openspace.bindKey("9", "openspace.time.setDeltaTime(1080)")
openspace.bindKey("F8", "openspace.setPropertyValue('PlutoProjection.renderable.clearAllProjections', true); openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);")
-- Quickfix backjumps in pluto sequence
openspace.bindKey("F9", "openspace.time.setTime('2015-07-14T09:00:00.00'); openspace.setPropertyValue('PlutoProjection.renderable.clearAllProjections', true); openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);")
openspace.bindKey("F10", "openspace.time.setTime('2015-07-14T10:00:00.00'); openspace.setPropertyValue('PlutoProjection.renderable.clearAllProjections', true); openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);")
openspace.bindKey("F11", "openspace.time.setTime('2015-07-14T11:17:00.00'); openspace.setPropertyValue('PlutoProjection.renderable.clearAllProjections', true); openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);")
openspace.bindKey("F12", "openspace.time.setTime('2015-07-14T12:45:00.00'); openspace.setPropertyValue('PlutoProjection.renderable.clearAllProjections', true); openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);")
openspace.bindKey("r", "local b = openspace.getPropertyValue('PlutoProjection.renderable.fk'); openspace.setPropertyValue('PlutoProjection.renderable.fk', not b)")
openspace.bindKey("a", "openspace.setPropertyValue('Interaction.origin', 'NewHorizons')")
openspace.bindKey("s", "openspace.setPropertyValue('Interaction.origin', 'PlutoProjection')")
openspace.bindKey("d", "openspace.setPropertyValue('Interaction.origin', 'Charon')")
openspace.bindKey("z", "openspace.setPropertyValue('Interaction.origin', 'JupiterProjection')")
openspace.bindKey("x", "openspace.setPropertyValue('Interaction.origin', 'Europa')")
openspace.bindKey("g", "openspace.time.setTime('2007-02-28T11:40:00.00'); openspace.time.setDeltaTime(1);")
openspace.bindKey("h", "openspace.time.setTime('2015-07-14T10:00:00.00'); openspace.time.setDeltaTime(1); openspace.setPropertyValue('Interaction.coordinateSystem', 'Pluto');openspace.setPropertyValue('Interaction.origin', 'PlutoProjection'); openspace.printInfo('Changing Viewpoint to Pluto-in-center');")
openspace.bindKey("i", "local b = openspace.getPropertyValue('PlutoTexture.renderable.enabled'); openspace.setPropertyValue('PlutoTexture.renderable.enabled', not b)")
openspace.bindKey("q", "local b = openspace.getPropertyValue('SunMarker.renderable.enabled'); openspace.setPropertyValue('SunMarker.renderable.enabled', not b)")
openspace.bindKey("e", "local b = openspace.getPropertyValue('EarthMarker.renderable.enabled'); openspace.setPropertyValue('EarthMarker.renderable.enabled', not b)")
openspace.bindKey("o", "local b = openspace.getPropertyValue('PlutoTrail.renderable.enabled'); openspace.setPropertyValue('PlutoTrail.renderable.enabled', not b)")
openspace.bindKey("k", "local b = openspace.getPropertyValue('HydraText.renderable.enabled'); openspace.setPropertyValue('HydraText.renderable.enabled', not b)")
openspace.bindKey("k", "local b = openspace.getPropertyValue('CharonText.renderable.enabled'); openspace.setPropertyValue('CharonText.renderable.enabled', not b)")
openspace.bindKey("k", "local b = openspace.getPropertyValue('NixText.renderable.enabled'); openspace.setPropertyValue('NixText.renderable.enabled', not b)")
openspace.bindKey("k", "local b = openspace.getPropertyValue('KerberosText.renderable.enabled'); openspace.setPropertyValue('KerberosText.renderable.enabled', not b)")
openspace.bindKey("k", "local b = openspace.getPropertyValue('StyxText.renderable.enabled'); openspace.setPropertyValue('StyxText.renderable.enabled', not b)")
openspace.bindKey("j", "local b = openspace.getPropertyValue('PlutoText.renderable.enabled'); openspace.setPropertyValue('PlutoText.renderable.enabled', not b)")
openspace.bindKey("l", "local b = openspace.getPropertyValue('Labels.renderable.performFading'); openspace.setPropertyValue('Labels.renderable.performFading', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_LORRI.renderable.solidDraw'); openspace.setPropertyValue('NH_LORRI.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_LEISA.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_LEISA.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_PAN1.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_PAN1.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_PAN2.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_PAN2.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_RED.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_RED.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_BLUE.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_BLUE.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_FT.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_FT.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_METHANE.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_METHANE.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_RALPH_MVIC_NIR.renderable.solidDraw'); openspace.setPropertyValue('NH_RALPH_MVIC_NIR.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_ALICE_AIRGLOW.renderable.solidDraw'); openspace.setPropertyValue('NH_ALICE_AIRGLOW.renderable.solidDraw', not b)")
openspace.bindKey("m", "local b = openspace.getPropertyValue('NH_ALICE_SOC.renderable.solidDraw'); openspace.setPropertyValue('NH_ALICE_SOC.renderable.solidDraw', not b)")
openspace.bindKey("t", "local b = openspace.getPropertyValue('PlutoShadow.renderable.enabled'); openspace.setPropertyValue('PlutoShadow.renderable.enabled', not b)")
openspace.bindKey("t", "local b = openspace.getPropertyValue('CharonShadow.renderable.enabled'); openspace.setPropertyValue('CharonShadow.renderable.enabled', not b)")
openspace.bindKey("p", "local b = openspace.getPropertyValue('JupiterProjection.renderable.performProjection'); openspace.setPropertyValue('JupiterProjection.renderable.performProjection', not b)")
openspace.bindKey("p", "local b = openspace.getPropertyValue('Io.renderable.performProjection'); openspace.setPropertyValue('Io.renderable.performProjection', not b)")
openspace.bindKey("p", "local b = openspace.getPropertyValue('Ganymede.renderable.performProjection'); openspace.setPropertyValue('Ganymede.renderable.performProjection', not b)")
openspace.bindKey("p", "local b = openspace.getPropertyValue('Europa.renderable.performProjection'); openspace.setPropertyValue('Europa.renderable.performProjection', not b)")
openspace.bindKey("p", "local b = openspace.getPropertyValue('Callisto.renderable.performProjection'); openspace.setPropertyValue('Callisto.renderable.performProjection', not b)")
openspace.bindKey("p", "local b = openspace.getPropertyValue('PlutoProjection.renderable.performProjection'); openspace.setPropertyValue('PlutoProjection.renderable.performProjection', not b)")
openspace.bindKey("p", "local b = openspace.getPropertyValue('Charon.renderable.performProjection'); openspace.setPropertyValue('Charon.renderable.performProjection', not b)")
openspace.bindKey("c", "openspace.parallel.setAddress('130.236.142.51');openspace.parallel.setPassword('newhorizons-20150714');openspace.parallel.connect();")
openspace.bindKey("COMMA", "openspace.setRenderer('Framebuffer');")
openspace.bindKey("PERIOD", "openspace.setRenderer('ABuffer');")
+45
View File
@@ -0,0 +1,45 @@
--[[ OpenSpace keybinding script ]]--
-- This script sets the default keybindings and is executed at startup
openspace.clearKeys()
openspace.bindKey("F1", "openspace.gui.toggle()")
openspace.bindKey("F2", "openspace.setPerformanceMeasurement(true)")
openspace.bindKey("F3", "openspace.setPerformanceMeasurement(false)")
openspace.bindKey("F5", "openspace.setPropertyValue('Interaction.coordinateSystem', 'Sun'); openspace.printInfo('Changing Viewpoint to Sun-in-center');");
openspace.bindKey("F6", "openspace.setPropertyValue('Interaction.coordinateSystem', '67P'); openspace.printInfo('Changing Viewpoint to 67P-in-center');");
openspace.bindKey("PRINT_SCREEN", "openspace.takeScreenshot()")
openspace.bindKey("SPACE", "openspace.time.togglePause()")
-- Bookmarks for the New Horizons encounter
openspace.bindKey("1", "openspace.time.setDeltaTime(1)")
openspace.bindKey("2", "openspace.time.setDeltaTime(5)")
openspace.bindKey("3", "openspace.time.setDeltaTime(10)")
openspace.bindKey("4", "openspace.time.setDeltaTime(20)")
openspace.bindKey("5", "openspace.time.setDeltaTime(40)")
openspace.bindKey("6", "openspace.time.setDeltaTime(90)")
openspace.bindKey("7", "openspace.time.setDeltaTime(360)")
openspace.bindKey("8", "openspace.time.setDeltaTime(720)")
openspace.bindKey("9", "openspace.time.setDeltaTime(2880)")
openspace.bindKey("0", "openspace.time.setDeltaTime(14400)")
openspace.bindKey("SHIFT+1", "openspace.time.setDeltaTime(28800)")
openspace.bindKey("SHIFT+2", "openspace.time.setDeltaTime(57600)")
openspace.bindKey("SHIFT+3", "openspace.time.setDeltaTime(115200)")
openspace.bindKey("SHIFT+4", "openspace.time.setDeltaTime(230400)")
openspace.bindKey("SHIFT+5", "openspace.time.setDeltaTime(460800)")
openspace.bindKey("i", "local b = openspace.getPropertyValue('ImagePlaneRosetta.renderable.enabled'); openspace.setPropertyValue('ImagePlaneRosetta.renderable.enabled', not b)")
openspace.bindKey("F8", "openspace.setPropertyValue('PlutoProjection.renderable.clearAllProjections', true); openspace.setPropertyValue('Charon.renderable.clearAllProjections', true);")
openspace.bindKey("a", "openspace.setPropertyValue('Interaction.origin', '67P')")
openspace.bindKey("s", "openspace.setPropertyValue('Interaction.origin', 'Rosetta')")
openspace.bindKey("q", "local b = openspace.getPropertyValue('SunMarker.renderable.enabled'); openspace.setPropertyValue('SunMarker.renderable.enabled', not b)")
openspace.bindKey("e", "local b = openspace.getPropertyValue('EarthMarker.renderable.enabled'); openspace.setPropertyValue('EarthMarker.renderable.enabled', not b)")
openspace.bindKey("c", "openspace.parallel.setAddress('130.236.142.51');openspace.parallel.setPassword('newhorizons-20150714');openspace.parallel.connect();")
openspace.bindKey("COMMA", "openspace.setRenderer('Framebuffer');")
openspace.bindKey("PERIOD", "openspace.setRenderer('ABuffer');")
+2 -9
View File
@@ -28,6 +28,7 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/assert.h>
#include <stdio.h>
#include <ghoul/misc/thread.h>
#include <chrono>
#include <fstream>
#include <thread>
@@ -415,15 +416,7 @@ void DownloadManager::downloadRequestFilesAsync(const std::string& identifier,
if (_useMultithreadedDownload) {
std::thread t = std::thread(downloadFunction);
#ifdef WIN32
std::thread::native_handle_type h = t.native_handle();
SetPriorityClass(h, IDLE_PRIORITY_CLASS);
SetThreadPriority(h, THREAD_PRIORITY_LOWEST);
#else
// TODO: Implement thread priority ---abock
#endif
ghoul::thread::setPriority(t, ghoul::thread::ThreadPriority::Lowest);
t.detach();
}
else
+30 -22
View File
@@ -197,7 +197,7 @@ bool RenderEngine::initialize() {
// init camera and set temporary position and scaling
_mainCamera = new Camera();
_mainCamera->setScaling(glm::vec2(1.0, -8.0));
_mainCamera->setPosition(psc(0.f, 0.f, 1.499823f, 11.f));
_mainCamera->setPosition(psc(0.5f, 0.f, 1.499823f, 11.f));
OsEng.interactionHandler().setCamera(_mainCamera);
if (_renderer) {
@@ -1225,33 +1225,38 @@ void RenderEngine::renderInformation() {
);
#ifdef OPENSPACE_MODULE_NEWHORIZONS_ENABLED
bool hasNewHorizons = scene()->sceneGraphNode("NewHorizons");
if (openspace::ImageSequencer::ref().isReady()) {
penPosition.y -= 25.f;
glm::vec4 targetColor(0.00, 0.75, 1.00, 1);
try {
double lt;
glm::dvec3 p =
SpiceManager::ref().targetPosition("PLUTO", "NEW HORIZONS", "GALACTIC", {}, currentTime, lt);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
float a, b, c;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = radii.x;
b = radii.y;
c = radii.z;
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
if (hasNewHorizons) {
try {
double lt;
glm::dvec3 p =
SpiceManager::ref().targetPosition("PLUTO", "NEW HORIZONS", "GALACTIC", {}, currentTime, lt);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
float a, b, c;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = radii.x;
b = radii.y;
c = radii.z;
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
RenderFont(*_fontInfo,
penPosition,
"Distance to Pluto: % .1f (KM)",
distToSurf
RenderFont(*_fontInfo,
penPosition,
"Distance to Pluto: % .1f (KM)",
distToSurf
);
penPosition.y -= _fontInfo->height();
penPosition.y -= _fontInfo->height();
}
catch (...) {
}
}
catch (...) {}
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - currentTime;
float t = static_cast<float>(1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength());
@@ -1324,8 +1329,10 @@ void RenderEngine::renderInformation() {
hh.c_str(), mm.c_str(), ss.c_str()
);
std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(2);
#if 0
// Why is it (2) in the original? ---abock
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(0);
//std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer::ref().getIncidentTargetList(2);
std::string space;
glm::vec4 color;
size_t isize = incidentTargets.second.size();
@@ -1346,6 +1353,7 @@ void RenderEngine::renderInformation() {
for (int k = 0; k < incidentTargets.second[p].size() + 2; k++)
space += " ";
}
#endif
penPosition.y -= _fontInfo->height();
std::map<std::string, bool> activeMap = ImageSequencer::ref().getActiveInstruments();