mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-09 13:12:58 -06:00
Merge remote-tracking branch 'origin/feature/spaceweather-stream' into thesis/2019/spaceweather-stream
This commit is contained in:
@@ -36,21 +36,19 @@
|
||||
#include <fstream>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
"This value specifies an image that is loaded from disk and is used as a texture "
|
||||
"that is applied to this plane. This image has to be square."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
"Texture",
|
||||
"Texture",
|
||||
"This value specifies an image that is loaded from disk and is used as a texture "
|
||||
"that is applied to this plane. This image has to be square."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RenderableTypeInfo = {
|
||||
"RenderableType",
|
||||
"RenderableType",
|
||||
"This value specifies if the plane should be rendered in the Background,"
|
||||
"Opaque, Transparent, or Overlay rendering step."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RenderableTypeInfo = {
|
||||
"RenderableType",
|
||||
"RenderableType",
|
||||
"This value specifies if the plane should be rendered in the Background,"
|
||||
"Opaque, Transparent, or Overlay rendering step."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -76,7 +74,7 @@ documentation::Documentation RenderablePlaneImageLocal::Documentation() {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& dictionary)
|
||||
: RenderablePlane(dictionary)
|
||||
, _texturePath(TextureInfo)
|
||||
@@ -101,7 +99,7 @@ RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& di
|
||||
if (dictionary.hasKey(RenderableTypeInfo.identifier)) {
|
||||
std::string renderType = dictionary.value<std::string>(
|
||||
RenderableTypeInfo.identifier
|
||||
);
|
||||
);
|
||||
if (renderType == "Background") {
|
||||
setRenderBin(Renderable::RenderBin::Background);
|
||||
}
|
||||
@@ -116,68 +114,68 @@ RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& di
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool RenderablePlaneImageLocal::isReady() const {
|
||||
return RenderablePlane::isReady() && (_texture != nullptr);
|
||||
}
|
||||
|
||||
|
||||
void RenderablePlaneImageLocal::initializeGL() {
|
||||
RenderablePlane::initializeGL();
|
||||
|
||||
loadTexture();
|
||||
}
|
||||
|
||||
|
||||
void RenderablePlaneImageLocal::deinitializeGL() {
|
||||
_textureFile = nullptr;
|
||||
|
||||
|
||||
BaseModule::TextureManager.release(_texture);
|
||||
RenderablePlane::deinitializeGL();
|
||||
}
|
||||
|
||||
|
||||
void RenderablePlaneImageLocal::bindTexture() {
|
||||
_texture->bind();
|
||||
}
|
||||
|
||||
|
||||
void RenderablePlaneImageLocal::update(const UpdateData& data) {
|
||||
RenderablePlane::update(data);
|
||||
|
||||
|
||||
if (_textureIsDirty) {
|
||||
loadTexture();
|
||||
_textureIsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RenderablePlaneImageLocal::loadTexture() {
|
||||
if (!_texturePath.value().empty()) {
|
||||
ghoul::opengl::Texture* t = _texture;
|
||||
|
||||
|
||||
unsigned int hash = ghoul::hashCRC32File(_texturePath);
|
||||
|
||||
|
||||
_texture = BaseModule::TextureManager.request(
|
||||
std::to_string(hash),
|
||||
[path = _texturePath]() -> std::unique_ptr<ghoul::opengl::Texture> {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
ghoul::io::TextureReader::ref().loadTexture(absPath(path));
|
||||
|
||||
|
||||
LDEBUGC(
|
||||
"RenderablePlaneImageLocal",
|
||||
fmt::format("Loaded texture from '{}'", absPath(path))
|
||||
);
|
||||
texture->uploadTexture();
|
||||
|
||||
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
|
||||
|
||||
|
||||
return texture;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
BaseModule::TextureManager.release(t);
|
||||
|
||||
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
|
||||
_textureFile->setCallback([&](const ghoul::filesystem::File&) {
|
||||
_textureIsDirty = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -31,38 +31,38 @@ namespace ghoul::filesystem { class File; }
|
||||
namespace ghoul::opengl { class Texture; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct RenderData;
|
||||
struct UpdateData;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class RenderablePlaneImageLocal : public RenderablePlane {
|
||||
public:
|
||||
RenderablePlaneImageLocal(const ghoul::Dictionary& dictionary);
|
||||
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
bool isReady() const override;
|
||||
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
protected:
|
||||
virtual void bindTexture() override;
|
||||
|
||||
private:
|
||||
void loadTexture();
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
ghoul::opengl::Texture* _texture = nullptr;
|
||||
std::unique_ptr<ghoul::filesystem::File> _textureFile;
|
||||
|
||||
bool _textureIsDirty = false;
|
||||
};
|
||||
|
||||
|
||||
struct RenderData;
|
||||
struct UpdateData;
|
||||
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
class RenderablePlaneImageLocal : public RenderablePlane {
|
||||
public:
|
||||
RenderablePlaneImageLocal(const ghoul::Dictionary& dictionary);
|
||||
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
bool isReady() const override;
|
||||
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
protected:
|
||||
virtual void bindTexture() override;
|
||||
|
||||
private:
|
||||
void loadTexture();
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
ghoul::opengl::Texture* _texture = nullptr;
|
||||
std::unique_ptr<ghoul::filesystem::File> _textureFile;
|
||||
|
||||
bool _textureIsDirty = false;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_BASE___RENDERABLEPLANEIMAGELOCAL___H__
|
||||
|
||||
@@ -41,10 +41,6 @@
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "RenderableSphere";
|
||||
} // namespace
|
||||
|
||||
|
||||
namespace {
|
||||
constexpr const char* ProgramName = "Sphere";
|
||||
|
||||
constexpr const std::array<const char*, 5> UniformNames = {
|
||||
@@ -416,7 +412,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) {
|
||||
|
||||
_shader->setUniform(_uniformCache.opacity, adjustedTransparency);
|
||||
_shader->setUniform(_uniformCache._mirrorTexture, _mirrorTexture.value());
|
||||
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
@@ -495,5 +491,4 @@ void RenderableSphere::loadTexture() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <ghoul/opengl/uniformcache.h>
|
||||
|
||||
// @TODO emiax: This dependency needs to be removed
|
||||
// possibly we can turn it upside down and
|
||||
// let the suntexturemanager own a renderablesphere?
|
||||
#include <modules/base/rendering/suntexturemanager.h>
|
||||
|
||||
|
||||
namespace ghoul::opengl {
|
||||
class ProgramObject;
|
||||
class Texture;
|
||||
@@ -65,7 +67,7 @@ public:
|
||||
|
||||
private:
|
||||
void loadTexture();
|
||||
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
properties::OptionProperty _orientation;
|
||||
|
||||
@@ -89,7 +91,8 @@ private:
|
||||
_mirrorTexture) _uniformCache;
|
||||
|
||||
bool _sphereIsDirty = false;
|
||||
|
||||
|
||||
// @TODO emiax: This needs to be removed
|
||||
SunTextureManager _sunTexMgr;
|
||||
};
|
||||
|
||||
|
||||
@@ -43,40 +43,33 @@ namespace openspace
|
||||
{
|
||||
|
||||
SunTextureManager::SunTextureManager()
|
||||
{
|
||||
_syncDir = absPath("${BASE}/sync/magnetograms") + ghoul::filesystem::FileSystem::PathSeparator;
|
||||
}
|
||||
|
||||
|
||||
: _syncDir(absPath("${BASE}/sync/magnetograms") +
|
||||
ghoul::filesystem::FileSystem::PathSeparator)
|
||||
{}
|
||||
|
||||
void SunTextureManager::loadWSATexture(std::unique_ptr<ghoul::opengl::Texture>& texture){
|
||||
processTextureFromName("", &_fitsImageToUpload, &_dateIDToUpload);
|
||||
texture = uploadAndReturnTexture(_fitsImageToUpload, _dateIDToUpload);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SunTextureManager::update(std::unique_ptr<ghoul::opengl::Texture> &texture) {
|
||||
|
||||
// If server is dead, we are not going to do anything
|
||||
if (_activeConnection){
|
||||
|
||||
|
||||
std::string currentTime = getOpenSpaceDateTime();
|
||||
|
||||
|
||||
if (_textureToUpload.empty() && currentTime != _activeTextureDate && (_textureListGPU.find(currentTime) != _textureListGPU.end()))
|
||||
std::string currentTime = getOpenSpaceDateTime();
|
||||
if (_textureToUpload.empty() &&
|
||||
currentTime != _activeTextureDate &&
|
||||
(_textureListGPU.find(currentTime) != _textureListGPU.end()))
|
||||
{
|
||||
_textureToUpload = currentTime;
|
||||
}
|
||||
if ((global::timeManager.deltaTime() * _direction) < 0)
|
||||
{
|
||||
|
||||
if ((global::timeManager.deltaTime() * _direction) < 0) {
|
||||
_textureToUpload = "";
|
||||
}
|
||||
|
||||
_direction = global::timeManager.deltaTime();
|
||||
|
||||
switch (_stage)
|
||||
{
|
||||
switch (_stage) {
|
||||
//This stage just checks what the next image applied should be,
|
||||
case 0:
|
||||
{
|
||||
|
||||
@@ -30,19 +30,15 @@ in vec4 vs_gPosition;
|
||||
in vec3 vs_gNormal;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
//uniform sampler2DArray texture1;
|
||||
uniform bool additiveBlending;
|
||||
uniform float opacity = 1.0;
|
||||
|
||||
|
||||
Fragment getFragment() {
|
||||
Fragment frag;
|
||||
if (gl_FrontFacing) {
|
||||
// frag.color = texture(texture1, vec3(vs_st, 0));
|
||||
frag.color = texture(texture1, vs_st);
|
||||
}
|
||||
else {
|
||||
// frag.color = texture(texture1, vec3(vec2(1 - vs_st.s, vs_st.t), 0));
|
||||
frag.color = texture(texture1, vec2(1 - vs_st.s, vs_st.t));
|
||||
}
|
||||
|
||||
@@ -60,9 +56,6 @@ Fragment getFragment() {
|
||||
// G-Buffer
|
||||
frag.gPosition = vs_gPosition;
|
||||
frag.gNormal = vec4(vs_gNormal, 1.0);
|
||||
|
||||
frag.color.g = frag.color.r;
|
||||
frag.color.b = frag.color.r;
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,6 @@ Fragment getFragment() {
|
||||
// G-Buffer
|
||||
frag.gPosition = vs_position;
|
||||
frag.gNormal = vec4(vs_normal, 1.0);
|
||||
|
||||
|
||||
frag.color = vec4(frag.color.r, frag.color.g, frag.color.b, frag.color.a);
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace openspace {
|
||||
using namespace properties;
|
||||
|
||||
RenderableFieldlinesSequence::RenderableFieldlinesSequence(
|
||||
const ghoul::Dictionary& dictionary)
|
||||
const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _pColorGroup({ "Color" })
|
||||
, _pColorMethod(ColorMethodInfo, OptionProperty::DisplayType::Radio)
|
||||
@@ -286,14 +286,13 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence(
|
||||
, _pJumpToStartBtn(TimeJumpButtonInfo)
|
||||
{
|
||||
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
|
||||
|
||||
}
|
||||
|
||||
void RenderableFieldlinesSequence::initializeGL() {
|
||||
// EXTRACT MANDATORY INFORMATION FROM DICTIONARY
|
||||
SourceFileType sourceFileType = SourceFileType::Invalid;
|
||||
if (!extractMandatoryInfoFromDictionary(sourceFileType)) {
|
||||
//wait for a fieldline
|
||||
// Wait for a fieldline
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -357,7 +356,7 @@ void RenderableFieldlinesSequence::initializeGL() {
|
||||
|
||||
extractPropertyInfoFromDictionary();
|
||||
|
||||
// dictionary is no longer needed as everything is extracted
|
||||
// Dictionary is no longer needed as everything is extracted
|
||||
_dictionary.reset();
|
||||
|
||||
// Setup shader program
|
||||
@@ -375,7 +374,6 @@ void RenderableFieldlinesSequence::initializeGL() {
|
||||
|
||||
// Needed for additive blending
|
||||
setRenderBin(Renderable::RenderBin::Overlay);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,9 +382,8 @@ void RenderableFieldlinesSequence::initializeGL() {
|
||||
* Returns false if it fails to extract mandatory information!
|
||||
*/
|
||||
bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
|
||||
SourceFileType& sourceFileType)
|
||||
SourceFileType& sourceFileType)
|
||||
{
|
||||
|
||||
_dictionary->getValue(SceneGraphNode::KeyIdentifier, _identifier);
|
||||
|
||||
// ------------------- EXTRACT MANDATORY VALUES FROM DICTIONARY ------------------- //
|
||||
@@ -643,7 +640,6 @@ void RenderableFieldlinesSequence::loadOsflsStatesIntoRAM(const std::string& out
|
||||
{
|
||||
// Load states from .osfls files into RAM!
|
||||
for (const std::string& filePath : _sourceFiles) {
|
||||
//LERROR("Loading file into RAM: " + filePath);
|
||||
FieldlinesState newState;
|
||||
if (newState.loadStateFromOsfls(filePath)) {
|
||||
addStateToSequence(newState);
|
||||
@@ -821,7 +817,7 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() {
|
||||
});
|
||||
|
||||
_pJumpToStartBtn.onChange([this] {
|
||||
global::timeManager.setTimeNextFrame(openspace::Time(_startTimes[0]));
|
||||
global::timeManager.setTimeNextFrame(Time(_startTimes[0]));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -829,17 +825,17 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() {
|
||||
|
||||
// Calculate expected end time.
|
||||
void RenderableFieldlinesSequence::computeSequenceEndTime() {
|
||||
if (_nStates > 1) {
|
||||
const double lastTriggerTime = _startTimes[_nStates - 1];
|
||||
const double sequenceDuration = lastTriggerTime - _startTimes[0];
|
||||
const double averageStateDuration = sequenceDuration /
|
||||
(static_cast<double>(_nStates) - 1.0);
|
||||
_sequenceEndTime = lastTriggerTime + averageStateDuration;
|
||||
}
|
||||
else {
|
||||
// If there's just one state it should never disappear!
|
||||
_sequenceEndTime = DBL_MAX;
|
||||
}
|
||||
if (_nStates > 1) {
|
||||
const double lastTriggerTime = _startTimes[_nStates - 1];
|
||||
const double sequenceDuration = lastTriggerTime - _startTimes[0];
|
||||
const double averageStateDuration = sequenceDuration /
|
||||
(static_cast<double>(_nStates) - 1.0);
|
||||
_sequenceEndTime = lastTriggerTime + averageStateDuration;
|
||||
}
|
||||
else {
|
||||
// If there's just one state it should never disappear!
|
||||
_sequenceEndTime = DBL_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -908,17 +904,13 @@ void RenderableFieldlinesSequence::extractTriggerTimesFromFileNames() {
|
||||
timeString.replace(16, 1, ":");
|
||||
timeString.replace(19, 1, ".");
|
||||
const double triggerTime = Time::convertTime(timeString);
|
||||
//LERROR("Adding starttime " + this->_identifier + " : " + std::to_string(triggerTime));
|
||||
_startTimes.push_back(triggerTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RenderableFieldlinesSequence::addStateToSequence(FieldlinesState& state) {
|
||||
_states.push_back(state);
|
||||
//LERROR("Adding state to list of states : " + std::to_string(state.triggerTime()));
|
||||
_startTimes.push_back(state.triggerTime());
|
||||
|
||||
_nStates++;
|
||||
}
|
||||
|
||||
@@ -965,8 +957,8 @@ bool RenderableFieldlinesSequence::getStatesFromCdfFiles(const std::string& outp
|
||||
* Returns false if it fails to extract mandatory information!
|
||||
*/
|
||||
bool RenderableFieldlinesSequence::extractCdfInfoFromDictionary(std::string& seedFilePath,
|
||||
std::string& tracingVar,
|
||||
std::vector<std::string>& extraVars)
|
||||
std::string& tracingVar,
|
||||
std::vector<std::string>& extraVars)
|
||||
{
|
||||
|
||||
if (_dictionary->getValue(KeyCdfSeedPointFile, seedFilePath)) {
|
||||
@@ -1009,7 +1001,7 @@ bool RenderableFieldlinesSequence::extractCdfInfoFromDictionary(std::string& see
|
||||
}
|
||||
|
||||
bool RenderableFieldlinesSequence::extractSeedPointsFromFile(const std::string& path,
|
||||
std::vector<glm::vec3>& outVec)
|
||||
std::vector<glm::vec3>& outVec)
|
||||
{
|
||||
|
||||
std::ifstream seedFile(FileSys.relativePath(path));
|
||||
@@ -1038,8 +1030,8 @@ bool RenderableFieldlinesSequence::extractSeedPointsFromFile(const std::string&
|
||||
}
|
||||
|
||||
void RenderableFieldlinesSequence::extractMagnitudeVarsFromStrings(
|
||||
std::vector<std::string>& extraVars,
|
||||
std::vector<std::string>& extraMagVars)
|
||||
std::vector<std::string>& extraVars,
|
||||
std::vector<std::string>& extraMagVars)
|
||||
{
|
||||
|
||||
for (int i = 0; i < static_cast<int>(extraVars.size()); i++) {
|
||||
@@ -1206,9 +1198,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
|
||||
const double currentTime = data.time.j2000Seconds();
|
||||
|
||||
|
||||
if (_dynamicWebContent) {
|
||||
|
||||
if (!_webFieldlinesManager.hasUpdated &&
|
||||
_webFieldlinesManager.checkIfWindowIsReadyToLoad())
|
||||
{
|
||||
@@ -1242,7 +1232,6 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
// true => We stepped forward to a time represented by another state
|
||||
(nextIdx < _nStates && currentTime >= _startTimes[nextIdx]))
|
||||
{
|
||||
|
||||
updateActiveTriggerTimeIndex(currentTime);
|
||||
|
||||
if (_loadingStatesDynamically) {
|
||||
@@ -1253,8 +1242,6 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
_activeStateIndex = _activeTriggerTimeIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// else {we're still in same state as previous frame (no changes needed)}
|
||||
}
|
||||
else {
|
||||
@@ -1277,7 +1264,7 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
std::string filePath = _sourceFiles[_activeTriggerTimeIndex];
|
||||
std::thread readBinaryThread([this, f = std::move(filePath)]{
|
||||
readNewState(f);
|
||||
});
|
||||
});
|
||||
readBinaryThread.detach();
|
||||
}
|
||||
}
|
||||
@@ -1286,7 +1273,6 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
|
||||
if (_loadingStatesDynamically) {
|
||||
_states[0] = std::move(*_newState);
|
||||
|
||||
}
|
||||
|
||||
updateVertexPositionBuffer();
|
||||
@@ -1319,7 +1305,7 @@ void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(double currentTi
|
||||
if (iter != _startTimes.begin()) {
|
||||
_activeTriggerTimeIndex = static_cast<int>(
|
||||
std::distance(_startTimes.begin(), iter)
|
||||
) - 1;
|
||||
) - 1;
|
||||
}
|
||||
else {
|
||||
_activeTriggerTimeIndex = 0;
|
||||
|
||||
@@ -101,7 +101,7 @@ void main() {
|
||||
|
||||
if (hasColor) {
|
||||
int direction = 1;
|
||||
if(in_color_scalar < 0){
|
||||
if (in_color_scalar < 0) {
|
||||
direction = -1;
|
||||
}
|
||||
bool isParticle = usingParticles && isPartOfParticle(time, gl_VertexID,
|
||||
|
||||
Reference in New Issue
Block a user