mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-08 04:31:08 -06:00
removed module Fluxnodes, added renderables to base and space.
This commit is contained in:
@@ -25,7 +25,7 @@ local EUV_Layer = {
|
||||
Type = "RenderableTimeVaryingSphere",
|
||||
Size = 6.96E8, -- Slightly bigger than the sun renderable,
|
||||
Enabled = false,
|
||||
Texture = textureSourcePath,
|
||||
TextureSource = textureSourcePath,
|
||||
--BlendMode = "Additive",
|
||||
Opacity = 1,
|
||||
Segments = 132
|
||||
|
||||
@@ -6,10 +6,10 @@ local transferFunctions = asset.localResource("transferfunctions")
|
||||
local masVelocityColorTable = transferFunctions .. "/velocity_fieldlines.txt"
|
||||
local masDensityColorTable = transferFunctions .. "/density_fieldlines.txt"
|
||||
|
||||
local fieldlinesDirectory = 'D:/data/2000_01_01_event/cdf/GM_CDF'
|
||||
local fieldlinesDirectory = 'D:/data/2000_01_01_event/cdf'
|
||||
--local fieldlinesDirectory = 'C:/Users/eolsson/Documents/openspace/data/20000101/osfls'
|
||||
--local seedPointDirectory = 'D:/data/2000_01_01_event/seedpoints'
|
||||
local seedPointDirectory = 'D:/data/2000_01_01_event/seedpoints/Masha_Kuznetsova_030106_2_data_257970025845'
|
||||
local seedPointDirectory = 'D:/data/2000_01_01_event/seedpoints'
|
||||
|
||||
--local sunRadius = 6.957E8
|
||||
local earthRadius = 6378137
|
||||
@@ -41,7 +41,9 @@ local fieldlines = {
|
||||
{ 100, 2000 }
|
||||
},
|
||||
ExtraVariables = {
|
||||
"rho"
|
||||
"rho",
|
||||
"p",
|
||||
"t"
|
||||
},
|
||||
ManualTimeOffset = -14400.0,
|
||||
LoadAtRuntime = true,
|
||||
|
||||
@@ -50,7 +50,9 @@ set(HEADER_FILES
|
||||
rendering/renderableplane.h
|
||||
rendering/renderableplaneimagelocal.h
|
||||
rendering/renderableplaneimageonline.h
|
||||
rendering/renderableplanetimevaryingimage.h
|
||||
rendering/renderablesphere.h
|
||||
rendering/renderabletimevaryingsphere.h
|
||||
rendering/renderabletrail.h
|
||||
rendering/renderabletrailorbit.h
|
||||
rendering/renderabletrailtrajectory.h
|
||||
@@ -101,7 +103,9 @@ set(SOURCE_FILES
|
||||
rendering/renderableplane.cpp
|
||||
rendering/renderableplaneimagelocal.cpp
|
||||
rendering/renderableplaneimageonline.cpp
|
||||
rendering/renderableplanetimevaryingimage.cpp
|
||||
rendering/renderablesphere.cpp
|
||||
rendering/renderabletimevaryingsphere.cpp
|
||||
rendering/renderabletrail.cpp
|
||||
rendering/renderabletrailorbit.cpp
|
||||
rendering/renderabletrailtrajectory.cpp
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
#include <modules/base/rendering/renderabletrailtrajectory.h>
|
||||
#include <modules/base/rendering/renderableplaneimagelocal.h>
|
||||
#include <modules/base/rendering/renderableplaneimageonline.h>
|
||||
#include <modules/base/rendering/renderableplanetimevaryingimage.h>
|
||||
#include <modules/base/rendering/renderabletimevaryingsphere.h>
|
||||
#include <modules/base/rendering/screenspacedashboard.h>
|
||||
#include <modules/base/rendering/screenspaceimagelocal.h>
|
||||
#include <modules/base/rendering/screenspaceimageonline.h>
|
||||
@@ -131,6 +133,8 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
fRenderable->registerClass<RenderableNodeLine>("RenderableNodeLine");
|
||||
fRenderable->registerClass<RenderablePlaneImageLocal>("RenderablePlaneImageLocal");
|
||||
fRenderable->registerClass<RenderablePlaneImageOnline>("RenderablePlaneImageOnline");
|
||||
fRenderable->registerClass<RenderablePlaneTimeVaryingImage>("RenderablePlaneTimeVaryingImage");
|
||||
fRenderable->registerClass<RenderableTimeVaryingSphere>("RenderableTimeVaryingSphere");
|
||||
fRenderable->registerClass<RenderableRadialGrid>("RenderableRadialGrid");
|
||||
fRenderable->registerClass<RenderableSphere>("RenderableSphere");
|
||||
fRenderable->registerClass<RenderableSphericalGrid>("RenderableSphericalGrid");
|
||||
@@ -199,10 +203,12 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
|
||||
RenderablePlane::Documentation(),
|
||||
RenderablePlaneImageLocal::Documentation(),
|
||||
RenderablePlaneImageOnline::Documentation(),
|
||||
RenderablePlaneTimeVaryingImage::Documentation(),
|
||||
RenderableRadialGrid::Documentation(),
|
||||
RenderableDisc::Documentation(),
|
||||
RenderableSphere::Documentation(),
|
||||
RenderableSphericalGrid::Documentation(),
|
||||
RenderableTimeVaryingSphere::Documentation(),
|
||||
RenderableTrailOrbit::Documentation(),
|
||||
RenderableTrailTrajectory::Documentation(),
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
|
||||
#pragma optimize ("", off)
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
* 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/fluxnodes/rendering/renderableplanetimevaryingimage.h>
|
||||
#include <modules/base/rendering/renderableplanetimevaryingimage.h>
|
||||
#include <modules/base/basemodule.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
@@ -92,29 +91,21 @@ RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage(
|
||||
|
||||
, _texturePath(TextureInfo)
|
||||
{
|
||||
codegen::bake<Parameters>(dictionary);
|
||||
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderablePlaneTimeVaryingImage"
|
||||
);
|
||||
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_blendMode);
|
||||
|
||||
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
|
||||
|
||||
_texturePath = absPath(p.texture).string();
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath.value());
|
||||
|
||||
addProperty(_texturePath);
|
||||
_texturePath.onChange([this]() {loadTexture(); });
|
||||
_textureFile->setCallback(
|
||||
[this](const ghoul::filesystem::File&) { _textureIsDirty = true; }
|
||||
[this]() { _textureIsDirty = true; }
|
||||
);
|
||||
|
||||
if (dictionary.hasKey(RenderableTypeInfo.identifier)) {
|
||||
std::string renderType = dictionary.value<std::string>(
|
||||
RenderableTypeInfo.identifier
|
||||
);
|
||||
if (p.renderableType.has_value()) {
|
||||
std::string renderType = *p.renderableType;
|
||||
if (renderType == "Background") {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
@@ -140,14 +131,14 @@ RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage(
|
||||
|
||||
if (_isLoadingLazily) {
|
||||
_enabled.onChange([this]() {
|
||||
if (!_enabled) {
|
||||
BaseModule::TextureManager.release(_texture);
|
||||
_texture = nullptr;
|
||||
}
|
||||
if (_enabled) {
|
||||
_textureIsDirty = true;
|
||||
}
|
||||
});
|
||||
else {
|
||||
BaseModule::TextureManager.release(_texture);
|
||||
_texture = nullptr;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,8 +169,8 @@ void RenderablePlaneTimeVaryingImage::initializeGL() {
|
||||
|
||||
for (int i = 0; i < _sourceFiles.size(); ++i) {
|
||||
|
||||
_textureFiles[i] = ghoul::io::TextureReader::ref().loadTexture
|
||||
(absPath(_sourceFiles[i]));
|
||||
_textureFiles[i] = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_sourceFiles[i]).string());
|
||||
_textureFiles[i]->setInternalFormat(GL_COMPRESSED_RGBA);
|
||||
_textureFiles[i]->uploadTexture();
|
||||
_textureFiles[i]->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
@@ -192,13 +183,18 @@ bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary()
|
||||
{
|
||||
// Ensure that the source folder exists and then extract
|
||||
// the files with the same extension as <inputFileTypeString>
|
||||
ghoul::filesystem::Directory sourceFolder(_texturePath);
|
||||
if (FileSys.directoryExists(sourceFolder)) {
|
||||
namespace fs = std::filesystem;
|
||||
fs::path sourceFolder = _texturePath.value();
|
||||
if (std::filesystem::is_directory(sourceFolder)) {
|
||||
// Extract all file paths from the provided folder
|
||||
_sourceFiles = sourceFolder.readFiles(
|
||||
ghoul::filesystem::Directory::Recursive::No,
|
||||
ghoul::filesystem::Directory::Sort::Yes
|
||||
);
|
||||
_sourceFiles.clear();
|
||||
namespace fs = std::filesystem;
|
||||
for (const fs::directory_entry& e : fs::directory_iterator(sourceFolder)) {
|
||||
if (e.is_regular_file()) {
|
||||
_sourceFiles.push_back(e.path().string());
|
||||
}
|
||||
}
|
||||
std::sort(_sourceFiles.begin(), _sourceFiles.end());
|
||||
// Ensure that there are available and valid source files left
|
||||
if (_sourceFiles.empty()) {
|
||||
LERROR(fmt::format(
|
||||
@@ -22,7 +22,7 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/fluxnodes/rendering/renderabletimevaryingsphere.h>
|
||||
#include <modules/base/rendering/renderabletimevaryingsphere.h>
|
||||
|
||||
#include <modules/base/basemodule.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
@@ -39,6 +39,8 @@
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/misc/crc32.h>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "Sphere";
|
||||
@@ -54,12 +56,12 @@ namespace {
|
||||
Both
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
"This value specifies an image that is loaded from disk and is used as a texture "
|
||||
"that is applied to this sphere. This image is expected to be an equirectangular "
|
||||
"projection."
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureSourceInfo = {
|
||||
"TextureSource",
|
||||
"TextureSource",
|
||||
"This value specifies a directory of images that are loaded from disk and is used"
|
||||
"as a texture that is applied to this sphere. The images are expected to be an"
|
||||
"equirectangular projection."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo MirrorTextureInfo = {
|
||||
@@ -118,84 +120,57 @@ namespace {
|
||||
"Sets the current sphere rendering as a background rendering type",
|
||||
"Enables/Disables background rendering."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenerableTimeVaryingSphere)]] Parameters {
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
float size;
|
||||
|
||||
// [[codegen::verbatim(SegmentsInfo.description)]]
|
||||
int segments;
|
||||
|
||||
// [[codegen::verbatim(TextureSourceInfo.description)]]
|
||||
std::string textureSource;
|
||||
|
||||
enum class Orientation {
|
||||
Outside,
|
||||
Inside,
|
||||
Both
|
||||
};
|
||||
|
||||
// [[codegen::verbatim(OrientationInfo.description)]]
|
||||
std::optional<Orientation> orientation;
|
||||
|
||||
// [[codegen::verbatim(UseAdditiveBlendingInfo.description)]]
|
||||
std::optional<bool> useAdditiveBlending;
|
||||
|
||||
// [[codegen::verbatim(MirrorTextureInfo.description)]]
|
||||
std::optional<bool> mirrorTexture;
|
||||
|
||||
// [[codegen::verbatim(FadeOutThresholdInfo.description)]]
|
||||
std::optional<float> fadeOutThreshold [[codegen::inrange(0.0, 1.0)]];
|
||||
|
||||
// [[codegen::verbatim(FadeInThresholdInfo.description)]]
|
||||
std::optional<float> fadeInThreshold;
|
||||
|
||||
// [[codegen::verbatim(DisableFadeInOutInfo.description)]]
|
||||
std::optional<bool> disableFadeInOut;
|
||||
|
||||
// [[codegen::verbatim(BackgroundInfo.description)]]
|
||||
std::optional<bool> background;
|
||||
};
|
||||
#include "renderabletimevaryingsphere_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableTimeVaryingSphere::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"RenderableTimeVaryingSphere",
|
||||
"base_renderable_sphere",
|
||||
{
|
||||
{
|
||||
SizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::No,
|
||||
SizeInfo.description
|
||||
},
|
||||
{
|
||||
SegmentsInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::No,
|
||||
SegmentsInfo.description
|
||||
},
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
TextureInfo.description
|
||||
},
|
||||
{
|
||||
OrientationInfo.identifier,
|
||||
new StringInListVerifier({ "Inside", "Outside", "Both" }),
|
||||
Optional::Yes,
|
||||
OrientationInfo.description
|
||||
},
|
||||
{
|
||||
UseAdditiveBlendingInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
UseAdditiveBlendingInfo.description
|
||||
},
|
||||
{
|
||||
MirrorTextureInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
MirrorTextureInfo.description
|
||||
},
|
||||
{
|
||||
FadeOutThresholdInfo.identifier,
|
||||
new DoubleInRangeVerifier(0.0, 1.0),
|
||||
Optional::Yes,
|
||||
FadeOutThresholdInfo.description
|
||||
},
|
||||
{
|
||||
FadeInThresholdInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
FadeInThresholdInfo.description
|
||||
},
|
||||
{
|
||||
DisableFadeInOutInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
DisableFadeInOutInfo.description
|
||||
},
|
||||
{
|
||||
BackgroundInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
BackgroundInfo.description
|
||||
},
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_time_varying_sphere";
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _texturePath(TextureInfo)
|
||||
, _textureSourcePath(TextureSourceInfo)
|
||||
, _orientation(OrientationInfo, properties::OptionProperty::DisplayType::Dropdown)
|
||||
, _size(SizeInfo, 1.f, 0.f, 1e35f)
|
||||
, _segments(SegmentsInfo, 8, 4, 1000)
|
||||
@@ -206,18 +181,14 @@ RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(const ghoul::Dictionary
|
||||
, _fadeInThreshold(FadeInThresholdInfo, -1.f, 0.f, 1.f)
|
||||
, _fadeOutThreshold(FadeOutThresholdInfo, -1.f, 0.f, 1.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableTimeVaryingSphere"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
addProperty(_opacity);
|
||||
registerUpdateRenderBinFromOpacity();
|
||||
|
||||
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
|
||||
_segments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
|
||||
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
|
||||
_size = p.size;
|
||||
_segments = p.segments;
|
||||
_textureSourcePath = p.textureSource;
|
||||
|
||||
_orientation.addOptions({
|
||||
{ static_cast<int>(Orientation::Outside), "Outside" },
|
||||
@@ -225,19 +196,19 @@ RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(const ghoul::Dictionary
|
||||
{ static_cast<int>(Orientation::Both), "Both" }
|
||||
});
|
||||
|
||||
if (dictionary.hasKey(OrientationInfo.identifier)) {
|
||||
const std::string& v = dictionary.value<std::string>(OrientationInfo.identifier);
|
||||
if (v == "Inside") {
|
||||
_orientation = static_cast<int>(Orientation::Inside);
|
||||
}
|
||||
else if (v == "Outside") {
|
||||
_orientation = static_cast<int>(Orientation::Outside);
|
||||
}
|
||||
else if (v == "Both") {
|
||||
_orientation = static_cast<int>(Orientation::Both);
|
||||
}
|
||||
else {
|
||||
throw ghoul::MissingCaseException();
|
||||
if (p.orientation.has_value()) {
|
||||
switch (*p.orientation) {
|
||||
case Parameters::Orientation::Inside:
|
||||
_orientation = static_cast<int>(Orientation::Inside);
|
||||
break;
|
||||
case Parameters::Orientation::Outside:
|
||||
_orientation = static_cast<int>(Orientation::Outside);
|
||||
break;
|
||||
case Parameters::Orientation::Both:
|
||||
_orientation = static_cast<int>(Orientation::Both);
|
||||
break;
|
||||
default:
|
||||
throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -245,58 +216,53 @@ RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(const ghoul::Dictionary
|
||||
}
|
||||
addProperty(_orientation);
|
||||
|
||||
_size.setViewOption(properties::Property::ViewOptions::Logarithmic);
|
||||
_size.onChange([this]() {
|
||||
setBoundingSphere(_size);
|
||||
_sphereIsDirty = true;
|
||||
});
|
||||
addProperty(_size);
|
||||
_size.onChange([this]() { _sphereIsDirty = true; });
|
||||
|
||||
addProperty(_segments);
|
||||
_segments.onChange([this]() { _sphereIsDirty = true; });
|
||||
|
||||
addProperty(_texturePath);
|
||||
_texturePath.onChange([this]() { loadTexture(); });
|
||||
addProperty(_textureSourcePath);
|
||||
_textureSourcePath.onChange([this]() { loadTexture(); });
|
||||
|
||||
addProperty(_mirrorTexture);
|
||||
addProperty(_useAdditiveBlending);
|
||||
|
||||
_mirrorTexture = p.mirrorTexture.value_or(_mirrorTexture);
|
||||
_useAdditiveBlending = p.useAdditiveBlending.value_or(_useAdditiveBlending);
|
||||
|
||||
if (dictionary.hasKey(MirrorTextureInfo.identifier)) {
|
||||
_mirrorTexture = dictionary.value<bool>(MirrorTextureInfo.identifier);
|
||||
}
|
||||
if (dictionary.hasKey(UseAdditiveBlendingInfo.identifier)) {
|
||||
_useAdditiveBlending = dictionary.value<bool>(UseAdditiveBlendingInfo.identifier);
|
||||
|
||||
if (_useAdditiveBlending) {
|
||||
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
|
||||
}
|
||||
if (_useAdditiveBlending) {
|
||||
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(FadeOutThresholdInfo.identifier)) {
|
||||
_fadeOutThreshold = static_cast<float>(
|
||||
dictionary.value<double>(FadeOutThresholdInfo.identifier)
|
||||
);
|
||||
bool hasGivenFadeOut = p.fadeOutThreshold.has_value();
|
||||
if (hasGivenFadeOut) {
|
||||
_fadeOutThreshold = *p.fadeOutThreshold;
|
||||
addProperty(_fadeOutThreshold);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(FadeInThresholdInfo.identifier)) {
|
||||
_fadeInThreshold = static_cast<float>(
|
||||
dictionary.value<double>(FadeInThresholdInfo.identifier)
|
||||
);
|
||||
bool hasGivenFadeIn = p.fadeInThreshold.has_value();
|
||||
if (hasGivenFadeIn) {
|
||||
_fadeInThreshold = *p.fadeInThreshold;
|
||||
addProperty(_fadeInThreshold);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(FadeOutThresholdInfo.identifier) ||
|
||||
dictionary.hasKey(FadeInThresholdInfo.identifier)) {
|
||||
_disableFadeInDistance.set(false);
|
||||
if (hasGivenFadeIn || hasGivenFadeOut) {
|
||||
_disableFadeInDistance = false;
|
||||
addProperty(_disableFadeInDistance);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(BackgroundInfo.identifier)) {
|
||||
_backgroundRendering = dictionary.value<bool>(BackgroundInfo.identifier);
|
||||
_backgroundRendering = p.background.value_or(_backgroundRendering);
|
||||
|
||||
if (_backgroundRendering) {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
if (_backgroundRendering) {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
|
||||
setBoundingSphere(_size);
|
||||
setRenderBinFromOpacity();
|
||||
}
|
||||
|
||||
@@ -323,18 +289,19 @@ void RenderableTimeVaryingSphere::initializeGL() {
|
||||
if (!extractMandatoryInfoFromDictionary()) {
|
||||
return;
|
||||
}
|
||||
extractTriggerTimesFromFileNames();
|
||||
computeSequenceEndTime();
|
||||
_textureFiles.resize(_sourceFiles.size());
|
||||
for (int i = 0; i < _sourceFiles.size(); ++i) {
|
||||
//_textureFiles.resize(_sourceFiles.size());
|
||||
for (int i = 0; i < _files.size(); ++i) {
|
||||
|
||||
_textureFiles[i] = ghoul::io::TextureReader::ref().loadTexture(absPath(_sourceFiles[i]));
|
||||
//_textureFiles[i] = ghoul::io::TextureReader::ref().loadTexture(
|
||||
// absPath(_sourceFiles[i]).string());
|
||||
_files[i].texture = ghoul::io::TextureReader::ref().loadTexture(_files[i].path);
|
||||
|
||||
_textureFiles[i]->setInternalFormat(GL_COMPRESSED_RGBA);
|
||||
_textureFiles[i]->uploadTexture();
|
||||
_textureFiles[i]->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_files[i].texture->setInternalFormat(GL_COMPRESSED_RGBA);
|
||||
_files[i].texture->uploadTexture();
|
||||
_files[i].texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
//_textureFiles[i]->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
|
||||
_textureFiles[i]->purgeFromRAM();
|
||||
_files[i].texture->purgeFromRAM();
|
||||
}
|
||||
|
||||
loadTexture();
|
||||
@@ -349,7 +316,7 @@ void RenderableTimeVaryingSphere::deinitializeGL() {
|
||||
global::renderEngine->removeRenderProgram(p);
|
||||
}
|
||||
);
|
||||
_textureFiles.clear();
|
||||
_files.clear();
|
||||
_shader = nullptr;
|
||||
}
|
||||
|
||||
@@ -485,33 +452,53 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&)
|
||||
bool RenderableTimeVaryingSphere::extractMandatoryInfoFromDictionary()
|
||||
{
|
||||
// Ensure that the source folder exists and then extract
|
||||
// the files with the same extension as <inputFileTypeString>
|
||||
ghoul::filesystem::Directory sourceFolder(_texturePath);
|
||||
if (FileSys.directoryExists(sourceFolder)) {
|
||||
// the files with the same extension as <inputFileTypeString>
|
||||
namespace fs = std::filesystem;
|
||||
fs::path sourceFolder = absPath(_textureSourcePath);
|
||||
if (std::filesystem::is_directory(sourceFolder)) {
|
||||
// Extract all file paths from the provided folder
|
||||
_sourceFiles = sourceFolder.readFiles(
|
||||
ghoul::filesystem::Directory::Recursive::No,
|
||||
ghoul::filesystem::Directory::Sort::Yes
|
||||
);
|
||||
_files.clear();
|
||||
//_sourceFiles.clear();
|
||||
namespace fs = std::filesystem;
|
||||
for (const fs::directory_entry& e : fs::directory_iterator(sourceFolder)) {
|
||||
if (e.is_regular_file()) {
|
||||
|
||||
std::string filePath = e.path().string();
|
||||
double time = extractTriggerTimeFromFileName(filePath);
|
||||
std::unique_ptr<ghoul::opengl::Texture> t =
|
||||
ghoul::io::TextureReader::ref().loadTexture(filePath);
|
||||
|
||||
t.get()->setInternalFormat(GL_COMPRESSED_RGBA);
|
||||
t.get()->uploadTexture();
|
||||
t.get()->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
t.get()->purgeFromRAM();
|
||||
|
||||
_files.push_back({ filePath, time, std::move(t) });
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(_files.begin(), _files.end(), [](const FileData& a, const FileData& b) {
|
||||
return a.time > b.time;
|
||||
});
|
||||
// Ensure that there are available and valid source files left
|
||||
if (_sourceFiles.empty()) {
|
||||
/*if (_files.empty()) {
|
||||
LERROR(fmt::format(
|
||||
"{}: {} contains no {} files",
|
||||
_identifier, _texturePath, "extension"
|
||||
_identifier, _textureSourcePath, "extension"
|
||||
));
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else {
|
||||
LERROR(fmt::format(
|
||||
"{}: FieldlinesSequence {} is not a valid directory",
|
||||
_identifier,
|
||||
_texturePath
|
||||
_textureSourcePath
|
||||
));
|
||||
return false;
|
||||
}
|
||||
_nStates = _sourceFiles.size();
|
||||
LDEBUG("returning true");
|
||||
|
||||
LDEBUG("returning true in extractMandatoryInfoFromDictionary");
|
||||
return true;
|
||||
}
|
||||
void RenderableTimeVaryingSphere::update(const UpdateData& data) {
|
||||
@@ -523,7 +510,7 @@ void RenderableTimeVaryingSphere::update(const UpdateData& data) {
|
||||
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
|
||||
}
|
||||
const double currentTime = data.time.j2000Seconds();
|
||||
const bool isInInterval = (currentTime >= _startTimes[0]) &&
|
||||
const bool isInInterval = (currentTime >= _files[0].time) &&
|
||||
(currentTime < _sequenceEndTime);
|
||||
//const bool isInInterval = true;
|
||||
if (isInInterval) {
|
||||
@@ -532,11 +519,11 @@ void RenderableTimeVaryingSphere::update(const UpdateData& data) {
|
||||
// true => Previous frame was not within the sequence interval
|
||||
//_activeTriggerTimeIndex < 0 ||
|
||||
// true => We stepped back to a time represented by another state
|
||||
currentTime < _startTimes[_activeTriggerTimeIndex] ||
|
||||
currentTime < _files[_activeTriggerTimeIndex].time ||
|
||||
// true => We stepped forward to a time represented by another state
|
||||
(nextIdx < _nStates && currentTime >= _startTimes[nextIdx]))
|
||||
(nextIdx < _files.size() && currentTime >= _files[nextIdx].time))
|
||||
{
|
||||
updateActiveTriggerTimeIndex(currentTime);
|
||||
updateActiveTriggerTimeIndex(currentTime);
|
||||
//LDEBUG("Vi borde uppdatera1");
|
||||
|
||||
// _mustLoadNewStateFromDisk = true;
|
||||
@@ -561,37 +548,41 @@ void RenderableTimeVaryingSphere::update(const UpdateData& data) {
|
||||
}
|
||||
// Extract J2000 time from file names
|
||||
// Requires files to be named as such: 'YYYY-MM-DDTHH-MM-SS-XXX.json'
|
||||
void RenderableTimeVaryingSphere::extractTriggerTimesFromFileNames() {
|
||||
double RenderableTimeVaryingSphere::extractTriggerTimeFromFileName(const std::string& filePath) {
|
||||
// number of characters in filename (excluding '.json')
|
||||
constexpr const int FilenameSize = 23;
|
||||
// size(".json")
|
||||
constexpr const int ExtSize = 4;
|
||||
|
||||
for (const std::string& filePath : _sourceFiles) {
|
||||
LDEBUG("filepath " + filePath);
|
||||
const size_t strLength = filePath.size();
|
||||
// Extract the filename from the path (without extension)
|
||||
std::string timeString = filePath.substr(
|
||||
strLength - FilenameSize - ExtSize,
|
||||
FilenameSize - 1
|
||||
);
|
||||
// Ensure the separators are correct
|
||||
timeString.replace(4, 1, "-");
|
||||
timeString.replace(7, 1, "-");
|
||||
timeString.replace(13, 1, ":");
|
||||
timeString.replace(16, 1, ":");
|
||||
timeString.replace(19, 1, ".");
|
||||
const double triggerTime = Time::convertTime(timeString);
|
||||
LDEBUG("timestring " + timeString);
|
||||
_startTimes.push_back(triggerTime);
|
||||
}
|
||||
LDEBUG("filepath " + filePath);
|
||||
const size_t strLength = filePath.size();
|
||||
// Extract the filename from the path (without extension)
|
||||
std::string timeString = filePath.substr(
|
||||
strLength - FilenameSize - ExtSize,
|
||||
FilenameSize - 1
|
||||
);
|
||||
// Ensure the separators are correct
|
||||
timeString.replace(4, 1, "-");
|
||||
timeString.replace(7, 1, "-");
|
||||
timeString.replace(13, 1, ":");
|
||||
timeString.replace(16, 1, ":");
|
||||
timeString.replace(19, 1, ".");
|
||||
|
||||
LDEBUG("timestring " + timeString);
|
||||
return Time::convertTime(timeString);
|
||||
|
||||
}
|
||||
|
||||
void RenderableTimeVaryingSphere::updateActiveTriggerTimeIndex(double currentTime) {
|
||||
auto iter = std::upper_bound(_startTimes.begin(), _startTimes.end(), currentTime);
|
||||
if (iter != _startTimes.end()) {
|
||||
if (iter != _startTimes.begin()) {
|
||||
|
||||
auto iter = std::upper_bound(_files.begin(), _files.end(), currentTime,
|
||||
[](double value, const FileData& f) {
|
||||
return value < f.time;
|
||||
});
|
||||
if (iter != _files.end()) {
|
||||
if (iter != _files.begin()) {
|
||||
_activeTriggerTimeIndex = static_cast<int>(
|
||||
std::distance(_startTimes.begin(), iter)
|
||||
std::distance(_files.begin(), iter)
|
||||
) - 1;
|
||||
}
|
||||
else {
|
||||
@@ -599,15 +590,16 @@ void RenderableTimeVaryingSphere::updateActiveTriggerTimeIndex(double currentTim
|
||||
}
|
||||
}
|
||||
else {
|
||||
_activeTriggerTimeIndex = static_cast<int>(_nStates) - 1;
|
||||
_activeTriggerTimeIndex = static_cast<int>(_files.size()) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableTimeVaryingSphere::computeSequenceEndTime() {
|
||||
if (_nStates > 1) {
|
||||
const double lastTriggerTime = _startTimes[_nStates - 1];
|
||||
const double sequenceDuration = lastTriggerTime - _startTimes[0];
|
||||
if (_files.size() > 1) {
|
||||
const double lastTriggerTime = _files[_files.size() - 1].time;
|
||||
const double sequenceDuration = lastTriggerTime - _files[0].time;
|
||||
const double averageStateDuration = sequenceDuration /
|
||||
(static_cast<double>(_nStates) - 1.0);
|
||||
(static_cast<double>(_files.size()) - 1.0);
|
||||
_sequenceEndTime = lastTriggerTime + averageStateDuration;
|
||||
}
|
||||
else {
|
||||
@@ -615,13 +607,14 @@ void RenderableTimeVaryingSphere::computeSequenceEndTime() {
|
||||
_sequenceEndTime = DBL_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableTimeVaryingSphere::loadTexture() {
|
||||
if (_activeTriggerTimeIndex != -1) {
|
||||
// ghoul::opengl::Texture* t = _texture;
|
||||
// std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
// ghoul::io::TextureReader::ref().loadTexture(_sourceFiles[_activeTriggerTimeIndex]);
|
||||
// unsigned int hash = ghoul::hashCRC32File(_sourceFiles[_activeTriggerTimeIndex]);
|
||||
_texture = _textureFiles[_activeTriggerTimeIndex].get();
|
||||
_texture = _files[_activeTriggerTimeIndex].texture.get();
|
||||
/*
|
||||
if (texture) {
|
||||
LDEBUGC(
|
||||
@@ -43,6 +43,11 @@ namespace openspace {
|
||||
class Sphere;
|
||||
struct RenderData;
|
||||
struct UpdateData;
|
||||
struct FileData {
|
||||
std::string path;
|
||||
double time;
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture;
|
||||
};
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
@@ -62,7 +67,7 @@ public:
|
||||
|
||||
private:
|
||||
void loadTexture();
|
||||
void extractTriggerTimesFromFileNames();
|
||||
double extractTriggerTimeFromFileName(const std::string& filePath);
|
||||
bool extractMandatoryInfoFromDictionary();
|
||||
void updateActiveTriggerTimeIndex(double currenttime);
|
||||
void computeSequenceEndTime();
|
||||
@@ -70,14 +75,14 @@ private:
|
||||
// Estimated end of sequence.
|
||||
double _sequenceEndTime;
|
||||
bool _needsUpdate = false;
|
||||
std::vector<std::string> _sourceFiles;
|
||||
std::vector<double> _startTimes;
|
||||
//std::vector<std::string> _sourceFiles;
|
||||
//std::vector<double> _startTimes;
|
||||
std::vector<FileData> _files;
|
||||
int _activeTriggerTimeIndex = 0;
|
||||
// Number of states in the sequence
|
||||
size_t _nStates = 274;
|
||||
bool _isLoadingTexture = false;
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
properties::StringProperty _textureSourcePath;
|
||||
properties::OptionProperty _orientation;
|
||||
|
||||
properties::FloatProperty _size;
|
||||
@@ -95,7 +100,7 @@ private:
|
||||
//std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
ghoul::opengl::Texture* _texture = nullptr;
|
||||
std::unique_ptr<ghoul::filesystem::File> _textureFile;
|
||||
std::vector<std::unique_ptr<ghoul::opengl::Texture>> _textureFiles;
|
||||
//std::vector<std::unique_ptr<ghoul::opengl::Texture>> _textureFiles;
|
||||
std::unique_ptr<Sphere> _sphere;
|
||||
|
||||
UniformCache(opacity, modelViewProjection, modelViewRotation, colorTexture,
|
||||
@@ -1,55 +0,0 @@
|
||||
##########################################################################################
|
||||
# #
|
||||
# OpenSpace #
|
||||
# #
|
||||
# Copyright (c) 2014-2020 #
|
||||
# #
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this #
|
||||
# software and associated documentation files (the "Software"), to deal in the Software #
|
||||
# without restriction, including without limitation the rights to use, copy, modify, #
|
||||
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to #
|
||||
# permit persons to whom the Software is furnished to do so, subject to the following #
|
||||
# conditions: #
|
||||
# #
|
||||
# The above copyright notice and this permission notice shall be included in all copies #
|
||||
# or substantial portions of the Software. #
|
||||
# #
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, #
|
||||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A #
|
||||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT #
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF #
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE #
|
||||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #
|
||||
##########################################################################################
|
||||
|
||||
include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
|
||||
|
||||
set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefluxnodes.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanetimevaryingimage.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletravelspeed.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletimevaryingsphere.h
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefluxnodes.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplanetimevaryingimage.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletravelspeed.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderabletimevaryingsphere.cpp
|
||||
)
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/fluxnodes_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/fluxnodes_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/travelspeed_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/travelspeed_vs.glsl
|
||||
)
|
||||
source_group("Shader Files" FILES ${SHADER_FILES})
|
||||
|
||||
create_new_module(
|
||||
"FluxNodes"
|
||||
Fluxnodes_module
|
||||
${HEADER_FILES} ${SOURCE_FILES} ${SHADER_FILES}
|
||||
)
|
||||
@@ -1,72 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* 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/fluxnodes/fluxnodesmodule.h>
|
||||
#include <modules/fluxnodes/rendering/renderablefluxnodes.h>
|
||||
#include <modules/fluxnodes/rendering/renderableplanetimevaryingimage.h>
|
||||
#include <modules/fluxnodes/rendering/renderabletravelspeed.h>
|
||||
#include <modules/fluxnodes/rendering/renderabletimevaryingsphere.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
#include <fstream>
|
||||
|
||||
namespace {
|
||||
constexpr const char* DefaultTransferfunctionSource =
|
||||
R"(
|
||||
width 5
|
||||
lower 0.0
|
||||
upper 1.0
|
||||
mappingkey 0.0 0 0 0 255
|
||||
mappingkey 0.25 255 0 0 255
|
||||
mappingkey 0.5 255 140 0 255
|
||||
mappingkey 0.75 255 255 0 255
|
||||
mappingkey 1.0 255 255 255 255
|
||||
)";
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
std::string FluxNodesModule::DefaultTransferFunctionFile = "";
|
||||
|
||||
FluxNodesModule::FluxNodesModule() : OpenSpaceModule(Name) {
|
||||
DefaultTransferFunctionFile = absPath("${TEMPORARY}/default_transfer_function.txt");
|
||||
|
||||
std::ofstream file(DefaultTransferFunctionFile);
|
||||
file << DefaultTransferfunctionSource;
|
||||
}
|
||||
|
||||
void FluxNodesModule::internalInitialize(const ghoul::Dictionary&) {
|
||||
auto factory = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(factory, "No renderable factory existed");
|
||||
|
||||
factory->registerClass<RenderableFluxNodes>("RenderableFluxNodes");
|
||||
factory->registerClass<RenderablePlaneTimeVaryingImage>
|
||||
("RenderablePlaneTimeVaryingImage");
|
||||
factory->registerClass<RenderableTravelSpeed>("RenderableTravelSpeed");
|
||||
factory->registerClass<RenderableTimeVaryingSphere>("RenderableTimeVaryingSphere");
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -1,46 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2021 *
|
||||
* *
|
||||
* 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 __OPENSPACE_MODULE_FLUXNODES___FLUXNODESMODULE___H__
|
||||
#define __OPENSPACE_MODULE_FLUXNODES___FLUXNODESMODULE___H__
|
||||
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class FluxNodesModule : public OpenSpaceModule {
|
||||
public:
|
||||
constexpr static const char* Name = "FluxNodes";
|
||||
|
||||
FluxNodesModule();
|
||||
|
||||
static std::string DefaultTransferFunctionFile;
|
||||
|
||||
private:
|
||||
void internalInitialize(const ghoul::Dictionary&) override;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_FLUXNODES___FLUXNODESMODULE___H__
|
||||
@@ -1,3 +0,0 @@
|
||||
set (OPENSPACE_DEPENDENCIES
|
||||
space
|
||||
)
|
||||
@@ -28,12 +28,14 @@ set(HEADER_FILES
|
||||
speckloader.h
|
||||
rendering/planetgeometry.h
|
||||
rendering/renderableconstellationbounds.h
|
||||
rendering/renderablefluxnodes.h
|
||||
rendering/renderablehabitablezone.h
|
||||
rendering/renderablerings.h
|
||||
rendering/renderableorbitalkepler.h
|
||||
rendering/renderablesatellites.h
|
||||
rendering/renderablesmallbody.h
|
||||
rendering/renderablestars.h
|
||||
rendering/renderabletravelspeed.h
|
||||
rendering/simplespheregeometry.h
|
||||
translation/keplertranslation.h
|
||||
translation/spicetranslation.h
|
||||
@@ -47,12 +49,14 @@ set(SOURCE_FILES
|
||||
speckloader.cpp
|
||||
rendering/planetgeometry.cpp
|
||||
rendering/renderableconstellationbounds.cpp
|
||||
rendering/renderablefluxnodes.cpp
|
||||
rendering/renderablehabitablezone.cpp
|
||||
rendering/renderablerings.cpp
|
||||
rendering/renderableorbitalkepler.cpp
|
||||
rendering/renderablesatellites.cpp
|
||||
rendering/renderablesmallbody.cpp
|
||||
rendering/renderablestars.cpp
|
||||
rendering/renderabletravelspeed.cpp
|
||||
rendering/simplespheregeometry.cpp
|
||||
translation/keplertranslation.cpp
|
||||
translation/spicetranslation.cpp
|
||||
@@ -67,6 +71,8 @@ set(SHADER_FILES
|
||||
shaders/constellationbounds_vs.glsl
|
||||
shaders/debrisViz_fs.glsl
|
||||
shaders/debrisViz_vs.glsl
|
||||
shaders/fluxnodes_fs.glsl
|
||||
shaders/fluxnodes_vs.glsl
|
||||
shaders/habitablezone_vs.glsl
|
||||
shaders/habitablezone_fs.glsl
|
||||
shaders/rings_vs.glsl
|
||||
@@ -74,6 +80,8 @@ set(SHADER_FILES
|
||||
shaders/star_fs.glsl
|
||||
shaders/star_ge.glsl
|
||||
shaders/star_vs.glsl
|
||||
shaders/travelspeed_fs.glsl
|
||||
shaders/travelspeed_vs.glsl
|
||||
)
|
||||
source_group("Shader Files" FILES ${SHADER_FILES})
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* 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/fluxnodes/rendering/renderablefluxnodes.h>
|
||||
#include <modules/space/rendering/renderablefluxnodes.h>
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/windowdelegate.h>
|
||||
@@ -46,13 +46,11 @@
|
||||
#include <openspace/json.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <sys/stat.h>
|
||||
#pragma
|
||||
#include <optional>
|
||||
|
||||
// This is a call to use the nlohmann json file
|
||||
using json = nlohmann::json;
|
||||
|
||||
#pragma optimize("", off)
|
||||
|
||||
namespace {
|
||||
// log category
|
||||
constexpr const char* _loggerCat = "renderableFluxNodes";
|
||||
@@ -386,6 +384,11 @@ namespace {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
struct [[codegen::Dictionary(RenderableFluxNodes)]] Parameters {
|
||||
// path to source folder with the 3 binary files in it
|
||||
};
|
||||
#include "renderablefluxnodes_codegen.cpp"
|
||||
|
||||
// Changed everything from dvec3 to vec3
|
||||
glm::vec3 sphericalToCartesianCoord(glm::vec3 position) {
|
||||
glm::vec3 cartesianPosition = glm::vec3();
|
||||
@@ -402,6 +405,13 @@ namespace {
|
||||
} //namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableFluxNodes::Documentation() {
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_flux_nodes";
|
||||
return doc;
|
||||
}
|
||||
|
||||
using namespace properties;
|
||||
RenderableFluxNodes::RenderableFluxNodes(const ghoul::Dictionary& dictionary)
|
||||
|
||||
@@ -530,8 +540,8 @@ void RenderableFluxNodes::initializeGL() {
|
||||
// Setup shader program
|
||||
_shaderProgram = global::renderEngine->buildRenderProgram(
|
||||
"Fluxnodes",
|
||||
absPath("${MODULE_FLUXNODES}/shaders/fluxnodes_vs.glsl"),
|
||||
absPath("${MODULE_FLUXNODES}/shaders/fluxnodes_fs.glsl")
|
||||
absPath("${MODULE_SPACE}/shaders/fluxnodes_vs.glsl"),
|
||||
absPath("${MODULE_SPACE}/shaders/fluxnodes_fs.glsl")
|
||||
);
|
||||
|
||||
_uniformCache.streamColor = _shaderProgram->uniformLocation("streamColor");
|
||||
@@ -557,10 +567,10 @@ void RenderableFluxNodes::initializeGL() {
|
||||
// Set a default color table, just in case the (optional) user defined paths are
|
||||
// corrupt or not provided!
|
||||
//_colorTablePaths.push_back(FieldlinesSequenceModule::DefaultTransferFunctionFile);
|
||||
_transferFunction = std::make_unique<TransferFunction>(absPath(_colorTablePaths[0]));
|
||||
_transferFunctionCMR = std::make_unique<TransferFunction>(absPath(_colorTablePaths[1]));
|
||||
_transferFunctionEarth = std::make_unique<TransferFunction>(absPath(_colorTablePaths[2])); // what if not in order?
|
||||
_transferFunctionFlow = std::make_unique<TransferFunction>(absPath(_colorTablePaths[3]));
|
||||
_transferFunction = std::make_unique<TransferFunction>(absPath(_colorTablePaths[0]).string());
|
||||
_transferFunctionCMR = std::make_unique<TransferFunction>(absPath(_colorTablePaths[1]).string());
|
||||
_transferFunctionEarth = std::make_unique<TransferFunction>(absPath(_colorTablePaths[2]).string()); // what if not in order?
|
||||
_transferFunctionFlow = std::make_unique<TransferFunction>(absPath(_colorTablePaths[3]).string());
|
||||
//_transferFunctionIlluminance = std::make_unique<TransferFunction>(absPath(_colorTablePaths[4]));
|
||||
//_transferFunctionIlluminance2 = std::make_unique<TransferFunction>(absPath(_colorTablePaths[5]));
|
||||
}
|
||||
@@ -627,7 +637,7 @@ void RenderableFluxNodes::loadNodeData() {
|
||||
}
|
||||
//if the files doesn't exist we create them, this is just so that we then can
|
||||
// cache the actual binary files
|
||||
if (!FileSys.fileExists(_file)) {
|
||||
if (!std::filesystem::is_regular_file(_file)) {
|
||||
std::ofstream fileStream(_file, std::ofstream::binary);
|
||||
std::ofstream fileStream2(_file2, std::ofstream::binary);
|
||||
std::ofstream fileStream3(_file3, std::ofstream::binary);
|
||||
@@ -646,12 +656,9 @@ void RenderableFluxNodes::loadNodeData() {
|
||||
);
|
||||
}
|
||||
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
|
||||
_file,
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
);
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(_file);
|
||||
//Check if we have a cached binary file for the data
|
||||
bool hasCachedFile = FileSys.fileExists(cachedFile);
|
||||
bool hasCachedFile = std::filesystem::is_regular_file(cachedFile);
|
||||
|
||||
if (hasCachedFile) {
|
||||
LINFO(fmt::format("Cached file '{}' used for Speck file '{}'",
|
||||
@@ -783,10 +790,7 @@ void RenderableFluxNodes::writeCachedFile() const {
|
||||
_file2 = "StreamnodesCacheColor_emin03";
|
||||
_file3 = "StreamnodesCacheRadius_emin03";
|
||||
}
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
|
||||
_file,
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
);
|
||||
std::string cachedFile = FileSys.cacheManager()->cachedFilename(_file);
|
||||
std::ofstream fileStream(cachedFile, std::ofstream::binary);
|
||||
|
||||
if (!fileStream.good()) {
|
||||
@@ -801,16 +805,10 @@ void RenderableFluxNodes::writeCachedFile() const {
|
||||
sizeof(int8_t)
|
||||
);
|
||||
|
||||
std::string cachedFile2 = FileSys.cacheManager()->cachedFilename(
|
||||
_file2,
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
);
|
||||
std::string cachedFile2 = FileSys.cacheManager()->cachedFilename(_file2);
|
||||
std::ofstream fileStream2(cachedFile2, std::ofstream::binary);
|
||||
|
||||
std::string cachedFile3 = FileSys.cacheManager()->cachedFilename(
|
||||
_file3,
|
||||
ghoul::filesystem::CacheManager::Persistent::Yes
|
||||
);
|
||||
std::string cachedFile3 = FileSys.cacheManager()->cachedFilename(_file3);
|
||||
std::ofstream fileStream3(cachedFile3, std::ofstream::binary);
|
||||
|
||||
int32_t nValues = static_cast<int32_t>(_vertexRadius.size());
|
||||
@@ -961,7 +959,8 @@ bool RenderableFluxNodes::extractMandatoryInfoFromDictionary()
|
||||
// return false;
|
||||
//}
|
||||
if (!_dictionary->hasValue<std::string>(KeyBinarySourceFolder)) {
|
||||
LERROR(fmt::format("{}: The field {} is missing", _identifier, KeyBinarySourceFolder));
|
||||
LERROR(fmt::format("{}: The field {} is missing", _identifier,
|
||||
KeyBinarySourceFolder));
|
||||
return false;
|
||||
}
|
||||
//constexpr const char temp = '\';
|
||||
@@ -971,13 +970,19 @@ bool RenderableFluxNodes::extractMandatoryInfoFromDictionary()
|
||||
_dictionary->value<std::string>(KeyBinarySourceFolder);
|
||||
_binarySourceFilePath = binarySourceFolderPath;
|
||||
LDEBUG(binarySourceFolderPath);
|
||||
ghoul::filesystem::Directory binarySourceFolder(binarySourceFolderPath);
|
||||
if (FileSys.directoryExists(binarySourceFolder)) {
|
||||
|
||||
if (std::filesystem::is_directory(binarySourceFolderPath)) {
|
||||
// Extract all file paths from the provided folder
|
||||
_binarySourceFiles = binarySourceFolder.readFiles(
|
||||
ghoul::filesystem::Directory::Recursive::No,
|
||||
ghoul::filesystem::Directory::Sort::Yes
|
||||
);
|
||||
_binarySourceFiles.clear();
|
||||
namespace fs = std::filesystem;
|
||||
for (const fs::directory_entry& e : fs::directory_iterator(
|
||||
binarySourceFolderPath)) {
|
||||
if (e.is_regular_file()) {
|
||||
_binarySourceFiles.push_back(e.path().string());
|
||||
}
|
||||
}
|
||||
std::sort(_binarySourceFiles.begin(), _binarySourceFiles.end());
|
||||
|
||||
// Ensure that there are available and valid source files left
|
||||
if (_binarySourceFiles.empty()) {
|
||||
LERROR(fmt::format(
|
||||
@@ -1026,43 +1031,6 @@ bool RenderableFluxNodes::extractMandatoryInfoFromDictionary()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderableFluxNodes::extractJsonInfoFromDictionary(fls::Model& model) {
|
||||
std::string modelStr;
|
||||
if (_dictionary->hasValue<std::string>(KeySimulationModel)) {
|
||||
modelStr = _dictionary->value<std::string>(KeySimulationModel);
|
||||
std::transform(
|
||||
modelStr.begin(),
|
||||
modelStr.end(),
|
||||
modelStr.begin(),
|
||||
[](char c) { return static_cast<char>(::tolower(c)); }
|
||||
);
|
||||
model = fls::stringToModel(modelStr);
|
||||
}
|
||||
else {
|
||||
LERROR(fmt::format(
|
||||
"{}: Must specify '{}'", _identifier, KeySimulationModel
|
||||
));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_dictionary->hasValue<std::string>(KeyLineWidth)) {
|
||||
_pLineWidth = stringToFloat(_dictionary->value<std::string>(KeyLineWidth));
|
||||
}
|
||||
if (_dictionary->hasValue<std::string>(KeyThresholdRadius)) {
|
||||
_pThresholdFlux = stringToFloat(_dictionary->value<std::string>(KeyThresholdRadius));
|
||||
}
|
||||
if (_dictionary->hasValue<std::string>(KeyJsonScalingFactor)) {
|
||||
_scalingFactor = stringToFloat(_dictionary->value<std::string>(KeyJsonScalingFactor));
|
||||
}
|
||||
else {
|
||||
LWARNING(fmt::format(
|
||||
"{}: Does not provide scalingFactor. Assumes coordinates are in meters",
|
||||
_identifier
|
||||
));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderableFluxNodes::setupProperties() {
|
||||
|
||||
// -------------- Add non-grouped properties (enablers and buttons) -------------- //
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
void updateActiveTriggerTimeIndex(double currentTime);
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
std::vector<GLsizei> _lineCount;
|
||||
std::vector<GLint> _lineStart;
|
||||
@@ -308,6 +310,7 @@ private:
|
||||
properties::BoolProperty _pPulseEnabled;
|
||||
properties::BoolProperty _pGaussianPulseEnabled;
|
||||
properties::BoolProperty _pPulseAlways;
|
||||
properties::FloatProperty _scaleFactor;
|
||||
|
||||
//properties::FloatProperty _pTestChange;
|
||||
|
||||
@@ -322,7 +325,6 @@ private:
|
||||
// --------------------- FUNCTIONS USED DURING INITIALIZATION --------------------- //
|
||||
bool extractMandatoryInfoFromDictionary();
|
||||
void definePropertyCallbackFunctions();
|
||||
bool extractJsonInfoFromDictionary(fls::Model& model);
|
||||
std::vector<std::string> LoadJsonfile(std::string filepath);
|
||||
//void extractTriggerTimesFromFileNames();
|
||||
void populateStartTimes();
|
||||
@@ -349,6 +351,5 @@ private:
|
||||
//std::unique_ptr<ghoul::opengl::Texture> _spriteTexture;
|
||||
//std::unique_ptr<ghoul::filesystem::File> _spriteTextureFile;
|
||||
|
||||
properties::FloatProperty _scaleFactor;
|
||||
};
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
* 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/fluxnodes/rendering/renderabletravelspeed.h>
|
||||
#include <modules/space/rendering/renderabletravelspeed.h>
|
||||
|
||||
#include <modules/base/basemodule.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
@@ -188,8 +188,8 @@ void RenderableTravelSpeed::initializeGL() {
|
||||
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
|
||||
return global::renderEngine->buildRenderProgram(
|
||||
"Travelspeed",
|
||||
absPath("${MODULE_FLUXNODES}/shaders/travelspeed_vs.glsl"),
|
||||
absPath("${MODULE_FLUXNODES}/shaders/travelspeed_fs.glsl")
|
||||
absPath("${MODULE_SPACE}/shaders/travelspeed_vs.glsl"),
|
||||
absPath("${MODULE_SPACE}/shaders/travelspeed_fs.glsl")
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -22,8 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_FLUXNODES___RENDERABLETRAVELSPEED___H__
|
||||
#define __OPENSPACE_MODULE_FLUXNODES___RENDERABLETRAVELSPEED___H__
|
||||
#ifndef __OPENSPACE_MODULE_SPACE___RENDERABLETRAVELSPEED___H__
|
||||
#define __OPENSPACE_MODULE_SPACE___RENDERABLETRAVELSPEED___H__
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
@@ -90,4 +90,4 @@ private:
|
||||
UniformCache(lineColor, opacity) _uniformCache;
|
||||
};
|
||||
} // namespace
|
||||
#endif //__OPENSPACE_MODULE_FLUXNODES___RENDERABLETRAVELSPEED___H__
|
||||
#endif //__OPENSPACE_MODULE_SPACE___RENDERABLETRAVELSPEED___H__
|
||||
@@ -25,11 +25,13 @@
|
||||
#include <modules/space/spacemodule.h>
|
||||
|
||||
#include <modules/space/rendering/renderableconstellationbounds.h>
|
||||
#include <modules/space/rendering/renderablefluxnodes.h>
|
||||
#include <modules/space/rendering/renderablehabitablezone.h>
|
||||
#include <modules/space/rendering/renderablerings.h>
|
||||
#include <modules/space/rendering/renderablesatellites.h>
|
||||
#include <modules/space/rendering/renderablesmallbody.h>
|
||||
#include <modules/space/rendering/renderablestars.h>
|
||||
#include <modules/space/rendering/renderabletravelspeed.h>
|
||||
#include <modules/space/rendering/simplespheregeometry.h>
|
||||
#include <modules/space/translation/keplertranslation.h>
|
||||
#include <modules/space/translation/spicetranslation.h>
|
||||
@@ -79,11 +81,13 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) {
|
||||
fRenderable->registerClass<RenderableConstellationBounds>(
|
||||
"RenderableConstellationBounds"
|
||||
);
|
||||
fRenderable->registerClass<RenderableFluxNodes>("RenderableFluxNodes");
|
||||
fRenderable->registerClass<RenderableHabitableZone>("RenderableHabitableZone");
|
||||
fRenderable->registerClass<RenderableRings>("RenderableRings");
|
||||
fRenderable->registerClass<RenderableSatellites>("RenderableSatellites");
|
||||
fRenderable->registerClass<RenderableSmallBody>("RenderableSmallBody");
|
||||
fRenderable->registerClass<RenderableStars>("RenderableStars");
|
||||
fRenderable->registerClass<RenderableTravelSpeed>("RenderableTravelSpeed");
|
||||
|
||||
auto fTranslation = FactoryManager::ref().factory<Translation>();
|
||||
ghoul_assert(fTranslation, "Ephemeris factory was not created");
|
||||
@@ -118,11 +122,13 @@ void SpaceModule::internalDeinitializeGL() {
|
||||
std::vector<documentation::Documentation> SpaceModule::documentations() const {
|
||||
return {
|
||||
RenderableConstellationBounds::Documentation(),
|
||||
RenderableFluxNodes::Documentation(),
|
||||
RenderableHabitableZone::Documentation(),
|
||||
RenderableRings::Documentation(),
|
||||
RenderableSatellites::Documentation(),
|
||||
RenderableSmallBody::Documentation(),
|
||||
RenderableStars::Documentation(),
|
||||
RenderableTravelSpeed::Documentation(),
|
||||
SpiceRotation::Documentation(),
|
||||
SpiceTranslation::Documentation(),
|
||||
KeplerTranslation::Documentation(),
|
||||
|
||||
Reference in New Issue
Block a user