Merged develop branch into PlanetShadows.
2
.gitignore
vendored
@@ -116,6 +116,8 @@ data/scene/dawn/vestaprojection/textures/projectMe.png
|
||||
data/spice/MAR063.BSP
|
||||
data/spice/de430_1850-2150.bsp
|
||||
data/spice/jup260.bsp
|
||||
data/BATSRUS.cdf
|
||||
data/ENLIL.cdf
|
||||
data/scene/newhorizons/pluto/pluto/images
|
||||
data/spice/nh_kernels/
|
||||
data/scene/jupiter/jupiter/textures/Jupiter-text.png
|
||||
|
||||
@@ -27,6 +27,8 @@ cmake_minimum_required (VERSION 3.0 FATAL_ERROR)
|
||||
project (OpenSpace)
|
||||
message(STATUS "Generating OpenSpace project")
|
||||
|
||||
set(BOOST_ROOT "G:/deps/bin/boost_1_60_0")
|
||||
|
||||
set(OPENSPACE_BASE_DIR "${PROJECT_SOURCE_DIR}")
|
||||
set(OPENSPACE_APPS_DIR "${OPENSPACE_BASE_DIR}/apps")
|
||||
set(OPENSPACE_EXT_DIR "${OPENSPACE_BASE_DIR}/ext")
|
||||
|
||||
47
apps/DataConverter/CMakeLists.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
#########################################################################################
|
||||
# #
|
||||
# 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
|
||||
${application_path}/milkywaypointsconversiontask.cpp
|
||||
)
|
||||
set(HEADER_FILES
|
||||
${application_path}/conversiontask.h
|
||||
${application_path}/milkywayconversiontask.h
|
||||
${application_path}/milkywaypointsconversiontask.h
|
||||
)
|
||||
|
||||
add_executable(${APPLICATION_NAME} MACOSX_BUNDLE
|
||||
${SOURCE_FILES}
|
||||
${HEADER_FILES}
|
||||
)
|
||||
|
||||
17
apps/DataConverter/conversiontask.h
Normal 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
|
||||
83
apps/DataConverter/main.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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>
|
||||
#include <apps/DataConverter/milkywaypointsconversiontask.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:/mw_june2016/volumeslices/img/comp/v003/frames/primary/0100/cam2_main.",
|
||||
".exr",
|
||||
1385,
|
||||
512,
|
||||
"F:/mw_june2016/mw_512_512_64_june.rawvolume",
|
||||
glm::vec3(512, 512, 64));
|
||||
|
||||
//MilkyWayPointsConversionTask mwpConversionTask("F:/mw_june2016/points.off", "F:/mw_june2016/points.off.binary");
|
||||
|
||||
|
||||
mwConversionTask.perform(onProgress);
|
||||
//mwpConversionTask.perform(onProgress);
|
||||
|
||||
|
||||
std::cout << "Done." << std::endl;
|
||||
|
||||
std::cin.get();
|
||||
return 0;
|
||||
};
|
||||
50
apps/DataConverter/milkywayconversiontask.cpp
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
41
apps/DataConverter/milkywayconversiontask.h
Normal file
@@ -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
|
||||
62
apps/DataConverter/milkywaypointsconversiontask.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <apps/DataConverter/milkywaypointsconversiontask.h>
|
||||
#include <modules/volume/textureslicevolumereader.h>
|
||||
#include <modules/volume/rawvolumewriter.h>
|
||||
#include <modules/volume/volumesampler.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace openspace {
|
||||
namespace dataconverter {
|
||||
|
||||
|
||||
|
||||
MilkyWayPointsConversionTask::MilkyWayPointsConversionTask(
|
||||
const std::string& inFilename,
|
||||
const std::string& outFilename)
|
||||
: _inFilename(inFilename)
|
||||
, _outFilename(outFilename) {}
|
||||
|
||||
|
||||
void MilkyWayPointsConversionTask::perform(const std::function<void(float)>& onProgress) {
|
||||
std::ifstream in(_inFilename, std::ios::in);
|
||||
std::ofstream out(_outFilename, std::ios::out | std::ios::binary);
|
||||
|
||||
std::string format;
|
||||
int64_t nPoints;
|
||||
in >> format >> nPoints;
|
||||
|
||||
|
||||
|
||||
size_t nFloats = nPoints * 7;
|
||||
|
||||
float* pointData = new float[nFloats];
|
||||
|
||||
float x, y, z, r, g, b, a;
|
||||
for (size_t i = 0; i < nPoints; ++i) {
|
||||
in >> x >> y >> z >> r >> g >> b >> a;
|
||||
if (in.good()) {
|
||||
pointData[i * 7 + 0] = x;
|
||||
pointData[i * 7 + 1] = y;
|
||||
pointData[i * 7 + 2] = z;
|
||||
pointData[i * 7 + 3] = r;
|
||||
pointData[i * 7 + 4] = g;
|
||||
pointData[i * 7 + 5] = b;
|
||||
pointData[i * 7 + 6] = a;
|
||||
onProgress(static_cast<float>(i + 1) / nPoints);
|
||||
} else {
|
||||
std::cout << "Failed to convert point data.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
out.write(reinterpret_cast<char*>(&nPoints), sizeof(int64_t));
|
||||
out.write(reinterpret_cast<char*>(pointData), nFloats * sizeof(float));
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
35
apps/DataConverter/milkywaypointsconversiontask.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef __MILKYWAYPOINTSCONVERSIONTASK_H__
|
||||
#define __MILKYWAYPOINTSCONVERSIONTASK_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 ascii based point data
|
||||
* int64_t n
|
||||
* (float x, float y, float z, float r, float g, float b) * n
|
||||
* to a binary (floating point) representation with the same layout.
|
||||
*/
|
||||
class MilkyWayPointsConversionTask : public ConversionTask {
|
||||
public:
|
||||
MilkyWayPointsConversionTask(const std::string& inFilename,
|
||||
const std::string& outFilename);
|
||||
|
||||
void perform(const std::function<void(float)>& onProgress) override;
|
||||
private:
|
||||
std::string _inFilename;
|
||||
std::string _outFilename;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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,7 +1,7 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false">
|
||||
<Window fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="test" />
|
||||
<!-- 16:9 aspect ratio -->
|
||||
<Size x="640" y="360" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="127.0.0.1">
|
||||
<Node address="127.0.0.1" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="0" border="true">
|
||||
<Window fullScreen="false" numberOfSamples="8" border="true">
|
||||
<Pos x="10" y="100" />
|
||||
<Size x="320" y="480" />
|
||||
<Viewport>
|
||||
@@ -17,7 +17,7 @@
|
||||
</Viewplane>
|
||||
</Viewport>
|
||||
</Window>
|
||||
<Window fullScreen="false" numberOfSamples="0" border="false">
|
||||
<Window fullScreen="false" numberOfSamples="8" border="false">
|
||||
<Pos x="340" y="100" />
|
||||
<Size x="320" y="480" />
|
||||
<Viewport>
|
||||
|
||||
32
data/cdflist.json
Normal file
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{"group" : "CCMC-3D-CDF",
|
||||
"fieldlinefile" : "${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json",
|
||||
"cdfs" : [
|
||||
{
|
||||
"name" : "CCMC-00:00:00",
|
||||
"path" : "${OPENSPACE_DATA}/../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf",
|
||||
"date" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-00:30:00",
|
||||
"path" : "${OPENSPACE_DATA}/../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf",
|
||||
"date" : "2000-01-01T00:30:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:00:00",
|
||||
"path" : "${OPENSPACE_DATA}/../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf",
|
||||
"date" : "2000-01-01T10:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:30:00",
|
||||
"path" : "${OPENSPACE_DATA}/../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf",
|
||||
"date" : "2000-01-01T01:30:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-02:00:00",
|
||||
"path" : "${OPENSPACE_DATA}/../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf",
|
||||
"date" : "2000-01-01T02:00:00.00"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
40
data/cdflist.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
{"cdfgroups" : [{
|
||||
"group" : "CCMC-3D-CDF",
|
||||
"fieldlinefile" : "${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json",
|
||||
"cdfs" : [
|
||||
{
|
||||
"name" : "CCMC-00:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf"
|
||||
"time" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-00:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf"
|
||||
"time" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf"
|
||||
"time" : "2000-01-01T10:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf"
|
||||
"time" : "2000-01-01T01:30:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-02:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf"
|
||||
"time" : "2000-01-01T02:00:00.00"
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
CCMC-3D-CDF
|
||||
${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json
|
||||
CCMC-00:00:00 ../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf 2000-01-01T00:00:00.00
|
||||
CCMC-00:30:00 ../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf 2000-01-01T00:30:00.00
|
||||
CCMC-01:00:00 ../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf 2000-01-01T01:00:00.00
|
||||
CCMC-01:30:00 ../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf 2000-01-01T01:30:00.00
|
||||
CCMC-02:00:00 ../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf 2000-01-01T02:00:00.00
|
||||
231917
data/ionosphere_variables.json
Normal file
@@ -20,14 +20,16 @@ function postInitialization()
|
||||
openspace.setPropertyValue("Sun.renderable.enabled", false)
|
||||
openspace.setPropertyValue("SunMarker.renderable.enabled", true)
|
||||
openspace.setPropertyValue("EarthMarker.renderable.enabled", true)
|
||||
--openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false)
|
||||
openspace.setPropertyValue("PlutoTrail.renderable.enabled", false)
|
||||
openspace.setPropertyValue("PlutoTexture.renderable.enabled", false)
|
||||
openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false)
|
||||
|
||||
openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.55)
|
||||
openspace.setPropertyValue("MilkyWay.renderable.segments", 50)
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
|
||||
if openspace.modules.isLoaded("ISWA") then
|
||||
openspace.iswa.addCdfFiles("${OPENSPACE_DATA}/cdflist.json");
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -36,7 +38,7 @@ return {
|
||||
CommonFolder = "common",
|
||||
Camera = {
|
||||
Focus = "Earth",
|
||||
Position = {1, 0, 0, 5},
|
||||
Position = {1, 0, 0, 2},
|
||||
},
|
||||
Modules = {
|
||||
"sun",
|
||||
@@ -49,17 +51,9 @@ return {
|
||||
"uranus",
|
||||
"neptune",
|
||||
"stars",
|
||||
-- "stars-denver",
|
||||
--"stars-denver",
|
||||
"milkyway",
|
||||
-- "milkyway-eso",
|
||||
--"constellationbounds",
|
||||
-- "fieldlines",
|
||||
--"io",
|
||||
--"europa",
|
||||
--"ganymede",
|
||||
--"callisto",
|
||||
--"gridGalactic",
|
||||
--"gridEcliptic",
|
||||
--"gridEquatorial",
|
||||
"constellationbounds",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ return {
|
||||
Textures = {
|
||||
Type = "simple",
|
||||
Color = "textures/earth_bluemarble.jpg",
|
||||
Night = "textures/earth_night.jpg",
|
||||
-- Depth = "textures/earth_depth.png"
|
||||
Night = "textures/earth_night.jpg",
|
||||
Height = "textures/earth_bluemarble_height.jpg"
|
||||
},
|
||||
Atmosphere = {
|
||||
Type = "Nishita", -- for example, values missing etc etc
|
||||
|
||||
@@ -14,6 +14,7 @@ return {
|
||||
Scaling = {1.1, 1.1, 1.1},
|
||||
ScalingExponent = 12,
|
||||
Source = "tsp/enlil_nh_128_128_16.tsp",
|
||||
ErrorHistogramsSource = "tsp/enlil_nh_128_128_16.errorHistograms",
|
||||
TransferFunction = "transferfunctions/fire.txt",
|
||||
BrickSelector = "tf",
|
||||
},
|
||||
|
||||
@@ -4,6 +4,8 @@ local file3 = '${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_open_sout
|
||||
local file4 = '${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_solar_wind_all.txt';
|
||||
local file5 = '${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_separatrix_seeds_all.txt';
|
||||
|
||||
local volumeFile = '${OPENSPACE_DATA}/batsrus.cdf';
|
||||
|
||||
return {
|
||||
{
|
||||
Name = "Fieldlines1",
|
||||
@@ -16,7 +18,7 @@ return {
|
||||
Type = "RenderableFieldlines",
|
||||
VectorField = {
|
||||
Type = "VolumeKameleon",
|
||||
File = "${OPENSPACE_DATA}/batsrus.cdf",
|
||||
File = volumeFile,
|
||||
Model = "BATSRUS",
|
||||
Variables = {"bx", "by", "bz"}
|
||||
},
|
||||
@@ -42,7 +44,7 @@ return {
|
||||
Type = "RenderableFieldlines",
|
||||
VectorField = {
|
||||
Type = "VolumeKameleon",
|
||||
File = "${OPENSPACE_DATA}/batsrus.cdf",
|
||||
File = volumeFile,
|
||||
Model = "BATSRUS",
|
||||
Variables = {"bx", "by", "bz"}
|
||||
},
|
||||
@@ -68,7 +70,7 @@ return {
|
||||
Type = "RenderableFieldlines",
|
||||
VectorField = {
|
||||
Type = "VolumeKameleon",
|
||||
File = "${OPENSPACE_DATA}/batsrus.cdf",
|
||||
File = volumeFile,
|
||||
Model = "BATSRUS",
|
||||
Variables = {"bx", "by", "bz"}
|
||||
},
|
||||
@@ -94,7 +96,7 @@ return {
|
||||
Type = "RenderableFieldlines",
|
||||
VectorField = {
|
||||
Type = "VolumeKameleon",
|
||||
File = "${OPENSPACE_DATA}/batsrus.cdf",
|
||||
File = volumeFile,
|
||||
Model = "BATSRUS",
|
||||
Variables = {"bx", "by", "bz"}
|
||||
},
|
||||
@@ -120,7 +122,7 @@ return {
|
||||
Type = "RenderableFieldlines",
|
||||
VectorField = {
|
||||
Type = "VolumeKameleon",
|
||||
File = "${OPENSPACE_DATA}/batsrus.cdf",
|
||||
File = volumeFile,
|
||||
Model = "BATSRUS",
|
||||
Variables = {"bx", "by", "bz"}
|
||||
},
|
||||
|
||||
7
data/scene/iswa/cdf/fieldlines.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"Separatrix Seeds": "${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_separatrix_seeds_all.txt",
|
||||
"Closed Seeds": "${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_closed_seeds_all.txt",
|
||||
"Open North Seeds": "${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_open_north_all.txt",
|
||||
"Open South Seeds": "${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_open_south_all.txt",
|
||||
"Solar Wind Seeds": "${OPENSPACE_DATA}/scene/fieldlines/bats_seeds/BATS_R_US_solar_wind_all.txt"
|
||||
}
|
||||
1
data/scene/iswa/tfs/autumn.tf
Normal file
@@ -0,0 +1 @@
|
||||
${SCENE}/iswa/tfs/colormap_autumn.png
|
||||
BIN
data/scene/iswa/tfs/blue.jpg
Normal file
|
After Width: | Height: | Size: 726 B |
15
data/scene/iswa/tfs/ccmc-cdf.tf
Normal file
@@ -0,0 +1,15 @@
|
||||
${SCENE}/iswa/tfs/red.jpg
|
||||
${SCENE}/iswa/tfs/green.jpg
|
||||
${SCENE}/iswa/tfs/blue.jpg
|
||||
${SCENE}/iswa/tfs/red.jpg
|
||||
${SCENE}/iswa/tfs/green.jpg
|
||||
${SCENE}/iswa/tfs/blue.jpg
|
||||
${SCENE}/iswa/tfs/red.jpg
|
||||
${SCENE}/iswa/tfs/green.jpg
|
||||
${SCENE}/iswa/tfs/blue.jpg
|
||||
${SCENE}/iswa/tfs/red.jpg
|
||||
${SCENE}/iswa/tfs/green.jpg
|
||||
${SCENE}/iswa/tfs/blue.jpg
|
||||
${SCENE}/iswa/tfs/colormap_hot.jpg
|
||||
${SCENE}/iswa/tfs/colormap_hot.jpg
|
||||
${SCENE}/iswa/tfs/colormap_hot.jpg
|
||||
BIN
data/scene/iswa/tfs/colormap_autumn.png
Normal file
|
After Width: | Height: | Size: 565 B |
BIN
data/scene/iswa/tfs/colormap_hot.jpg
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
data/scene/iswa/tfs/colormap_hot.png
Normal file
|
After Width: | Height: | Size: 613 B |
BIN
data/scene/iswa/tfs/colormap_parula.jpg
Normal file
|
After Width: | Height: | Size: 953 B |
BIN
data/scene/iswa/tfs/colormap_parula.png
Normal file
|
After Width: | Height: | Size: 846 B |
1
data/scene/iswa/tfs/default.tf
Normal file
@@ -0,0 +1 @@
|
||||
${SCENE}/iswa/tfs/colormap_hot.png
|
||||
BIN
data/scene/iswa/tfs/green.jpg
Normal file
|
After Width: | Height: | Size: 799 B |
1
data/scene/iswa/tfs/hot.tf
Normal file
@@ -0,0 +1 @@
|
||||
${SCENE}/iswa/tfs/colormap_hot.jpg
|
||||
1
data/scene/iswa/tfs/parula.tf
Normal file
@@ -0,0 +1 @@
|
||||
${SCENE}/iswa/tfs/colormap_parula.jpg
|
||||
BIN
data/scene/iswa/tfs/red.jpg
Normal file
|
After Width: | Height: | Size: 772 B |
3
data/scene/iswa/tfs/rgb.tf
Normal file
@@ -0,0 +1,3 @@
|
||||
${SCENE}/iswa/tfs/red.jpg
|
||||
${SCENE}/iswa/tfs/green.jpg
|
||||
${SCENE}/iswa/tfs/blue.jpg
|
||||
@@ -7,7 +7,7 @@ return {
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableSphere",
|
||||
Size = {10, 20},
|
||||
Size = {10, 25},
|
||||
Segments = 40,
|
||||
Texture = "textures/DarkUniverse_mellinger_8k.jpg",
|
||||
Orientation = "Inside/Outside"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
UseAccurateNewHorizonsKernels = false
|
||||
-- TextureResolution = "low"
|
||||
TextureResolution = "med"
|
||||
-- TextureResolution = "high"
|
||||
|
||||
function preInitialization()
|
||||
--[[
|
||||
@@ -8,6 +11,8 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
-- openspace.time.setTime("2007-02-28T11:40:00.000")
|
||||
|
||||
-- openspace.time.setTime("2015-07-08T15:57:45.00")
|
||||
-- openspace.time.setTime("2015-07-12T07:41:00.00")
|
||||
-- openspace.time.setTime("2015-07-12T15:43:00.00")
|
||||
@@ -16,7 +21,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()
|
||||
|
||||
@@ -39,7 +39,7 @@ return {
|
||||
},
|
||||
Projection = {
|
||||
--Sequence = "F:/JupiterFullSequence",
|
||||
Sequence = "${OPENSPACE_DATA}/scene/newhorizons/jupiter/jupiterprojection/ProjectionsOfInterest",
|
||||
Sequence = "${OPENSPACE_DATA}/scene/newhorizons/jupiter/jupiter/ProjectionsOfInterest",
|
||||
SequenceType = "image-sequence",
|
||||
Observer = "NEW HORIZONS",
|
||||
Target = "JUPITER",
|
||||
|
||||
@@ -8,6 +8,12 @@ else
|
||||
}
|
||||
end
|
||||
|
||||
Files = {
|
||||
low = "textures/charon_highres.jpg",
|
||||
med = "textures/charon_highres.jpg",
|
||||
high = "textures/cpmap_cyl_HR_0e.jpg"
|
||||
}
|
||||
ColorTexture = Files[TextureResolution]
|
||||
|
||||
return {
|
||||
-- CharonProjection module
|
||||
@@ -25,15 +31,11 @@ return {
|
||||
},
|
||||
Textures = {
|
||||
Type = "simple",
|
||||
Color = "textures/charon_highres.jpg",
|
||||
Color = ColorTexture,
|
||||
Height = "textures/cpdem-Mcolor2-MLorriCA-lr-5_ZMfs-cyl.jpg",
|
||||
Project = "textures/defaultProj.png",
|
||||
Sequencing = "true",
|
||||
},
|
||||
Atmosphere = {
|
||||
Type = "Nishita", -- for example, values missing etc etc
|
||||
MieFactor = 1.0,
|
||||
MieColor = {1.0, 1.0, 1.0}
|
||||
},
|
||||
Projection = {
|
||||
Observer = "NEW HORIZONS",
|
||||
Target = "CHARON",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
return {
|
||||
FileRequest = {
|
||||
{ Identifier = "newhorizons_plutoencounter_pluto_assets", Destination = "assets", Version = 1 },
|
||||
{ Identifier = "newhorizons_plutoencounter_pluto_textures", Destination = "textures", Version = 2 },
|
||||
{ Identifier = "newhorizons_plutoencounter_pluto_textures", Destination = "textures", Version = 3 },
|
||||
{ Identifier = "pluto_textures", Destination = "textures", Version = 2 },
|
||||
{ Identifier = "newhorizons_plutoencounter_pluto_images", Destination = "images", Version = 1 }
|
||||
},
|
||||
|
||||
@@ -9,6 +9,13 @@ else
|
||||
}
|
||||
end
|
||||
|
||||
Files = {
|
||||
low = "textures/pluto_large.jpg",
|
||||
med = "textures/Shenk_180.jpg",
|
||||
high = "textures/pmap_cyl_HR_LOR_lowres.jpg"
|
||||
}
|
||||
ColorTexture = Files[TextureResolution]
|
||||
|
||||
return {
|
||||
-- Pluto barycenter module
|
||||
{
|
||||
@@ -37,21 +44,14 @@ return {
|
||||
},
|
||||
Textures = {
|
||||
Type = "simple",
|
||||
-- Color = "textures/pluto_highres_180.jpg",
|
||||
Color = "textures/Shenk_180.jpg",
|
||||
-- Color = "textures/pluto_large.jpg",
|
||||
-- Color = "textures/white.png",
|
||||
Color = ColorTexture,
|
||||
Height = "textures/pluto_shenk_heightmap.jpg",
|
||||
Project = "textures/3.jpg",
|
||||
Sequencing = "true",
|
||||
},
|
||||
Atmosphere = {
|
||||
Type = "Nishita", -- for example, values missing etc etc
|
||||
MieFactor = 1.0,
|
||||
MieColor = {1.0, 1.0, 1.0}
|
||||
Sequencing = "true"
|
||||
},
|
||||
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/full_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",
|
||||
@@ -209,7 +209,7 @@ return {
|
||||
Size = {1.0, 6.4},
|
||||
Origin = "Center",
|
||||
Billboard = true,
|
||||
ProjectionListener = true,
|
||||
ProjectionListener = false,
|
||||
Texture = "textures/Pluto-Text.png"
|
||||
},
|
||||
Ephemeris = {
|
||||
|
||||
@@ -6,8 +6,12 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.time.setTime("2014 AUG 21 18:00:00")
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
openspace.time.setTime("2014-08-15T03:05:18.101")
|
||||
-- openspace.time.setTime("2014-11-17T03:05:18.101")
|
||||
-- openspace.time.setTime("2015-07-29T06:02:10.000")
|
||||
-- openspace.time.setTime("2014 AUG 21 18:00:00")
|
||||
-- openspace.time.setTime("2015 SEP 10 19:39:00")
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys_rosetta.lua'))
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -78,6 +78,10 @@ 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',
|
||||
@@ -87,20 +91,10 @@ return {
|
||||
"${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",
|
||||
|
||||
-- FK
|
||||
"${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/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",
|
||||
|
||||
-- PCK
|
||||
"${OPENSPACE_DATA}/spice/RosettaKernels/PCK/ROS_CGS_RSOC_V03.TPC",
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
@@ -30,31 +30,54 @@ 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",
|
||||
|
||||
--SCLK
|
||||
-- "${OPENSPACE_DATA}/spice/RosettaKernels/SCLK/ROS_150227_STEP.TSC",
|
||||
"${OPENSPACE_DATA}/spice/RosettaKernels_New/SCLK/ROS_160425_STEP.TSC",
|
||||
|
||||
-- FK
|
||||
|
||||
"${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",
|
||||
|
||||
"${OPENSPACE_DATA}/spice/RosettaKernels/CK/ROS_SA_2014_V0044.BC",
|
||||
"${OPENSPACE_DATA}/spice/RosettaKernels/CK/ROS_SA_2015_V0009.BC",
|
||||
-- PCK
|
||||
"${OPENSPACE_DATA}/spice/RosettaKernels_New/PCK/ROS_CGS_RSOC_V03.TPC",
|
||||
-- "${OPENSPACE_DATA}/spice/RosettaKernels/PCK/ROS_CGS_RSOC_V03.TPC",
|
||||
|
||||
|
||||
|
||||
"${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 +113,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"
|
||||
},
|
||||
|
||||
31
data/spice/iSWAKernels/GSE.ti
Normal file
@@ -0,0 +1,31 @@
|
||||
Geocentric Solar Ecliptic (GSE) frame:
|
||||
|
||||
+X is parallel to the geometric earth-sun position vector.
|
||||
|
||||
+Y axis is the normalized component of the geometric earth-sun velocity
|
||||
vector orthogonal to the GSE +X axis.
|
||||
|
||||
+Z axis is parallel to the cross product of the GSE +X axis
|
||||
and the GSE +Y axis.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_GSE = 2
|
||||
FRAME_2_NAME = 'GSE'
|
||||
FRAME_2_CLASS = 5
|
||||
FRAME_2_CLASS_ID = 2
|
||||
FRAME_2_CENTER = 399
|
||||
FRAME_2_RELATIVE = 'J2000'
|
||||
FRAME_2_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_2_FAMILY = 'TWO-VECTOR'
|
||||
FRAME_2_PRI_AXIS = 'X'
|
||||
FRAME_2_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
|
||||
FRAME_2_PRI_OBSERVER = 'EARTH'
|
||||
FRAME_2_PRI_TARGET = 'SUN'
|
||||
FRAME_2_PRI_ABCORR = 'NONE'
|
||||
FRAME_2_SEC_AXIS = 'Y'
|
||||
FRAME_2_SEC_VECTOR_DEF = 'OBSERVER_TARGET_VELOCITY'
|
||||
FRAME_2_SEC_OBSERVER = 'EARTH'
|
||||
FRAME_2_SEC_TARGET = 'SUN'
|
||||
FRAME_2_SEC_ABCORR = 'NONE'
|
||||
FRAME_2_SEC_FRAME = 'J2000'
|
||||
31
data/spice/iSWAKernels/GSM.ti
Normal file
@@ -0,0 +1,31 @@
|
||||
Geocentric Solar Magnetospheric (GSM) frame:
|
||||
|
||||
+X is parallel to the geometric earth-sun position vector.
|
||||
|
||||
+Z axis is normalized component of north centered geomagnetic dipole
|
||||
vector orthogonal to GSM +X axis.
|
||||
|
||||
+Y completes the right-handed frame.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_GSM = 1
|
||||
FRAME_1_NAME = 'GSM'
|
||||
FRAME_1_CLASS = 5
|
||||
FRAME_1_CLASS_ID = 1
|
||||
FRAME_1_CENTER = 399
|
||||
FRAME_1_RELATIVE = 'GALACTIC'
|
||||
FRAME_1_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_1_FAMILY = 'TWO-VECTOR'
|
||||
FRAME_1_PRI_AXIS = 'X'
|
||||
FRAME_1_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
|
||||
FRAME_1_PRI_OBSERVER = 'EARTH'
|
||||
FRAME_1_PRI_TARGET = 'SUN'
|
||||
FRAME_1_PRI_ABCORR = 'NONE'
|
||||
FRAME_1_SEC_AXIS = 'Z'
|
||||
FRAME_1_SEC_VECTOR_DEF = 'CONSTANT'
|
||||
FRAME_1_SEC_FRAME = 'ECLIPJ2000'
|
||||
FRAME_1_SEC_SPEC = 'LATITUDINAL'
|
||||
FRAME_1_SEC_UNITS = 'DEGREES'
|
||||
FRAME_1_SEC_LONGITUDE = 288.43
|
||||
FRAME_1_SEC_LATITUDE = 79.54
|
||||
264
data/spice/iSWAKernels/heliospheric.tf
Normal file
@@ -0,0 +1,264 @@
|
||||
Dynamic Heliospheric Coordinate Frames developed for the NASA STEREO mission
|
||||
|
||||
The coordinate frames in this file all have ID values based on the pattern
|
||||
18ccple, where
|
||||
|
||||
18 = Prefix to put in the allowed 1400000 to 2000000 range
|
||||
cc = 03 for geocentric, 10 for heliocentric
|
||||
p = Pole basis: 1=geographic, 2=geomagnetic, 3=ecliptic, 4=solar
|
||||
l = Longitude basis: 1=Earth-Sun, 2=ecliptic
|
||||
e = Ecliptic basis: 0=J2000, 1=mean, 2=true
|
||||
|
||||
Author: William Thompson
|
||||
NASA Goddard Space Flight Center
|
||||
Code 612.1
|
||||
Greenbelt, MD 20771
|
||||
|
||||
William.T.Thompson.1@gsfc.nasa.gov
|
||||
|
||||
History
|
||||
|
||||
Version 1, 18-Feb-2005, WTT, initial release
|
||||
GSE and ECLIPDATE definitions from examples in frames.req by C.H. Acton
|
||||
HEE definition is based on the GSE example
|
||||
|
||||
Version 2, 22-Feb-2005, WTT
|
||||
Modified HCI definition to tie to IAU_SUN frame
|
||||
Use RECTANGULAR specification in HEEQ frame
|
||||
|
||||
Version 3, 23-Feb-2005, WTT
|
||||
Correct GSE and HEE definitions to use ECLIPDATE axis
|
||||
|
||||
Version 4, 08-Aug-2008, WTT
|
||||
Add GEORTN coordinate system (comment added 30-Aug-2010)
|
||||
|
||||
Mean Ecliptic of Date (ECLIPDATE) Frame
|
||||
|
||||
Definition of the Mean Ecliptic of Date frame:
|
||||
|
||||
All vectors are geometric: no aberration corrections are
|
||||
used.
|
||||
|
||||
The X axis is the first point in Aries for the mean ecliptic of
|
||||
date, and the Z axis points along the ecliptic north pole.
|
||||
|
||||
The Y axis is Z cross X, completing the right-handed
|
||||
reference frame.
|
||||
|
||||
This reference frame can be used to realize the HAE coordinate
|
||||
system by using the sun as the observing body.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_ECLIPDATE = 1803321
|
||||
FRAME_1803321_NAME = 'ECLIPDATE'
|
||||
FRAME_1803321_CLASS = 5
|
||||
FRAME_1803321_CLASS_ID = 1803321
|
||||
FRAME_1803321_CENTER = 399
|
||||
FRAME_1803321_RELATIVE = 'J2000'
|
||||
FRAME_1803321_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_1803321_FAMILY = 'MEAN_ECLIPTIC_AND_EQUINOX_OF_DATE'
|
||||
FRAME_1803321_PREC_MODEL = 'EARTH_IAU_1976'
|
||||
FRAME_1803321_OBLIQ_MODEL = 'EARTH_IAU_1980'
|
||||
FRAME_1803321_ROTATION_STATE = 'ROTATING'
|
||||
|
||||
\begintext
|
||||
|
||||
Geocentric Solar Ecliptic (GSE) Frame
|
||||
|
||||
Definition of the Geocentric Solar Ecliptic frame:
|
||||
|
||||
All vectors are geometric: no aberration corrections are
|
||||
used.
|
||||
|
||||
The position of the sun relative to the earth is the primary
|
||||
vector: the X axis points from the earth to the sun.
|
||||
|
||||
The northern surface normal to the mean ecliptic of date is the
|
||||
secondary vector: the Z axis is the component of this vector
|
||||
orthogonal to the X axis.
|
||||
|
||||
The Y axis is Z cross X, completing the right-handed
|
||||
reference frame.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_GSE = 1803311
|
||||
FRAME_1803311_NAME = 'GSE'
|
||||
FRAME_1803311_CLASS = 5
|
||||
FRAME_1803311_CLASS_ID = 1803311
|
||||
FRAME_1803311_CENTER = 399
|
||||
FRAME_1803311_RELATIVE = 'J2000'
|
||||
FRAME_1803311_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_1803311_FAMILY = 'TWO-VECTOR'
|
||||
FRAME_1803311_PRI_AXIS = 'X'
|
||||
FRAME_1803311_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
|
||||
FRAME_1803311_PRI_OBSERVER = 'EARTH'
|
||||
FRAME_1803311_PRI_TARGET = 'SUN'
|
||||
FRAME_1803311_PRI_ABCORR = 'NONE'
|
||||
FRAME_1803311_SEC_AXIS = 'Z'
|
||||
FRAME_1803311_SEC_VECTOR_DEF = 'CONSTANT'
|
||||
FRAME_1803311_SEC_FRAME = 'ECLIPDATE'
|
||||
FRAME_1803311_SEC_SPEC = 'RECTANGULAR'
|
||||
FRAME_1803311_SEC_VECTOR = ( 0, 0, 1 )
|
||||
|
||||
\begintext
|
||||
|
||||
Heliocentric Inertial (HCI) Frame
|
||||
|
||||
Definition of the Heliocentric Inertial frame:
|
||||
|
||||
All vectors are geometric: no aberration corrections are
|
||||
used.
|
||||
|
||||
The solar rotation axis is the primary vector: the Z axis points
|
||||
in the solar north direction.
|
||||
|
||||
The solar ascending node on the ecliptic of J2000 forms the X
|
||||
axis.
|
||||
|
||||
The Y axis is Z cross X, completing the right-handed
|
||||
reference frame.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_HCI = 1810420
|
||||
FRAME_1810420_NAME = 'HCI'
|
||||
FRAME_1810420_CLASS = 5
|
||||
FRAME_1810420_CLASS_ID = 1810420
|
||||
FRAME_1810420_CENTER = 10
|
||||
FRAME_1810420_RELATIVE = 'J2000'
|
||||
FRAME_1810420_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_1810420_FAMILY = 'TWO-VECTOR'
|
||||
FRAME_1810420_PRI_AXIS = 'Z'
|
||||
FRAME_1810420_PRI_VECTOR_DEF = 'CONSTANT'
|
||||
FRAME_1810420_PRI_FRAME = 'IAU_SUN'
|
||||
FRAME_1810420_PRI_SPEC = 'RECTANGULAR'
|
||||
FRAME_1810420_PRI_VECTOR = ( 0, 0, 1 )
|
||||
FRAME_1810420_SEC_AXIS = 'Y'
|
||||
FRAME_1810420_SEC_VECTOR_DEF = 'CONSTANT'
|
||||
FRAME_1810420_SEC_FRAME = 'ECLIPJ2000'
|
||||
FRAME_1810420_SEC_SPEC = 'RECTANGULAR'
|
||||
FRAME_1810420_SEC_VECTOR = ( 0, 0, 1 )
|
||||
|
||||
\begintext
|
||||
|
||||
Heliocentric Earth Ecliptic (HEE) Frame
|
||||
|
||||
Definition of the Heliocentric Earth Ecliptic frame:
|
||||
|
||||
All vectors are geometric: no aberration corrections are
|
||||
used.
|
||||
|
||||
The position of the earth relative to the sun is the primary
|
||||
vector: the X axis points from the sun to the earth.
|
||||
|
||||
The northern surface normal to the mean ecliptic of date is the
|
||||
secondary vector: the Z axis is the component of this vector
|
||||
orthogonal to the X axis.
|
||||
|
||||
The Y axis is Z cross X, completing the right-handed
|
||||
reference frame.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_HEE = 1810311
|
||||
FRAME_1810311_NAME = 'HEE'
|
||||
FRAME_1810311_CLASS = 5
|
||||
FRAME_1810311_CLASS_ID = 1810311
|
||||
FRAME_1810311_CENTER = 10
|
||||
FRAME_1810311_RELATIVE = 'J2000'
|
||||
FRAME_1810311_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_1810311_FAMILY = 'TWO-VECTOR'
|
||||
FRAME_1810311_PRI_AXIS = 'X'
|
||||
FRAME_1810311_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
|
||||
FRAME_1810311_PRI_OBSERVER = 'SUN'
|
||||
FRAME_1810311_PRI_TARGET = 'EARTH'
|
||||
FRAME_1810311_PRI_ABCORR = 'NONE'
|
||||
FRAME_1810311_SEC_AXIS = 'Z'
|
||||
FRAME_1810311_SEC_VECTOR_DEF = 'CONSTANT'
|
||||
FRAME_1810311_SEC_FRAME = 'ECLIPDATE'
|
||||
FRAME_1810311_SEC_SPEC = 'RECTANGULAR'
|
||||
FRAME_1810311_SEC_VECTOR = ( 0, 0, 1 )
|
||||
|
||||
\begintext
|
||||
|
||||
Heliocentric Earth Equatorial (HEEQ) Frame
|
||||
|
||||
Definition of the Heliocentric Earth Equatorial frame:
|
||||
|
||||
All vectors are geometric: no aberration corrections are
|
||||
used.
|
||||
|
||||
The solar rotation axis is the primary vector: the Z axis points
|
||||
in the solar north direction.
|
||||
|
||||
The position of the sun relative to the earth is the secondary
|
||||
vector: the X axis is the component of this position vector
|
||||
orthogonal to the Z axis.
|
||||
|
||||
The Y axis is Z cross X, completing the right-handed
|
||||
reference frame.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_HEEQ = 1810411
|
||||
FRAME_1810411_NAME = 'HEEQ'
|
||||
FRAME_1810411_CLASS = 5
|
||||
FRAME_1810411_CLASS_ID = 1810411
|
||||
FRAME_1810411_CENTER = 10
|
||||
FRAME_1810411_RELATIVE = 'J2000'
|
||||
FRAME_1810411_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_1810411_FAMILY = 'TWO-VECTOR'
|
||||
FRAME_1810411_PRI_AXIS = 'Z'
|
||||
FRAME_1810411_PRI_VECTOR_DEF = 'CONSTANT'
|
||||
FRAME_1810411_PRI_FRAME = 'IAU_SUN'
|
||||
FRAME_1810411_PRI_SPEC = 'RECTANGULAR'
|
||||
FRAME_1810411_PRI_VECTOR = ( 0, 0, 1 )
|
||||
FRAME_1810411_SEC_AXIS = 'X'
|
||||
FRAME_1810411_SEC_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
|
||||
FRAME_1810411_SEC_OBSERVER = 'SUN'
|
||||
FRAME_1810411_SEC_TARGET = 'EARTH'
|
||||
FRAME_1810411_SEC_ABCORR = 'NONE'
|
||||
FRAME_1810411_SEC_FRAME = 'IAU_SUN'
|
||||
|
||||
\begintext
|
||||
|
||||
Geocentric Radial Tangential Normal (GEORTN) Frame
|
||||
|
||||
Definition of the Geocentric RTN Frame
|
||||
|
||||
All vectors are geometric: no aberration corrections are used.
|
||||
|
||||
The position of Earth relative to the Sun is the primary
|
||||
vector: the X axis points from the Sun center to Earth
|
||||
|
||||
The solar rotation axis is the secondary vector: the Z axis is
|
||||
the component of the solar north direction perpendicular to X.
|
||||
|
||||
The Y axis is Z cross X, completing the right-handed reference
|
||||
frame.
|
||||
|
||||
\begindata
|
||||
|
||||
FRAME_GEORTN = 1803410
|
||||
FRAME_1803410_NAME = 'GEORTN'
|
||||
FRAME_1803410_CLASS = 5
|
||||
FRAME_1803410_CLASS_ID = 1803410
|
||||
FRAME_1803410_CENTER = 10
|
||||
FRAME_1803410_RELATIVE = 'J2000'
|
||||
FRAME_1803410_DEF_STYLE = 'PARAMETERIZED'
|
||||
FRAME_1803410_FAMILY = 'TWO-VECTOR'
|
||||
FRAME_1803410_PRI_AXIS = 'X'
|
||||
FRAME_1803410_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
|
||||
FRAME_1803410_PRI_OBSERVER = 'SUN'
|
||||
FRAME_1803410_PRI_TARGET = 'EARTH'
|
||||
FRAME_1803410_PRI_ABCORR = 'NONE'
|
||||
FRAME_1803410_PRI_FRAME = 'IAU_SUN'
|
||||
FRAME_1803410_SEC_AXIS = 'Z'
|
||||
FRAME_1803410_SEC_VECTOR_DEF = 'CONSTANT'
|
||||
FRAME_1803410_SEC_FRAME = 'IAU_SUN'
|
||||
FRAME_1803410_SEC_SPEC = 'RECTANGULAR'
|
||||
FRAME_1803410_SEC_VECTOR = ( 0, 0, 1 )
|
||||
|
||||
\begintext
|
||||
BIN
data/test2.jpg
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
data/test3.jpg
Normal file
|
After Width: | Height: | Size: 186 KiB |
8236
ext/json/json.hpp
Normal file
@@ -34,6 +34,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <future>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -55,20 +56,37 @@ public:
|
||||
bool isAborted;
|
||||
std::string filePath;
|
||||
std::string errorMessage;
|
||||
|
||||
std::string format;
|
||||
// Values set by others to be consumed by the DownloadManager
|
||||
bool abortDownload;
|
||||
};
|
||||
|
||||
struct MemoryFile {
|
||||
char* buffer;
|
||||
size_t size;
|
||||
std::string format;
|
||||
bool corrupted;
|
||||
};
|
||||
|
||||
using DownloadProgressCallback = std::function<void(const FileFuture&)>;
|
||||
using DownloadFinishedCallback = std::function<void(const FileFuture&)>;
|
||||
|
||||
using SuccessCallback = std::function<void(const MemoryFile&)>;
|
||||
using ErrorCallback = std::function<void(const std::string&)>;
|
||||
|
||||
using RequestFinishedCallback = std::function<void(std::string)>;
|
||||
using AsyncDownloadFinishedCallback =
|
||||
std::function<void(const std::vector<std::shared_ptr<FileFuture>>&)>;
|
||||
|
||||
//Just a helper function to check if a future is ready to ".get()". Not specific
|
||||
// to DownloadManager but is useful for anyone using the DownloadManager
|
||||
template<typename R>
|
||||
static bool futureReady(std::future<R> const& f)
|
||||
{ return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready; }
|
||||
|
||||
DownloadManager(std::string requestURL, int applicationVersion,
|
||||
bool useMultithreadedDownload = true);
|
||||
|
||||
// callers responsibility to delete
|
||||
// callbacks happen on a different thread
|
||||
std::shared_ptr<FileFuture> downloadFile(const std::string& url, const ghoul::filesystem::File& file,
|
||||
bool overrideFile = true,
|
||||
@@ -76,6 +94,10 @@ public:
|
||||
DownloadProgressCallback progressCallback = DownloadProgressCallback()
|
||||
);
|
||||
|
||||
std::future<MemoryFile> fetchFile(
|
||||
const std::string& url,
|
||||
SuccessCallback successCallback = SuccessCallback(), ErrorCallback errorCallback = ErrorCallback());
|
||||
|
||||
std::vector<std::shared_ptr<FileFuture>> downloadRequestFiles(const std::string& identifier,
|
||||
const ghoul::filesystem::Directory& destination, int version,
|
||||
bool overrideFiles = true,
|
||||
@@ -88,6 +110,9 @@ public:
|
||||
bool overrideFiles, AsyncDownloadFinishedCallback callback
|
||||
);
|
||||
|
||||
void getFileExtension(const std::string& url,
|
||||
RequestFinishedCallback finishedCallback = RequestFinishedCallback());
|
||||
|
||||
private:
|
||||
std::vector<std::string> _requestURL;
|
||||
int _applicationVersion;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __MODULEENGINE_H__
|
||||
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -74,6 +75,12 @@ public:
|
||||
*/
|
||||
std::vector<OpenSpaceModule*> modules() const;
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* modules.
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
/// The list of all registered OpenSpaceModule%s
|
||||
std::vector<std::unique_ptr<OpenSpaceModule>> _modules;
|
||||
|
||||
@@ -83,7 +83,10 @@ public:
|
||||
properties::PropertyOwner& globalPropertyOwner();
|
||||
WindowWrapper& windowWrapper();
|
||||
ghoul::fontrendering::FontManager& fontManager();
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
gui::GUI& gui();
|
||||
#endif
|
||||
|
||||
// SGCT callbacks
|
||||
bool initialize();
|
||||
@@ -127,7 +130,9 @@ private:
|
||||
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
|
||||
std::unique_ptr<LuaConsole> _console;
|
||||
std::unique_ptr<ModuleEngine> _moduleEngine;
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
std::unique_ptr<gui::GUI> _gui;
|
||||
#endif
|
||||
std::unique_ptr<network::ParallelConnection> _parallelConnection;
|
||||
std::unique_ptr<WindowWrapper> _windowWrapper;
|
||||
std::unique_ptr<ghoul::fontrendering::FontManager> _fontManager;
|
||||
|
||||
@@ -32,10 +32,10 @@ namespace openspace {
|
||||
std::string licenseText();
|
||||
|
||||
const int OPENSPACE_VERSION_MAJOR = 0;
|
||||
const int OPENSPACE_VERSION_MINOR = 3;
|
||||
const int OPENSPACE_VERSION_MINOR = 4;
|
||||
const int OPENSPACE_VERSION_PATCH = 0;
|
||||
|
||||
const std::string OPENSPACE_VERSION_STRING = "prerelease-8";
|
||||
const std::string OPENSPACE_VERSION_STRING = "prerelease-9 (IPS)";
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
SelectionProperty(std::string identifier, std::string guiName);
|
||||
|
||||
void addOption(Option option);
|
||||
void removeOptions();
|
||||
const std::vector<Option>& options() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace properties {
|
||||
class Renderable;
|
||||
class Scene;
|
||||
class SceneGraphNode;
|
||||
class IswaGroup;
|
||||
class ScreenSpaceRenderable;
|
||||
|
||||
Scene* sceneGraph();
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <map>
|
||||
|
||||
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <openspace/rendering/volume.h>
|
||||
#include <openspace/rendering/renderer.h>
|
||||
#include <openspace/rendering/raycasterlistener.h>
|
||||
@@ -69,6 +70,9 @@ public:
|
||||
void setScene(Scene* scene) override;
|
||||
void setResolution(glm::ivec2 res) override;
|
||||
|
||||
void preRaycast(ghoul::opengl::ProgramObject& programObject);
|
||||
void postRaycast(ghoul::opengl::ProgramObject& programObject);
|
||||
|
||||
void update();
|
||||
void render(float blackoutFactor, bool doPerformanceMeasurements) override;
|
||||
|
||||
@@ -110,6 +114,12 @@ private:
|
||||
|
||||
ghoul::Dictionary _resolveDictionary;
|
||||
|
||||
GLuint _mainColorTexture;
|
||||
GLuint _mainDepthTexture;
|
||||
std::unique_ptr<ghoul::opengl::TextureUnit> _mainColorTextureUnit;
|
||||
std::unique_ptr<ghoul::opengl::TextureUnit> _mainDepthTextureUnit;
|
||||
|
||||
GLuint _mainFramebuffer;
|
||||
GLuint _screenQuad;
|
||||
GLuint _anchorPointerTexture;
|
||||
GLuint _anchorPointerTextureInitializer;
|
||||
@@ -119,6 +129,11 @@ private:
|
||||
GLuint _vertexPositionBuffer;
|
||||
int _nAaSamples;
|
||||
|
||||
|
||||
std::unique_ptr<RendererTasks> _rendererTasks;
|
||||
std::unique_ptr<RenderData> _renderData;
|
||||
float _blackoutFactor;
|
||||
|
||||
ghoul::Dictionary _rendererData;
|
||||
}; // ABufferRenderer
|
||||
} // openspace
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
|
||||
virtual void render(const RenderData& data);
|
||||
virtual void render(const RenderData& data, RendererTasks& rendererTask);
|
||||
virtual void postRender(const RenderData& data);
|
||||
virtual void update(const UpdateData& data);
|
||||
|
||||
bool isVisible() const;
|
||||
@@ -83,8 +84,10 @@ public:
|
||||
|
||||
static void setPscUniforms(ghoul::opengl::ProgramObject& program, const Camera& camera, const PowerScaledCoordinate& position);
|
||||
|
||||
private:
|
||||
protected:
|
||||
properties::BoolProperty _enabled;
|
||||
|
||||
private:
|
||||
PowerScaledScalar boundingSphere_;
|
||||
std::string _startTime;
|
||||
std::string _endTime;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
|
||||
|
||||
namespace ghoul {
|
||||
@@ -51,6 +52,7 @@ class Scene;
|
||||
class Renderer;
|
||||
class RaycasterManager;
|
||||
class ScreenLog;
|
||||
class ScreenSpaceRenderable;
|
||||
|
||||
class RenderEngine {
|
||||
public:
|
||||
@@ -60,6 +62,12 @@ public:
|
||||
Invalid
|
||||
};
|
||||
|
||||
enum class RenderProgramType {
|
||||
Default = 0,
|
||||
Post
|
||||
};
|
||||
|
||||
|
||||
static const std::string PerformanceMeasurementSharedData;
|
||||
|
||||
static const std::string KeyFontMono;
|
||||
@@ -100,28 +108,52 @@ public:
|
||||
|
||||
void setDisableRenderingOnMaster(bool enabled);
|
||||
|
||||
void registerScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
|
||||
void unregisterScreenSpaceRenderable(std::shared_ptr<ScreenSpaceRenderable> s);
|
||||
void unregisterScreenSpaceRenderable(std::string name);
|
||||
std::shared_ptr<ScreenSpaceRenderable> screenSpaceRenderable(std::string name);
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
|
||||
std::string name,
|
||||
std::string vsPath,
|
||||
std::string fsPath,
|
||||
const ghoul::Dictionary& dictionary = ghoul::Dictionary());
|
||||
const ghoul::Dictionary& dictionary = ghoul::Dictionary(),
|
||||
RenderEngine::RenderProgramType type = RenderEngine::RenderProgramType::Default);
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
|
||||
std::string name,
|
||||
std::string vsPath,
|
||||
std::string fsPath,
|
||||
std::string csPath,
|
||||
const ghoul::Dictionary& dictionary = ghoul::Dictionary());
|
||||
const ghoul::Dictionary& dictionary = ghoul::Dictionary(),
|
||||
RenderEngine::RenderProgramType type = RenderEngine::RenderProgramType::Default);
|
||||
|
||||
void removeRenderProgram(const std::unique_ptr<ghoul::opengl::ProgramObject>& program);
|
||||
|
||||
/**
|
||||
* Set raycasting uniforms on the program object, and setup raycasting.
|
||||
*/
|
||||
void preRaycast(ghoul::opengl::ProgramObject& programObject);
|
||||
|
||||
/**
|
||||
* Tear down raycasting for the specified program object.
|
||||
*/
|
||||
void postRaycast(ghoul::opengl::ProgramObject& programObject);
|
||||
|
||||
|
||||
void setRendererFromString(const std::string& method);
|
||||
|
||||
/**
|
||||
* Let's the renderer update the data to be brought into the rendererer programs
|
||||
* Lets the renderer update the data to be brought into the rendererer programs
|
||||
* as a 'rendererData' variable in the dictionary.
|
||||
*/
|
||||
void setRendererData(const ghoul::Dictionary& renderer);
|
||||
void setRendererData(const ghoul::Dictionary& rendererData);
|
||||
|
||||
/**
|
||||
* Lets the renderer update the data to be brought into the post rendererer programs
|
||||
* as a 'resolveData' variable in the dictionary.
|
||||
*/
|
||||
void setResolveData(const ghoul::Dictionary& resolveData);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
@@ -135,13 +167,14 @@ public:
|
||||
// Temporary fade functionality
|
||||
void startFading(int direction, float fadeDuration);
|
||||
|
||||
void sortScreenspaceRenderables();
|
||||
// This is temporary until a proper screenspace solution is found ---abock
|
||||
struct {
|
||||
glm::vec2 _position;
|
||||
unsigned int _size;
|
||||
int _node;
|
||||
} _onScreenInformation;
|
||||
|
||||
|
||||
private:
|
||||
void setRenderer(std::unique_ptr<Renderer> renderer);
|
||||
RendererImplementation rendererFromString(const std::string& method);
|
||||
@@ -156,6 +189,7 @@ private:
|
||||
std::unique_ptr<Renderer> _renderer;
|
||||
RendererImplementation _rendererImplementation;
|
||||
ghoul::Dictionary _rendererData;
|
||||
ghoul::Dictionary _resolveData;
|
||||
ScreenLog* _log;
|
||||
|
||||
bool _showInfo;
|
||||
@@ -171,6 +205,7 @@ private:
|
||||
int _fadeDirection;
|
||||
|
||||
std::vector<ghoul::opengl::ProgramObject*> _programs;
|
||||
std::vector<std::shared_ptr<ScreenSpaceRenderable>> _screenSpaceRenderables;
|
||||
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _fontInfo = nullptr;
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _fontDate = nullptr;
|
||||
|
||||
@@ -59,6 +59,18 @@ public:
|
||||
virtual void setScene(Scene* scene) = 0;
|
||||
virtual void setResolution(glm::ivec2 res) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set raycasting uniforms on the program object, and setup raycasting.
|
||||
*/
|
||||
virtual void preRaycast(ghoul::opengl::ProgramObject& programObject) {};
|
||||
|
||||
/**
|
||||
* Tear down raycasting for the specified program object.
|
||||
*/
|
||||
virtual void postRaycast(ghoul::opengl::ProgramObject& programObject) {};
|
||||
|
||||
|
||||
virtual void update() = 0;
|
||||
virtual void render(float blackoutFactor, bool doPerformanceMeasurements) = 0;
|
||||
/**
|
||||
|
||||
126
include/openspace/rendering/screenspacerenderable.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __SCREENSPACERENDERABLE_H__
|
||||
#define __SCREENSPACERENDERABLE_H__
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <openspace/util/camera.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
namespace openspace {
|
||||
/**
|
||||
* @brief The base class for screen scape images and screen space framebuffers
|
||||
* @details This base class handles general functionality specific to planes that
|
||||
* are rendered infront of the camera. It implements protected methods and properties for converting
|
||||
* the planes from spherical to euclidean coordinates and back. It also specifies the interface
|
||||
* that it's children needs to implement.
|
||||
*/
|
||||
class ScreenSpaceRenderable : public properties::PropertyOwner {
|
||||
public:
|
||||
static ScreenSpaceRenderable* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
ScreenSpaceRenderable(const ghoul::Dictionary& dictionary);
|
||||
~ScreenSpaceRenderable();
|
||||
|
||||
virtual void render() = 0;
|
||||
virtual bool initialize() = 0;
|
||||
virtual bool deinitialize() = 0;
|
||||
virtual void update() = 0;
|
||||
virtual bool isReady() const = 0;
|
||||
bool isEnabled() const;
|
||||
|
||||
glm::vec2 euclideanPosition() const {return _euclideanPosition.value();};
|
||||
glm::vec2 sphericalPosition() const {return _sphericalPosition.value();};
|
||||
float depth() const {return _depth.value();};
|
||||
|
||||
protected:
|
||||
void createPlane();
|
||||
void useEuclideanCoordinates(bool b);
|
||||
|
||||
/**
|
||||
* @brief Converts vec2 polar coordinates to euclidean
|
||||
*
|
||||
* @param polar the coordinates theta and phi
|
||||
* @param radius the radius position value of the plane
|
||||
*
|
||||
* @return glm::vec2 with the x and y position value of the plane
|
||||
*/
|
||||
glm::vec2 toEuclidean(glm::vec2 polar, float radius);
|
||||
|
||||
/**
|
||||
* @brief Converts vec2 euclidean coordinates to sperical
|
||||
*
|
||||
* @param euclidean the coordinates x and y
|
||||
* @return glm::vec2 with the spherical coordinates theta and phi.
|
||||
*/
|
||||
glm::vec2 toSpherical(glm::vec2 euclidean);
|
||||
void registerProperties();
|
||||
void unregisterProperties();
|
||||
|
||||
void createShaders();
|
||||
glm::mat4 scaleMatrix();
|
||||
glm::mat4 rotationMatrix();
|
||||
glm::mat4 translationMatrix();
|
||||
void draw(glm::mat4 modelTransform);
|
||||
|
||||
properties::BoolProperty _enabled;
|
||||
properties::BoolProperty _useFlatScreen;
|
||||
properties::Vec2Property _euclideanPosition;
|
||||
properties::Vec2Property _sphericalPosition;
|
||||
properties::FloatProperty _depth;
|
||||
properties::FloatProperty _scale;
|
||||
properties::FloatProperty _alpha;
|
||||
properties::TriggerProperty _delete;
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
const std::string _rendererPath;
|
||||
ghoul::Dictionary _rendererData;
|
||||
const std::string _vertexPath;
|
||||
const std::string _fragmentPath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
|
||||
bool _useEuclideanCoordinates;
|
||||
const float _planeDepth = -2.0;
|
||||
glm::vec2 _originalViewportSize;
|
||||
|
||||
float _radius;
|
||||
};
|
||||
} // namespace openspace
|
||||
#endif // __SCREENSPACERENDERABLE_H__
|
||||
@@ -41,6 +41,7 @@ namespace openspace {
|
||||
TransferFunction(const std::string& filepath, TfChangedCallback tfChangedCallback = TfChangedCallback());
|
||||
void setPath(const std::string& filepath);
|
||||
ghoul::opengl::Texture& getTexture();
|
||||
void bind();
|
||||
void update();
|
||||
glm::vec4 sample(size_t t);
|
||||
size_t width();
|
||||
|
||||
@@ -70,6 +70,11 @@ public:
|
||||
*/
|
||||
virtual void postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {};
|
||||
|
||||
/**
|
||||
* Return true if the camera is inside the volume.
|
||||
* Also set localPosition to the camera position in the volume's local coordainte system.
|
||||
*/
|
||||
virtual bool cameraIsInside(const RenderData& data, glm::vec3& localPosition) { return false; };
|
||||
/**
|
||||
* Return a path the file to use as vertex shader
|
||||
*
|
||||
|
||||
@@ -84,6 +84,11 @@ public:
|
||||
*/
|
||||
void render(const RenderData& data, RendererTasks& tasks);
|
||||
|
||||
/*
|
||||
* Post-Render visible SceneGraphNodes using the provided camera
|
||||
*/
|
||||
void postRender(const RenderData& data);
|
||||
|
||||
/*
|
||||
* Returns the root SceneGraphNode
|
||||
*/
|
||||
@@ -97,6 +102,11 @@ public:
|
||||
|
||||
std::vector<SceneGraphNode*> allSceneGraphNodes();
|
||||
|
||||
SceneGraph& sceneGraph();
|
||||
|
||||
void addSceneGraphNode(SceneGraphNode* node){
|
||||
_graph.addSceneGraphNode(node);
|
||||
}
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to change the
|
||||
* scene graph. The functions contained are
|
||||
|
||||
@@ -25,11 +25,8 @@
|
||||
#ifndef __SCENEGRAPH_H__
|
||||
#define __SCENEGRAPH_H__
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <string>
|
||||
namespace openspace {
|
||||
|
||||
class SceneGraphNode;
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
void update(const UpdateData& data);
|
||||
void evaluate(const Camera* camera, const psc& parentPosition = psc());
|
||||
void render(const RenderData& data, RendererTasks& tasks);
|
||||
void postRender(const RenderData& data);
|
||||
void updateCamera(Camera* camera) const;
|
||||
|
||||
//void addNode(SceneGraphNode* child);
|
||||
|
||||
@@ -33,19 +33,29 @@ class Histogram {
|
||||
|
||||
public:
|
||||
Histogram();
|
||||
Histogram(float minBin, float maxBin, int numBins);
|
||||
Histogram(float minBin, float maxBin, int numBins, float *data);
|
||||
Histogram(float minValue, float maxValue, int numBins);
|
||||
Histogram(float minValue, float maxValue, int numBins, float *data);
|
||||
Histogram(Histogram&& other);
|
||||
~Histogram();
|
||||
|
||||
Histogram& operator=(Histogram&& other);
|
||||
|
||||
int numBins() const;
|
||||
float minBin() const;
|
||||
float maxBin() const;
|
||||
float minValue() const;
|
||||
float maxValue() const;
|
||||
bool isValid() const;
|
||||
|
||||
bool add(float bin, float value);
|
||||
/**
|
||||
* Enter value into the histogram. The add method takes the given
|
||||
* value, works out which bin this corresponds to, and increments
|
||||
* this bin by 'repeat'.
|
||||
*
|
||||
* @param value The Value to insert into the histogram
|
||||
* @param repeat How many times you want to insert it
|
||||
*
|
||||
* @return Returns true if succesful insertion, otherwise return false
|
||||
*/
|
||||
bool add(float value, float repeat = 1.0f);
|
||||
bool add(const Histogram& histogram);
|
||||
bool addRectangle(float lowBin, float highBin, float value);
|
||||
|
||||
@@ -56,13 +66,25 @@ public:
|
||||
|
||||
void normalize();
|
||||
void print() const;
|
||||
void generateEqualizer();
|
||||
Histogram equalize();
|
||||
float equalize (float);
|
||||
float entropy();
|
||||
|
||||
float highestBinValue(bool equalized);
|
||||
float binWidth();
|
||||
|
||||
void changeRange(float minValue, float maxValue);
|
||||
|
||||
private:
|
||||
int _numBins;
|
||||
float _minBin;
|
||||
float _maxBin;
|
||||
float _minValue;
|
||||
float _maxValue;
|
||||
|
||||
|
||||
float* _data;
|
||||
std::vector<float> _equalizer;
|
||||
int _numValues;
|
||||
|
||||
}; // class Histogram
|
||||
} // namespace openspace
|
||||
59
include/openspace/util/transformationmanager.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __TRANSFORMATIONMANAGER__
|
||||
#define __TRANSFORMATIONMANAGER__
|
||||
|
||||
#include <ghoul/designpattern/singleton.h>
|
||||
#include <ghoul/glm.h>
|
||||
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
#include <ccmc/Kameleon.h>
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace openspace {
|
||||
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
class ccmc::Kameleon;
|
||||
#endif
|
||||
class TransformationManager : public ghoul::Singleton<TransformationManager> {
|
||||
friend class ghoul::Singleton<TransformationManager>;
|
||||
|
||||
public:
|
||||
TransformationManager();
|
||||
~TransformationManager();
|
||||
|
||||
glm::dmat3 frameTransformationMatrix(std::string from, std::string to, double ephemerisTime) const;
|
||||
|
||||
private:
|
||||
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
std::shared_ptr<ccmc::Kameleon> _kameleon;
|
||||
#endif
|
||||
std::set<std::string> _kameleonFrames;
|
||||
std::set<std::string> _dipoleFrames;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //__TRANSFORMATIONMANAGER__
|
||||
@@ -38,6 +38,8 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/spiceephemeris.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/staticephemeris.h
|
||||
)
|
||||
@@ -57,6 +59,8 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletrail.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/spiceephemeris.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ephemeris/staticephemeris.cpp
|
||||
)
|
||||
@@ -85,6 +89,8 @@ set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_ge.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screnspace_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screnspace_vs.glsl
|
||||
)
|
||||
source_group("Shader Files" FILES ${SHADER_FILES})
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <modules/base/basemodule.h>
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
@@ -42,6 +43,8 @@
|
||||
#include <modules/base/rendering/simplespheregeometry.h>
|
||||
#include <modules/base/rendering/modelgeometry.h>
|
||||
#include <modules/base/rendering/multimodelgeometry.h>
|
||||
#include <modules/base/rendering/screenspaceimage.h>
|
||||
#include <modules/base/rendering/screenspaceframebuffer.h>
|
||||
|
||||
#include <modules/base/ephemeris/staticephemeris.h>
|
||||
#include <modules/base/ephemeris/spiceephemeris.h>
|
||||
@@ -57,6 +60,13 @@ BaseModule::BaseModule()
|
||||
void BaseModule::internalInitialize() {
|
||||
FactoryManager::ref().addFactory(std::make_unique<ghoul::TemplateFactory<planetgeometry::PlanetGeometry>>());
|
||||
FactoryManager::ref().addFactory(std::make_unique<ghoul::TemplateFactory<modelgeometry::ModelGeometry>>());
|
||||
FactoryManager::ref().addFactory(std::make_unique<ghoul::TemplateFactory<ScreenSpaceRenderable>>());
|
||||
|
||||
auto fScreenSpaceRenderable = FactoryManager::ref().factory<ScreenSpaceRenderable>();
|
||||
ghoul_assert(fScreenSpaceRenderable, "ScreenSpaceRenderable factory was not created");
|
||||
|
||||
fScreenSpaceRenderable->registerClass<ScreenSpaceImage>("ScreenSpaceImage");
|
||||
fScreenSpaceRenderable->registerClass<ScreenSpaceFramebuffer>("ScreenSpaceFramebuffer");
|
||||
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fRenderable, "Renderable factory was not created");
|
||||
|
||||
@@ -62,16 +62,20 @@ 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)
|
||||
, _planetRadius(0.f)
|
||||
, _nightTexturePath("")
|
||||
, _hasNightTexture(false)
|
||||
, _hasNightTexture(false)
|
||||
, _hasHeightTexture(false)
|
||||
{
|
||||
std::string name;
|
||||
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
|
||||
@@ -112,17 +116,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);
|
||||
@@ -249,11 +267,12 @@ bool RenderablePlanet::initialize() {
|
||||
"pscstandard",
|
||||
"${MODULE_BASE}/shaders/pscstandard_vs.glsl",
|
||||
"${MODULE_BASE}/shaders/pscstandard_fs.glsl");
|
||||
if (!_programObject)
|
||||
if (!_programObject)
|
||||
return false;
|
||||
}
|
||||
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
|
||||
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
|
||||
_programObject->setIgnoreUniformLocationError(IgnoreError::Yes);
|
||||
|
||||
loadTexture();
|
||||
_geometry->initialize(this);
|
||||
@@ -335,20 +354,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);
|
||||
|
||||
@@ -449,7 +480,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 << "'");
|
||||
@@ -459,6 +490,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
|
||||
|
||||
@@ -80,9 +80,16 @@ 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;
|
||||
@@ -91,10 +98,10 @@ private:
|
||||
float _planetRadius;
|
||||
|
||||
glm::dmat3 _stateMatrix;
|
||||
std::string _nightTexturePath;
|
||||
std::string _frame;
|
||||
std::string _target;
|
||||
bool _hasNightTexture;
|
||||
bool _hasHeightTexture;
|
||||
double _time;
|
||||
};
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ void RenderableTrail::update(const UpdateData& data) {
|
||||
double lightTime = 0.0;
|
||||
|
||||
bool intervalSet = hasTimeInterval();
|
||||
double start = DBL_MIN;
|
||||
double start = -DBL_MAX;
|
||||
double end = DBL_MAX;
|
||||
if (intervalSet) {
|
||||
getInterval(start, end);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -282,7 +276,7 @@ void RenderableTrail::fullYearSweep(double time) {
|
||||
int segments = static_cast<int>(_tropic);
|
||||
|
||||
bool intervalSet = hasTimeInterval();
|
||||
double start = DBL_MIN;
|
||||
double start = -DBL_MAX;
|
||||
double end = DBL_MAX;
|
||||
if (intervalSet) {
|
||||
intervalSet &= getInterval(start, end);
|
||||
|
||||
158
modules/base/rendering/screenspaceframebuffer.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/base/rendering/screenspaceframebuffer.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#include <openspace/util/camera.h>
|
||||
|
||||
#include <openspace/rendering/renderer.h>
|
||||
#include <openspace/rendering/abufferrenderer.h>
|
||||
#include <openspace/rendering/framebufferrenderer.h>
|
||||
|
||||
namespace openspace {
|
||||
ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictionary)
|
||||
:ScreenSpaceRenderable(dictionary)
|
||||
,_size("size", "Size", glm::vec4(0), glm::vec4(0), glm::vec4(2000))
|
||||
,_framebuffer(nullptr)
|
||||
{
|
||||
_id = id();
|
||||
setName("ScreenSpaceFramebuffer" + std::to_string(_id));
|
||||
registerProperties();
|
||||
|
||||
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
|
||||
addProperty(_size);
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_size);
|
||||
_size.set(glm::vec4(0, 0, resolution.x,resolution.y));
|
||||
|
||||
_scale.setValue(1.0f);
|
||||
}
|
||||
|
||||
ScreenSpaceFramebuffer::~ScreenSpaceFramebuffer(){}
|
||||
|
||||
bool ScreenSpaceFramebuffer::initialize(){
|
||||
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
|
||||
|
||||
createPlane();
|
||||
createShaders();
|
||||
createFragmentbuffer();
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool ScreenSpaceFramebuffer::deinitialize(){
|
||||
unregisterProperties();
|
||||
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
_quad = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
_vertexPositionBuffer = 0;
|
||||
|
||||
_texture = nullptr;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
|
||||
_framebuffer->detachAll();
|
||||
removeAllRenderFunctions();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScreenSpaceFramebuffer::render(){
|
||||
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
|
||||
glm::vec4 size = _size.value();
|
||||
|
||||
float xratio = _originalViewportSize.x / (size.z-size.x);
|
||||
float yratio = _originalViewportSize.y / (size.w-size.y);;
|
||||
|
||||
if(!_renderFunctions.empty()){
|
||||
glViewport (-size.x*xratio, -size.y*yratio, _originalViewportSize.x*xratio, _originalViewportSize.y*yratio);
|
||||
GLint defaultFBO = _framebuffer->getActiveObject();
|
||||
_framebuffer->activate();
|
||||
|
||||
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
for(auto renderFunction : _renderFunctions){
|
||||
(*renderFunction)();
|
||||
}
|
||||
_framebuffer->deactivate();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
|
||||
glViewport (0, 0, resolution.x, resolution.y);
|
||||
|
||||
glm::mat4 rotation = rotationMatrix();
|
||||
glm::mat4 translation = translationMatrix();
|
||||
glm::mat4 scale = scaleMatrix();
|
||||
scale = glm::scale(scale, glm::vec3((1.0/xratio), -(1.0/yratio), 1.0f));
|
||||
glm::mat4 modelTransform = rotation*translation*scale;
|
||||
draw(modelTransform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ScreenSpaceFramebuffer::update(){}
|
||||
|
||||
bool ScreenSpaceFramebuffer::isReady() const{
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
}
|
||||
|
||||
|
||||
void ScreenSpaceFramebuffer::setSize(glm::vec4 size){
|
||||
_size.set(size);
|
||||
}
|
||||
|
||||
void ScreenSpaceFramebuffer::addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction){
|
||||
_renderFunctions.push_back(renderFunction);
|
||||
}
|
||||
|
||||
void ScreenSpaceFramebuffer::removeAllRenderFunctions(){
|
||||
_renderFunctions.clear();
|
||||
}
|
||||
|
||||
void ScreenSpaceFramebuffer::createFragmentbuffer(){
|
||||
_framebuffer = std::make_unique<ghoul::opengl::FramebufferObject>();
|
||||
_framebuffer->activate();
|
||||
_texture = std::make_unique<ghoul::opengl::Texture>(glm::uvec3(_originalViewportSize.x, _originalViewportSize.y, 1));
|
||||
_texture->uploadTexture();
|
||||
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_framebuffer->attachTexture(_texture.get(), GL_COLOR_ATTACHMENT0);
|
||||
_framebuffer->deactivate();
|
||||
}
|
||||
|
||||
int ScreenSpaceFramebuffer::id(){
|
||||
static int id = 0;
|
||||
return id++;
|
||||
}
|
||||
} //namespace openspace
|
||||
67
modules/base/rendering/screenspaceframebuffer.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __SCREENSPACEFRAMEBUFFER_H__
|
||||
#define __SCREENSPACEFRAMEBUFFER_H__
|
||||
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <ghoul/opengl/framebufferobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
#include <modules/base/rendering/screenspaceimage.h>
|
||||
|
||||
namespace openspace {
|
||||
/**
|
||||
* @brief Creates a texture by rendering to a framebuffer, this is then used on a screen space plane.
|
||||
* @details This class lets you ass renderfunctions that should render to a framebuffer with an attached texture.
|
||||
* The texture is then used on a screen space plane that works both in fisheye and flat screens.
|
||||
*/
|
||||
class ScreenSpaceFramebuffer : public ScreenSpaceRenderable {
|
||||
public:
|
||||
ScreenSpaceFramebuffer(const ghoul::Dictionary& dictionary = ghoul::Dictionary());
|
||||
~ScreenSpaceFramebuffer();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
void render() override;
|
||||
void update() override;
|
||||
bool isReady() const override;
|
||||
|
||||
void setSize(glm::vec4);
|
||||
void addRenderFunction(std::shared_ptr<std::function<void()>> renderFunction);
|
||||
void removeAllRenderFunctions();
|
||||
|
||||
private:
|
||||
void createFragmentbuffer();
|
||||
static int id();
|
||||
|
||||
properties::Vec4Property _size;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::FramebufferObject> _framebuffer;
|
||||
std::vector<std::shared_ptr<std::function<void()>>> _renderFunctions;
|
||||
|
||||
int _id;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
#endif //__SCREENSPACEFRAMEBUFFER_H__
|
||||
201
modules/base/rendering/screenspaceimage.cpp
Normal file
@@ -0,0 +1,201 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/base/rendering/screenspaceimage.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ScreenSpaceImage";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
ScreenSpaceImage::ScreenSpaceImage(const ghoul::Dictionary& dictionary)
|
||||
:ScreenSpaceRenderable(dictionary)
|
||||
,_texturePath("texturePath", "Texture path", "")
|
||||
,_downloadImage(false)
|
||||
{
|
||||
std::string name;
|
||||
if(dictionary.getValue("Name", name)){
|
||||
setName(name);
|
||||
}else{
|
||||
_id = id();
|
||||
setName("ScreenSpaceImage" + std::to_string(_id));
|
||||
}
|
||||
|
||||
addProperty(_texturePath);
|
||||
registerProperties();
|
||||
|
||||
std::string texturePath;
|
||||
bool texturesucces = (dictionary.getValue("TexturePath", texturePath));
|
||||
if(texturesucces){
|
||||
_texturePath.set(texturePath);
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_texturePath);
|
||||
_texturePath.onChange([this](){ loadTexture(); });
|
||||
}
|
||||
|
||||
bool urlsucces = dictionary.getValue("URL", _url);
|
||||
if(urlsucces){
|
||||
_downloadImage =true;
|
||||
}
|
||||
|
||||
//screenspaceCygnet does not have url or texturePath
|
||||
// if(!texturesucces && !urlsucces){
|
||||
// LERROR("Must specify TexturePath or URL");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
ScreenSpaceImage::~ScreenSpaceImage(){}
|
||||
|
||||
bool ScreenSpaceImage::initialize(){
|
||||
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
|
||||
|
||||
createPlane();
|
||||
createShaders();
|
||||
updateTexture();
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool ScreenSpaceImage::deinitialize(){
|
||||
unregisterProperties();
|
||||
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
_quad = 0;
|
||||
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
_vertexPositionBuffer = 0;
|
||||
|
||||
_texturePath = "";
|
||||
_texture = nullptr;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScreenSpaceImage::render(){
|
||||
if(!isReady()) return;
|
||||
if(!_enabled) return;
|
||||
|
||||
glm::mat4 rotation = rotationMatrix();
|
||||
glm::mat4 translation = translationMatrix();
|
||||
glm::mat4 scale = scaleMatrix();
|
||||
glm::mat4 modelTransform = rotation*translation*scale;
|
||||
|
||||
draw(modelTransform);
|
||||
}
|
||||
|
||||
|
||||
void ScreenSpaceImage::update(){
|
||||
if(_downloadImage && _futureImage.valid() && DownloadManager::futureReady(_futureImage)){
|
||||
loadTexture();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ScreenSpaceImage::isReady() const{
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
}
|
||||
|
||||
void ScreenSpaceImage::loadTexture() {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = nullptr;
|
||||
if(!_downloadImage)
|
||||
texture = std::move(loadFromDisk());
|
||||
else
|
||||
texture = std::move(loadFromMemory());
|
||||
|
||||
if (texture) {
|
||||
// LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
|
||||
texture->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
|
||||
_texture = std::move(texture);
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSpaceImage::updateTexture(){
|
||||
if(!_downloadImage){
|
||||
loadTexture();
|
||||
} else {
|
||||
if(_futureImage.valid())
|
||||
return;
|
||||
|
||||
std::future<DownloadManager::MemoryFile> future = downloadImageToMemory(_url);
|
||||
if(future.valid()){
|
||||
_futureImage = std::move(future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> ScreenSpaceImage::loadFromDisk(){
|
||||
if (_texturePath.value() != "")
|
||||
return (ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath.value())));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> ScreenSpaceImage::loadFromMemory(){
|
||||
|
||||
if(_futureImage.valid() && DownloadManager::futureReady(_futureImage) ){
|
||||
DownloadManager::MemoryFile imageFile = _futureImage.get();
|
||||
|
||||
if(imageFile.corrupted)
|
||||
return nullptr;
|
||||
|
||||
return (ghoul::io::TextureReader::ref().loadTexture(
|
||||
(void*) imageFile.buffer,
|
||||
imageFile.size,
|
||||
imageFile.format));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::future<DownloadManager::MemoryFile> ScreenSpaceImage::downloadImageToMemory(std::string url){
|
||||
return std::move( DlManager.fetchFile(
|
||||
url,
|
||||
[url](const DownloadManager::MemoryFile& file){
|
||||
LDEBUG("Download to memory finished for screen space image");
|
||||
},
|
||||
[url](const std::string& err){
|
||||
LDEBUG("Download to memory failer for screen space image: " +err);
|
||||
}
|
||||
) );
|
||||
}
|
||||
|
||||
int ScreenSpaceImage::id(){
|
||||
static int id = 0;
|
||||
return id++;
|
||||
}
|
||||
}
|
||||
75
modules/base/rendering/screenspaceimage.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
#ifndef __SCREENSPACEIMAGE_H__
|
||||
#define __SCREENSPACEIMAGE_H__
|
||||
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
|
||||
|
||||
namespace openspace {
|
||||
/**
|
||||
* @brief Creates a textured plane rendered in screenspace
|
||||
* @details The plane gets the same ratio as the texture. Implements
|
||||
* the interface that ScreenSpaceImage speciefies.
|
||||
*
|
||||
* @param texturePath Path to the image that should be used as texture
|
||||
*/
|
||||
class ScreenSpaceImage : public ScreenSpaceRenderable {
|
||||
|
||||
public:
|
||||
ScreenSpaceImage(std::string texturePath);
|
||||
ScreenSpaceImage(const ghoul::Dictionary& dictionary);
|
||||
~ScreenSpaceImage();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
void render() override;
|
||||
virtual void update() override;
|
||||
bool isReady() const override;
|
||||
|
||||
protected:
|
||||
std::string _url;
|
||||
bool _downloadImage;
|
||||
std::future<DownloadManager::MemoryFile> _futureImage;
|
||||
|
||||
void loadTexture();
|
||||
void updateTexture();
|
||||
private:
|
||||
|
||||
static int id();
|
||||
std::future<DownloadManager::MemoryFile> downloadImageToMemory(std::string url);
|
||||
std::unique_ptr<ghoul::opengl::Texture> loadFromDisk();
|
||||
std::unique_ptr<ghoul::opengl::Texture> loadFromMemory();
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
//std::string _memorybuffer;
|
||||
|
||||
|
||||
int _id;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
#endif //__SCREENSPACEIMAGE_H__
|
||||
@@ -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;
|
||||
@@ -77,7 +77,6 @@ SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
else
|
||||
_segments = static_cast<int>(segments);
|
||||
|
||||
// The shader need the radii values but they are not changeable runtime
|
||||
// TODO: Possibly add a scaling property @AA
|
||||
addProperty(_realRadius);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
50
modules/base/shaders/screnspace_fs.glsl
Normal file
@@ -0,0 +1,50 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
//#version __CONTEXT__
|
||||
uniform sampler2D texture1;
|
||||
uniform float OcclusionDepth;
|
||||
uniform float Alpha;
|
||||
|
||||
in vec2 vs_st;
|
||||
in vec4 vs_position;
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
|
||||
|
||||
Fragment getFragment(){
|
||||
Fragment frag;
|
||||
|
||||
// power scale coordinates for depth. w value is set to 1.0.
|
||||
float depth = (1.0 + log(abs(OcclusionDepth) + 1/pow(k, 1.0))/log(k)) / 27.0;
|
||||
frag.color = texture(texture1, vec2(vs_st.s, 1-vs_st.t));
|
||||
frag.color.a = (frag.color.a != 0.0f) ? Alpha : frag.color.a;
|
||||
if(frag.color.a == 0.0f){
|
||||
discard;
|
||||
}
|
||||
frag.depth = denormalizeFloat(depth);
|
||||
|
||||
return frag;
|
||||
}
|
||||
41
modules/base/shaders/screnspace_vs.glsl
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 ModelTransform;
|
||||
uniform mat4 ViewProjectionMatrix;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
layout(location = 1) in vec2 in_st;
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_position;
|
||||
|
||||
void main(){
|
||||
vs_st = in_st;
|
||||
vs_position = ViewProjectionMatrix*ModelTransform*in_position;
|
||||
gl_Position = vec4(vs_position);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ void main()
|
||||
|
||||
vec4 position = pscTransform(tmp, mt);
|
||||
|
||||
vs_position = in_position;
|
||||
vs_position = tmp;
|
||||
vs_st = in_st;
|
||||
|
||||
position = ViewProjection * position;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <modules/fieldlines/rendering/renderablefieldlines.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <modules/kameleon/include/kameleonwrapper.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
@@ -94,9 +95,10 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
|
||||
dictionary.hasKeyAndValue<std::string>(SceneGraphNode::KeyName),
|
||||
"Renderable does not have a name"
|
||||
);
|
||||
|
||||
|
||||
std::string name;
|
||||
dictionary.getValue(SceneGraphNode::KeyName, name);
|
||||
setName(name);
|
||||
|
||||
_loggerCat = "RenderableFieldlines [" + name + "]";
|
||||
|
||||
@@ -144,6 +146,13 @@ RenderableFieldlines::RenderableFieldlines(const ghoul::Dictionary& dictionary)
|
||||
|
||||
_seedPointSourceFile.onChange(dirtySeedpoints);
|
||||
addProperty(_seedPointSourceFile);
|
||||
|
||||
// OsEng.gui()._property.registerProperty(&_enabled);
|
||||
// OsEng.gui()._property.registerProperty(&_stepSize);
|
||||
// OsEng.gui()._property.registerProperty(&_classification);
|
||||
// OsEng.gui()._property.registerProperty(&_fieldlineColor);
|
||||
// OsEng.gui()._property.registerProperty(&_seedPointSource);
|
||||
// OsEng.gui()._property.registerProperty(&_seedPointSourceFile);
|
||||
}
|
||||
|
||||
void RenderableFieldlines::initializeDefaultPropertyValues() {
|
||||
@@ -200,12 +209,13 @@ bool RenderableFieldlines::initialize() {
|
||||
return false;
|
||||
}
|
||||
|
||||
_program = ghoul::opengl::ProgramObject::Build(
|
||||
_program = OsEng.renderEngine().buildRenderProgram(
|
||||
"Fieldline",
|
||||
"${MODULE_FIELDLINES}/shaders/fieldline_vs.glsl",
|
||||
"${MODULE_FIELDLINES}/shaders/fieldline_fs.glsl",
|
||||
"${MODULE_FIELDLINES}/shaders/fieldline_gs.glsl"
|
||||
);
|
||||
|
||||
if (!_program)
|
||||
return false;
|
||||
|
||||
@@ -217,6 +227,13 @@ bool RenderableFieldlines::deinitialize() {
|
||||
_fieldlineVAO = 0;
|
||||
glDeleteBuffers(1, &_vertexPositionBuffer);
|
||||
_vertexPositionBuffer = 0;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_program) {
|
||||
renderEngine.removeRenderProgram(_program);
|
||||
_program = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -225,7 +242,7 @@ void RenderableFieldlines::render(const RenderData& data) {
|
||||
_program->setUniform("modelViewProjection", data.camera.viewProjectionMatrix());
|
||||
_program->setUniform("modelTransform", glm::mat4(1.0));
|
||||
_program->setUniform("cameraViewDir", data.camera.viewDirection());
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
setPscUniforms(*_program, data.camera, data.position);
|
||||
|
||||
_program->setUniform("classification", _classification);
|
||||
@@ -240,7 +257,7 @@ void RenderableFieldlines::render(const RenderData& data) {
|
||||
static_cast<GLsizei>(_lineStart.size())
|
||||
);
|
||||
glBindVertexArray(0);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
_program->deactivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
in vec4 gs_color;
|
||||
in vec4 gs_position;
|
||||
in vec3 gs_normal;
|
||||
@@ -31,19 +29,44 @@ in vec3 gs_normal;
|
||||
uniform bool classification;
|
||||
uniform vec4 fieldLineColor;
|
||||
|
||||
#include "ABuffer/abufferStruct.hglsl"
|
||||
#include "ABuffer/abufferAddToBuffer.hglsl"
|
||||
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
void main() {
|
||||
|
||||
Fragment getFragment()
|
||||
{
|
||||
float alpha = 1-length(gs_normal)*length(gs_normal);
|
||||
vec4 fragColor;
|
||||
if (classification)
|
||||
fragColor = vec4(gs_color.rgb, alpha);
|
||||
fragColor = vec4(gs_color.rgb * alpha, 1.0);
|
||||
else
|
||||
fragColor = vec4(fieldLineColor.rgb, fieldLineColor.a * alpha);
|
||||
fragColor = vec4(fieldLineColor.rgb * fieldLineColor.a * alpha, 1.0);
|
||||
|
||||
float depth = pscDepth(gs_position);
|
||||
ABufferStruct_t frag = createGeometryFragment(fragColor, gs_position, depth);
|
||||
addToBuffer(frag);
|
||||
}
|
||||
|
||||
Fragment frag;
|
||||
frag.depth = depth;
|
||||
frag.color = fragColor;
|
||||
return frag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #include "ABuffer/abufferStruct.hglsl"
|
||||
// #include "ABuffer/abufferAddToBuffer.hglsl"
|
||||
// #include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
// void main() {
|
||||
// float alpha = 1-length(gs_normal)*length(gs_normal);
|
||||
// vec4 fragColor;
|
||||
// if (classification)
|
||||
// fragColor = vec4(gs_color.rgb, alpha);
|
||||
// else
|
||||
// fragColor = vec4(fieldLineColor.rgb, fieldLineColor.a * alpha);
|
||||
|
||||
// float depth = pscDepth(gs_position);
|
||||
// ABufferStruct_t frag = createGeometryFragment(fragColor, gs_position, depth);
|
||||
// addToBuffer(frag);
|
||||
// }
|
||||
@@ -49,7 +49,7 @@ void ABufferEmitVertex(vec4 pos) {
|
||||
|
||||
// project the position to view space
|
||||
position = modelViewProjection*position;
|
||||
gl_Position = position;
|
||||
gl_Position = z_normalization(position);
|
||||
EmitVertex();
|
||||
}
|
||||
|
||||
|
||||
45
modules/galaxy/CMakeLists.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
#########################################################################################
|
||||
# #
|
||||
# OpenSpace #
|
||||
# #
|
||||
# Copyright (c) 2014-2015 #
|
||||
# #
|
||||
# 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}/galaxymodule.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/galaxyraycaster.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablegalaxy.h
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/galaxymodule.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/galaxyraycaster.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablegalaxy.cpp
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
create_new_module(
|
||||
"Galaxy"
|
||||
galaxy
|
||||
${HEADER_FILES} ${SOURCE_FILES}
|
||||
)
|
||||
41
modules/galaxy/galaxymodule.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* 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/galaxy/galaxymodule.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <modules/galaxy/rendering/renderablegalaxy.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
GalaxyModule::GalaxyModule() : OpenSpaceModule("Galaxy") {}
|
||||
|
||||
void GalaxyModule::internalInitialize() {
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fRenderable, "No renderable factory existed");
|
||||
fRenderable->registerClass<RenderableGalaxy>("RenderableGalaxy");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
40
modules/galaxy/galaxymodule.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* 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 __GALAXYMODULE_H__
|
||||
#define __GALAXYMODULE_H__
|
||||
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class GalaxyModule : public OpenSpaceModule {
|
||||
public:
|
||||
GalaxyModule();
|
||||
void internalInitialize() override;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __GALAXYMODULE_H__
|
||||
4
modules/galaxy/include.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
set (DEFAULT_MODULE ON)
|
||||
set (OPENSPACE_DEPENDENCIES
|
||||
volume
|
||||
)
|
||||
177
modules/galaxy/rendering/galaxyraycaster.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/galaxy/rendering/galaxyraycaster.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <sstream>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
const std::string GlslRaycastPath = "${MODULES}/galaxy/shaders/galaxyraycast.glsl";
|
||||
const std::string GlslBoundsVsPath = "${MODULES}/galaxy/shaders/raycasterbounds.vs";
|
||||
const std::string GlslBoundsFsPath = "${MODULES}/galaxy/shaders/raycasterbounds.fs";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
GalaxyRaycaster::GalaxyRaycaster(ghoul::opengl::Texture& texture)
|
||||
: _boundingBox(glm::vec3(1.0))
|
||||
, _texture(texture)
|
||||
, _textureUnit(nullptr) {}
|
||||
|
||||
GalaxyRaycaster::~GalaxyRaycaster() {}
|
||||
|
||||
void GalaxyRaycaster::initialize() {
|
||||
_boundingBox.initialize();
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::deinitialize() {
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
|
||||
program.setUniform("blendMode", static_cast<unsigned int>(1));
|
||||
|
||||
Renderable::setPscUniforms(program, data.camera, data.position);
|
||||
|
||||
// Cull back face
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
// Render bounding geometry
|
||||
_boundingBox.render();
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject& program) {
|
||||
// Uniforms
|
||||
program.setUniform("modelTransform", _modelTransform);
|
||||
program.setUniform("viewProjection", data.camera.viewProjectionMatrix());
|
||||
program.setUniform("blendMode", static_cast<unsigned int>(1));
|
||||
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 GalaxyRaycaster::preRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
|
||||
std::string colorUniformName = "color" + std::to_string(data.id);
|
||||
std::string stepSizeUniformName = "maxStepSize" + std::to_string(data.id);
|
||||
std::string galaxyTextureUniformName = "galaxyTexture" + std::to_string(data.id);
|
||||
std::string volumeAspectUniformName = "aspect" + std::to_string(data.id);
|
||||
std::string opacityCoefficientUniformName = "opacityCoefficient" + std::to_string(data.id);
|
||||
|
||||
program.setUniform(volumeAspectUniformName, _aspect);
|
||||
program.setUniform(stepSizeUniformName, _stepSize);
|
||||
program.setUniform(opacityCoefficientUniformName, _opacityCoefficient);
|
||||
|
||||
_textureUnit = std::make_unique<ghoul::opengl::TextureUnit>();
|
||||
_textureUnit->activate();
|
||||
_texture.bind();
|
||||
program.setUniform(galaxyTextureUniformName, *_textureUnit);
|
||||
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::postRaycast(const RaycastData& data, ghoul::opengl::ProgramObject& program) {
|
||||
_textureUnit = nullptr; // release texture unit.
|
||||
}
|
||||
|
||||
bool GalaxyRaycaster::cameraIsInside(const RenderData& data, glm::vec3& localPosition) {
|
||||
// Camera rig position in world coordinates.
|
||||
glm::vec4 rigWorldPos = glm::vec4(data.camera.position().vec3(), 1.0);
|
||||
//rigWorldPos /= data.camera.scaling().x * pow(10.0, data.camera.scaling().y);
|
||||
//glm::mat4 invSgctMatrix = glm::inverse(data.camera.viewMatrix());
|
||||
|
||||
// Camera position in world coordinates.
|
||||
glm::vec4 camWorldPos = rigWorldPos;
|
||||
glm::vec3 objPos = data.position.vec3();
|
||||
|
||||
glm::mat4 modelTransform = glm::translate(_modelTransform, objPos);
|
||||
|
||||
float divisor = 1.0;
|
||||
for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) {
|
||||
if (abs(modelTransform[i][j] > divisor)) divisor = modelTransform[i][j];
|
||||
}
|
||||
|
||||
glm::mat4 scaledModelTransform = modelTransform / divisor;
|
||||
|
||||
glm::vec4 modelPos = (glm::inverse(scaledModelTransform) / divisor) * camWorldPos;
|
||||
|
||||
localPosition = (modelPos.xyz() + glm::vec3(0.5));
|
||||
return (localPosition.x > 0 && localPosition.y > 0 && localPosition.z > 0 && localPosition.x < 1 && localPosition.y < 1 && localPosition.z < 1);
|
||||
}
|
||||
|
||||
std::string GalaxyRaycaster::getBoundsVsPath() const {
|
||||
return GlslBoundsVsPath;
|
||||
}
|
||||
|
||||
std::string GalaxyRaycaster::getBoundsFsPath() const {
|
||||
return GlslBoundsFsPath;
|
||||
}
|
||||
|
||||
std::string GalaxyRaycaster::getRaycastPath() const {
|
||||
return GlslRaycastPath;
|
||||
}
|
||||
|
||||
std::string GalaxyRaycaster::getHelperPath() const {
|
||||
return ""; // no helper file
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setAspect(const glm::vec3& aspect) {
|
||||
_aspect = aspect / std::max(std::max(aspect.x, aspect.y), aspect.z);
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setModelTransform(glm::mat4 transform) {
|
||||
_modelTransform = transform;
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setOpacityCoefficient(float opacityCoefficient) {
|
||||
_opacityCoefficient = opacityCoefficient;
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setTime(double time) {
|
||||
_time = time;
|
||||
}
|
||||
|
||||
void GalaxyRaycaster::setStepSize(float stepSize) {
|
||||
_stepSize = stepSize;
|
||||
}
|
||||
|
||||
}
|
||||
87
modules/galaxy/rendering/galaxyraycaster.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __GALAXYRAYCASTER_H__
|
||||
#define __GALAXYRAYCASTER_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 TextureUnit;
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderData;
|
||||
class RaycastData;
|
||||
|
||||
class GalaxyRaycaster : public VolumeRaycaster {
|
||||
public:
|
||||
|
||||
GalaxyRaycaster(ghoul::opengl::Texture& texture);
|
||||
|
||||
virtual ~GalaxyRaycaster();
|
||||
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;
|
||||
bool cameraIsInside(const RenderData& data, glm::vec3& localPosition) override;
|
||||
|
||||
|
||||
std::string getBoundsVsPath() const override;
|
||||
std::string getBoundsFsPath() const override;
|
||||
std::string getRaycastPath() const override;
|
||||
std::string getHelperPath() const override;
|
||||
|
||||
void setAspect(const glm::vec3& aspect);
|
||||
void setModelTransform(glm::mat4 transform);
|
||||
void setTime(double time);
|
||||
void setStepSize(float stepSize);
|
||||
void setOpacityCoefficient(float opacityCoefficient);
|
||||
private:
|
||||
BoxGeometry _boundingBox;
|
||||
float _stepSize;
|
||||
glm::mat4 _modelTransform;
|
||||
glm::vec3 _aspect;
|
||||
double _time;
|
||||
float _opacityCoefficient;
|
||||
ghoul::opengl::Texture& _texture;
|
||||
std::unique_ptr<ghoul::opengl::TextureUnit> _textureUnit;
|
||||
|
||||
}; // GalaxyRaycaster
|
||||
|
||||
} // openspace
|
||||
|
||||
#endif // __GALAXYRRAYCASTER_H__
|
||||
361
modules/galaxy/rendering/renderablegalaxy.cpp
Normal file
@@ -0,0 +1,361 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/galaxy/rendering/renderablegalaxy.h>
|
||||
#include <modules/galaxy/rendering/galaxyraycaster.h>
|
||||
|
||||
#include <ghoul/io/texture/texturereader.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>
|
||||
|
||||
#include <modules/volume/rawvolumereader.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
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";
|
||||
const std::string _loggerCat = "Renderable Galaxy";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _stepSize("stepSize", "Step Size", 0.001, 0.0005, 0.05)
|
||||
, _pointStepSize("pointStepSize", "Point Step Size", 0.01, 0.01, 0.1)
|
||||
, _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)) {
|
||||
|
||||
float stepSize;
|
||||
glm::vec3 scaling, translation, rotation;
|
||||
glm::vec4 color;
|
||||
ghoul::Dictionary volumeDictionary, pointsDictionary;
|
||||
|
||||
if (dictionary.getValue("Translation", translation)) {
|
||||
_translation = translation;
|
||||
}
|
||||
if (dictionary.getValue("Rotation", rotation)) {
|
||||
_rotation = rotation;
|
||||
}
|
||||
if (dictionary.getValue("StepSize", stepSize)) {
|
||||
_stepSize = stepSize;
|
||||
}
|
||||
if (dictionary.getValue("Volume", volumeDictionary)) {
|
||||
std::string volumeFilename;
|
||||
if (volumeDictionary.getValue("Filename", volumeFilename)) {
|
||||
_volumeFilename = absPath(volumeFilename);
|
||||
} else {
|
||||
LERROR("No volume filename specified.");
|
||||
}
|
||||
glm::vec3 volumeDimensions;
|
||||
if (volumeDictionary.getValue("Dimensions", volumeDimensions)) {
|
||||
_volumeDimensions = static_cast<glm::ivec3>(volumeDimensions);
|
||||
} else {
|
||||
LERROR("No volume dimensions specified.");
|
||||
}
|
||||
glm::vec3 volumeSize;
|
||||
if (volumeDictionary.getValue("Size", volumeSize)) {
|
||||
_volumeSize = static_cast<glm::vec3>(volumeSize);
|
||||
}
|
||||
else {
|
||||
LERROR("No volume dimensions specified.");
|
||||
}
|
||||
|
||||
} else {
|
||||
LERROR("No volume dictionary specified.");
|
||||
}
|
||||
if (dictionary.getValue("Points", pointsDictionary)) {
|
||||
std::string pointsFilename;
|
||||
if (pointsDictionary.getValue("Filename", pointsFilename)) {
|
||||
_pointsFilename = absPath(pointsFilename);
|
||||
} else {
|
||||
LERROR("No points filename specified.");
|
||||
}
|
||||
glm::vec3 pointsScaling;
|
||||
if (pointsDictionary.getValue("Scaling", pointsScaling)) {
|
||||
_pointScaling = static_cast<glm::vec3>(pointsScaling);
|
||||
}
|
||||
else {
|
||||
LERROR("No volume dimensions specified.");
|
||||
}
|
||||
} else {
|
||||
LERROR("No points dictionary specified.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RenderableGalaxy::~RenderableGalaxy() {}
|
||||
|
||||
bool RenderableGalaxy::initialize() {
|
||||
// Aspect is currently hardcoded to cubic voxels.
|
||||
_aspect = static_cast<glm::vec3>(_volumeDimensions);
|
||||
_aspect = _aspect / std::max(std::max(_aspect.x, _aspect.y), _aspect.z);
|
||||
|
||||
RawVolumeReader<glm::tvec4<GLfloat>> reader(_volumeFilename, _volumeDimensions);
|
||||
_volume = reader.read();
|
||||
|
||||
_texture = std::make_unique<ghoul::opengl::Texture>(
|
||||
_volumeDimensions,
|
||||
ghoul::opengl::Texture::Format::RGBA,
|
||||
GL_RGBA32F,
|
||||
GL_FLOAT,
|
||||
ghoul::opengl::Texture::FilterMode::Linear,
|
||||
ghoul::opengl::Texture::WrappingMode::Clamp);
|
||||
|
||||
_texture->setPixelData(reinterpret_cast<char*>(_volume->data()), ghoul::opengl::Texture::TakeOwnership::No);
|
||||
_texture->setDimensions(_volume->dimensions());
|
||||
_texture->uploadTexture();
|
||||
|
||||
_raycaster = std::make_unique<GalaxyRaycaster>(*_texture);
|
||||
_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(_stepSize);
|
||||
addProperty(_pointStepSize);
|
||||
addProperty(_translation);
|
||||
addProperty(_rotation);
|
||||
|
||||
// initialize points.
|
||||
std::ifstream pointFile(_pointsFilename, std::ios::in | std::ios::binary);
|
||||
|
||||
std::vector<glm::vec3> pointPositions;
|
||||
std::vector<glm::vec3> pointColors;
|
||||
|
||||
int64_t nPoints;
|
||||
pointFile.seekg(0, std::ios::beg); // read heder.
|
||||
pointFile.read(reinterpret_cast<char*>(&nPoints), sizeof(int64_t));
|
||||
|
||||
_nPoints = static_cast<size_t>(nPoints);
|
||||
|
||||
size_t nFloats = _nPoints * 7;
|
||||
|
||||
float* pointData = new float[nFloats];
|
||||
pointFile.seekg(sizeof(int64_t), std::ios::beg); // read past heder.
|
||||
pointFile.read(reinterpret_cast<char*>(pointData), nFloats * sizeof(float));
|
||||
pointFile.close();
|
||||
|
||||
float maxdist = 0;
|
||||
|
||||
|
||||
float x, y, z, r, g, b, a;
|
||||
for (size_t i = 0; i < _nPoints; ++i) {
|
||||
float x = pointData[i * 7 + 0];
|
||||
float y = pointData[i * 7 + 1];
|
||||
float z = pointData[i * 7 + 2];
|
||||
float r = pointData[i * 7 + 3];
|
||||
float g = pointData[i * 7 + 4];
|
||||
float b = pointData[i * 7 + 5];
|
||||
maxdist = std::max(maxdist, glm::length(glm::vec3(x, y, z)));
|
||||
//float a = pointData[i * 7 + 6]; alpha is not used.
|
||||
|
||||
pointPositions.push_back(glm::vec3(x, y, z));
|
||||
pointColors.push_back(glm::vec3(r, g, b));
|
||||
}
|
||||
|
||||
std::cout << maxdist << std::endl;
|
||||
|
||||
delete[] pointData;
|
||||
|
||||
glGenVertexArrays(1, &_pointsVao);
|
||||
glGenBuffers(1, &_positionVbo);
|
||||
glGenBuffers(1, &_colorVbo);
|
||||
|
||||
glBindVertexArray(_pointsVao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _positionVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
pointPositions.size()*sizeof(glm::vec3),
|
||||
pointPositions.data(),
|
||||
GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
|
||||
glBufferData(GL_ARRAY_BUFFER,
|
||||
pointColors.size()*sizeof(glm::vec3),
|
||||
pointColors.data(),
|
||||
GL_STATIC_DRAW);
|
||||
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
_pointsProgram = renderEngine.buildRenderProgram("Galaxy points",
|
||||
"${MODULE_GALAXY}/shaders/points.vs",
|
||||
"${MODULE_GALAXY}/shaders/points.fs",
|
||||
ghoul::Dictionary(),
|
||||
RenderEngine::RenderProgramType::Post);
|
||||
|
||||
_pointsProgram->setIgnoreUniformLocationError(ghoul::opengl::ProgramObject::IgnoreError::Yes);
|
||||
|
||||
GLint positionAttrib = _pointsProgram->attributeLocation("inPosition");
|
||||
GLint colorAttrib = _pointsProgram->attributeLocation("inColor");
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _positionVbo);
|
||||
glEnableVertexAttribArray(positionAttrib);
|
||||
glVertexAttribPointer(positionAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _colorVbo);
|
||||
glEnableVertexAttribArray(colorAttrib);
|
||||
glVertexAttribPointer(colorAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderableGalaxy::deinitialize() {
|
||||
if (_raycaster) {
|
||||
OsEng.renderEngine().raycasterManager().detachRaycaster(*_raycaster.get());
|
||||
_raycaster = nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderableGalaxy::isReady() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderableGalaxy::update(const UpdateData& data) {
|
||||
if (_raycaster) {
|
||||
|
||||
//glm::mat4 transform = glm::translate(, static_cast<glm::vec3>(_translation));
|
||||
glm::vec3 eulerRotation = static_cast<glm::vec3>(_rotation);
|
||||
glm::mat4 transform = glm::rotate(glm::mat4(1.0), 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));
|
||||
|
||||
|
||||
glm::mat4 volumeTransform = glm::scale(transform, static_cast<glm::vec3>(_volumeSize));
|
||||
_pointTransform = glm::scale(transform, static_cast<glm::vec3>(_pointScaling));
|
||||
|
||||
// Todo: handle floating point overflow, to actually support translation.
|
||||
volumeTransform = glm::translate(volumeTransform, static_cast<glm::vec3>(_translation));
|
||||
_pointTransform = glm::translate(_pointTransform, static_cast<glm::vec3>(_translation));
|
||||
|
||||
_raycaster->setStepSize(_stepSize);
|
||||
_raycaster->setAspect(_aspect);
|
||||
_raycaster->setModelTransform(volumeTransform);
|
||||
_raycaster->setTime(data.time);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) {
|
||||
RaycasterTask task{ _raycaster.get(), data };
|
||||
|
||||
glm::vec3 position = data.camera.position().vec3();
|
||||
float length = safeLength(position);
|
||||
glm::vec3 galaxySize = static_cast<glm::vec3>(_volumeSize);
|
||||
|
||||
float maxDim = std::max(std::max(galaxySize.x, galaxySize.y), galaxySize.z);
|
||||
|
||||
|
||||
float lowerRampStart = maxDim * 0.02;
|
||||
float lowerRampEnd = maxDim * 0.5;
|
||||
|
||||
float upperRampStart = maxDim * 2.0;
|
||||
float upperRampEnd = maxDim * 10;
|
||||
|
||||
float opacityCoefficient = 1.0;
|
||||
|
||||
if (length < lowerRampStart) {
|
||||
opacityCoefficient = 0; // camera really close
|
||||
} else if (length < lowerRampEnd) {
|
||||
opacityCoefficient = (length - lowerRampStart) / (lowerRampEnd - lowerRampStart);
|
||||
} else if (length < upperRampStart) {
|
||||
opacityCoefficient = 1.0; // sweet spot (max)
|
||||
} else if (length < upperRampEnd) {
|
||||
opacityCoefficient = 1.0 - (length - upperRampStart) / (upperRampEnd - upperRampStart); //fade out
|
||||
} else {
|
||||
opacityCoefficient = 0;
|
||||
}
|
||||
|
||||
_opacityCoefficient = opacityCoefficient;
|
||||
ghoul_assert(_opacityCoefficient >= 0.0 && _opacityCoefficient <= 1.0, "Opacity coefficient was not between 0 and 1");
|
||||
if (opacityCoefficient > 0) {
|
||||
_raycaster->setOpacityCoefficient(_opacityCoefficient);
|
||||
tasks.raycasterTasks.push_back(task);
|
||||
}
|
||||
}
|
||||
|
||||
float RenderableGalaxy::safeLength(const glm::vec3& vector) {
|
||||
float maxComponent = std::max(std::max(std::abs(vector.x), std::abs(vector.y)), std::abs(vector.z));
|
||||
return glm::length(vector / maxComponent) * maxComponent;
|
||||
}
|
||||
|
||||
void RenderableGalaxy::postRender(const RenderData& data) {
|
||||
|
||||
_raycaster->setStepSize(_pointStepSize);
|
||||
|
||||
_pointsProgram->activate();
|
||||
setPscUniforms(*_pointsProgram.get(), data.camera, data.position);
|
||||
|
||||
OsEng.ref().renderEngine().preRaycast(*_pointsProgram);
|
||||
|
||||
glm::mat4 modelMatrix = _pointTransform;
|
||||
glm::mat4 viewMatrix = data.camera.viewMatrix();
|
||||
glm::mat4 projectionMatrix = data.camera.projectionMatrix();
|
||||
|
||||
_pointsProgram->setUniform("model", modelMatrix);
|
||||
_pointsProgram->setUniform("view", viewMatrix);
|
||||
_pointsProgram->setUniform("projection", projectionMatrix);
|
||||
|
||||
float emittanceFactor = _opacityCoefficient * static_cast<glm::vec3>(_volumeSize).x;
|
||||
_pointsProgram->setUniform("emittanceFactor", emittanceFactor);
|
||||
|
||||
glBindVertexArray(_pointsVao);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(false);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glDrawArrays(GL_POINTS, 0, _nPoints);
|
||||
glBindVertexArray(0);
|
||||
glDepthMask(true);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
OsEng.ref().renderEngine().postRaycast(*_pointsProgram);
|
||||
}
|
||||
|
||||
}
|
||||
79
modules/galaxy/rendering/renderablegalaxy.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 __RENDERABLEGALAXY_H__
|
||||
#define __RENDERABLEGALAXY_H__
|
||||
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/util/boxgeometry.h>
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <modules/galaxy/rendering/galaxyraycaster.h>
|
||||
#include <modules/volume/rawvolume.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct RenderData;
|
||||
|
||||
class RenderableGalaxy : public Renderable {
|
||||
public:
|
||||
RenderableGalaxy(const ghoul::Dictionary& dictionary);
|
||||
~RenderableGalaxy();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
bool isReady() const override;
|
||||
void render(const RenderData& data, RendererTasks& tasks) override;
|
||||
void postRender(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
float safeLength(const glm::vec3& vector);
|
||||
|
||||
glm::vec3 _volumeSize;
|
||||
glm::vec3 _pointScaling;
|
||||
properties::FloatProperty _stepSize;
|
||||
properties::FloatProperty _pointStepSize;
|
||||
properties::Vec3Property _translation;
|
||||
properties::Vec3Property _rotation;
|
||||
|
||||
std::string _volumeFilename;
|
||||
glm::ivec3 _volumeDimensions;
|
||||
std::string _pointsFilename;
|
||||
|
||||
std::unique_ptr<GalaxyRaycaster> _raycaster;
|
||||
std::unique_ptr<RawVolume<glm::tvec4<GLfloat>>> _volume;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
glm::mat4 _pointTransform;
|
||||
glm::vec3 _aspect;
|
||||
float _opacityCoefficient;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _pointsProgram;
|
||||
size_t _nPoints;
|
||||
GLuint _pointsVao;
|
||||
GLuint _positionVbo;
|
||||
GLuint _colorVbo;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __RENDERABLEGALAXY_H__
|
||||
97
modules/galaxy/shaders/galaxyraycast.glsl
Normal file
@@ -0,0 +1,97 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 float maxStepSize#{id} = 0.1;
|
||||
uniform vec3 aspect#{id} = vec3(1.0);
|
||||
uniform float opacityCoefficient#{id} = 1.0;
|
||||
|
||||
uniform sampler3D galaxyTexture#{id};
|
||||
|
||||
void sample#{id}(vec3 samplePos,
|
||||
vec3 dir,
|
||||
inout vec3 accumulatedColor,
|
||||
inout vec3 accumulatedAlpha,
|
||||
inout float maxStepSize) {
|
||||
|
||||
vec3 aspect = aspect#{id};
|
||||
maxStepSize = maxStepSize#{id} * length(dir * 1/aspect);
|
||||
|
||||
vec4 sampledColor = texture(galaxyTexture#{id}, samplePos.xyz);
|
||||
|
||||
float STEP_SIZE = maxStepSize;
|
||||
|
||||
vec3 alphaTint = vec3(0.3, 0.54, 0.85);
|
||||
//alphaTint = vec3(0.0, 0.5, 1.0);
|
||||
|
||||
sampledColor = sampledColor*sampledColor;
|
||||
sampledColor.a = pow(sampledColor.a, 0.7);
|
||||
//sampledColor.rgba = min(vec4(1.0), sampledColor.rgba);
|
||||
|
||||
//sampledColor.a = clamp(sampledColor.a * 10000000000.0, 0.0, 1.0);
|
||||
//sampledColor.a = exp(-sampledColor.a);
|
||||
//
|
||||
|
||||
//sampledColor.rgb = pow(sampledColor.rgb, vec3(10.0));
|
||||
//sampledColor.a = pow(sampledColor.a, 10.0);
|
||||
//sampledColor.a = pow(sampledColor.a, 100000000.0);
|
||||
sampledColor.rgb *= 4000.0;
|
||||
sampledColor.a = sampledColor.a * 0.3; //1.0;
|
||||
|
||||
|
||||
//float emissionCoefficient = 80;
|
||||
//float absorptionCoefficient = 1;
|
||||
// sampledColor = clamp(sampledColor, 0.0, 1.0);
|
||||
|
||||
//backColor = vec3(1.0) - pow(vec3(1.0) - backColor, vec3(STEP_SIZE));
|
||||
/*if (sampledColor.a > 1.0) {
|
||||
sampledColor.a = 1.0;
|
||||
//accumulatedColor = vec3(1.0, 0.0, 0.0);
|
||||
//accumulatedAlpha = vec3(1.0, 1.0, 1.0);
|
||||
//return;
|
||||
}*/
|
||||
//sampledColor.a = 1.2;
|
||||
|
||||
//sampledColor.a *= 0.00001;
|
||||
|
||||
vec3 backColor = sampledColor.rgb;
|
||||
vec3 backAlpha = sampledColor.a * alphaTint;
|
||||
|
||||
backColor *= STEP_SIZE * opacityCoefficient#{id};
|
||||
backAlpha *= STEP_SIZE * opacityCoefficient#{id};
|
||||
|
||||
backColor = clamp(backColor, 0.0, 1.0);
|
||||
backAlpha = clamp(backAlpha, 0.0, 1.0);
|
||||
|
||||
vec3 oneMinusFrontAlpha = vec3(1.0) - accumulatedAlpha;
|
||||
accumulatedColor += oneMinusFrontAlpha * backColor;
|
||||
accumulatedAlpha += oneMinusFrontAlpha * backAlpha;
|
||||
|
||||
// acc+= 1.0;
|
||||
|
||||
//accumulatedColor = vec3(opacityCoefficient#{id});
|
||||
}
|
||||
|
||||
float stepSize#{id}(vec3 samplePos, vec3 dir) {
|
||||
return maxStepSize#{id} * length(dir * 1.0/aspect#{id});
|
||||
}
|
||||
47
modules/galaxy/shaders/points.fs
Normal file
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
uniform float emittanceFactor;
|
||||
|
||||
in vec3 vsPosition;
|
||||
in vec3 vsColor;
|
||||
|
||||
#include "fragment.glsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
Fragment getFragment() {
|
||||
vec4 color = vec4(vsColor, 1.0);
|
||||
|
||||
Fragment frag;
|
||||
float depth = pscDepth(vec4(vsPosition, 0.0));
|
||||
|
||||
float coefficient = exp(1.27 * log(emittanceFactor) - 2*log(depth));
|
||||
|
||||
frag.color = vec4(vsColor.rgb * coefficient, 1.0);
|
||||
|
||||
|
||||
frag.depth = depth;
|
||||
|
||||
return frag;
|
||||
}
|
||||
50
modules/galaxy/shaders/points.vs
Normal file
@@ -0,0 +1,50 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec3 inColor;
|
||||
|
||||
out vec3 vsPosition;
|
||||
out vec3 vsColor;
|
||||
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vec4 p = vec4(inPosition, 0.0);
|
||||
|
||||
vec4 tmp = p;
|
||||
vec4 position = pscTransform(tmp, model);
|
||||
vsPosition = position.xyz;
|
||||
position = projection * view * position;
|
||||
gl_Position = z_normalization(position);
|
||||
|
||||
vsColor = inColor;
|
||||
}
|
||||
43
modules/galaxy/shaders/raycasterbounds.fs
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. *
|
||||
****************************************************************************************/
|
||||
|
||||
in vec3 vPosition;
|
||||
in vec4 worldPosition;
|
||||
|
||||
uniform uint blendMode;
|
||||
|
||||
#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;
|
||||
frag.blend = blendMode;
|
||||
return frag;
|
||||
}
|
||||
48
modules/galaxy/shaders/raycasterbounds.vs
Normal file
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 = vec4(vertPosition.xyz, 0.0);
|
||||
vec4 position = pscTransform(worldPosition, modelTransform);
|
||||
|
||||
|
||||
|
||||
// project the position to view space
|
||||
gl_Position = z_normalization(viewProjection * position);
|
||||
//gl_Position.z = 1.0;
|
||||
}
|
||||