mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-24 13:09:22 -06:00
Merge branch 'develop' of openspace.itn.liu.se:/openspace into develop
This commit is contained in:
64
include/openspace/rendering/renderablecrawlingline.h
Normal file
64
include/openspace/rendering/renderablecrawlingline.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __RENDERABLECRAWLINGLINE_H__
|
||||
#define __RENDERABLECRAWLINGLINE_H__
|
||||
|
||||
#include <openspace/rendering/renderable.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class RenderableCrawlingLine : public Renderable {
|
||||
public:
|
||||
RenderableCrawlingLine(const ghoul::Dictionary& dictionary);
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
bool isReady() const override;
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
ghoul::opengl::ProgramObject* _program;
|
||||
bool _programIsDirty;
|
||||
|
||||
std::string _instrumentName;
|
||||
std::string _source;
|
||||
std::string _target;
|
||||
std::string _referenceFrame;
|
||||
|
||||
psc _positions[2];
|
||||
|
||||
bool _drawLine;
|
||||
float _imageSequenceTime;
|
||||
|
||||
GLuint _vao;
|
||||
GLuint _vbo;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __RENDERABLECRAWLINGLINE_H__
|
||||
@@ -133,6 +133,9 @@ public:
|
||||
* returns true if instrumentID is within a capture range.
|
||||
*/
|
||||
bool instumentActive(std::string instrumentID);
|
||||
|
||||
float instrumentActiveTime(const std::string& instrumentID) const;
|
||||
|
||||
/*
|
||||
* returns latest captured image
|
||||
*/
|
||||
|
||||
Submodule openspace-data updated: acddeaf905...643df333af
47
shaders/modules/crawlingline/crawlingline_fs.glsl
Normal file
47
shaders/modules/crawlingline/crawlingline_fs.glsl
Normal file
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform vec4 campos;
|
||||
uniform vec4 objpos;
|
||||
|
||||
uniform float _alpha;
|
||||
|
||||
in vec4 vs_position;
|
||||
|
||||
#include "ABuffer/abufferStruct.hglsl"
|
||||
#include "ABuffer/abufferAddToBuffer.hglsl"
|
||||
#include "PowerScaling/powerScaling_fs.hglsl"
|
||||
|
||||
void main() {
|
||||
vec4 position = vs_position;
|
||||
float depth = pscDepth(position);
|
||||
// vec4 diffuse = texture(texture1, vs_st);
|
||||
vec4 diffuse = vec4(1.0);
|
||||
diffuse.a = _alpha;
|
||||
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
|
||||
addToBuffer(frag);
|
||||
|
||||
}
|
||||
44
shaders/modules/crawlingline/crawlingline_vs.glsl
Normal file
44
shaders/modules/crawlingline/crawlingline_vs.glsl
Normal file
@@ -0,0 +1,44 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#version __CONTEXT__
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
|
||||
out vec4 vs_position;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main() {
|
||||
vs_position = in_position;
|
||||
vec4 tmp = in_position;
|
||||
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
vs_position = tmp;
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
164
src/rendering/renderablecrawlingline.cpp
Normal file
164
src/rendering/renderablecrawlingline.cpp
Normal file
@@ -0,0 +1,164 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/renderablecrawlingline.h>
|
||||
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/imagesequencer2.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderableCrawlingLine";
|
||||
|
||||
const std::string KeySource = "Source";
|
||||
const std::string KeyTarget = "Target";
|
||||
const std::string KeyInstrument = "Instrument";
|
||||
const std::string KeyReferenceFrame = "Frame";
|
||||
|
||||
static const int SourcePosition = 0;
|
||||
static const int TargetPosition = 1;
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _program(nullptr)
|
||||
, _programIsDirty(false)
|
||||
, _imageSequenceTime(-1.f)
|
||||
, _vao(0)
|
||||
, _vbo(0)
|
||||
{
|
||||
dictionary.getValue(KeySource, _source);
|
||||
dictionary.getValue(KeyTarget, _target);
|
||||
dictionary.getValue(KeyInstrument, _instrumentName);
|
||||
dictionary.getValue(KeyReferenceFrame, _referenceFrame);
|
||||
}
|
||||
|
||||
bool RenderableCrawlingLine::isReady() const {
|
||||
bool ready = true;
|
||||
ready &= !_source.empty();
|
||||
ready &= !_target.empty();
|
||||
ready &= !_instrumentName.empty();
|
||||
ready &= (_program != nullptr);
|
||||
return ready;
|
||||
}
|
||||
|
||||
bool RenderableCrawlingLine::initialize() {
|
||||
bool completeSuccess = true;
|
||||
_program = ghoul::opengl::ProgramObject::Build("RenderableCrawlingLine",
|
||||
"${SHADERS}/modules/crawlingline/crawlingline_vs.glsl",
|
||||
"${SHADERS}/modules/crawlingline/crawlingline_fs.glsl"
|
||||
);
|
||||
if (!_program)
|
||||
return false;
|
||||
_program->setProgramObjectCallback([&](ghoul::opengl::ProgramObject*){ _programIsDirty = true; });
|
||||
|
||||
glGenVertexArrays(1, &_vao);
|
||||
glGenBuffers(1, &_vbo);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(psc), NULL, GL_DYNAMIC_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, (void*)0);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
|
||||
bool RenderableCrawlingLine::deinitialize(){
|
||||
glDeleteVertexArrays(1, &_vao);
|
||||
_vao = 0;
|
||||
glDeleteBuffers(1, &_vbo);
|
||||
_vbo = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderableCrawlingLine::render(const RenderData& data) {
|
||||
if (_drawLine) {
|
||||
_program->activate();
|
||||
|
||||
// fetch data
|
||||
psc currentPosition = data.position;
|
||||
psc campos = data.camera.position();
|
||||
glm::mat4 camrot = data.camera.viewRotationMatrix();
|
||||
|
||||
glm::mat4 transform = glm::mat4(1);
|
||||
|
||||
// setup the data to the shader
|
||||
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_program->setUniform("ModelTransform", transform);
|
||||
|
||||
static const float CutoffValue = 0.15f;
|
||||
float alpha;
|
||||
if (_imageSequenceTime < 0.5f)
|
||||
alpha = std::min(_imageSequenceTime / CutoffValue, 1.f);
|
||||
else
|
||||
alpha = std::min((1.f - _imageSequenceTime) / CutoffValue, 1.f);
|
||||
|
||||
_program->setUniform("_alpha", alpha);
|
||||
setPscUniforms(_program, &data.camera, data.position);
|
||||
|
||||
glBindVertexArray(_vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions);
|
||||
//glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(psc), _positions, GL_DYNAMIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
glDrawArrays(GL_LINES, 0, 2);
|
||||
glBindVertexArray(0);
|
||||
|
||||
_program->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableCrawlingLine::update(const UpdateData& data) {
|
||||
double t;
|
||||
//_positions[SourcePosition][0] = 0.f;
|
||||
//_positions[SourcePosition][1] = 0.f;
|
||||
//_positions[SourcePosition][2] = 0.f;
|
||||
//_positions[SourcePosition][3] = 0.f;
|
||||
//
|
||||
//_positions[TargetPosition][0] = 0.f;
|
||||
//_positions[TargetPosition][1] = 0.f;
|
||||
//_positions[TargetPosition][2] = 0.f;
|
||||
//_positions[TargetPosition][3] = 0.f;
|
||||
SpiceManager::ref().getTargetPosition(_source, "SUN", _referenceFrame, "NONE", data.time, _positions[SourcePosition], t);
|
||||
_positions[SourcePosition][3] += 3;
|
||||
SpiceManager::ref().getTargetPosition(_target, "SUN", _referenceFrame, "NONE", data.time, _positions[TargetPosition], t);
|
||||
_positions[TargetPosition][3] += 3;
|
||||
|
||||
if (ImageSequencer2::ref().isReady()) {
|
||||
_imageSequenceTime = ImageSequencer2::ref().instrumentActiveTime(_instrumentName);
|
||||
_drawLine = _imageSequenceTime != -1.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <openspace/rendering/renderablesphere.h>
|
||||
#include <openspace/rendering/renderablesphericalgrid.h>
|
||||
#include <openspace/rendering/renderablefieldlines.h>
|
||||
#include <openspace/rendering/renderablecrawlingline.h>
|
||||
#include <openspace/rendering/planets/renderableplanet.h>
|
||||
#include <openspace/rendering/planets/simplespheregeometry.h>
|
||||
#include <openspace/rendering/renderableplane.h>
|
||||
@@ -101,8 +102,10 @@ void FactoryManager::initialize()
|
||||
"RenderableVolumeGL");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableFieldlines>(
|
||||
"RenderableFieldlines");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableCrawlingLine>(
|
||||
"RenderableCrawlingLine");
|
||||
|
||||
// Add Ephimerides
|
||||
// Add Ephemerides
|
||||
_manager->addFactory(new ghoul::TemplateFactory<Ephemeris>);
|
||||
_manager->factory<Ephemeris>()->registerClass<StaticEphemeris>("Static");
|
||||
_manager->factory<Ephemeris>()->registerClass<StaticEphemeris>("Dynamic");
|
||||
|
||||
@@ -204,6 +204,24 @@ bool ImageSequencer2::instumentActive(std::string instrumentID){
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float ImageSequencer2::instrumentActiveTime(const std::string& instrumentID) const {
|
||||
for (auto i : _instrumentTimes){
|
||||
//check if this instrument is in range
|
||||
if (i.second.inRange(_currentTime)){
|
||||
//if so, then get the corresponding spiceID
|
||||
std::vector<std::string> spiceIDs = _fileTranslation.at(i.first)->getTranslation();
|
||||
//check which specific subinstrument is firing
|
||||
for (auto s : spiceIDs){
|
||||
if (s == instrumentID) {
|
||||
return static_cast<float>((_currentTime - i.second._min) / (i.second._max - i.second._min));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1.f;
|
||||
}
|
||||
|
||||
bool ImageSequencer2::getImagePaths(std::vector<Image>& captures,
|
||||
std::string projectee,
|
||||
std::string instrumentID){
|
||||
|
||||
Reference in New Issue
Block a user