easily fixed comments on PR

This commit is contained in:
elon
2021-08-13 15:39:13 -04:00
parent 9e47e09654
commit 9c2086170b
41 changed files with 850 additions and 1052 deletions

View File

@@ -18,7 +18,6 @@ local sunRadius = 6.957E8
local fieldlines = {
Identifier = "MAS_MHD_Fieldlines",
Parent = heliosphereTransforms.HNMReferenceFrame.Identifier,
--wrong Parent = sunTransforms.SunIAU.Identifier,
Transform = {
Scale = {
Type = "StaticScale",

View File

@@ -58,7 +58,7 @@ local Cutplane2 = {
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { -1.5707965, -3.141593, 0.0 }
Rotation = { -math.pi/2, -math.pi, 0.0 }
}
},
Renderable = {

View File

@@ -1,31 +0,0 @@
local assetHelper = asset.require('util/asset_helper')
openspace.setPropertyValueSingle("Modules.Space.ShowExceptions", false)
local focusPoint = {
Identifier = "focusPoint",
Parent = "SunIAU",
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = "Sun",
Longitude = -45,
Latitude = 20,
Altitude = 102000000
}
},
GUI = {
Path = "/Solar System/Heliosphere",
Name = "Focus point"
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, { focusPoint })
asset.meta = {
Name = "Focus point",
Version = "1.0",
Description = "Speed of light from sun to earth",
Author = "Christian Adamsson, Emilie Ho",
URL = "https://dx.doi.org/10.3847/1538-4357/aab36d",
License = ""
}

View File

@@ -14,8 +14,8 @@ asset.export("TexturesPath", TexturesPath)
asset.meta = {
Name = "Predictive Science Inc. MAS Bastille Day Textures",
Version = "1.0",
Description = " Magnetograms of the sun ",
Description = "Magnetograms of the sun",
Author = "Jonathan Grangien, Matthias Berg",
URL = "https://dx.doi.org/10.3847/1538-4357/aab36d",
License = ""
}
}

View File

@@ -1,4 +1,3 @@
width 10
lower 0.0
upper 1.0

View File

@@ -1,4 +1,3 @@
width 10
lower 0.0
upper 1.0

View File

@@ -11,24 +11,24 @@ This Kernel's ID is not a valid ID!
\begindata
FRAME_GSM = 13371333
FRAME_13371333_NAME = 'GSM'
FRAME_13371333_CLASS = 5
FRAME_13371333_CLASS_ID = 13371333
FRAME_13371333_CENTER = 399
FRAME_13371333_RELATIVE = 'GALACTIC'
FRAME_13371333_DEF_STYLE = 'PARAMETERIZED'
FRAME_13371333_FAMILY = 'TWO-VECTOR'
FRAME_13371333_PRI_AXIS = 'X'
FRAME_13371333_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
FRAME_13371333_PRI_OBSERVER = 'EARTH'
FRAME_13371333_PRI_TARGET = 'SUN'
FRAME_13371333_PRI_ABCORR = 'NONE'
FRAME_13371333_SEC_AXIS = 'Z'
FRAME_13371333_SEC_VECTOR_DEF = 'CONSTANT'
FRAME_13371333_SEC_FRAME = 'ECLIPJ2000'
FRAME_13371333_SEC_SPEC = 'LATITUDINAL'
FRAME_13371333_SEC_UNITS = 'DEGREES'
FRAME_13371333_SEC_LONGITUDE = 288.43
FRAME_13371333_SEC_LATITUDE = 79.54
FRAME_GSM = 13371333
FRAME_13371333_NAME = 'GSM'
FRAME_13371333_CLASS = 5
FRAME_13371333_CLASS_ID = 13371333
FRAME_13371333_CENTER = 399
FRAME_13371333_RELATIVE = 'GALACTIC'
FRAME_13371333_DEF_STYLE = 'PARAMETERIZED'
FRAME_13371333_FAMILY = 'TWO-VECTOR'
FRAME_13371333_PRI_AXIS = 'X'
FRAME_13371333_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
FRAME_13371333_PRI_OBSERVER = 'EARTH'
FRAME_13371333_PRI_TARGET = 'SUN'
FRAME_13371333_PRI_ABCORR = 'NONE'
FRAME_13371333_SEC_AXIS = 'Z'
FRAME_13371333_SEC_VECTOR_DEF = 'CONSTANT'
FRAME_13371333_SEC_FRAME = 'ECLIPJ2000'
FRAME_13371333_SEC_SPEC = 'LATITUDINAL'
FRAME_13371333_SEC_UNITS = 'DEGREES'
FRAME_13371333_SEC_LONGITUDE = 288.43
FRAME_13371333_SEC_LATITUDE = 79.54

View File

@@ -1,7 +1,6 @@
local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require('../../planets/earth/transforms_magnetosphere')
--local fieldlinesDirectory = "C:/Users/elono/Documents/OpenSpace/data/earthMagnetoSphere"
local fieldlinesDirectory = asset.syncedResource({
Name = "Magnetosphere 2012 event",
Type = "HttpSynchronization",
@@ -13,7 +12,6 @@ local fieldlinesDirectory = asset.syncedResource({
local earthMagnetosphere = {
Identifier = "Earths_Magnetosphere",
Parent = transforms.GSMReferenceFrame.Identifier,
--Parent = sunTransforms.SunIAU.Identifier,
Renderable = {
Type = "RenderableFieldlinesSequence",
SourceFolder = fieldlinesDirectory,
@@ -42,9 +40,9 @@ local earthMagnetosphere = {
assetHelper.registerSceneGraphNodesAndExport(asset, { earthMagnetosphere })
asset.meta = {
Name = "",
Name = "Static generic magnetosphere of fieldlines",
Version = "1.0",
Description = " Magnetic fieldlines for the bastille day CME event ",
Description = "Magnetic fieldlines for the bastille day CME event",
Author = "CCMC",
URL = "",
License = ""

View File

@@ -2,6 +2,8 @@ local assetHelper = asset.require('util/asset_helper')
local transforms = asset.require('scene/solarsystem/sun/transforms')
asset.require("spice/base")
local EarthBarycenter = {
Identifier = "EarthBarycenter",
Parent = transforms.SolarSystemBarycenter.Identifier,
@@ -72,20 +74,20 @@ local EarthIAU = {
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
EarthBarycenter,
EarthCenter,
EarthInertial,
EarthIAU,
EarthBarycenter,
EarthCenter,
EarthInertial,
EarthIAU,
})
asset.meta = {
Name = "Earth Transforms",
Version = "1.0",
Description = [[ Earth transforms: Earth Barycenter, Earth Center, Earth Inertial,
Earth IAU. A scene graph node is created for each transform.]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"EarthBarycenter", "EarthCenter", "EarthInertial", "EarthIAU"}
Name = "Earth Transforms",
Version = "1.0",
Description = [[ Earth transforms: Earth Barycenter, Earth Center, Earth Inertial,
Earth IAU. A scene graph node is created for each transform.]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"EarthBarycenter", "EarthCenter", "EarthInertial", "EarthIAU"}
}

View File

@@ -27,9 +27,9 @@ assetHelper.registerSceneGraphNodesAndExport(asset, { GSMReferenceFrame })
asset.meta = {
Name = "Earth magnetosphere transforms",
Version = "1.0",
Description = [[ Earth transforms: GSMReferenceFrame. Geocentric Solar Magnetospheric]],
Description = "Earth transforms: GSMReferenceFrame. Geocentric Solar Magnetospheric",
Author = "CCMC",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"GSMReferenceFrame"}
}
}

View File

@@ -24,7 +24,7 @@ local EUV_Layer = {
GUI = {
Name = "EUV_Layer",
Path = "/Solar System/Sun"
},
},
}
assetHelper.registerSceneGraphNodesAndExport(asset, { EUV_Layer })

View File

@@ -1,6 +1,8 @@
local assetHelper = asset.require("util/asset_helper")
asset.require("spice/base")
-- Barycenter of the solar system, expressed in the Galactic frame
local SolarSystemBarycenter = {
Identifier = "SolarSystemBarycenter",

View File

@@ -27,9 +27,9 @@ assetHelper.registerSceneGraphNodesAndExport(asset, { HNMReferenceFrame })
asset.meta = {
Name = "Sun Transform, HNM",
Version = "1.0",
Description = [[ Sun transform: HNM]],
Description = "Sun transform: HNM",
Author = "CCMC",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"HNMReferenceFrame"}
}
}

View File

@@ -1,13 +0,0 @@
return {{
Type = "KameleonVolumeToRawTask",
Input = "C:/Users/Chrad171/openspace/OpenSpace/sync/http/bastille_day_streamnodes_3D/2000-07-14T08-38-26-000.json",
-- Variable = "rho",
VariableVector = "ur uphi utheta",
InnerRadialLimit = 1.75,
FactorRSquared = "false",
Dimensions = {200, 100, 180},
LowerDomainBound = {1, -90, 0},
UpperDomainBound = {15, 90, 360},
RawVolumeOutput = "${DATA}/mas/bastille/test/teststreams1.rawvolume",
DictionaryOutput = "${DATA}/mas/bastille/test/teststreams1.dictionary"
}}

View File

@@ -1,13 +0,0 @@
return {{
Type = "KameleonVolumeToRawTask",
Input = "C:/Users/Chrad171/openspace/OpenSpace/sync/http/bastille_day_streamnodes_3D/2000-07-14T08-38-26-000.json",
-- Variable = "rho",
VariableVector = "ur uphi utheta",
InnerRadialLimit = 1.75,
FactorRSquared = "false",
Dimensions = {200, 100, 180},
LowerDomainBound = {1, -90, 0},
UpperDomainBound = {15, 90, 360},
RawVolumeOutput = "${DATA}/mas/bastille/test/teststreams1.rawvolume",
DictionaryOutput = "${DATA}/mas/bastille/test/teststreams1.dictionary"
}}

View File

@@ -1,13 +0,0 @@
return {{
Type = "KameleonVolumeToRawTask",
Input = "C:/Users/Chrad171/openspace/OpenSpace/sync/http/bastille_day_streamnodes_3D/2000-07-14T08-38-26-000.json",
-- Variable = "rho",
VariableVector = "ur uphi utheta",
InnerRadialLimit = 1.75,
FactorRSquared = "false",
Dimensions = {200, 100, 180},
LowerDomainBound = {1, -90, 0},
UpperDomainBound = {15, 90, 360},
RawVolumeOutput = "${DATA}/mas/bastille/test/teststreams1.rawvolume",
DictionaryOutput = "${DATA}/mas/bastille/test/teststreams1.dictionary"
}}

View File

@@ -118,7 +118,7 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _billboard(BillboardInfo, false)
, _mirrorBackside(MirrorBacksideInfo, true)
, _mirrorBackside(MirrorBacksideInfo, false)
, _size(SizeInfo, 10.f, 0.f, 1e25f)
, _multiplyColor(MultiplyColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
{

View File

@@ -21,14 +21,10 @@
* 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/renderableplanetimevaryingimage.h>
#include <modules/base/basemodule.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/io/texture/texturereader.h>
// Test debugging tools more then logmanager
#include <ghoul/logging/logmanager.h>
//#include <ghoul/logging/consolelog.h>
#include <modules/base/rendering/renderableplanetimevaryingimage.h>
#include <modules/base/basemodule.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
@@ -37,6 +33,12 @@
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/io/texture/texturereader.h>
// Test debugging tools more then logmanager
#include <ghoul/logging/logmanager.h>
//#include <ghoul/logging/consolelog.h>
#include <optional>
namespace {
@@ -58,7 +60,6 @@ namespace {
};
struct [[codegen::Dictionary(RenderablePlaneTimeVaryingImage)]] Parameters {
// [[codegen::verbatim(TextureInfo.description)]]
std::string texture;
@@ -71,16 +72,7 @@ namespace {
};
// [[codegen::verbatim(RenderTypeInfo.description)]]
std::optional<RenderType> renderType [[codegen::key("RenderType")]];
//KeyLazyLoading, // TODO, might be useful for potential realtime streaming
// new BoolVerifier,
// Optional::Yes,
// "If this value is set to 'true', the image for this plane will not"
// "be loaded at startup but rather when image is shown for the first "
// "time. Additionally, if the plane is hidden, the image will "
// "automatically be unloaded"
std::optional<RenderType> renderType;
};
#include "renderableplanetimevaryingimage_codegen.cpp"
} // namespace
@@ -92,9 +84,8 @@ documentation::Documentation RenderablePlaneTimeVaryingImage::Documentation() {
}
RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage(
const ghoul::Dictionary& dictionary)
const ghoul::Dictionary& dictionary)
: RenderablePlane(dictionary)
, _texturePath(TextureInfo)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
@@ -112,21 +103,21 @@ RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage(
if (p.renderType.has_value()) {
switch (*p.renderType) {
case Parameters::RenderType::Background:
setRenderBin(Renderable::RenderBin::Background);
break;
case Parameters::RenderType::Opaque:
setRenderBin(Renderable::RenderBin::Opaque);
break;
case Parameters::RenderType::PreDeferredTransparency:
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
break;
case Parameters::RenderType::PostDeferredTransparency:
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
break;
case Parameters::RenderType::Overlay:
setRenderBin(Renderable::RenderBin::Overlay);
break;
case Parameters::RenderType::Background:
setRenderBin(Renderable::RenderBin::Background);
break;
case Parameters::RenderType::Opaque:
setRenderBin(Renderable::RenderBin::Opaque);
break;
case Parameters::RenderType::PreDeferredTransparency:
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
break;
case Parameters::RenderType::PostDeferredTransparency:
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
break;
case Parameters::RenderType::Overlay:
setRenderBin(Renderable::RenderBin::Overlay);
break;
}
}
else {
@@ -154,11 +145,9 @@ bool RenderablePlaneTimeVaryingImage::isReady() const {
return RenderablePlane::isReady();
}
void RenderablePlaneTimeVaryingImage::initialize() {
LDEBUG("sourcefiles size:" + std::to_string(_sourceFiles.size()));
if (!extractMandatoryInfoFromDictionary()) {
void RenderablePlaneTimeVaryingImage::initialize() {
bool success = extractMandatoryInfoFromDictionary();
if (!success) {
return;
}
extractTriggerTimesFromFileNames();
@@ -174,20 +163,18 @@ void RenderablePlaneTimeVaryingImage::initialize() {
void RenderablePlaneTimeVaryingImage::initializeGL() {
RenderablePlane::initializeGL();
for (int i = 0; i < _sourceFiles.size(); ++i) {
for (size_t i = 0; i < _sourceFiles.size(); ++i) {
_textureFiles[i] = ghoul::io::TextureReader::ref().loadTexture(
absPath(_sourceFiles[i]).string());
absPath(_sourceFiles[i]).string()
);
_textureFiles[i]->setInternalFormat(GL_COMPRESSED_RGBA);
_textureFiles[i]->uploadTexture();
_textureFiles[i]->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
_textureFiles[i]->purgeFromRAM();
}
}
bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary()
{
bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary() {
// Ensure that the source folder exists and then extract
// the files with the same extension as <inputFileTypeString>
namespace fs = std::filesystem;
@@ -205,8 +192,8 @@ bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary()
// Ensure that there are available and valid source files left
if (_sourceFiles.empty()) {
LERROR(fmt::format(
"{}: {} contains no {} files",
_identifier, _texturePath, "extension"
"{}: Plane sequence filepath {} was empty",
_identifier, _texturePath
));
return false;
}
@@ -214,13 +201,11 @@ bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary()
else {
LERROR(fmt::format(
"{}: Plane sequence filepath {} is not a valid directory",
_identifier,
_texturePath
_identifier, _texturePath
));
return false;
}
_nStates = _sourceFiles.size();
LDEBUG("returning true");
return true;
}
void RenderablePlaneTimeVaryingImage::deinitializeGL() {
@@ -240,19 +225,16 @@ void RenderablePlaneTimeVaryingImage::update(const UpdateData& data) {
ZoneScoped
RenderablePlane::update(data);
if (!this->_enabled) {
if (!_enabled) {
return;
}
const double currentTime = data.time.j2000Seconds();
const bool isInInterval = (currentTime >= _startTimes[0]) &&
(currentTime < _sequenceEndTime);
//const bool isInInterval = true;
if (isInInterval) {
const size_t nextIdx = _activeTriggerTimeIndex + 1;
if (
// 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] ||
// true => We stepped forward to a time represented by another state
@@ -264,7 +246,7 @@ void RenderablePlaneTimeVaryingImage::update(const UpdateData& data) {
} // else we're still in same state as previous frame (no changes needed)
}
else {
//not in interval => set everything to false
// not in interval => set everything to false
_activeTriggerTimeIndex = 0;
_needsUpdate = false;
}
@@ -274,23 +256,15 @@ void RenderablePlaneTimeVaryingImage::update(const UpdateData& data) {
loadTexture();
_textureIsDirty = false;
}
}
// Requires time to be formated as such: 'YYYY-MM-DDTHH-MM-SS-XXX'
void RenderablePlaneTimeVaryingImage::extractTriggerTimesFromFileNames() {
constexpr const int FilenameSize = 23;
// size(.png or .jpg)
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
);
std::string timeString = std::filesystem::path(filePath).stem().string();
// Ensure the separators are correct
timeString.replace(4, 1, "-");
timeString.replace(7, 1, "-");
@@ -298,19 +272,17 @@ void RenderablePlaneTimeVaryingImage::extractTriggerTimesFromFileNames() {
timeString.replace(16, 1, ":");
timeString.replace(19, 1, ".");
const double triggerTime = Time::convertTime(timeString);
LDEBUG("timestring " + timeString);
_startTimes.push_back(triggerTime);
}
}
void RenderablePlaneTimeVaryingImage::updateActiveTriggerTimeIndex
(double currentTime) {
void RenderablePlaneTimeVaryingImage::updateActiveTriggerTimeIndex(double currentTime) {
auto iter = std::upper_bound(_startTimes.begin(), _startTimes.end(), currentTime);
if (iter != _startTimes.end()) {
if (iter != _startTimes.begin()) {
_activeTriggerTimeIndex = static_cast<int>(
std::distance(_startTimes.begin(), iter)
) - 1;
) - 1;
}
else {
_activeTriggerTimeIndex = 0;
@@ -330,7 +302,7 @@ void RenderablePlaneTimeVaryingImage::computeSequenceEndTime() {
}
else {
// If there's just one state it should never disappear!
_sequenceEndTime = DBL_MAX;
_sequenceEndTime = std::numeric_limits<double>::max();
}
}
void RenderablePlaneTimeVaryingImage::loadTexture() {

View File

@@ -32,51 +32,51 @@ namespace ghoul::opengl { class Texture; }
namespace openspace {
struct RenderData;
struct UpdateData;
struct RenderData;
struct UpdateData;
namespace documentation { struct Documentation; }
namespace documentation { struct Documentation; }
class RenderablePlaneTimeVaryingImage : public RenderablePlane {
public:
RenderablePlaneTimeVaryingImage(const ghoul::Dictionary& dictionary);
class RenderablePlaneTimeVaryingImage : public RenderablePlane {
public:
RenderablePlaneTimeVaryingImage(const ghoul::Dictionary& dictionary);
void initialize() override;
void initializeGL() override;
void deinitializeGL() override;
void initialize() override;
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
bool isReady() const override;
void update(const UpdateData& data) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
static documentation::Documentation Documentation();
protected:
virtual void bindTexture() override;
protected:
virtual void bindTexture() override;
private:
void loadTexture();
void extractTriggerTimesFromFileNames();
bool extractMandatoryInfoFromDictionary();
void updateActiveTriggerTimeIndex(double currenttime);
void computeSequenceEndTime();
// Estimated end of sequence.
double _sequenceEndTime;
bool _needsUpdate = false;
std::vector<std::string> _sourceFiles;
std::vector<double> _startTimes;
int _activeTriggerTimeIndex = 0;
// Number of states in the sequence/ number of images.
size_t _nStates;
properties::StringProperty _texturePath;
ghoul::opengl::Texture* _texture = nullptr;
// std::unique_ptr<ghoul::opengl::Texture> _texture;
std::vector<std::unique_ptr<ghoul::opengl::Texture>> _textureFiles;
std::unique_ptr<ghoul::filesystem::File> _textureFile;
bool _isLoadingTexture = false;
bool _isLoadingLazily = false;
bool _textureIsDirty = false;
};
private:
void loadTexture();
void extractTriggerTimesFromFileNames();
bool extractMandatoryInfoFromDictionary();
void updateActiveTriggerTimeIndex(double currenttime);
void computeSequenceEndTime();
// Estimated end of sequence.
double _sequenceEndTime;
bool _needsUpdate = false;
std::vector<std::string> _sourceFiles;
std::vector<double> _startTimes;
int _activeTriggerTimeIndex = 0;
// Number of states in the sequence/ number of images.
size_t _nStates;
properties::StringProperty _texturePath;
ghoul::opengl::Texture* _texture = nullptr;
// std::unique_ptr<ghoul::opengl::Texture> _texture;
std::vector<std::unique_ptr<ghoul::opengl::Texture>> _textureFiles;
std::unique_ptr<ghoul::filesystem::File> _textureFile;
bool _isLoadingTexture = false;
bool _isLoadingLazily = false;
bool _textureIsDirty = false;
};
} // namespace openspace

View File

@@ -50,7 +50,7 @@ namespace {
"mirrorTexture"
};
enum class Orientation : int {
enum class Orientation {
Outside = 0,
Inside,
Both
@@ -58,7 +58,7 @@ namespace {
constexpr openspace::properties::Property::PropertyInfo TextureSourceInfo = {
"TextureSource",
"TextureSource",
"Texture Source",
"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."
@@ -117,7 +117,7 @@ namespace {
constexpr openspace::properties::Property::PropertyInfo BackgroundInfo = {
"Background",
"Sets the current sphere rendering as a background rendering type",
"Render as Background",
"Enables/Disables background rendering."
};
@@ -162,12 +162,13 @@ namespace {
} // namespace
namespace openspace {
documentation::Documentation RenderableTimeVaryingSphere::Documentation() {
return codegen::doc<Parameters>("base_renderable_time_varying_sphere");
}
RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(
const ghoul::Dictionary& dictionary)
const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _textureSourcePath(TextureSourceInfo)
, _orientation(OrientationInfo, properties::OptionProperty::DisplayType::Dropdown)
@@ -230,27 +231,19 @@ RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(
addProperty(_mirrorTexture);
addProperty(_useAdditiveBlending);
addProperty(_fadeOutThreshold);
addProperty(_fadeInThreshold);
_mirrorTexture = p.mirrorTexture.value_or(_mirrorTexture);
_useAdditiveBlending = p.useAdditiveBlending.value_or(_useAdditiveBlending);
_fadeOutThreshold = p.fadeOutThreshold.value_or(_fadeOutThreshold);
_fadeInThreshold = p.fadeInThreshold.value_or(_fadeInThreshold);
if (_useAdditiveBlending) {
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
}
bool hasGivenFadeOut = p.fadeOutThreshold.has_value();
if (hasGivenFadeOut) {
_fadeOutThreshold = *p.fadeOutThreshold;
addProperty(_fadeOutThreshold);
}
bool hasGivenFadeIn = p.fadeInThreshold.has_value();
if (hasGivenFadeIn) {
_fadeInThreshold = *p.fadeInThreshold;
addProperty(_fadeInThreshold);
}
if (hasGivenFadeIn || hasGivenFadeOut) {
if (_fadeOutThreshold || _fadeInThreshold) {
_disableFadeInDistance = false;
addProperty(_disableFadeInDistance);
}
@@ -314,8 +307,7 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&)
glm::dmat4(data.modelTransform.rotation) *
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
glm::dmat3 modelRotation =
glm::dmat3(data.modelTransform.rotation);
glm::dmat3 modelRotation = glm::dmat3(data.modelTransform.rotation);
// Activate shader
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
@@ -337,7 +329,7 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&)
if (_fadeInThreshold > -1.0) {
const float logDistCamera = glm::log(static_cast<float>(
glm::distance(data.camera.positionVec3(), data.modelTransform.translation)
));
));
const float startLogFadeDistance = glm::log(_size * _fadeInThreshold);
const float stopLogFadeDistance = startLogFadeDistance + 1.f;
@@ -345,7 +337,7 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&)
logDistCamera < stopLogFadeDistance) {
const float fadeFactor = glm::clamp(
(logDistCamera - startLogFadeDistance) /
(stopLogFadeDistance - startLogFadeDistance),
(stopLogFadeDistance - startLogFadeDistance),
0.f,
1.f
);
@@ -359,7 +351,7 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&)
if (_fadeOutThreshold > -1.0) {
const float logDistCamera = glm::log(static_cast<float>(
glm::distance(data.camera.positionVec3(), data.modelTransform.translation)
));
));
const float startLogFadeDistance = glm::log(_size * _fadeOutThreshold);
const float stopLogFadeDistance = startLogFadeDistance + 1.f;
@@ -367,7 +359,7 @@ void RenderableTimeVaryingSphere::render(const RenderData& data, RendererTasks&)
logDistCamera < stopLogFadeDistance) {
const float fadeFactor = glm::clamp(
(logDistCamera - startLogFadeDistance) /
(stopLogFadeDistance - startLogFadeDistance),
(stopLogFadeDistance - startLogFadeDistance),
0.f,
1.f
);
@@ -456,18 +448,21 @@ bool RenderableTimeVaryingSphere::extractMandatoryInfoFromDictionary()
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();
t->setInternalFormat(GL_COMPRESSED_RGBA);
t->uploadTexture();
t->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
t->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;
});
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 (_files.empty()) {
LERROR(fmt::format(
@@ -480,8 +475,7 @@ bool RenderableTimeVaryingSphere::extractMandatoryInfoFromDictionary()
else {
LERROR(fmt::format(
"{}: FieldlinesSequence {} is not a valid directory",
_identifier,
_textureSourcePath
_identifier, _textureSourcePath
));
return false;
}
@@ -489,8 +483,9 @@ bool RenderableTimeVaryingSphere::extractMandatoryInfoFromDictionary()
LDEBUG("returning true in extractMandatoryInfoFromDictionary");
return true;
}
void RenderableTimeVaryingSphere::update(const UpdateData& data) {
if (!this->_enabled) {
if (!_enabled) {
return;
}
if (_shader->isDirty()) {
@@ -500,12 +495,9 @@ void RenderableTimeVaryingSphere::update(const UpdateData& data) {
const double currentTime = data.time.j2000Seconds();
const bool isInInterval = (currentTime >= _files[0].time) &&
(currentTime < _sequenceEndTime);
//const bool isInInterval = true;
if (isInInterval) {
const size_t nextIdx = _activeTriggerTimeIndex + 1;
if (
// true => Previous frame was not within the sequence interval
//_activeTriggerTimeIndex < 0 ||
// true => We stepped back to a time represented by another state
currentTime < _files[_activeTriggerTimeIndex].time ||
// true => We stepped forward to a time represented by another state
@@ -519,7 +511,7 @@ void RenderableTimeVaryingSphere::update(const UpdateData& data) {
} // else {we're still in same state as previous frame (no changes needed)}
}
else {
//not in interval => set everything to false
// not in interval => set everything to false
_activeTriggerTimeIndex = 0;
_needsUpdate = false;
}
@@ -534,20 +526,11 @@ 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.png'
double RenderableTimeVaryingSphere::extractTriggerTimeFromFileName(
const std::string& filePath) {
// number of characters in filename (excluding '.png')
constexpr const int FilenameSize = 23;
// size(".png")
constexpr const int ExtSize = 4;
const std::string& filePath) {
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
);
std::string timeString = std::filesystem::path(filePath).stem().string();
// Ensure the separators are correct
timeString.replace(4, 1, "-");
timeString.replace(7, 1, "-");
@@ -555,22 +538,21 @@ double RenderableTimeVaryingSphere::extractTriggerTimeFromFileName(
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(_files.begin(), _files.end(), currentTime,
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(_files.begin(), iter)
) - 1;
) - 1;
}
else {
_activeTriggerTimeIndex = 0;
@@ -591,7 +573,7 @@ void RenderableTimeVaryingSphere::computeSequenceEndTime() {
}
else {
// If there's just one state it should never disappear!
_sequenceEndTime = DBL_MAX;
_sequenceEndTime = std::numeric_limits<double>::max();
}
}

View File

@@ -43,6 +43,7 @@ namespace openspace {
class Sphere;
struct RenderData;
struct UpdateData;
struct FileData {
std::string path;
double time;
@@ -75,8 +76,6 @@ private:
// Estimated end of sequence.
double _sequenceEndTime;
bool _needsUpdate = false;
//std::vector<std::string> _sourceFiles;
//std::vector<double> _startTimes;
std::vector<FileData> _files;
int _activeTriggerTimeIndex = 0;
// Number of states in the sequence
@@ -97,10 +96,8 @@ private:
properties::FloatProperty _fadeOutThreshold;
ghoul::opengl::ProgramObject* _shader = nullptr;
//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::unique_ptr<Sphere> _sphere;
UniformCache(opacity, modelViewProjection, modelViewRotation, colorTexture,

View File

@@ -24,13 +24,6 @@
#include <modules/fieldlinessequence/rendering/renderablefieldlinessequence.h>
#include <filesystem>
#include <fstream>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
#include <map>
#include <modules/fieldlinessequence/fieldlinessequencemodule.h>
#include <modules/fieldlinessequence/util/kameleonfieldlinehelper.h>
#include <openspace/engine/globals.h>
@@ -41,6 +34,13 @@
#include <openspace/scene/scene.h>
#include <openspace/util/timemanager.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
#include <filesystem>
#include <fstream>
#include <map>
#include <optional>
#include <thread>
@@ -53,99 +53,99 @@ namespace {
// --------------------------------- Property Info -------------------------------- //
constexpr openspace::properties::Property::PropertyInfo ColorMethodInfo = {
"colorMethod",
"ColorMethod",
"Color Method",
"Color lines uniformly or using color tables based on extra quantities like, for "
"examples, temperature or particle density."
};
constexpr openspace::properties::Property::PropertyInfo ColorQuantityInfo = {
"colorQuantity",
"ColorQuantity",
"Quantity to Color By",
"Quantity used to color lines if the 'By Quantity' color method is selected."
};
constexpr openspace::properties::Property::PropertyInfo ColorQuantityMinInfo = {
"colorQuantityMin",
"ColorQuantityMin",
"ColorTable Min Value",
"Value to map to the lowest end of the color table."
};
constexpr openspace::properties::Property::PropertyInfo ColorQuantityMaxInfo = {
"colorQuantityMax",
"ColorQuantityMax",
"ColorTable Max Value",
"Value to map to the highest end of the color table."
};
constexpr openspace::properties::Property::PropertyInfo ColorTablePathInfo = {
"colorTablePath",
"ColorTablePath",
"Path to Color Table",
"Color Table/Transfer Function to use for 'By Quantity' coloring."
};
constexpr openspace::properties::Property::PropertyInfo ColorUniformInfo = {
"uniform",
"Uniform",
"Uniform Line Color",
"The uniform color of lines shown when 'Color Method' is set to 'Uniform'."
};
constexpr openspace::properties::Property::PropertyInfo ColorUseABlendingInfo = {
"aBlendingEnabled",
"ABlendingEnabled",
"Additive Blending",
"Activate/deactivate additive blending."
};
constexpr openspace::properties::Property::PropertyInfo DomainEnabledInfo = {
"domainEnabled",
"DomainEnabled",
"Domain Limits",
"Enable/Disable domain limits"
};
constexpr openspace::properties::Property::PropertyInfo DomainXInfo = {
"limitsX",
"LimitsX",
"X-limits",
"Valid range along the X-axis. [Min, Max]"
};
constexpr openspace::properties::Property::PropertyInfo DomainYInfo = {
"limitsY",
"LimitsY",
"Y-limits",
"Valid range along the Y-axis. [Min, Max]"
};
constexpr openspace::properties::Property::PropertyInfo DomainZInfo = {
"limitsZ",
"LimitsZ",
"Z-limits",
"Valid range along the Z-axis. [Min, Max]"
};
constexpr openspace::properties::Property::PropertyInfo DomainRInfo = {
"limitsR",
"LimitsR",
"Radial limits",
"Valid radial range. [Min, Max]"
};
constexpr openspace::properties::Property::PropertyInfo FlowColorInfo = {
"color",
"Color",
"Color",
"Color of particles."
};
constexpr openspace::properties::Property::PropertyInfo FlowEnabledInfo = {
"flowEnabled",
"FlowEnabled",
"Flow Direction",
"Toggles the rendering of moving particles along the lines. Can, for example, "
"illustrate magnetic flow."
};
constexpr openspace::properties::Property::PropertyInfo FlowReversedInfo = {
"reversed",
"Reversed",
"Reversed Flow",
"Toggle to make the flow move in the opposite direction."
};
constexpr openspace::properties::Property::PropertyInfo FlowParticleSizeInfo = {
"particleSize",
"ParticleSize",
"Particle Size",
"Size of the particles."
};
constexpr openspace::properties::Property::PropertyInfo FlowParticleSpacingInfo = {
"particleSpacing",
"ParticleSpacing",
"Particle Spacing",
"Spacing inbetween particles."
};
constexpr openspace::properties::Property::PropertyInfo FlowSpeedInfo = {
"speed",
"Speed",
"Speed",
"Speed of the flow."
};
constexpr openspace::properties::Property::PropertyInfo MaskingEnabledInfo = {
"maskingEnabled",
"MaskingEnabled",
"Masking",
"Enable/disable masking. Use masking to show lines where a given quantity is "
"within a given range, for example, if you only want to see where the "
@@ -153,32 +153,32 @@ namespace {
"topologies like solar wind & closed lines."
};
constexpr openspace::properties::Property::PropertyInfo MaskingMinInfo = {
"maskingMinLimit",
"MaskingMinLimit",
"Lower Limit",
"Lower limit of the valid masking range"
};
constexpr openspace::properties::Property::PropertyInfo MaskingMaxInfo = {
"maskingMaxLimit",
"MaskingMaxLimit",
"Upper Limit",
"Upper limit of the valid masking range"
};
constexpr openspace::properties::Property::PropertyInfo MaskingQuantityInfo = {
"maskingQuantity",
"MaskingQuantity",
"Quantity used for Masking",
"Quantity used for masking."
};
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"lineWidth",
"LineWidth",
"Line Width",
"This value specifies the line width of the field lines if the "
"selected rendering method includes lines."
};
constexpr openspace::properties::Property::PropertyInfo TimeJumpButtonInfo = {
"timeJumpToStart",
"TimeJumpToStart",
"Jump to Start Of Sequence",
"Performs a time jump to the start of the sequence."
};
enum class SourceFileType : int {
enum class SourceFileType {
Cdf = 0,
Json,
Osfls,
@@ -186,54 +186,54 @@ namespace {
};
struct [[codegen::Dictionary(RenderableFieldlinesSequence)]] Parameters {
// [STRING] osfls, cdf or json
// osfls, cdf or json
std::string inputFileType;
// [STRING] should be path to folder containing the input files
// Should be path to folder containing the input files
std::string sourceFolder;
// [STRING] Path to a .txt file containing seed points. Mandatory if CDF as input.
// Path to a .txt file containing seed points. Mandatory if CDF as input.
// Files need time stamp in file name like so: yyyymmdd_hhmmss.txt
std::optional<std::string> seedPointDirectory;
// [STRING] Currently supports: batsrus, enlil & pfss
// Currently supports: batsrus, enlil & pfss
std::optional<std::string> simluationModel;
// [VECTOR of STRING] Extra variables such as rho, p or t
// Extra variables such as rho, p or t
std::optional<std::vector<std::string>> extraVariables;
// [STRING] Which variable in CDF file to trace. b is default for fieldline
// Which variable in CDF file to trace. b is default for fieldline
std::optional<std::string> tracingVariable;
// [FLOAT] 1.f is default, assuming meters as input.
// 1.f is default, assuming meters as input.
// In setup it is used to scale JSON coordinates.
// During runtime it is used to scale domain limits.
std::optional<float> scaleToMeters;
// [BOOLEAN] If False (default) => Load in initializing step and store in RAM
// If False (default) => Load in initializing step and store in RAM
std::optional<bool> loadAtRuntime;
// [VECTOR of STRING] Values should be paths to .txt files
// Values should be paths to .txt files
std::optional<std::vector<std::string>> colorTablePaths;
// [VECTOR of VEC2] Values should be entered as {X, Y}, where X & Y are numbers
// Values should be entered as {X, Y}, where X & Y are numbers
std::optional<std::vector<glm::vec2>> colorTableRanges;
// [BOOL] Enables Flow
// Enables Flow
std::optional<bool> flowEnabled;
// [VECTOR of VEC2] Values should be entered as {X, Y}, where X & Y are numbers
// Values should be entered as {X, Y}, where X & Y are numbers
std::optional<std::vector<glm::vec2>> maskingRanges;
// [STRING] Value should be path to folder where states are saved. Specifying this
// Value should be path to folder where states are saved. Specifying this
// makes it use file type converter
// (JSON/CDF input => osfls output & oslfs input => JSON output)
std::optional<std::string> outputFolder;
// [FLOAT] Line width of line
// Line width of line
std::optional<float> lineWidth;
// [DOUBLE] If data sets parameter start_time differ from start of run,
// If data sets parameter start_time differ from start of run,
// elapsed_time_in_seconds might be in relation to start of run.
// ManuelTimeOffset will be added to trigger time.
std::optional<double> manualTimeOffset;
@@ -252,7 +252,7 @@ namespace {
return backupValue;
}
return tmp;
}
}
} // namespace
namespace openspace {
@@ -379,10 +379,7 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence(
// Ensure that there are available and valid source files left
if (_sourceFiles.empty()) {
LERROR(fmt::format(
"{} contains no {} files",
sourcePath, _inputFileTypeString
));
LERROR(fmt::format("{} contains no {} files", sourcePath, _inputFileTypeString));
}
_colorTablePaths = p.colorTablePaths.value_or(_colorTablePaths);
@@ -415,21 +412,15 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence(
_outputFolderPath = p.outputFolder.value_or(_outputFolderPath);
if (!_outputFolderPath.empty() && !std::filesystem::is_directory(_outputFolderPath)) {
_outputFolderPath = "";
_outputFolderPath.clear();
LERROR(fmt::format(
"The specified output path: '{}', does not exist",
_outputFolderPath)
);
_outputFolderPath
));
}
if (p.scaleToMeters.has_value()) {
_scalingFactor = p.scaleToMeters.value_or(_scalingFactor);
}
else {
LWARNING("Does not provide scalingFactor. Assumes coordinates are in meters");
}
} // constructor
_scalingFactor = p.scaleToMeters.value_or(_scalingFactor);
}
void RenderableFieldlinesSequence::initialize() {
// Set a default color table, just in case the (optional) user defined paths are
@@ -807,13 +798,12 @@ void RenderableFieldlinesSequence::addStateToSequence(FieldlinesState& state) {
bool RenderableFieldlinesSequence::getStatesFromCdfFiles() {
std::vector<std::string> extraMagVars;
extractMagnitudeVarsFromStrings(extraMagVars);
std::vector<std::string> extraMagVars = extractMagnitudeVarsFromStrings();
std::unordered_map<std::string, std::vector<glm::vec3>> seedsPerFiles =
extractSeedPointsFromFiles();
extractSeedPointsFromFiles();
if (seedsPerFiles.empty()) {
LERROR("no seed files");
LERROR("No seed files found");
return false;
}
@@ -841,7 +831,8 @@ bool RenderableFieldlinesSequence::getStatesFromCdfFiles() {
}
std::unordered_map<std::string, std::vector<glm::vec3>>
RenderableFieldlinesSequence::extractSeedPointsFromFiles() {
RenderableFieldlinesSequence::extractSeedPointsFromFiles()
{
std::vector<std::string> files;
std::filesystem::path seedPointDir;
std::unordered_map<std::string, std::vector<glm::vec3>> outMap;
@@ -870,7 +861,7 @@ std::unordered_map<std::string, std::vector<glm::vec3>>
if (!seedFile.good()) {
LERROR(fmt::format("Could not open seed points file '{}'", seedFilePath));
outMap.clear();
return outMap;
return {};
}
LDEBUG(fmt::format("Reading seed points from file '{}'", seedFilePath));
@@ -888,13 +879,13 @@ std::unordered_map<std::string, std::vector<glm::vec3>>
if (outVec.size() == 0) {
LERROR(fmt::format("Found no seed points in: {}", seedFilePath));
outMap.clear();
return outMap;
return {};
}
size_t lastIndex = seedFilePath.find_last_of('.');
std::string name = seedFilePath.substr(0, lastIndex); // remove file extention
size_t dateAndTimeSeperator = name.find_last_of('_');
std::string time = name.substr(dateAndTimeSeperator+1, name.length());
std::string time = name.substr(dateAndTimeSeperator + 1, name.length());
std::string date = name.substr(dateAndTimeSeperator - 8, 8); //8 for yyyymmdd
std::string dateAndTime = date + time;
@@ -904,9 +895,8 @@ std::unordered_map<std::string, std::vector<glm::vec3>>
return outMap;
}
void RenderableFieldlinesSequence::extractMagnitudeVarsFromStrings(
std::vector<std::string>& extraMagVars) {
std::vector<std::string> RenderableFieldlinesSequence::extractMagnitudeVarsFromStrings() {
std::vector<std::string> extraMagVars;
for (int i = 0; i < static_cast<int>(_extraVars.size()); i++) {
const std::string& str = _extraVars[i];
// Check if string is in the format specified for magnitude variables
@@ -936,6 +926,7 @@ void RenderableFieldlinesSequence::extractMagnitudeVarsFromStrings(
i--;
}
}
return extraMagVars;
}
void RenderableFieldlinesSequence::deinitializeGL() {
@@ -1041,9 +1032,10 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks&
}
glBindVertexArray(_vertexArrayObject);
#ifndef __APPLE__
glLineWidth(_pLineWidth);
#ifdef __APPLE__
glLineWidth(1);
#else
glLineWidth(1.f);
#endif
glMultiDrawArrays(

View File

@@ -221,7 +221,7 @@ private:
void definePropertyCallbackFunctions();
//bool extractCdfInfoFromDictionary();
fls::Model extractJsonInfoFromDictionary();
void extractMagnitudeVarsFromStrings(std::vector<std::string>& extraMagVars);
std::vector<std::string> extractMagnitudeVarsFromStrings();
//bool extractMandatoryInfoFromDictionary(std::string sourceFolderPath);
std::unordered_map<std::string, std::vector<glm::vec3>> extractSeedPointsFromFiles();
void extractTriggerTimesFromFileNames();

View File

@@ -60,7 +60,7 @@ void FieldlinesState::scalePositions(float scale) {
p *= scale;
}
}
#pragma optimize("", off)
bool FieldlinesState::loadStateFromOsfls(const std::string& pathToOsflsFile) {
std::ifstream ifs(pathToOsflsFile, std::ifstream::binary);
if (!ifs.is_open()) {
@@ -136,7 +136,6 @@ bool FieldlinesState::loadStateFromOsfls(const std::string& pathToOsflsFile) {
bool FieldlinesState::loadStateFromJson(const std::string& pathToJsonFile,
fls::Model Model, float coordToMeters)
{
// --------------------- ENSURE FILE IS VALID, THEN PARSE IT --------------------- //
std::ifstream ifs(pathToJsonFile);
@@ -296,8 +295,6 @@ void FieldlinesState::saveStateToOsfls(const std::string& absPath) {
ofs.write(reinterpret_cast<char*>(vec.data()), sizeof(float) * nPoints);
}
ofs.write(allExtraQuantityNamesInOne.c_str(), nStringBytes);
ofs.close();
}
// TODO: This should probably be rewritten, but this is the way the files were structured

View File

@@ -89,14 +89,13 @@ namespace openspace::fls {
* vector at each line vertex
*/
bool convertCdfToFieldlinesState(FieldlinesState& state, const std::string& cdfPath,
const std::unordered_map<std::string,
std::vector<glm::vec3>>& seedMap,
double manualTimeOffset,
const std::string& tracingVar,
std::vector<std::string>& extraVars,
std::vector<std::string>& extraMagVars)
const std::unordered_map<std::string,
std::vector<glm::vec3>>& seedMap,
double manualTimeOffset,
const std::string& tracingVar,
std::vector<std::string>& extraVars,
std::vector<std::string>& extraMagVars)
{
#ifndef OPENSPACE_MODULE_KAMELEON_ENABLED
LERROR("CDF inputs provided but Kameleon module is deactivated");
return false;
@@ -111,13 +110,14 @@ bool convertCdfToFieldlinesState(FieldlinesState& state, const std::string& cdfP
state.setTriggerTime(cdfDoubleTime);
//get time as string.
std::string cdfStringTime = SpiceManager::ref().dateFromEphemerisTime(cdfDoubleTime,
"YYYYMMDDHRMNSC::RND"); //YYYY MM DD HOUR MIN SEC ROUNDED
std::string cdfStringTime = SpiceManager::ref().dateFromEphemerisTime(
cdfDoubleTime, "YYYYMMDDHRMNSC::RND"
); //YYYY MM DD HOUR MIN SEC ROUNDED
// use time as string for picking seedpoints from seedm
std::vector<glm::vec3> seedPoints = seedMap.at(cdfStringTime);
if (addLinesToState(kameleon.get(), seedPoints, tracingVar, state)) {
bool success = addLinesToState(kameleon.get(), seedPoints, tracingVar, state);
if (success) {
// The line points are in their RAW format (unscaled & maybe spherical)
// Before we scale to meters (and maybe cartesian) we must extract
// the extraQuantites, as the iterpolator needs the unaltered positions

View File

@@ -21,6 +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/space/rendering/renderablefluxnodes.h>
#include <openspace/engine/globals.h>
@@ -31,25 +32,24 @@
#include <openspace/scene/scene.h>
#include <openspace/util/timemanager.h>
#include <openspace/util/updatestructures.h>
#include <openspace/query/query.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/logging/logmanager.h>
// Test debugging tools more then logmanager
#include <ghoul/logging/consolelog.h>
#include <ghoul/logging/visualstudiooutputlog.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
#include <functional>
#include <fstream>
#include <thread>
#include <openspace/query/query.h>
#include <sys/stat.h>
#include <functional>
#include <optional>
#include <sys/stat.h>
#include <thread>
namespace {
// log category
constexpr const char* _loggerCat = "renderableFluxNodes";
constexpr const char* _loggerCat = "RenderableFluxNodes";
// GL variables for shaders, probably needed some of them atleast
constexpr const GLuint VaPosition = 0; // MUST CORRESPOND TO THE SHADER PROGRAM
@@ -83,241 +83,241 @@ namespace {
"Default is Emin03 where values > 100 Mev."
};
constexpr openspace::properties::Property::PropertyInfo ColorModeInfo = {
"colorMode",
"ColorMode",
"Color Mode",
"Color lines uniformly or using color tables based on specific values on nodes,"
"for examples flux values."
};
constexpr openspace::properties::Property::PropertyInfo ColorTablePathInfo = {
"colorTablePath",
"ColorTablePath",
"Path to Color Table",
"Color Table/Transfer Function to use for 'By Flux Value' coloring."
};
constexpr openspace::properties::Property::PropertyInfo StreamColorInfo = {
"color",
"Color",
"Color",
"Color of particles."
};
constexpr openspace::properties::Property::PropertyInfo NodeSizeInfo = {
"nodeSize",
"NodeSize",
"Size of nodes",
"Change the size of the nodes"
};
constexpr openspace::properties::Property::PropertyInfo NodeSizeLargerFluxInfo = {
"nodeSizeLargerFlux",
"NodeSizeLargerFlux",
"Size of nodes for larger flux",
"Change the size of the nodes when flux is larger than flux threshold value"
};
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"lineWidth",
"LineWidth",
"Line Width",
"This value specifies the line width of the field lines if the "
"selected render method includes lines."
};
constexpr openspace::properties::Property::PropertyInfo ThresholdFluxInfo = {
"thresholdFlux",
"ThresholdFlux",
"Threshold flux value",
"This value specifies the threshold that will be changed with the flux value."
};
constexpr openspace::properties::Property::PropertyInfo FilteringInfo = {
"filterLower",
"FilterLower",
"Filtering Lower Value in AU",
"Use filtering to show nodes within a given range."
};
constexpr openspace::properties::Property::PropertyInfo FilteringUpperInfo = {
"filterUpper",
"FilterUpper",
"Filtering Upper Value in AU",
"Use filtering to show nodes within a given range."
};
constexpr openspace::properties::Property::PropertyInfo AmountofNodesInfo = {
"amountOfNodes",
"AmountOfNodes",
"Every nth node to render in",
"Show only every nth node"
};
constexpr openspace::properties::Property::PropertyInfo DefaultNodeSkipInfo = {
"nodeSkip",
"NodeSkip",
"Every nth node to render default",
"Show only every nth node outside of skippingmethod"
};
constexpr openspace::properties::Property::PropertyInfo EarthNodeSkipInfo = {
"nodeSkipEarth",
"NodeSkipEarth",
"Every nth node to render close to Earth",
"Show only every nth node outside of skippingmethod"
};
constexpr openspace::properties::Property::PropertyInfo ScalingmethodInfo = {
"scalingFlux",
"ScalingFlux",
"Scale the flux value with color table",
"Use scaling to color nodes with a given method."
};
constexpr openspace::properties::Property::PropertyInfo NodeskipMethodInfo = {
"skippingNodes",
"SkippingNodes",
"How to select nodes to skip",
"Methods to select nodes to skip."
};
constexpr openspace::properties::Property::PropertyInfo colorTableRangeInfo = {
"colorTableRange",
"ColorTableRange",
"Color Table Range",
"Valid range for the color table. [Min, Max]"
};
constexpr openspace::properties::Property::PropertyInfo DomainZInfo = {
"zLimit",
"ZLimit",
"Z-limits",
"Valid range along the Z-axis. [Min, Max]"
};
constexpr openspace::properties::Property::PropertyInfo FluxColorAlphaInfo = {
"fluxColorAlpha",
"FluxColorAlpha",
"Flux Color Alpha",
"The value of alpha for the flux color mode."
};
constexpr openspace::properties::Property::PropertyInfo
FluxColorAlphaIlluminanceInfo = {
"fluxColorAlphaIlluminance",
FluxColorAlphaIlluminanceInfo = {
"FluxColorAlphaIlluminance",
"Flux Color Alpha for illuminance",
"The value of alpha for the flux color mode."
};
constexpr openspace::properties::Property::PropertyInfo FluxNodeskipThresholdInfo = {
"skippingNodesByFlux",
"SkippingNodesByFlux",
"Skipping Nodes By Flux",
"Select nodes to skip depending on flux value."
};
constexpr openspace::properties::Property::PropertyInfo
RadiusNodeSkipThresholdInfo = {
"skippingNodesByRadius",
RadiusNodeSkipThresholdInfo = {
"SkippingNodesByRadius",
"Skipping Nodes By Radius",
"Select nodes to skip depending on Radius."
};
constexpr openspace::properties::Property::PropertyInfo EnhanceMethodInfo = {
"enhanceMethod",
"EnhanceMethod",
"Enhance Method",
"Deciding what method to use for nodes close to earth"
};
constexpr openspace::properties::Property::PropertyInfo DistanceplanetInfo = {
"distanceplanet",
"Distanceplanet",
"Distance Planet",
"Deciding what planet to check distance to."
};
constexpr openspace::properties::Property::PropertyInfo DistanceThresholdInfo = {
"distancePlanetThreshold",
"DistancePlanetThreshold",
"Threshold for distance between planet",
"Enhance the size of nodes dependent on distance to planet."
};
constexpr openspace::properties::Property::PropertyInfo MisalignedIndexInfo = {
"misalignedIndex",
"MisalignedIndex",
"Index to shift sequence number",
"The misalignement number for sequence for fluxnodes vs Fieldlines"
};
constexpr openspace::properties::Property::PropertyInfo FlowColorInfo = {
"flowcolor",
"Flowcolor",
"Color of Flow",
"Color of Flow."
};
constexpr openspace::properties::Property::PropertyInfo FlowEnabledInfo = {
"flowEnabled",
"FlowEnabled",
"Flow Direction",
"Toggles the rendering of moving particles along the lines. Can, for example, "
"illustrate magnetic flow."
};
constexpr openspace::properties::Property::PropertyInfo InterestingStreamsInfo = {
"interestingStreamsEnabled",
"InterestingStreamsEnabled",
"Interesting Streams Enabled",
"Toggles the rendering of selected streams."
};
constexpr openspace::properties::Property::PropertyInfo FlowParticleSizeInfo = {
"particleSize",
"ParticleSize",
"Particle Size",
"Size of the particles."
};
constexpr openspace::properties::Property::PropertyInfo FlowParticleSpacingInfo = {
"particleSpacing",
"ParticleSpacing",
"Particle Spacing",
"Spacing inbetween particles."
};
constexpr openspace::properties::Property::PropertyInfo FlowSpeedInfo = {
"speed",
"Speed",
"Speed",
"Speed of the flow."
};
constexpr openspace::properties::Property::PropertyInfo UseFlowColorInfo = {
"coloring",
"Coloring",
"Color either by Flowcolor or Flow colortable",
"If set to true the flow will be colored by Flowcolor."
};
constexpr openspace::properties::Property::PropertyInfo TempInfo1 = {
"temp1",
"Temp1",
"temp",
"Temp"
};
constexpr openspace::properties::Property::PropertyInfo MaxNodeDistanceSizeInfo = {
"maxNodeDistanceSize",
"MaxNodeDistanceSize",
"Max Node Distance Size",
"The maximum size of the nodes at a certin distance."
};
constexpr openspace::properties::Property::PropertyInfo NodeDistanceThresholdInfo = {
"nodeDistanceThreshold",
"NodeDistanceThreshold",
"Node Distance Threshold",
"Threshold for where to interpolate between the max and min node distance."
};
constexpr openspace::properties::Property::PropertyInfo
CameraPerspectiveEnabledInfo = {
"cameraPerspectiveEnabled",
CameraPerspectiveEnabledInfo = {
"CameraPerspectiveEnabled",
"Use Camera perspective",
"Camera perspective changes the size of the nodes dependent on "
"distance from camera."
};
constexpr openspace::properties::Property::PropertyInfo DrawingCirclesInfo = {
"renderingcircles",
"Renderingcircles",
"Render as circles",
"Using fragment shader to draw nodes as circles instead of squares."
};
constexpr openspace::properties::Property::PropertyInfo DrawingHollowInfo = {
"renderingHollowCircles",
"RenderingHollowCircles",
"Render as hollow circles",
"Using fragment shader to draw nodes as hollow circles."
};
constexpr openspace::properties::Property::PropertyInfo GaussiandAlphaFilterInfo = {
"renderingGaussianAlphaFilter",
"RenderingGaussianAlphaFilter",
"Alpha by Gaussian",
"Using fragment shader to draw nodes with Gaussian filter for alpha value."
};
constexpr openspace::properties::Property::PropertyInfo
RadiusPerspectiveEnabledInfo = {
"radiusPerspectiveEnabled",
RadiusPerspectiveEnabledInfo = {
"RadiusPerspectiveEnabled",
"Include radius with cameraperspective",
"If false, then nodes closer to the sun will not be larger "
"regardless of distance to camera."
};
constexpr openspace::properties::Property::PropertyInfo
PerspectiveDistanceFactorInfo = {
"perspectiveDistanceFactor",
PerspectiveDistanceFactorInfo = {
"PerspectiveDistanceFactor",
"Perspective Distance factor",
"This value decides how far away the camera must be to start "
"impacting the node size."
};
constexpr openspace::properties::Property::PropertyInfo MinNodeSizeInfo = {
"minNodeSize",
"MinNodeSize",
"Minimum node size",
"The minimum node size."
};
constexpr openspace::properties::Property::PropertyInfo MaxNodeSizeInfo = {
"maxNodeSize",
"MaxNodeSize",
"Maximum node size",
"The minimum node size."
};
constexpr openspace::properties::Property::PropertyInfo AlwaysPulseInfo = {
"alwaysPulsate",
"AlwaysPulsate",
"Pulsate regardless of camera position",
"Always have nodes close to earth pulsate regardless of position."
};
constexpr openspace::properties::Property::PropertyInfo pulseEnabledInfo = {
"pulseEnabled",
"Nodes close to Earth pulsate",
"Toggles the pulse for nodes close to Earth."
"PulseEnabled",
"Nodes close to Earth pulsate",
"Toggles the pulse for nodes close to Earth."
};
constexpr openspace::properties::Property::PropertyInfo gaussianPulseEnabledInfo = {
"gaussianPulseEnabled",
"Nodes close to Earth pulsate with alpha by gaussian",
"Toggles the pulse with alpha by gaussian for nodes close to Earth."
"GaussianPulseEnabled",
"Nodes close to Earth pulsate with alpha by gaussian",
"Toggles the pulse with alpha by gaussian for nodes close to Earth."
};
float stringToFloat(const std::string input, const float backupValue = 0.f) {
@@ -328,7 +328,7 @@ namespace {
catch (const std::invalid_argument& ia) {
LWARNING(fmt::format(
"Invalid argument: {}. '{}' is NOT a valid number", ia.what(), input
));
));
return backupValue;
}
return tmp;
@@ -354,8 +354,8 @@ namespace {
#include "renderablefluxnodes_codegen.cpp"
// Changed everything from dvec3 to vec3
glm::vec3 sphericalToCartesianCoord(glm::vec3 position) {
glm::vec3 cartesianPosition = glm::vec3();
glm::vec3 sphericalToCartesianCoord(const glm::vec3& position) {
glm::vec3 cartesianPosition;
// ρsinφcosθ
cartesianPosition.x = position.x * sin(position.z) * cos(position.y);
@@ -366,7 +366,7 @@ namespace {
return cartesianPosition;
}
} //namespace
} // namespace
namespace openspace {
@@ -437,7 +437,6 @@ RenderableFluxNodes::RenderableFluxNodes(const ghoul::Dictionary& dictionary)
, _pPulseEnabled(pulseEnabledInfo, false)
, _pGaussianPulseEnabled(gaussianPulseEnabledInfo, false)
, _pPulseAlways(AlwaysPulseInfo, false)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
@@ -528,7 +527,6 @@ void RenderableFluxNodes::initialize() {
}
void RenderableFluxNodes::initializeGL() {
// Setup shader program
_shaderProgram = global::renderEngine->buildRenderProgram(
"Fluxnodes",
@@ -572,7 +570,7 @@ void RenderableFluxNodes::setModelDependentConstants() {
float limit = 8.f;
_pColorTableRange.setMinValue(glm::vec2(-limit));
_pColorTableRange.setMaxValue(glm::vec2(limit));
_pColorTableRange = glm::vec2(-2, 4);
_pColorTableRange = glm::vec2(-2.f, 4.f);
float limitZMin = -2.5f;
float limitZMax = 2.5f;
@@ -582,31 +580,29 @@ void RenderableFluxNodes::setModelDependentConstants() {
_pDomainZ = glm::vec2(limitZMin, limitZMax);
}
void RenderableFluxNodes::loadNodeData(const int& energybinOption) {
constexpr const float AuToMeter = 149597870700.f; // Astronomical Units
void RenderableFluxNodes::loadNodeData(int energybinOption) {
LDEBUG("Loading in binary files directly from sync folder");
std::string energybin;
switch (energybinOption) {
case 0:
energybin = "_emin01";
break;
case 1:
energybin = "_emin03";
break;
case 0:
energybin = "_emin01";
break;
case 1:
energybin = "_emin03";
break;
}
std::string _file = _binarySourceFolderPath + "\\positions" + energybin;
std::string _file2 = _binarySourceFolderPath + "\\fluxes" + energybin;
std::string _file3 = _binarySourceFolderPath + "\\radiuses" + energybin;
std::string file = _binarySourceFolderPath + "\\positions" + energybin;
std::string file2 = _binarySourceFolderPath + "\\fluxes" + energybin;
std::string file3 = _binarySourceFolderPath + "\\radiuses" + energybin;
std::ifstream fileStream(_file, std::ifstream::binary);
std::ifstream fileStream2(_file2, std::ifstream::binary);
std::ifstream fileStream3(_file3, std::ifstream::binary);
std::ifstream fileStream(file, std::ifstream::binary);
std::ifstream fileStream2(file2, std::ifstream::binary);
std::ifstream fileStream3(file3, std::ifstream::binary);
if (!fileStream.good()) {
LERROR(fmt::format("Could not read file '{}'", _file));
LERROR(fmt::format("Could not read file '{}'", file));
return;
}
@@ -618,8 +614,8 @@ void RenderableFluxNodes::loadNodeData(const int& energybinOption) {
_nStates = nTimeSteps;
if (_nStates != _startTimes.size()) {
LERROR("number of states, _nStates, and number of start times, _startTimes, "
"dont match");
LERROR("Number of states, _nStates, and number of start times, _startTimes, "
"do not match");
return;
}
@@ -630,8 +626,8 @@ void RenderableFluxNodes::loadNodeData(const int& energybinOption) {
for (unsigned int i = 0; i < _nStates; ++i) {
_vertexPositions.resize(nNodesPerTimestep);
fileStream.read(reinterpret_cast<char*>(
_vertexPositions.data()),
nNodesPerTimestep * sizeof(glm::vec3));
_vertexPositions.data()), nNodesPerTimestep * sizeof(glm::vec3)
);
_statesPos.push_back(_vertexPositions);
_vertexPositions.clear();
@@ -639,8 +635,8 @@ void RenderableFluxNodes::loadNodeData(const int& energybinOption) {
for (unsigned int i = 0; i < _nStates; ++i) {
_vertexColor.resize(nNodesPerTimestep);
fileStream2.read(reinterpret_cast<char*>(
_vertexColor.data()),
nNodesPerTimestep * sizeof(float));
_vertexColor.data()), nNodesPerTimestep * sizeof(float)
);
_statesColor.push_back(_vertexColor);
_vertexColor.clear();
@@ -648,8 +644,8 @@ void RenderableFluxNodes::loadNodeData(const int& energybinOption) {
for (unsigned int i = 0; i < _nStates; ++i) {
_vertexRadius.resize(nNodesPerTimestep);
fileStream3.read(reinterpret_cast<char*>(
_vertexRadius.data()),
nNodesPerTimestep * sizeof(float));
_vertexRadius.data()), nNodesPerTimestep * sizeof(float)
);
_statesRadius.push_back(_vertexRadius);
_vertexRadius.clear();
@@ -657,7 +653,6 @@ void RenderableFluxNodes::loadNodeData(const int& energybinOption) {
}
void RenderableFluxNodes::setupProperties() {
// -------------- Add non-grouped properties (enablers and buttons) -------------- //
addProperty(_pGoesEnergyBins);
addProperty(_pLineWidth);
@@ -747,13 +742,12 @@ bool RenderableFluxNodes::isReady() const {
}
void RenderableFluxNodes::populateStartTimes() {
// number of characters in UTC ISO8601 format (without additional Z)
// 'YYYY-MM-DDTHH-MM-SS-XXX'
constexpr const int timeFormatSize = 23;
std::string timeFile = "";
std::string fileType = "";
std::string timeFile;
std::string fileType;
for (const std::string& filePath : _binarySourceFiles) {
timeFile = filePath;
@@ -761,12 +755,10 @@ void RenderableFluxNodes::populateStartTimes() {
fileType = "csv";
break;
}
else if (filePath.substr(filePath.find_last_of(".") + 1) == "dat") {
fileType = "dat";
break;
}
else if (filePath.substr(filePath.find_last_of(".") + 1) == "txt") {
fileType = "txt";
break;
@@ -777,11 +769,11 @@ void RenderableFluxNodes::populateStartTimes() {
break;
}
else {
LERROR(fmt::format("Error in file type or nameing of file '{}'.",
" Time meta file supports csv, dat, txt or without file extention",
" (but then have to include 'time' in filename)", filePath
LERROR(fmt::format("Error in file type or nameing of file '{}'. ",
"Time meta file supports csv, dat, txt or without file extention ",
"(but then have to include 'time' in filename)", filePath
));
timeFile = "";
timeFile.clear();
}
}
@@ -789,9 +781,12 @@ void RenderableFluxNodes::populateStartTimes() {
LERROR("Could not find a metadata file with time steps,"
" such as a csv, dat, txt or no file extention with 'time' in filename");
}
// time filestream
std::ifstream tfs(timeFile);
if (!tfs.is_open()) throw std::runtime_error("Could not open file");
if (!tfs.is_open()) {
throw std::runtime_error("Could not open file");
}
std::string line;
std::getline(tfs, line); //gets only first line
@@ -801,31 +796,34 @@ void RenderableFluxNodes::populateStartTimes() {
int nColumns = 0;
std::string columnName;
//loops through the names/columns in first line/header
while (s >> columnName) ++nColumns;
while (s >> columnName) {
++nColumns;
}
while (std::getline(tfs, line)) { //for each line of data
std::istringstream iss(line);
for (int i = 0; i < nColumns; ++i) { //for each column in line
std::string columnValue;
iss >> columnValue;
if (i == nColumns - 1) { // last column
if (columnValue.length() == 23) {
// Ensure the separators are correct
columnValue.replace(4, 1, "-");
columnValue.replace(7, 1, "-");
columnValue.replace(13, 1, ":");
columnValue.replace(16, 1, ":");
columnValue.replace(19, 1, ".");
const double triggerTime = Time::convertTime(columnValue);
LDEBUG("timestring " + columnValue);
_startTimes.push_back(triggerTime);
}
else {
LERROR(fmt::format("Error in file formating. Last column in ",
"file '{}' is not on UTC ISO8601 format", timeFile
));
}
if (i != nColumns - 1) { // last column
continue;
}
if (columnValue.length() == 23) {
// Ensure the separators are correct
columnValue.replace(4, 1, "-");
columnValue.replace(7, 1, "-");
columnValue.replace(13, 1, ":");
columnValue.replace(16, 1, ":");
columnValue.replace(19, 1, ".");
const double triggerTime = Time::convertTime(columnValue);
LDEBUG("timestring " + columnValue);
_startTimes.push_back(triggerTime);
}
else {
LERROR(fmt::format("Error in file formating. Last column in ",
"file '{}' is not on UTC ISO8601 format", timeFile
));
}
}
}
}
@@ -836,7 +834,7 @@ void RenderableFluxNodes::updateActiveTriggerTimeIndex(double currentTime) {
if (iter != _startTimes.begin()) {
_activeTriggerTimeIndex = static_cast<int>(
std::distance(_startTimes.begin(), iter)
) - 1;
) - 1;
}
else {
_activeTriggerTimeIndex = 0;
@@ -855,39 +853,55 @@ void RenderableFluxNodes::render(const RenderData& data, RendererTasks&) {
const glm::dmat4 modelMat =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
rotMat *
glm::dmat4(glm::scale(glm::dmat4(1), glm::dvec3(data.modelTransform.scale)));
glm::dmat4(glm::scale(
glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)
));
const glm::dmat4 modelViewMat = data.camera.combinedViewMatrix() * modelMat;
//not in use atm.
_shaderProgram->setUniform("modelViewProjection",
data.camera.sgctInternal.projectionMatrix() * glm::mat4(modelViewMat));
data.camera.sgctInternal.projectionMatrix() * glm::mat4(modelViewMat)
);
SceneGraphNode* earthNode = sceneGraphNode("Earth");
if (!earthNode) {
LWARNING("Could not find scene graph node 'Earth'.");
}
glm::vec3 earthPos = earthNode->worldPosition() * data.modelTransform.rotation;
_shaderProgram->setUniform(_uniformCache.streamColor, _pStreamColor);
_shaderProgram->setUniform(_uniformCache.nodeSize, _pNodeSize);
_shaderProgram->setUniform(_uniformCache.nodeSizeLargerFlux,
_pNodeSizeLargerFlux);
_shaderProgram->setUniform(
_uniformCache.nodeSizeLargerFlux,
_pNodeSizeLargerFlux
);
_shaderProgram->setUniform(_uniformCache.thresholdFlux, _pThresholdFlux);
_shaderProgram->setUniform(_uniformCache.colorMode, _pColorMode);
_shaderProgram->setUniform(_uniformCache.filterLower, _pFilteringLower);
_shaderProgram->setUniform(_uniformCache.filterUpper, _pFilteringUpper);
_shaderProgram->setUniform(_uniformCache.scalingMode, _pScalingmethod);
_shaderProgram->setUniform(_uniformCache.colorTableRange,
_pColorTableRange.value());
_shaderProgram->setUniform(
_uniformCache.colorTableRange,
_pColorTableRange.value()
);
_shaderProgram->setUniform(_uniformCache.domainLimZ, _pDomainZ.value());
_shaderProgram->setUniform(_uniformCache.nodeSkip, _pAmountofNodes);
_shaderProgram->setUniform(_uniformCache.nodeSkipDefault, _pDefaultNodeSkip);
_shaderProgram->setUniform(_uniformCache.nodeSkipEarth, _pEarthNodeSkip);
_shaderProgram->setUniform(_uniformCache.nodeSkipMethod, _pNodeskipMethod);
_shaderProgram->setUniform(_uniformCache.nodeSkipFluxThreshold,
_pFluxNodeskipThreshold);
_shaderProgram->setUniform(_uniformCache.nodeSkipRadiusThreshold,
_pRadiusNodeSkipThreshold);
_shaderProgram->setUniform(
_uniformCache.nodeSkipFluxThreshold,
_pFluxNodeskipThreshold
);
_shaderProgram->setUniform(
_uniformCache.nodeSkipRadiusThreshold,
_pRadiusNodeSkipThreshold
);
_shaderProgram->setUniform(_uniformCache.fluxColorAlpha, _pFluxColorAlpha);
_shaderProgram->setUniform(_uniformCache.fluxColorAlphaIlluminance,
_pFluxColorAlphaIlluminance);
_shaderProgram->setUniform(
_uniformCache.fluxColorAlphaIlluminance,
_pFluxColorAlphaIlluminance
);
_shaderProgram->setUniform(_uniformCache.earthPos, earthPos);
_shaderProgram->setUniform(_uniformCache.distanceThreshold, _pDistanceThreshold);
_shaderProgram->setUniform(_uniformCache.enhanceMethod, _pEnhancemethod);
@@ -896,52 +910,63 @@ void RenderableFluxNodes::render(const RenderData& data, RendererTasks&) {
_shaderProgram->setUniform(_uniformCache.particleSize, _pFlowParticleSize);
_shaderProgram->setUniform(_uniformCache.particleSpacing, _pFlowParticleSpacing);
_shaderProgram->setUniform(_uniformCache.particleSpeed, _pFlowSpeed);
_shaderProgram->setUniform(_uniformCache2.time,
global::windowDelegate->applicationTime() * -1);
_shaderProgram->setUniform(
_uniformCache2.time,
global::windowDelegate->applicationTime() * -1
);
_shaderProgram->setUniform(_uniformCache2.flowColoring, _pUseFlowColor);
_shaderProgram->setUniform(_uniformCache2.maxNodeDistanceSize,
_pMaxNodeDistanceSize);
_shaderProgram->setUniform(_uniformCache2.usingCameraPerspective,
_pCameraPerspectiveEnabled);
_shaderProgram->setUniform(
_uniformCache2.maxNodeDistanceSize,
_pMaxNodeDistanceSize
);
_shaderProgram->setUniform(
_uniformCache2.usingCameraPerspective,
_pCameraPerspectiveEnabled
);
_shaderProgram->setUniform(_uniformCache2.drawCircles, _pDrawingCircles);
_shaderProgram->setUniform(_uniformCache2.drawHollow, _pDrawingHollow);
_shaderProgram->setUniform(_uniformCache2.useGaussian, _pGaussianAlphaFilter);
_shaderProgram->setUniform(_uniformCache2.usingRadiusPerspective,
_pRadiusPerspectiveEnabled);
_shaderProgram->setUniform(_uniformCache2.perspectiveDistanceFactor,
_pPerspectiveDistanceFactor);
_shaderProgram->setUniform(
_uniformCache2.usingRadiusPerspective,
_pRadiusPerspectiveEnabled
);
_shaderProgram->setUniform(
_uniformCache2.perspectiveDistanceFactor,
_pPerspectiveDistanceFactor
);
_shaderProgram->setUniform(_uniformCache2.maxNodeSize, _pMaxNodeSize);
_shaderProgram->setUniform(_uniformCache2.minNodeSize, _pMinNodeSize);
_shaderProgram->setUniform(_uniformCache2.usingPulse, _pPulseEnabled);
_shaderProgram->setUniform(_uniformCache2.usingGaussianPulse,
_pGaussianPulseEnabled);
_shaderProgram->setUniform(
_uniformCache2.usingGaussianPulse,
_pGaussianPulseEnabled
);
_shaderProgram->setUniform(_uniformCache2.pulsatingAlways, _pPulseAlways);
glm::vec3 cameraPos = data.camera.positionVec3() * data.modelTransform.rotation;
_shaderProgram->setUniform("cameraPos", cameraPos);
ghoul::opengl::TextureUnit textureUnit;
ghoul::opengl::TextureUnit textureUnitCMR;
ghoul::opengl::TextureUnit textureUnitEarth;
ghoul::opengl::TextureUnit textureUnitFlow;
if (_pColorMode == static_cast<int>(ColorMethod::ByFluxValue)) {
ghoul::opengl::TextureUnit textureUnit;
textureUnit.activate();
_transferFunction->bind(); // Calls update internally
_shaderProgram->setUniform("colorTable", textureUnit);
ghoul::opengl::TextureUnit textureUnitCMR;
textureUnitCMR.activate();
_transferFunctionCMR->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableCMR", textureUnitCMR);
ghoul::opengl::TextureUnit textureUnitEarth;
textureUnitEarth.activate();
_transferFunctionEarth->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableEarth", textureUnitEarth);
ghoul::opengl::TextureUnit textureUnitFlow;
textureUnitFlow.activate();
_transferFunctionFlow->bind(); // Calls update internally
_shaderProgram->setUniform("colorTableFlow", textureUnitFlow);
}
glBindVertexArray(_vertexArrayObject);
@@ -956,10 +981,6 @@ void RenderableFluxNodes::render(const RenderData& data, RendererTasks&) {
_shaderProgram->deactivate();
}
}
inline void unbindGL() {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
void RenderableFluxNodes::computeSequenceEndTime() {
if (_nStates > 1) {
@@ -971,15 +992,17 @@ void RenderableFluxNodes::computeSequenceEndTime() {
}
else if (_nStates == 1) {
// If there's just one state it should never disappear!
_sequenceEndTime = DBL_MAX;
_sequenceEndTime = std::numeric_limits<double>::max();
}
else {
LWARNING("Start up or error?");
LERROR("No states were found. The position file include this data");
}
}
void RenderableFluxNodes::update(const UpdateData& data) {
if (!this->_enabled) return;
if (!_enabled) {
return;
}
if (_shaderProgram->isDirty()) {
_shaderProgram->rebuildFromFile();
}
@@ -992,17 +1015,13 @@ void RenderableFluxNodes::update(const UpdateData& data) {
if (isInInterval) {
const size_t nextIdx = _activeTriggerTimeIndex + 1;
if (
// 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] ||
// true => We stepped forward to a time represented by another state
(nextIdx < _nStates && currentTime >= _startTimes[nextIdx]))
{
updateActiveTriggerTimeIndex(currentTime);
needsUpdate = true;
} // else {we're still in same state as previous frame (no changes needed)}
}
else {
@@ -1011,8 +1030,7 @@ void RenderableFluxNodes::update(const UpdateData& data) {
}
if (needsUpdate) {
if(!_statesPos[_activeTriggerTimeIndex].empty()) {
if (!_statesPos[_activeTriggerTimeIndex].empty()) {
//if (_activeTriggerTimeIndex > _pMisalignedIndex) {
// _activeTriggerTimeIndex += -_pMisalignedIndex;
//}
@@ -1028,10 +1046,16 @@ void RenderableFluxNodes::update(const UpdateData& data) {
if (_shaderProgram->isDirty()) {
_shaderProgram->rebuildFromFile();
ghoul::opengl::updateUniformLocations(*_shaderProgram, _uniformCache,
UniformNames);
ghoul::opengl::updateUniformLocations(*_shaderProgram, _uniformCache2,
UniformNames2);
ghoul::opengl::updateUniformLocations(
*_shaderProgram,
_uniformCache,
UniformNames
);
ghoul::opengl::updateUniformLocations(
*_shaderProgram,
_uniformCache2,
UniformNames2
);
}
}
@@ -1052,7 +1076,8 @@ void RenderableFluxNodes::updatePositionBuffer() {
glEnable(GL_PROGRAM_POINT_SIZE);
glVertexAttribPointer(VaPosition, 3, GL_FLOAT, GL_FALSE, 0, 0);
unbindGL();
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
void RenderableFluxNodes::updateVertexColorBuffer() {
glBindVertexArray(_vertexArrayObject);
@@ -1060,34 +1085,36 @@ void RenderableFluxNodes::updateVertexColorBuffer() {
const std::vector<float>& vertColor = _vertexColor;
glBufferData(
GL_ARRAY_BUFFER,
vertColor.size() * sizeof(float),
vertColor.data(),
GL_STATIC_DRAW
);
glBufferData(
GL_ARRAY_BUFFER,
vertColor.size() * sizeof(float),
vertColor.data(),
GL_STATIC_DRAW
);
glEnableVertexAttribArray(VaColor);
glVertexAttribPointer(VaColor, 1, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(VaColor);
glVertexAttribPointer(VaColor, 1, GL_FLOAT, GL_FALSE, 0, 0);
unbindGL();
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
void RenderableFluxNodes::updateVertexFilteringBuffer() {
glBindVertexArray(_vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, _vertexFilteringBuffer);
glBindVertexArray(_vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, _vertexFilteringBuffer);
const std::vector<float>& vertexRadius = _vertexRadius;
const std::vector<float>& vertexRadius = _vertexRadius;
glBufferData(
GL_ARRAY_BUFFER,
vertexRadius.size() * sizeof(float),
vertexRadius.data(),
GL_STATIC_DRAW
);
glBufferData(
GL_ARRAY_BUFFER,
vertexRadius.size() * sizeof(float),
vertexRadius.data(),
GL_STATIC_DRAW
);
glEnableVertexAttribArray(VaFiltering);
glVertexAttribPointer(VaFiltering, 1, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(VaFiltering);
glVertexAttribPointer(VaFiltering, 1, GL_FLOAT, GL_FALSE, 0, 0);
unbindGL();
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
} // namespace openspace

View File

@@ -1,40 +1,40 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
* *
* 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 <openspace/rendering/renderable.h>
#include <modules/base/rendering/renderabletrail.h>
#include <modules/fieldlinessequence/util/fieldlinesstate.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/vector/vec2property.h>
#include <openspace/properties/vector/vec4property.h>
#include <openspace/rendering/transferfunction.h>
#include <atomic>
#include <modules/base/rendering/renderabletrail.h>
namespace openspace {
@@ -59,28 +59,28 @@ private:
std::vector<GLint> _lineStart;
// ------------------------------------- ENUMS -------------------------------------//
// Used to determine if lines should be colored UNIFORMLY or by Flux Value
enum class ColorMethod : int {
enum class ColorMethod {
ByFluxValue = 0,
Uniform = 1
};
enum class GoesEnergyBins : int {
enum class GoesEnergyBins {
Emin01 = 0,
Emin03 = 1
};
enum class ScalingMethod : int {
enum class ScalingMethod {
Flux = 0,
RFlux = 1,
R2Flux = 2,
log10RFlux = 3,
lnRFlux = 4
};
enum class NodeSkipMethod : int {
enum class NodeSkipMethod {
Uniform = 0,
Flux = 1,
Radius = 2,
Streamnumber = 3
};
enum class EnhanceMethod : int {
enum class EnhanceMethod {
Sizescaling = 0,
Colortables = 1,
Sizeandcolor = 2,
@@ -269,17 +269,10 @@ private:
void setupProperties();
void updateActiveTriggerTimeIndex(double currentTime);
void loadNodeData(const int& energybinOption);
void loadNodeData(int energybinOption);
// ------------------------- FUNCTIONS USED DURING RUNTIME ------------------------ //
void updatePositionBuffer();
void updateVertexColorBuffer();
void updateVertexFilteringBuffer();
// ----------------------TEMPORARY VARIABLES ------------------
//properties::StringProperty _spriteTexturePath;
//std::unique_ptr<ghoul::opengl::Texture> _spriteTexture;
//std::unique_ptr<ghoul::filesystem::File> _spriteTextureFile;
};
}
} // namespace openspace

View File

@@ -21,6 +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/space/rendering/renderabletravelspeed.h>
#include <modules/base/basemodule.h>
@@ -40,50 +41,50 @@ namespace {
constexpr const char* _loggerCat = "renderableTravelSpeed";
constexpr const std::array<const char*, 2> UniformNames = {
"lineColor", "opacity"
"lineColor", "opacity"
};
constexpr openspace::properties::Property::PropertyInfo SpeedInfo = {
"travelSpeed",
"Speed of travel",
"The speed of light is the default value."
"TravelSpeed",
"Speed of travel",
"The speed of light is the default value."
};
constexpr openspace::properties::Property::PropertyInfo TargetInfo = {
"targetNode",
"Target object",
"This value sets which scene graph node to target with the light speed indicator"
"TargetNode",
"Target object",
"This value sets which scene graph node to target with the light speed indicator"
};
constexpr openspace::properties::Property::PropertyInfo LineColorInfo = {
"Color",
"Color",
"This value determines the RGB color for the line."
"Color",
"Color",
"This value determines the RGB color for the line."
};
constexpr openspace::properties::Property::PropertyInfo LineOpacityInfo = {
"Opacity",
"Opacity",
"This value determines the opacity for the line."
"Opacity",
"Opacity",
"This value determines the opacity for the line."
};
constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = {
"LineWidth",
"Line Width",
"This value specifies the line width."
"LineWidth",
"Line Width",
"This value specifies the line width."
};
constexpr openspace::properties::Property::PropertyInfo IndicatorLengthInfo = {
"IndicatorLength",
"Indicator Length",
"This value specifies the length of the light indicator set in light seconds."
"IndicatorLength",
"Indicator Length",
"This value specifies the length of the light indicator set in light seconds."
};
constexpr openspace::properties::Property::PropertyInfo FadeLengthInfo = {
"FadeLength",
"Fade Length",
"This value specifies the length of the faded tail of the light indicator "
"set in light seconds."
"FadeLength",
"Fade Length",
"This value specifies the length of the faded tail of the light indicator "
"set in light seconds."
};
struct [[codegen::Dictionary(RenderableLightTravel)]] Parameters {
@@ -107,8 +108,6 @@ namespace {
// [[codegen::verbatim(FadeLengthInfo.description)]]
std::optional<int> fadeLength;
};
#include "renderabletravelspeed_codegen.cpp"
} // namespace
@@ -123,14 +122,17 @@ documentation::Documentation RenderableTravelSpeed::Documentation() {
RenderableTravelSpeed::RenderableTravelSpeed(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _targetName(TargetInfo)
, _travelSpeed(SpeedInfo, distanceconstants::LightSecond, 1.0,
distanceconstants::LightSecond)
, _travelSpeed(
SpeedInfo,
distanceconstants::LightSecond,
1.0,
distanceconstants::LightSecond
)
, _indicatorLength(IndicatorLengthInfo, 1, 1, 360)
, _fadeLength(FadeLengthInfo, 1, 0, 360)
, _lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, _opacity(LineOpacityInfo, 1.0, 0.0, 1.0)
, _lineWidth(LineWidthInfo, 2.f, 1.f, 20.f)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
setRenderBin(RenderBin::Overlay);
@@ -153,11 +155,12 @@ RenderableTravelSpeed::RenderableTravelSpeed(const ghoul::Dictionary& dictionary
_targetName = p.target;
addProperty(_targetName);
_targetName.onChange([this]() {
if (SceneGraphNode* n = sceneGraphNode(_targetName); n) {
if (SceneGraphNode* n = sceneGraphNode(_targetName); n) {
_targetNode = n;
_targetPosition = _targetNode->worldPosition();
_lightTravelTime = calculateLightTravelTime(
_sourcePosition, _targetPosition
_sourcePosition,
_targetPosition
);
calculateDirectionVector();
reinitiateTravel();
@@ -169,18 +172,14 @@ RenderableTravelSpeed::RenderableTravelSpeed(const ghoul::Dictionary& dictionary
_travelSpeed.onChange([this]() {
reinitiateTravel();
});
} // constructor
}
void RenderableTravelSpeed::initialize() {
_initiationTime = -1;
_targetNode = sceneGraphNode(_targetName);
} // initialize
}
void RenderableTravelSpeed::initializeGL() {
_shaderProgram = BaseModule::ProgramObjectManager.request(
"Travelspeed",
[]() -> std::unique_ptr<ghoul::opengl::ProgramObject> {
@@ -196,8 +195,7 @@ void RenderableTravelSpeed::initializeGL() {
glGenBuffers(1, &_vBufferId);
ghoul::opengl::updateUniformLocations(*_shaderProgram, _uniformCache, UniformNames);
} // initializeGL
}
void RenderableTravelSpeed::deinitializeGL() {
BaseModule::ProgramObjectManager.release(
@@ -208,7 +206,7 @@ void RenderableTravelSpeed::deinitializeGL() {
);
glDeleteVertexArrays(1, &_vaoId);
glDeleteBuffers(1, &_vBufferId);
} // deinitializeGL
}
double RenderableTravelSpeed::calculateLightTravelTime(glm::dvec3 startPosition,
glm::dvec3 targetPosition) {
@@ -221,24 +219,16 @@ void RenderableTravelSpeed::calculateDirectionVector() {
}
void RenderableTravelSpeed::calculateVerticesPositions() {
// 3: start of light, 2: start of fade, 1: end of fade
_verticesPositions[2].x = _travelSpeed * _timeSinceStart * _directionVector.x;
_verticesPositions[2].y = _travelSpeed * _timeSinceStart * _directionVector.y;
_verticesPositions[2].z = _travelSpeed * _timeSinceStart * _directionVector.z;
_verticesPositions[2] = _travelSpeed * _timeSinceStart * _directionVector;
// This if statment is there to not start the line from behind the source node
if (_timeSinceStart < _indicatorLength) {
_verticesPositions[1] = glm::vec3(0.0, 0.0, 0.0); // = source node
}
else {
_verticesPositions[1].x =
_travelSpeed * _directionVector.x * (_timeSinceStart - _indicatorLength);
_verticesPositions[1].y =
_travelSpeed * _directionVector.y * (_timeSinceStart - _indicatorLength);
_verticesPositions[1].z =
_travelSpeed * _directionVector.z * (_timeSinceStart - _indicatorLength);
_verticesPositions[1] =
_travelSpeed * (_timeSinceStart - _indicatorLength) * _directionVector;
}
// This if statment is there to not start the line from behind the source node
@@ -246,20 +236,14 @@ void RenderableTravelSpeed::calculateVerticesPositions() {
_verticesPositions[0] = glm::vec3(0.0, 0.0, 0.0); // = source node
}
else {
_verticesPositions[0].x =
_travelSpeed * _directionVector.x *
(_timeSinceStart - _indicatorLength - _fadeLength);
_verticesPositions[0].y =
_travelSpeed * _directionVector.y *
(_timeSinceStart - _indicatorLength - _fadeLength);
_verticesPositions[0].z =
_travelSpeed * _directionVector.z *
(_timeSinceStart - _indicatorLength - _fadeLength);
_verticesPositions[0] =
_travelSpeed *
(_timeSinceStart - _indicatorLength - _fadeLength) *
_directionVector;
}
}
void RenderableTravelSpeed::updateVertexData() {
calculateVerticesPositions();
glBindVertexArray(_vaoId);
@@ -285,7 +269,6 @@ bool RenderableTravelSpeed::isReady() const{
}
void RenderableTravelSpeed::update(const UpdateData& data) {
if (_initiationTime == -1) {
_initiationTime = data.time.j2000Seconds();
std::string_view temp = data.time.ISO8601();
@@ -298,17 +281,16 @@ void RenderableTravelSpeed::update(const UpdateData& data) {
_sourcePosition = mySGNPointer->worldPosition();
_lightTravelTime = calculateLightTravelTime(
_sourcePosition, _targetPosition
_sourcePosition,
_targetPosition
);
const double currentTime = data.time.j2000Seconds();
// Unless we've reached the target
if (_initiationTime < currentTime && _arrivalTime > currentTime) {
_timeSinceStart = currentTime - _initiationTime;
calculateDirectionVector();
updateVertexData();
}
else { // in case we've reached the target
reinitiateTravel();
@@ -316,12 +298,12 @@ void RenderableTravelSpeed::update(const UpdateData& data) {
_shaderProgram->setUniform("lineColor", _lineColor);
_shaderProgram->setUniform("opacity", _opacity);
} // update
}
void RenderableTravelSpeed::render(const RenderData& data, RendererTasks& ) {
if (!this->_enabled) return;
if (!_enabled) {
return;
}
_shaderProgram->activate();
const glm::dmat4 modelTransform =
@@ -335,9 +317,10 @@ void RenderableTravelSpeed::render(const RenderData& data, RendererTasks& ) {
_shaderProgram->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
_shaderProgram->setUniform("projectionTransform", data.camera.projectionMatrix());
#ifndef __APPLE__
glLineWidth(_lineWidth);
#ifdef __APPLE__
glLineWidth(1);
#else
glLineWidth(1.f);
#endif
glBindVertexArray(_vaoId);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferId);
@@ -349,6 +332,5 @@ void RenderableTravelSpeed::render(const RenderData& data, RendererTasks& ) {
glBindVertexArray(0);
_shaderProgram->deactivate();
} // render
} // namespace
}
} // namespace openspace

View File

@@ -1,35 +1,34 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
* *
* 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_SPACE___RENDERABLETRAVELSPEED___H__
#define __OPENSPACE_MODULE_SPACE___RENDERABLETRAVELSPEED___H__
#include <openspace/rendering/renderable.h>
#include <openspace/properties/vector/vec3property.h>
#include <openspace/properties/scalar/intproperty.h>
#include <ghoul/opengl/uniformcache.h>
namespace openspace {
@@ -38,7 +37,7 @@ class SceneGraphNode;
namespace documentation { struct Documentation; }
class RenderableTravelSpeed : public Renderable{
class RenderableTravelSpeed : public Renderable {
public:
RenderableTravelSpeed(const ghoul::Dictionary& dictionary);
@@ -53,6 +52,13 @@ public:
void update(const UpdateData& data) override;
private:
double calculateLightTravelTime(glm::dvec3 startPosition, glm::dvec3 targetPosition);
void calculateVerticesPositions();
void calculateDirectionVector();
void updateVertexData();
void reinitiateTravel();
UniformCache(lineColor, opacity) _uniformCache;
properties::StringProperty _targetName;
SceneGraphNode* _targetNode = nullptr;
properties::DoubleProperty _travelSpeed;
@@ -73,21 +79,14 @@ private:
glm::dvec3 _directionVector;
double _initiationTime;
double _arrivalTime;
double _timeSinceStart = -1.f;
double _timeSinceStart = -1.0;
ghoul::opengl::ProgramObject* _shaderProgram = nullptr;
// The vertex attribute location for position
// must correlate to layout location in vertex shader
GLuint _vaoId = 0;
GLuint _vBufferId = 0;
double calculateLightTravelTime(glm::dvec3 startPosition, glm::dvec3 targetPosition);
void calculateVerticesPositions();
void calculateDirectionVector();
void updateVertexData();
void reinitiateTravel();
UniformCache(lineColor, opacity) _uniformCache;
};
} // namespace
} // namespace openspace
#endif //__OPENSPACE_MODULE_SPACE___RENDERABLETRAVELSPEED___H__

View File

@@ -24,6 +24,13 @@
#include "fragment.glsl"
in vec2 vs_st;
in vec4 vs_color;
in float vs_depth;
in float vs_closeToEarth;
in flat double vs_time;
in float camera_IsCloseEnough;
uniform sampler2D texture1;
uniform bool drawCircles;
uniform bool drawHollow;
@@ -36,141 +43,89 @@ uniform bool usingGaussianPulse;
uniform vec3 cameraPos;
uniform vec4 streamColor;
in vec2 vs_st;
in vec4 vs_color;
in float vs_depth;
in float vs_closeToEarth;
in flat double vs_time;
in float camera_IsCloseEnough;
Fragment getFragment() {
vec4 fragColor = vs_color;
if (vs_color.a == 0) {
discard;
// //fragColor = vec4(1.0,1.0,1.0,1.0);
}
vec2 pos = vec2(0.5)-vs_st;
float r = length(pos)*2.0;
float a = atan(pos.y,pos.x);
float f = cos(a*3.);
float f = cos(a*3.0);
vec3 color = vec3(0.0);
color = vec3( 1.-smoothstep(f,f, r) );
color = vec3(1.-smoothstep(f,f, r));
//fragColor = vec4(color, 1.0);
//hÄr
Fragment frag;
frag.depth = vs_depth;
frag.color = fragColor;
vec2 coord = gl_PointCoord - vec2(0.5);
// if(camera_IsCloseEnough > 0.5){
/*zif(length(coord.x) > 0.15){
if(length(coord.y) > 0.15){
discard;
}
}*/
if(drawCircles){
if(length(coord) > 0.5){
if (drawCircles) {
if (length(coord) > 0.5) {
discard;
}
}
// if(vs_closeToEarth > 0.5){
if(drawHollow &&
length(coord) < 0.4 &&
(vs_closeToEarth > 0.5 ||
distance(cameraPos, vec3(0)) < 500000000000.0f)){
if (drawHollow &&
length(coord) < 0.4 &&
(vs_closeToEarth > 0.5 || distance(cameraPos, vec3(0)) < 500000000000.0f))
{
//frag.color.xyz = streamColor.xyz;
if(usingGaussianPulse &&
usingCameraPerspective &&
vs_closeToEarth > 0.5){
if(length(coord) < 0.3 &&
(pulsatingAlways ||
camera_IsCloseEnough > 0.5)){
float e = 2.718055f;
float y = 1 * pow(e, -(pow(length(coord), 2)) /( 2 * pow(0.2, 2)));
if(y < 0.05){
if (usingGaussianPulse &&
usingCameraPerspective &&
vs_closeToEarth > 0.5)
{
if (length(coord) < 0.3 &&
(pulsatingAlways || camera_IsCloseEnough > 0.5))
{
float e = 2.718055;
float y = 1.0 *
pow(
e, - (pow(length(coord), 2.0)) /( 2.0 * pow(0.2, 2.0))
);
if (y < 0.05) {
discard;
}
frag.color.a = y;
}
}
else{
else {
discard;
}
}
float e = 2.718055f;
float e = 2.718055;
if(useGaussian){
float y = 1 * pow(e, - (pow(length(coord), 2)) /( 2 * pow(0.2, 2)));
if(y < 0.05){
discard;
}
frag.color.a = y;
}
if (useGaussian) {
float y = 1.0 * pow(e, - (pow(length(coord), 2.0)) /( 2.0 * pow(0.2, 2.0)));
if (y < 0.05) {
discard;
}
frag.color.a = y;
}
if(usingPulse &&
if (usingPulse &&
usingCameraPerspective &&
vs_closeToEarth > 0.5 &&
(pulsatingAlways || camera_IsCloseEnough > 0.5) &&
length(coord) > 0.46){
//0.46 (without vec4(1, 1, 1, 1)), 0.4, 0.32
//frag.color = vec4(1,1,1,1); //Here!
float speed = 60.0f;
length(coord) > 0.46)
{
float speed = 60.0;
int modulusResult = int(double(speed) * vs_time) % 60;
if(modulusResult > 0 && modulusResult < 30){
if (modulusResult > 0 && modulusResult < 30) {
discard;
}
}
//homecooked solution to get similar to normal distribution
/*
float alphaV = sqrt(pow(1 - length(coord), 3));
alphaV = pow(alphaV, 3);
if(alphaV < 0.1){
discard;
}
*/
//else{
//frag.color.a = alphaV;
//}
//vec2 coord = gl_PointCoord;
/*
vec2 coord = gl_PointCoord;
if(coord.y > 0.5){
discard;
}
*/
//if(vs_st.x != -1){
//if (gl_FrontFacing) {
// frag.color = texture(texture1, vs_st);
// }
// else {
// frag.color = texture(texture1, vec2(1 - vs_st.s, vs_st.t));
// }
// }
// G-Buffer
// frag.gPosition = vec4(0.0); //vs_gPosition;
frag.gPosition = vec4(1e27, 1e27, 1e27, 1.0);
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
// There is no normal here
// TODO: Add the correct normal if necessary (JCC)
//frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
// frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
return frag;
}

View File

@@ -23,7 +23,48 @@
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScalingMath.hglsl"
// Inputs
// Should be provided in meters VaPosition
layout(location = 0) in vec3 in_position;
// The extra value used to color lines. Location must correspond to VaColor in
// renderablefluxnodes.h
layout(location = 1) in float fluxValue;
// The extra value used to mask out parts of lines. Location must correspond to
// VaFiltering in renderablefluxnodes.h
layout(location = 2) in float rValue;
// These should correspond to the enum 'ColorMode' in renderablefluxnodes.cpp
const int colorByFluxValue = 0;
const int uniformColor = 1;
const int uniformskip = 0;
const int fluxSkip = 1;
const int radiusSkip = 2;
const int fluxMode = 0;
const int RFlux = 1;
const int R2Flux = 2;
const int log10RFlux = 3;
const int lnRFlux = 4;
const int sizeScaling = 0;
const int colorTables = 1;
const int sizeAndColor = 2;
const int illuminance = 3;
const float AUtoMeter = 149597871000.0;
varying out vec4 vs_color;
varying out float vs_depth;
varying out vec2 vs_st;
varying out float camera_IsCloseEnough;
varying out float vs_closeToEarth;
varying out double vs_time;
varying out vec3 vs_camerapos;
// General Uniforms that's always needed
uniform mat4 modelViewProjection;
@@ -89,125 +130,83 @@ uniform float maxNodeSize;
uniform float minNodeSize;
uniform bool usingPulse;
// Inputs
// Should be provided in meters VaPosition
layout(location = 0) in vec3 in_position;
// The extra value used to color lines. Location must correspond to VaColor in
// renderablefluxnodes.h
layout(location = 1) in float fluxValue;
// The extra value used to mask out parts of lines. Location must correspond to
// VaFiltering in renderablefluxnodes.h
layout(location = 2) in float rValue;
// These should correspond to the enum 'ColorMode' in renderablefluxnodes.cpp
const int colorByFluxValue = 0;
const int uniformColor = 1;
const int uniformskip = 0;
const int fluxSkip = 1;
const int radiusSkip = 2;
const int fluxMode = 0;
const int RFlux = 1;
const int R2Flux = 2;
const int log10RFlux = 3;
const int lnRFlux = 4;
const int sizeScaling = 0;
const int colorTables = 1;
const int sizeAndColor = 2;
const int illuminance = 3;
const float AUtoMeter = 149597871000.0;
varying out vec4 vs_color;
varying out float vs_depth;
varying out vec2 vs_st;
varying out float camera_IsCloseEnough;
varying out float vs_closeToEarth;
varying out double vs_time;
varying out vec3 vs_camerapos;
vec4 getTransferFunctionColor(sampler1D InColorTable) {
vec4 getTransferFunctionColor(sampler1D inColorTable) {
// Remap the color scalar to a [0,1] range
float scaleValue = 0;
if(scalingMode == fluxMode){
float scaleValue = 0.0;
if (scalingMode == fluxMode) {
scaleValue = fluxValue;
}
else if(scalingMode == RFlux){
else if (scalingMode == RFlux) {
scaleValue = rValue * fluxValue;
}
else if(scalingMode == log10RFlux){
else if (scalingMode == log10RFlux) {
//conversion from logbase e to log10 since glsl does not support log10.
float logtoTen = log(rValue) / log(10);
float logtoTen = log(rValue) / log(10.0);
scaleValue = logtoTen * fluxValue;
}
else if(scalingMode == lnRFlux){
else if (scalingMode == lnRFlux) {
scaleValue = log(rValue) * fluxValue;
}
else if(scalingMode == R2Flux){
else if (scalingMode == R2Flux) {
scaleValue = rValue * rValue * fluxValue;
}
float lookUpVal = (scaleValue - colorTableRange.x)
/(colorTableRange.y - colorTableRange.x);
return texture(InColorTable, lookUpVal);
float lookUpVal = (scaleValue - colorTableRange.x) /
(colorTableRange.y - colorTableRange.x);
return texture(inColorTable, lookUpVal);
}
bool CheckvertexIndex(){
bool CheckvertexIndex() {
int nodeIndex = gl_VertexID;
if(nodeSkipMethod == uniformskip){
if(mod(nodeIndex, nodeSkip) == 0){
if (nodeSkipMethod == uniformskip) {
if (mod(nodeIndex, nodeSkip) == 0) {
return true;
}
}
else if(nodeSkipMethod == fluxSkip){
if(fluxValue > nodeSkipFluxThreshold && mod(nodeIndex, nodeSkip) == 0){
else if (nodeSkipMethod == fluxSkip) {
if (fluxValue > nodeSkipFluxThreshold && mod(nodeIndex, nodeSkip) == 0) {
return true;
}
if(fluxValue < nodeSkipFluxThreshold && mod(nodeIndex, nodeSkipDefault) == 0){
if (fluxValue < nodeSkipFluxThreshold && mod(nodeIndex, nodeSkipDefault) == 0) {
return true;
}
}
else if(nodeSkipMethod == radiusSkip){
if(rValue < nodeSkipRadiusThreshold && mod(nodeIndex, nodeSkip) == 0){
else if (nodeSkipMethod == radiusSkip) {
if (rValue < nodeSkipRadiusThreshold && mod(nodeIndex, nodeSkip) == 0) {
return true;
}
if(rValue > nodeSkipRadiusThreshold && mod(nodeIndex, nodeSkipDefault) == 0){
if (rValue > nodeSkipRadiusThreshold && mod(nodeIndex, nodeSkipDefault) == 0) {
return true;
}
}
return false;
}
//todo fix gl_VertexID
bool isParticle(){
bool isParticle() {
int modulusResult = int(double(particleSpeed) * time + gl_VertexID) % particleSpacing;
return modulusResult > 0 && modulusResult <= particleSize;
return false;
}
//function for showing nodes different depending on distance to earth
void DecidehowtoshowClosetoEarth(){
// SizeScaling
if(enhanceMethod == sizeScaling || enhanceMethod == illuminance){
void DecidehowtoshowClosetoEarth() {
// SizeScaling
if (enhanceMethod == sizeScaling || enhanceMethod == illuminance) {
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
vs_color = vec4(fluxColor.xyz, fluxColor.a);
}
// ColorTables
if(enhanceMethod == colorTables){
if (enhanceMethod == colorTables) {
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColor.a);
}
// SizeColor
if(enhanceMethod == sizeAndColor){
if (enhanceMethod == sizeAndColor) {
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, fluxColor3.a);
float tempR2 = rValue + 0.4;
if(tempR2 > 1.5){
if (tempR2 > 1.5) {
tempR2 = 1.5;
}
gl_PointSize = tempR2 * tempR2 * tempR2 * gl_PointSize * 5;
@@ -215,46 +214,44 @@ void DecidehowtoshowClosetoEarth(){
}
void CheckdistanceMethod() {
//Enhance by distance to Earth
float maxdist = 10000000000.f * perspectiveDistanceFactor;
float distancevec = distance(earthPos, in_position.xyz);
//Enhance by distance to Earth
float maxdist = 10000000000.0 * perspectiveDistanceFactor;
float distancevec = distance(earthPos, in_position.xyz);
vs_closeToEarth = 0;
vs_closeToEarth = 0.0;
if(distancevec < AUtoMeter * distanceThreshold && usingPulse){
vs_closeToEarth = 1;
gl_PointSize = gl_PointSize * 5;
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
}
if (distancevec < AUtoMeter * distanceThreshold && usingPulse) {
vs_closeToEarth = 1.0;
gl_PointSize = gl_PointSize * 5;
vec4 fluxColor = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
}
if(enhanceMethod == colorTables || enhanceMethod == sizeAndColor){
vec4 fluxColor2 = getTransferFunctionColor(colorTableEarth);
vs_color = vec4(fluxColor2.xyz, fluxColorAlpha);
//vs_color = vec4(0.3, 0.3, 0.3, fluxColorAlpha);
if (enhanceMethod == colorTables || enhanceMethod == sizeAndColor) {
vec4 fluxColor2 = getTransferFunctionColor(colorTableEarth);
vs_color = vec4(fluxColor2.xyz, fluxColorAlpha);
}
if (enhanceMethod == illuminance) {
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
}
if (distance(earthPos, in_position) < AUtoMeter * distanceThreshold) {
if (mod(gl_VertexID, nodeSkipEarth) == 0) {
DecidehowtoshowClosetoEarth();
}
if(enhanceMethod == illuminance){
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
else {
vs_color = vec4(0.0);
}
if(distance(earthPos, in_position) < AUtoMeter * distanceThreshold){
if(mod(gl_VertexID, nodeSkipEarth) == 0){
DecidehowtoshowClosetoEarth();
}
else{
vs_color = vec4(0);
}
}
else {
if (enhanceMethod == illuminance) {
vs_color.a = fluxColorAlphaIlluminance;
}
else{
if(enhanceMethod == illuminance){
vs_color.a = fluxColorAlphaIlluminance;
}
if(fluxValue < thresholdFlux){
vs_color.a = fluxColorAlpha;
}
if (fluxValue < thresholdFlux) {
vs_color.a = fluxColorAlpha;
}
}
}
void main() {
@@ -263,94 +260,92 @@ void main() {
// Checking if we should render the vertex dependent on the vertexindex,
// by using modulus.
if(CheckvertexIndex() ||
if (CheckvertexIndex() ||
distance(earthPos, in_position) < (distanceThreshold * AUtoMeter) &&
rValue/AUtoMeter > filterLower &&
rValue/AUtoMeter < filterUpper &&
in_position.z > (domainLimZ.x * AUtoMeter) &&
in_position.z < (domainLimZ.y * AUtoMeter)){
in_position.z < (domainLimZ.y * AUtoMeter))
{
// We should color it by flux
if(colorMode == 0){
if (colorMode == 0) {
//vec4 fluxColor = getTransferFunctionColor(colorTable);
vec4 fluxColor = getTransferFunctionColor(colorTableCMR);
if(fluxValue > thresholdFlux){
if (fluxValue > thresholdFlux) {
vs_color = vec4(fluxColor.xyz, fluxColor.a);
gl_PointSize = nodeSizeLargerFlux;
}
else{
else {
vs_color = vec4(fluxColor.xyz, fluxColorAlpha);
gl_PointSize = nodeSize;
}
}
else{
else {
//Uniform coloring
vs_color = streamColor;
}
CheckdistanceMethod();
}
else{
vs_color = vec4(0);
else {
vs_color = vec4(0.0);
}
if(usingParticles && isParticle() && rValue > 0.f){
if (usingParticles && isParticle() && rValue > 0.0) {
int modulusResult = int(double(particleSpeed) * time + gl_VertexID)
% particleSpacing;
if(modulusResult >= particleSize - 30){
if(flowColoring){
if (modulusResult >= particleSize - 30) {
if (flowColoring) {
vec4 fluxColor3 = getTransferFunctionColor(colorTable);
vs_color = vec4(fluxColor3.xyz, flowColor.a * 0.8);
}
else{
vs_color = vec4(0.9,0.9,0.9,0.5);
else {
vs_color = vec4(0.9, 0.9, 0.9, 0.5);
}
}
else{
else {
vec4 fluxColorFlow = getTransferFunctionColor(colorTableFlow);
vs_color = vec4(fluxColorFlow.xyz, 1);
vs_color = vec4(fluxColorFlow.xyz, 1.0);
}
}
if(usingCameraPerspective){
if (usingCameraPerspective) {
float rtemp = 1.0;
if(rValue > 1.0){
if (rValue > 1.0) {
rtemp = 1.0;
}
else{
}
else {
rtemp = rValue;
}
}
float maxDistance = 100000000000.f * perspectiveDistanceFactor;
float maxDistance = 100000000000.0 * perspectiveDistanceFactor;
float distanceVec = distance(cameraPos, in_position.xyz);
if(distanceVec < maxDistance){
camera_IsCloseEnough = 0;
camera_IsCloseEnough = 0.0;
}
else{
camera_IsCloseEnough = 1;
camera_IsCloseEnough = 1.0;
}
if(distanceVec < maxDistance){
float distScale = 1 - smoothstep(0, maxDistance, distanceVec);
if (distanceVec < maxDistance) {
float distScale = 1.0 - smoothstep(0.0, maxDistance, distanceVec);
float factorS = 1.0;
if(usingRadiusPerspective){
factorS = pow(distScale, 9) * 500.0 * pow(rtemp, 2);
if (usingRadiusPerspective) {
factorS = pow(distScale, 9.0) * 500.0 * pow(rtemp, 2.0);
}
else{
factorS = pow(distScale, 9) * 500.0;
else {
factorS = pow(distScale, 9.0) * 500.0;
}
gl_PointSize = factorS * maxNodeDistanceSize * 0.8;
}
// else{
// gl_PointSize = nodeSize;
// }
if(gl_PointSize > maxNodeSize){
if (gl_PointSize > maxNodeSize) {
gl_PointSize = maxNodeSize;
}
if(gl_PointSize < minNodeSize){
if (gl_PointSize < minNodeSize) {
gl_PointSize = minNodeSize;
}
}
@@ -362,5 +357,4 @@ void main() {
gl_Position = vec4(positionClipSpace.xy, 0, positionClipSpace.w);
vs_depth = gl_Position.w;
}

View File

@@ -1,4 +1,3 @@
/*****************************************************************************************
* *
* OpenSpace *
@@ -22,6 +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 "fragment.glsl"
#include "floatoperations.glsl"
@@ -30,7 +30,6 @@
in vec4 vs_positionViewSpace;
Fragment getFragment() {
Fragment frag;
frag.color = finalColor;
@@ -40,5 +39,3 @@
return frag;
}

View File

@@ -1,4 +1,3 @@
/*****************************************************************************************
* *
* OpenSpace *
@@ -36,9 +35,8 @@ uniform float opacity;
uniform mat4 modelViewTransform;
uniform mat4 projectionTransform;
void main(){
vs_positionViewSpace = vec4(modelViewTransform * dvec4(in_position, 1));
void main() {
vs_positionViewSpace = vec4(modelViewTransform * dvec4(in_position, 1.0));
vec4 positionScreenSpace = projectionTransform * vs_positionViewSpace;
vs_depth = positionScreenSpace.w;
gl_Position = positionScreenSpace;
@@ -47,7 +45,6 @@ void main(){
if (gl_VertexID == 0) {
finalColor = vec4(0.0, 0.0, 0.0, 0.0);
}
// Makes sure the line between index 1 and 2 is uniformly colored
else if (gl_VertexID == 1) {
finalColor = vec4(lineColor, opacity);
@@ -55,7 +52,6 @@ void main(){
else if (gl_VertexID == 2 ) {
finalColor = vec4(lineColor, opacity);
}
// should never hit else
else {
finalColor = vec4(1.0, 1.0, 0.0, 1.0);

View File

@@ -30,29 +30,29 @@
namespace openspace::volume {
template <typename T> class RawVolume;
template <typename T> class RawVolume;
template <typename Type>
class RawVolumeReader {
public:
using VoxelType = Type;
template <typename Type>
class RawVolumeReader {
public:
using VoxelType = Type;
RawVolumeReader(const std::string& path, const glm::uvec3& dimensions);
RawVolumeReader(const std::string& path, const glm::uvec3& dimensions);
glm::uvec3 dimensions() const;
std::string path() const;
void setPath(const std::string& path);
void setDimensions(const glm::uvec3& dimensions);
//VoxelType get(const glm::ivec3& coordinates) const; // TODO: Implement this
//VoxelType get(const size_t index) const; // TODO: Implement this
std::unique_ptr<RawVolume<VoxelType>> read(bool invertZ = false);
glm::uvec3 dimensions() const;
std::string path() const;
void setPath(const std::string& path);
void setDimensions(const glm::uvec3& dimensions);
//VoxelType get(const glm::ivec3& coordinates) const; // TODO: Implement this
//VoxelType get(const size_t index) const; // TODO: Implement this
std::unique_ptr<RawVolume<VoxelType>> read(bool invertZ = false);
private:
size_t coordsToIndex(const glm::uvec3& cartesian) const;
glm::uvec3 indexToCoords(size_t linear) const;
glm::uvec3 _dimensions;
std::string _path;
};
private:
size_t coordsToIndex(const glm::uvec3& cartesian) const;
glm::uvec3 indexToCoords(size_t linear) const;
glm::uvec3 _dimensions;
std::string _path;
};
} // namespace openspace::volume

View File

@@ -76,7 +76,7 @@ public:
void setVolumeTexture(std::shared_ptr<ghoul::opengl::Texture> texture);
std::shared_ptr<ghoul::opengl::Texture> volumeTexture() const;
void setTransferFunction(std::shared_ptr<openspace::TransferFunction> transferFunction);
void setTransferFunction(std::shared_ptr<TransferFunction> transferFunction);
void setStepSize(float stepSize);
float opacity() const;

View File

@@ -54,74 +54,74 @@ namespace {
constexpr const float VolumeMaxOpacity = 500;
static const openspace::properties::Property::PropertyInfo StepSizeInfo = {
"stepSize",
"StepSize",
"Step Size",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo GridTypeInfo = {
"gridType",
"GridType",
"Grid Type",
"", // @TODO Missing documentation
openspace::properties::Property::Visibility::Developer
};
constexpr openspace::properties::Property::PropertyInfo SecondsBeforeInfo = {
"secondsBefore",
"SecondsBefore",
"Seconds before",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo SecondsAfterInfo = {
"secondsAfter",
"SecondsAfter",
"Seconds after",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo SourceDirectoryInfo = {
"sourceDirectory",
"SourceDirectory",
"Source Directory",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo TransferFunctionInfo = {
"transferFunctionPath",
"TransferFunctionPath",
"Transfer Function Path",
""
};
constexpr openspace::properties::Property::PropertyInfo TriggerTimeJumpInfo = {
"triggerTimeJump",
"TriggerTimeJump",
"Jump",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo JumpToTimestepInfo = {
"jumpToTimestep",
"JumpToTimestep",
"Jump to timestep",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo CurrentTimeStepInfo = {
"currentTimestep",
"CurrentTimestep",
"Current timestep",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo OpacityInfo = {
"opacity",
"Opacity",
"Opacity",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo rNormalizationInfo = {
"rNormalization",
"RNormalization",
"Radius normalization",
"" // @TODO Missing documentation
};
constexpr openspace::properties::Property::PropertyInfo rUpperBoundInfo = {
"rUpperBound",
"RUpperBound",
"Radius upper bound",
"" // @TODO Missing documentation
};
@@ -213,7 +213,7 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
VolumeGridType gridType = volume::parseGridType(*p.gridType);
_gridType = static_cast<std::underlying_type_t<VolumeGridType>>(gridType);
}
addProperty(_opacity);
}
@@ -263,7 +263,7 @@ void RenderableTimeVaryingVolume::initializeGL() {
GL_FLOAT,
ghoul::opengl::Texture::FilterMode::Linear,
ghoul::opengl::Texture::WrappingMode::Clamp
);
);
t.texture->setPixelData(
reinterpret_cast<void*>(data),
@@ -278,7 +278,7 @@ void RenderableTimeVaryingVolume::initializeGL() {
nullptr,
_transferFunction,
_clipPlanes
);
);
_raycaster->initialize();
global::raycasterManager->attachRaycaster(*_raycaster.get());
@@ -316,7 +316,7 @@ void RenderableTimeVaryingVolume::initializeGL() {
_raycaster->setGridType(static_cast<VolumeGridType>(_gridType.value()));
_gridType.onChange([this] {
_raycaster->setGridType(static_cast<VolumeGridType>(_gridType.value()));
});
});
_transferFunctionPath.onChange([this] {
_transferFunction = std::make_shared<openspace::TransferFunction>(

View File

@@ -33,16 +33,6 @@
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/triggerproperty.h>
// #include <modules/volume/rawvolume.h>
// #include <modules/volume/rawvolumemetadata.h>
// #include <modules/volume/rendering/basicvolumeraycaster.h>
// #include <modules/volume/rendering/volumeclipplanes.h>
// #include <openspace/properties/vectorproperty.h>
// #include <openspace/properties/optionproperty.h>
// #include <openspace/properties/stringproperty.h>
// #include <openspace/util/boxgeometry.h>
// #include <openspace/util/histogram.h>
#include <openspace/rendering/transferfunction.h>
namespace openspace {
@@ -52,65 +42,65 @@ namespace openspace {
namespace openspace::volume {
//class TransferFunction;
class BasicVolumeRaycaster;
template <typename T> class RawVolume;
class VolumeClipPlanes;
//class TransferFunction;
class BasicVolumeRaycaster;
template <typename T> class RawVolume;
class VolumeClipPlanes;
class RenderableTimeVaryingVolume : public Renderable {
public:
RenderableTimeVaryingVolume(const ghoul::Dictionary& dictionary);
~RenderableTimeVaryingVolume();
class RenderableTimeVaryingVolume : public Renderable {
public:
RenderableTimeVaryingVolume(const ghoul::Dictionary& dictionary);
~RenderableTimeVaryingVolume();
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
void render(const RenderData& data, RendererTasks& tasks) override;
void update(const UpdateData& data) override;
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
void render(const RenderData& data, RendererTasks& tasks) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
static documentation::Documentation Documentation();
private:
struct Timestep {
std::string baseName;
bool inRam;
bool onGpu;
RawVolumeMetadata metadata;
std::shared_ptr<RawVolume<float>> rawVolume;
std::shared_ptr<ghoul::opengl::Texture> texture;
std::shared_ptr<Histogram> histogram;
};
Timestep* currentTimestep();
int timestepIndex(const Timestep* t) const;
Timestep* timestepFromIndex(int index);
void jumpToTimestep(int i);
void loadTimestepMetadata(const std::string& path);
properties::OptionProperty _gridType;
std::shared_ptr<VolumeClipPlanes> _clipPlanes;
properties::FloatProperty _stepSize;
properties::FloatProperty _opacity;
properties::FloatProperty _rNormalization;
properties::FloatProperty _rUpperBound;
properties::FloatProperty _secondsBefore;
properties::FloatProperty _secondsAfter;
properties::StringProperty _sourceDirectory;
properties::StringProperty _transferFunctionPath;
properties::TriggerProperty _triggerTimeJump;
properties::IntProperty _jumpToTimestep;
properties::IntProperty _currentTimestep;
std::map<double, Timestep> _volumeTimesteps;
std::unique_ptr<BasicVolumeRaycaster> _raycaster;
bool _invertDataAtZ;
std::shared_ptr<openspace::TransferFunction> _transferFunction;
private:
struct Timestep {
std::string baseName;
bool inRam;
bool onGpu;
RawVolumeMetadata metadata;
std::shared_ptr<RawVolume<float>> rawVolume;
std::shared_ptr<ghoul::opengl::Texture> texture;
std::shared_ptr<Histogram> histogram;
};
Timestep* currentTimestep();
int timestepIndex(const Timestep* t) const;
Timestep* timestepFromIndex(int index);
void jumpToTimestep(int i);
void loadTimestepMetadata(const std::string& path);
properties::OptionProperty _gridType;
std::shared_ptr<VolumeClipPlanes> _clipPlanes;
properties::FloatProperty _stepSize;
properties::FloatProperty _opacity;
properties::FloatProperty _rNormalization;
properties::FloatProperty _rUpperBound;
properties::FloatProperty _secondsBefore;
properties::FloatProperty _secondsAfter;
properties::StringProperty _sourceDirectory;
properties::StringProperty _transferFunctionPath;
properties::TriggerProperty _triggerTimeJump;
properties::IntProperty _jumpToTimestep;
properties::IntProperty _currentTimestep;
std::map<double, Timestep> _volumeTimesteps;
std::unique_ptr<BasicVolumeRaycaster> _raycaster;
bool _invertDataAtZ;
std::shared_ptr<openspace::TransferFunction> _transferFunction;
};
} // namespace openspace::volume
#endif // __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__