mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-03 18:19:38 -06:00
Merge remote-tracking branch 'origin/feature/iSWA' into release/ips
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" ?>
|
||||
<Cluster masterAddress="localhost">
|
||||
<!-- <Scene>
|
||||
<Orientation yaw="0.0" pitch="-27.0" roll="0.0" />
|
||||
<Offset x="0.0" y="0.0" z="0.0" />
|
||||
<Scale value="1.0" />
|
||||
</Scene> -->
|
||||
<Node address="localhost" port="20401">
|
||||
<Window fullScreen="false" numberOfSamples="8" name="OpenSpace">
|
||||
<Stereo type="none" />
|
||||
@@ -20,7 +25,7 @@
|
||||
<Viewport name="fisheye">
|
||||
<Pos x="0.0" y="0.0" />
|
||||
<Size x="1.0" y="1.0" />
|
||||
<FisheyeProjection fov="180" quality="1k" tilt="27.0">
|
||||
<FisheyeProjection fov="180" quality="1k" tilt="27.0">
|
||||
<Background r="0.1" g="0.1" b="0.1" a="1.0" />
|
||||
</FisheyeProjection>
|
||||
</Viewport>
|
||||
|
||||
Submodule ext/ghoul updated: 9bb5ce6bf4...53fe2859c3
@@ -51,6 +51,7 @@ public:
|
||||
bool isRegularRendering() const override;
|
||||
|
||||
glm::mat4 viewProjectionMatrix() const override;
|
||||
glm::mat4 modelMatrix() const override;
|
||||
void setNearFarClippingPlane(float near, float far) override;
|
||||
|
||||
glm::ivec4 viewportPixelCoordinates() const override;
|
||||
|
||||
@@ -131,6 +131,13 @@ public:
|
||||
* \return The currently employed view-projection matrix
|
||||
*/
|
||||
virtual glm::mat4 viewProjectionMatrix() const;
|
||||
|
||||
/**
|
||||
* Returns the currently employed model matrix. On default, this method will return
|
||||
* the identity matrix.
|
||||
* \return The currently employed model matrix
|
||||
*/
|
||||
virtual glm::mat4 modelMatrix() const;
|
||||
|
||||
/**
|
||||
* Sets the near and far clipping planes of the rendering window. This method defaults
|
||||
|
||||
@@ -24,38 +24,33 @@
|
||||
|
||||
#ifndef __SCREENSPACERENDERABLE_H__
|
||||
#define __SCREENSPACERENDERABLE_H__
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <openspace/util/camera.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#endif
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/properties/scalarproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
/**
|
||||
* @brief The base class for screen scape images and screen space framebuffers
|
||||
* @details This base class handles general functionality specific to planes that
|
||||
* are rendered infront of the camera. It implements protected methods and properties for converting
|
||||
* the planes from spherical to euclidean coordinates and back. It also specifies the interface
|
||||
* that it's children needs to implement.
|
||||
* The base class for screen space images and screen space framebuffers.
|
||||
* This base class handles general functionality specific to planes that are rendered in
|
||||
* front of the camera. It implements protected methods and properties for converting
|
||||
* the planes from Spherical to Euclidean coordinates and back. It also specifies the
|
||||
* interface that its children need to implement.
|
||||
*/
|
||||
class ScreenSpaceRenderable : public properties::PropertyOwner {
|
||||
public:
|
||||
static ScreenSpaceRenderable* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
static ScreenSpaceRenderable* createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary);
|
||||
|
||||
ScreenSpaceRenderable(const ghoul::Dictionary& dictionary);
|
||||
~ScreenSpaceRenderable();
|
||||
virtual ~ScreenSpaceRenderable();
|
||||
|
||||
virtual void render() = 0;
|
||||
virtual bool initialize() = 0;
|
||||
@@ -64,31 +59,30 @@ public:
|
||||
virtual bool isReady() const = 0;
|
||||
bool isEnabled() const;
|
||||
|
||||
glm::vec2 euclideanPosition() const {return _euclideanPosition.value();};
|
||||
glm::vec2 sphericalPosition() const {return _sphericalPosition.value();};
|
||||
float depth() const {return _depth.value();};
|
||||
glm::vec3 euclideanPosition() const;
|
||||
glm::vec3 sphericalPosition() const;
|
||||
float depth() const;
|
||||
|
||||
protected:
|
||||
void createPlane();
|
||||
void useEuclideanCoordinates(bool b);
|
||||
|
||||
/**
|
||||
* @brief Converts vec2 polar coordinates to euclidean
|
||||
*
|
||||
* @param polar the coordinates theta and phi
|
||||
* @param radius the radius position value of the plane
|
||||
*
|
||||
* @return glm::vec2 with the x and y position value of the plane
|
||||
* Converts Spherical coordinates to Euclidean.
|
||||
* \param spherical The coordinates theta and phi
|
||||
* \param radius The radius position value of the plane
|
||||
* \return The x and y position value of the plane
|
||||
*/
|
||||
glm::vec2 toEuclidean(glm::vec2 polar, float radius);
|
||||
glm::vec2 toEuclidean(const glm::vec2& spherical, float radius);
|
||||
|
||||
/**
|
||||
* @brief Converts vec2 euclidean coordinates to sperical
|
||||
*
|
||||
* @param euclidean the coordinates x and y
|
||||
* @return glm::vec2 with the spherical coordinates theta and phi.
|
||||
* Converts Euclidean coordinates to Spherical.
|
||||
* \param euclidean The coordinates x and y
|
||||
* \return The spherical coordinates theta and phi.
|
||||
*/
|
||||
glm::vec2 toSpherical(glm::vec2 euclidean);
|
||||
glm::vec2 toSpherical(const glm::vec2& euclidean);
|
||||
|
||||
|
||||
void registerProperties();
|
||||
void unregisterProperties();
|
||||
|
||||
@@ -109,18 +103,15 @@ protected:
|
||||
|
||||
GLuint _quad;
|
||||
GLuint _vertexPositionBuffer;
|
||||
const std::string _rendererPath;
|
||||
ghoul::Dictionary _rendererData;
|
||||
const std::string _vertexPath;
|
||||
const std::string _fragmentPath;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _texture;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
|
||||
|
||||
bool _useEuclideanCoordinates;
|
||||
const float _planeDepth = -2.0;
|
||||
glm::vec2 _originalViewportSize;
|
||||
|
||||
float _radius;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
#endif // __SCREENSPACERENDERABLE_H__
|
||||
|
||||
#endif // __SCREENSPACERENDERABLE_H__
|
||||
|
||||
@@ -89,8 +89,8 @@ set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_ge.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/star_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screnspace_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screnspace_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screenspace_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/screenspace_vs.glsl
|
||||
)
|
||||
source_group("Shader Files" FILES ${SHADER_FILES})
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <openspace/rendering/renderer.h>
|
||||
#include <openspace/rendering/abufferrenderer.h>
|
||||
#include <openspace/rendering/framebufferrenderer.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
|
||||
namespace openspace {
|
||||
ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictionary)
|
||||
|
||||
@@ -1,74 +1,80 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/base/rendering/screenspaceimage.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ScreenSpaceImage";
|
||||
|
||||
const std::string KeyName = "Name";
|
||||
const std::string KeyTexturePath = "TexturePath";
|
||||
const std::string KeyUrl = "URL";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ScreenSpaceImage::ScreenSpaceImage(const ghoul::Dictionary& dictionary)
|
||||
:ScreenSpaceRenderable(dictionary)
|
||||
,_texturePath("texturePath", "Texture path", "")
|
||||
,_downloadImage(false)
|
||||
: ScreenSpaceRenderable(dictionary)
|
||||
, _texturePath("texturePath", "Texture path", "")
|
||||
, _downloadImage(false)
|
||||
{
|
||||
std::string name;
|
||||
if(dictionary.getValue("Name", name)){
|
||||
if (dictionary.getValue(KeyName, name)) {
|
||||
setName(name);
|
||||
}else{
|
||||
_id = id();
|
||||
setName("ScreenSpaceImage" + std::to_string(_id));
|
||||
} else {
|
||||
static int id = 0;
|
||||
setName("ScreenSpaceImage " + std::to_string(id));
|
||||
++id;
|
||||
}
|
||||
|
||||
addProperty(_texturePath);
|
||||
registerProperties();
|
||||
|
||||
std::string texturePath;
|
||||
bool texturesucces = (dictionary.getValue("TexturePath", texturePath));
|
||||
if(texturesucces){
|
||||
_texturePath.set(texturePath);
|
||||
if (dictionary.getValue(KeyTexturePath, texturePath)) {
|
||||
_texturePath = texturePath;
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_texturePath);
|
||||
_texturePath.onChange([this](){ loadTexture(); });
|
||||
}
|
||||
|
||||
bool urlsucces = dictionary.getValue("URL", _url);
|
||||
if(urlsucces){
|
||||
_downloadImage =true;
|
||||
if (dictionary.getValue(KeyUrl, _url)) {
|
||||
_downloadImage = true;
|
||||
}
|
||||
|
||||
//screenspaceCygnet does not have url or texturePath
|
||||
// if(!texturesucces && !urlsucces){
|
||||
// LERROR("Must specify TexturePath or URL");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
ScreenSpaceImage::~ScreenSpaceImage(){}
|
||||
ScreenSpaceImage::~ScreenSpaceImage() {}
|
||||
|
||||
bool ScreenSpaceImage::initialize(){
|
||||
bool ScreenSpaceImage::initialize() {
|
||||
_originalViewportSize = OsEng.windowWrapper().currentWindowResolution();
|
||||
|
||||
createPlane();
|
||||
@@ -78,7 +84,7 @@ bool ScreenSpaceImage::initialize(){
|
||||
return isReady();
|
||||
}
|
||||
|
||||
bool ScreenSpaceImage::deinitialize(){
|
||||
bool ScreenSpaceImage::deinitialize() {
|
||||
unregisterProperties();
|
||||
|
||||
glDeleteVertexArrays(1, &_quad);
|
||||
@@ -90,47 +96,32 @@ bool ScreenSpaceImage::deinitialize(){
|
||||
_texturePath = "";
|
||||
_texture = nullptr;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
if (_shader) {
|
||||
renderEngine.removeRenderProgram(_shader);
|
||||
OsEng.renderEngine().removeRenderProgram(_shader);
|
||||
_shader = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScreenSpaceImage::render(){
|
||||
if(!isReady()) return;
|
||||
if(!_enabled) return;
|
||||
|
||||
glm::mat4 rotation = rotationMatrix();
|
||||
glm::mat4 translation = translationMatrix();
|
||||
glm::mat4 scale = scaleMatrix();
|
||||
glm::mat4 modelTransform = rotation*translation*scale;
|
||||
|
||||
draw(modelTransform);
|
||||
void ScreenSpaceImage::render() {
|
||||
draw(rotationMatrix() * translationMatrix() * scaleMatrix());
|
||||
}
|
||||
|
||||
|
||||
void ScreenSpaceImage::update(){
|
||||
if(_downloadImage && _futureImage.valid() && DownloadManager::futureReady(_futureImage)){
|
||||
void ScreenSpaceImage::update() {
|
||||
bool futureReady = DownloadManager::futureReady(_futureImage);
|
||||
if (_downloadImage && _futureImage.valid() && futureReady) {
|
||||
loadTexture();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ScreenSpaceImage::isReady() const{
|
||||
bool ready = true;
|
||||
if (!_shader)
|
||||
ready &= false;
|
||||
if(!_texture)
|
||||
ready &= false;
|
||||
return ready;
|
||||
bool ScreenSpaceImage::isReady() const {
|
||||
return _shader && _texture;
|
||||
}
|
||||
|
||||
void ScreenSpaceImage::loadTexture() {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = nullptr;
|
||||
if(!_downloadImage)
|
||||
if (!_downloadImage)
|
||||
texture = std::move(loadFromDisk());
|
||||
else
|
||||
texture = std::move(loadFromMemory());
|
||||
@@ -146,56 +137,54 @@ void ScreenSpaceImage::loadTexture() {
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSpaceImage::updateTexture(){
|
||||
if(!_downloadImage){
|
||||
void ScreenSpaceImage::updateTexture() {
|
||||
if (!_downloadImage) {
|
||||
loadTexture();
|
||||
} else {
|
||||
if(_futureImage.valid())
|
||||
if (_futureImage.valid())
|
||||
return;
|
||||
|
||||
std::future<DownloadManager::MemoryFile> future = downloadImageToMemory(_url);
|
||||
if(future.valid()){
|
||||
if (future.valid()) {
|
||||
_futureImage = std::move(future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> ScreenSpaceImage::loadFromDisk(){
|
||||
std::unique_ptr<ghoul::opengl::Texture> ScreenSpaceImage::loadFromDisk() {
|
||||
if (_texturePath.value() != "")
|
||||
return (ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath.value())));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<ghoul::opengl::Texture> ScreenSpaceImage::loadFromMemory(){
|
||||
|
||||
if(_futureImage.valid() && DownloadManager::futureReady(_futureImage) ){
|
||||
std::unique_ptr<ghoul::opengl::Texture> ScreenSpaceImage::loadFromMemory() {
|
||||
if (_futureImage.valid() && DownloadManager::futureReady(_futureImage)) {
|
||||
DownloadManager::MemoryFile imageFile = _futureImage.get();
|
||||
|
||||
if(imageFile.corrupted)
|
||||
if (imageFile.corrupted)
|
||||
return nullptr;
|
||||
|
||||
return (ghoul::io::TextureReader::ref().loadTexture(
|
||||
(void*) imageFile.buffer,
|
||||
reinterpret_cast<void*>(imageFile.buffer),
|
||||
imageFile.size,
|
||||
imageFile.format));
|
||||
imageFile.format)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::future<DownloadManager::MemoryFile> ScreenSpaceImage::downloadImageToMemory(std::string url){
|
||||
return std::move( DlManager.fetchFile(
|
||||
url,
|
||||
[url](const DownloadManager::MemoryFile& file){
|
||||
LDEBUG("Download to memory finished for screen space image");
|
||||
},
|
||||
[url](const std::string& err){
|
||||
LDEBUG("Download to memory failer for screen space image: " +err);
|
||||
}
|
||||
) );
|
||||
std::future<DownloadManager::MemoryFile> ScreenSpaceImage::downloadImageToMemory(
|
||||
std::string url)
|
||||
{
|
||||
return std::move(DlManager.fetchFile(
|
||||
url,
|
||||
[url](const DownloadManager::MemoryFile& file) {
|
||||
LDEBUG("Download to memory finished for screen space image");
|
||||
},
|
||||
[url](const std::string& err) {
|
||||
LDEBUG("Download to memory failer for screen space image: " +err);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
int ScreenSpaceImage::id(){
|
||||
static int id = 0;
|
||||
return id++;
|
||||
}
|
||||
}
|
||||
} // namespace openspace
|
||||
|
||||
@@ -21,55 +21,46 @@
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __SCREENSPACEIMAGE_H__
|
||||
#define __SCREENSPACEIMAGE_H__
|
||||
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
namespace openspace {
|
||||
/**
|
||||
* @brief Creates a textured plane rendered in screenspace
|
||||
* @details The plane gets the same ratio as the texture. Implements
|
||||
* the interface that ScreenSpaceImage speciefies.
|
||||
*
|
||||
* @param texturePath Path to the image that should be used as texture
|
||||
*/
|
||||
class ScreenSpaceImage : public ScreenSpaceRenderable {
|
||||
|
||||
class ScreenSpaceImage : public ScreenSpaceRenderable {
|
||||
public:
|
||||
ScreenSpaceImage(std::string texturePath);
|
||||
ScreenSpaceImage(const ghoul::Dictionary& dictionary);
|
||||
~ScreenSpaceImage();
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
void render() override;
|
||||
virtual void update() override;
|
||||
void update() override;
|
||||
bool isReady() const override;
|
||||
|
||||
protected:
|
||||
void loadTexture();
|
||||
void updateTexture();
|
||||
|
||||
std::string _url;
|
||||
bool _downloadImage;
|
||||
std::future<DownloadManager::MemoryFile> _futureImage;
|
||||
|
||||
void loadTexture();
|
||||
void updateTexture();
|
||||
private:
|
||||
|
||||
static int id();
|
||||
std::future<DownloadManager::MemoryFile> downloadImageToMemory(std::string url);
|
||||
std::unique_ptr<ghoul::opengl::Texture> loadFromDisk();
|
||||
std::unique_ptr<ghoul::opengl::Texture> loadFromMemory();
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
//std::string _memorybuffer;
|
||||
|
||||
|
||||
int _id;
|
||||
};
|
||||
|
||||
} //namespace openspace
|
||||
#endif //__SCREENSPACEIMAGE_H__
|
||||
|
||||
#endif //__SCREENSPACEIMAGE_H__
|
||||
|
||||
@@ -39,7 +39,7 @@ Fragment getFragment(){
|
||||
|
||||
// power scale coordinates for depth. w value is set to 1.0.
|
||||
float depth = (1.0 + log(abs(OcclusionDepth) + 1/pow(k, 1.0))/log(k)) / 27.0;
|
||||
frag.color = texture(texture1, vec2(vs_st.s, 1-vs_st.t));
|
||||
frag.color = texture(texture1, vec2(vs_st.s, vs_st.t));
|
||||
frag.color.a = (frag.color.a != 0.0f) ? Alpha : frag.color.a;
|
||||
if(frag.color.a == 0.0f){
|
||||
discard;
|
||||
@@ -65,10 +65,10 @@ set(SOURCE_FILES
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
set(SHADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/cygnetplane_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/cygnetplane_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/dataplane_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/dataplane_vs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/textureplane_fs.glsl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shaders/textureplane_vs.glsl
|
||||
)
|
||||
|
||||
source_group("Shader Files" FILES ${SHADER_FILES})
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
set (OPENSPACE_DEPENDENCIES
|
||||
base
|
||||
base kameleon
|
||||
)
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
#include <modules/iswa/util/dataprocessortext.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DataPlane";
|
||||
}
|
||||
|
||||
@@ -26,6 +26,13 @@
|
||||
#include <openspace/util/powerscaledsphere.h>
|
||||
#include <modules/iswa/util/dataprocessorjson.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DataSphere";
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <modules/iswa/rendering/datasphere.h>
|
||||
#include <modules/iswa/rendering/kameleonplane.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "IswaBaseGroup";
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/transformationmanager.h>
|
||||
#include <modules/iswa/rendering/iswabasegroup.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <modules/iswa/rendering/datasphere.h>
|
||||
#include <modules/iswa/rendering/kameleonplane.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "IswaDataGroup";
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <modules/iswa/rendering/dataplane.h>
|
||||
#include <modules/iswa/rendering/datasphere.h>
|
||||
#include <modules/iswa/rendering/kameleonplane.h>
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "IswaDataGroup";
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
namespace {
|
||||
using json = nlohmann::json;
|
||||
const std::string _loggerCat = "KameleonPlane";
|
||||
@@ -222,8 +224,8 @@ std::vector<float*> KameleonPlane::textureData() {
|
||||
bool KameleonPlane::updateTextureResource(){
|
||||
|
||||
_data->offset[_cut] = _data->gridMin[_cut]+_slice.value()*_scale;
|
||||
_textureDirty = true;
|
||||
|
||||
// _textureDirty = true;
|
||||
updateTexture();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
#include <openspace/util/time.h>
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ScreenSpaceCygnet";
|
||||
|
||||
@@ -48,6 +48,7 @@ DataProcessor::DataProcessor()
|
||||
,_useHistogram(false)
|
||||
,_normValues(glm::vec2(1.0))
|
||||
,_filterValues(glm::vec2(0.0))
|
||||
,_histNormValues(glm::vec2(10.f, 10.f))
|
||||
{
|
||||
_coordinateVariables = {"x", "y", "z", "phi", "theta"};
|
||||
}
|
||||
@@ -90,20 +91,21 @@ float DataProcessor::processDataPoint(float value, int option){
|
||||
float mean = (1.0 / _numValues[option]) * _sum[option];
|
||||
float sd = _standardDeviation[option];
|
||||
|
||||
float v;
|
||||
if(_useHistogram){
|
||||
sd = histogram->equalize(sd);
|
||||
mean = histogram->equalize(mean);
|
||||
value = histogram->equalize(value);
|
||||
v = histogram->equalize(normalizeWithStandardScore(value, mean, sd, _histNormValues))/(float)512;
|
||||
}else{
|
||||
v = normalizeWithStandardScore(value, mean, sd, _normValues);
|
||||
}
|
||||
|
||||
float v = normalizeWithStandardScore(value, mean, sd);
|
||||
// float v = normalizeWithStandardScore(value, mean, sd, _normValues);
|
||||
return v;
|
||||
}
|
||||
|
||||
float DataProcessor::normalizeWithStandardScore(float value, float mean, float sd){
|
||||
float DataProcessor::normalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues){
|
||||
|
||||
float zScoreMin = _normValues.x;
|
||||
float zScoreMax = _normValues.y;
|
||||
float zScoreMin = normalizationValues.x; //10.0f;//_normValues.x;
|
||||
float zScoreMax = normalizationValues.y; //10.0f;//_normValues.y;
|
||||
float standardScore = ( value - mean ) / sd;
|
||||
// Clamp intresting values
|
||||
standardScore = glm::clamp(standardScore, -zScoreMin, zScoreMax);
|
||||
@@ -111,6 +113,22 @@ float DataProcessor::normalizeWithStandardScore(float value, float mean, float s
|
||||
return ( standardScore + zScoreMin )/(zScoreMin + zScoreMax );
|
||||
}
|
||||
|
||||
float DataProcessor::unnormalizeWithStandardScore(float standardScore, float mean, float sd, glm::vec2 normalizationValues){
|
||||
float zScoreMin = normalizationValues.x;
|
||||
float zScoreMax = normalizationValues.y;
|
||||
|
||||
float value = standardScore*(zScoreMax+zScoreMin)-zScoreMin;
|
||||
value = value*sd+mean;
|
||||
|
||||
// std::cout << value << std::endl;
|
||||
return value;
|
||||
// float standardScore = ( value - mean ) / sd;
|
||||
// // Clamp intresting values
|
||||
// standardScore = glm::clamp(standardScore, -zScoreMin, zScoreMax);
|
||||
// //return and normalize
|
||||
// return ( standardScore + zScoreMin )/(zScoreMin + zScoreMax );
|
||||
}
|
||||
|
||||
void DataProcessor::initializeVectors(int numOptions){
|
||||
if(_min.empty()) _min = std::vector<float>(numOptions, std::numeric_limits<float>::max());
|
||||
if(_max.empty()) _max = std::vector<float>(numOptions, std::numeric_limits<float>::min());
|
||||
@@ -130,22 +148,24 @@ void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions){
|
||||
|
||||
if(!_histograms.empty()){
|
||||
for(int option : selectedOptions){
|
||||
histogram = _histograms[option];
|
||||
mean = (1.0/_numValues[option])*_sum[option];
|
||||
standardDeviation = _standardDeviation[option];
|
||||
|
||||
filterMid = histogram->highestBinValue(_useHistogram);
|
||||
filterWidth = mean+histogram->binWidth();
|
||||
|
||||
if(_useHistogram){
|
||||
standardDeviation = histogram->equalize(standardDeviation);
|
||||
mean = histogram->equalize(mean);
|
||||
filterWidth = mean+1;
|
||||
if(!_useHistogram){
|
||||
mean = (1.0/_numValues[option])*_sum[option];
|
||||
standardDeviation = _standardDeviation[option];
|
||||
histogram = _histograms[option];
|
||||
|
||||
filterMid = histogram->highestBinValue(_useHistogram);
|
||||
filterWidth = mean+histogram->binWidth();
|
||||
|
||||
filterMid = normalizeWithStandardScore(filterMid, mean, standardDeviation, _normValues);
|
||||
filterWidth = fabs(0.5-normalizeWithStandardScore(filterWidth, mean, standardDeviation, _normValues));
|
||||
}else{
|
||||
Histogram hist = _histograms[option]->equalize();
|
||||
filterMid = hist.highestBinValue(true);
|
||||
std::cout << filterMid << std::endl;
|
||||
filterWidth = 1.f/512.f;
|
||||
}
|
||||
|
||||
filterMid = normalizeWithStandardScore(filterMid, mean, standardDeviation);
|
||||
filterWidth = fabs(0.5-normalizeWithStandardScore(filterWidth, mean, standardDeviation));
|
||||
_filterValues += glm::vec2(filterMid, filterWidth);
|
||||
_filterValues += glm::vec2(filterMid, filterWidth);
|
||||
|
||||
}
|
||||
_filterValues /= numSelected;
|
||||
@@ -158,12 +178,6 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues, std::vect
|
||||
float mean, value, variance, standardDeviation;
|
||||
|
||||
for(int i=0; i<numOptions; i++){
|
||||
if(!_histograms[i]){
|
||||
_histograms[i] = std::make_shared<Histogram>(_min[i], _max[i], 512);
|
||||
}
|
||||
else{
|
||||
_histograms[i]->changeRange(_min[i], _max[i]);
|
||||
}
|
||||
|
||||
std::vector<float> values = optionValues[i];
|
||||
numValues = values.size();
|
||||
@@ -174,17 +188,64 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues, std::vect
|
||||
for(int j=0; j<numValues; j++){
|
||||
value = values[j];
|
||||
variance += pow(value-mean, 2);
|
||||
_histograms[i]->add(value, 1);
|
||||
}
|
||||
|
||||
standardDeviation = sqrt(variance/ numValues);
|
||||
|
||||
float oldStandardDeviation = _standardDeviation[i];
|
||||
float oldMean = (1.0f/_numValues[i])*_sum[i];
|
||||
|
||||
_sum[i] += sum[i];
|
||||
_standardDeviation[i] = sqrt(pow(standardDeviation, 2) + pow(_standardDeviation[i], 2));
|
||||
_numValues[i] += numValues;
|
||||
|
||||
|
||||
mean = (1.0f/_numValues[i])*_sum[i];
|
||||
float min = normalizeWithStandardScore(_min[i], mean, _standardDeviation[i], _histNormValues);
|
||||
float max = normalizeWithStandardScore(_max[i], mean, _standardDeviation[i], _histNormValues);
|
||||
|
||||
if(!_histograms[i]){
|
||||
_histograms[i] = std::make_shared<Histogram>(min, max, 512);
|
||||
}
|
||||
else{
|
||||
|
||||
const float* histData = _histograms[i]->data();
|
||||
float histMin = _histograms[i]->minValue();
|
||||
float histMax = _histograms[i]->maxValue();
|
||||
int numBins = _histograms[i]->numBins();
|
||||
|
||||
float unNormHistMin = unnormalizeWithStandardScore(histMin, oldMean, oldStandardDeviation, _histNormValues);
|
||||
float unNormHistMax = unnormalizeWithStandardScore(histMax, oldMean, oldStandardDeviation, _histNormValues);
|
||||
//unnormalize histMin, histMax
|
||||
// min = std::min(min, histMin)
|
||||
std::shared_ptr<Histogram> newHist = std::make_shared<Histogram>(
|
||||
std::min(min, normalizeWithStandardScore(unNormHistMin, mean, _standardDeviation[i], _histNormValues)),
|
||||
std::min(max, normalizeWithStandardScore(unNormHistMax, mean, _standardDeviation[i], _histNormValues)),
|
||||
numBins
|
||||
);
|
||||
|
||||
for(int j=0; j<numBins; j++){
|
||||
value = j*(histMax-histMin)+histMin;
|
||||
value = unnormalizeWithStandardScore(value, oldMean, oldStandardDeviation, _histNormValues);
|
||||
_histograms[i]->add(normalizeWithStandardScore(value, mean, _standardDeviation[i], _histNormValues), histData[j]);
|
||||
}
|
||||
// _histograms[i]->changeRange(min, max);
|
||||
_histograms[i] = newHist;
|
||||
}
|
||||
|
||||
for(int j=0; j<numValues; j++){
|
||||
value = values[j];
|
||||
_histograms[i]->add(normalizeWithStandardScore(value, mean, _standardDeviation[i], _histNormValues), 1);
|
||||
}
|
||||
|
||||
_histograms[i]->generateEqualizer();
|
||||
// _histograms[i]->print();
|
||||
|
||||
std::cout << std::endl;
|
||||
_histograms[i]->print();
|
||||
std::cout << std::endl;
|
||||
std::cout << "Eq: ";
|
||||
Histogram hist = _histograms[i]->equalize();
|
||||
hist.print();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ public:
|
||||
void clear();
|
||||
protected:
|
||||
float processDataPoint(float value, int option);
|
||||
float normalizeWithStandardScore(float value, float mean, float sd);
|
||||
float normalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
float unnormalizeWithStandardScore(float value, float mean, float sd, glm::vec2 normalizationValues = glm::vec2(1.0f, 1.0f));
|
||||
|
||||
void initializeVectors(int numOptions);
|
||||
void calculateFilterValues(std::vector<int> selectedOptions);
|
||||
@@ -72,6 +73,8 @@ protected:
|
||||
std::vector<float> _numValues;
|
||||
std::vector<std::shared_ptr<Histogram>> _histograms;
|
||||
std::set<std::string> _coordinateVariables;
|
||||
|
||||
glm::vec2 _histNormValues;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
#include <modules/iswa/util/dataprocessortext.h>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <boost/iostreams/device/mapped_file.hpp>
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
//#include <boost/iostreams/device/mapped_file.hpp>
|
||||
//
|
||||
//#include <boost/config/warning_disable.hpp>
|
||||
//#include <boost/spirit/include/qi.hpp>
|
||||
//#include <boost/spirit/include/phoenix_core.hpp>
|
||||
//#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
//#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DataProcessorText";
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
namespace {
|
||||
using json = nlohmann::json;
|
||||
const std::string _loggerCat = "IswaManager";
|
||||
std::string baseUrl = "https://iswa-demo-server.herokuapp.com/";
|
||||
//const std::string baseUrl = "http://128.183.168.116:3000/";
|
||||
}
|
||||
|
||||
namespace openspace{
|
||||
@@ -145,8 +147,7 @@ void IswaManager::addIswaCygnet(int id, std::string type, std::string group){
|
||||
|
||||
// Download metadata
|
||||
DlManager.fetchFile(
|
||||
"http://128.183.168.116:3000/" + std::to_string(-id),
|
||||
// "http://localhost:3000/" + std::to_string(-id),
|
||||
baseUrl + std::to_string(-id),
|
||||
metadataCallback,
|
||||
[id](const std::string& err){
|
||||
LDEBUG("Download to memory was aborted for data cygnet with id "+ std::to_string(id)+": " + err);
|
||||
@@ -195,8 +196,7 @@ std::future<DownloadManager::MemoryFile> IswaManager::fetchDataCygnet(int id, do
|
||||
std::string IswaManager::iswaUrl(int id, double timestamp, std::string type){
|
||||
std::string url;
|
||||
if(id < 0){
|
||||
url = "http://128.183.168.116:3000/"+type+"/" + std::to_string(-id) + "/";
|
||||
// url = "http://localhost:3000/"+type+"/" + std::to_string(-id) + "/";
|
||||
url = baseUrl+type+"/" + std::to_string(-id) + "/";
|
||||
} else{
|
||||
url = "http://iswa3.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?window=-1&cygnetId="+ std::to_string(id) +"×tamp=";
|
||||
}
|
||||
@@ -262,8 +262,7 @@ std::shared_ptr<MetadataFuture> IswaManager::downloadMetadata(int id){
|
||||
|
||||
metaFuture->id = id;
|
||||
DlManager.fetchFile(
|
||||
"http://128.183.168.116:3000/" + std::to_string(-id),
|
||||
// "http://localhost:3000/" + std::to_string(-id),
|
||||
baseUrl + std::to_string(-id),
|
||||
[&metaFuture](const DownloadManager::MemoryFile& file){
|
||||
metaFuture->json = std::string(file.buffer, file.size);
|
||||
metaFuture->isFinished = true;
|
||||
@@ -648,6 +647,11 @@ void IswaManager::addCdfFiles(std::string path){
|
||||
}
|
||||
}
|
||||
|
||||
void IswaManager::setBaseUrl(std::string bUrl){
|
||||
LDEBUG("Swapped baseurl to: " + bUrl);
|
||||
baseUrl = bUrl;
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary IswaManager::luaLibrary() {
|
||||
return {
|
||||
"iswa",
|
||||
@@ -707,6 +711,13 @@ scripting::ScriptEngine::LuaLibrary IswaManager::luaLibrary() {
|
||||
"int",
|
||||
"Remove a group of Cygnets",
|
||||
true
|
||||
},
|
||||
{
|
||||
"setBaseUrl",
|
||||
&luascriptfunctions::iswa_setBaseUrl,
|
||||
"string",
|
||||
"sets the base url",
|
||||
true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,6 +106,7 @@ public:
|
||||
}
|
||||
|
||||
void addCdfFiles(std::string path);
|
||||
void setBaseUrl(std::string bUrl);
|
||||
private:
|
||||
std::shared_ptr<MetadataFuture> downloadMetadata(int id);
|
||||
std::string jsonPlaneToLuaTable(std::shared_ptr<MetadataFuture> data);
|
||||
|
||||
@@ -164,6 +164,12 @@ int iswa_addKameleonPlanes(lua_State* L){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iswa_setBaseUrl(lua_State* L){
|
||||
std::string url = luaL_checkstring(L, 1);
|
||||
IswaManager::ref().setBaseUrl(url);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}// namespace luascriptfunctions
|
||||
|
||||
}// namespace openspace
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <modules/newhorizons/rendering/renderablemodelprojection.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <modules/base/rendering/planetgeometry.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
@@ -36,6 +37,11 @@
|
||||
#include <ghoul/opengl/textureconversion.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderablePlanetProjection";
|
||||
|
||||
|
||||
@@ -16,3 +16,9 @@ openspace.bindKey("e", helper.renderable.toggle('EarthMarker'))
|
||||
openspace.bindKey("x", helper.renderable.toggle('Constellation Bounds'))
|
||||
|
||||
openspace.bindKey("c", "openspace.parallel.setAddress('130.236.142.51');openspace.parallel.setPassword('newhorizons-20150714');openspace.parallel.connect();")
|
||||
|
||||
openspace.bindKey("h", "openspace.iswa.setBaseUrl('https://iswa-demo-server.herokuapp.com/')");
|
||||
openspace.bindKey("g", "openspace.iswa.setBaseUrl('http://128.183.168.116:3000/')");
|
||||
openspace.bindKey("l", "openspace.iswa.setBaseUrl('http://localhost:3000/')");
|
||||
|
||||
openspace.bindKey("v", "openspace.time.setTime('2015-03-15T02:00:00.00')");
|
||||
@@ -115,6 +115,10 @@ bool SGCTWindowWrapper::isRegularRendering() const {
|
||||
glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const {
|
||||
return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix();
|
||||
}
|
||||
|
||||
glm::mat4 SGCTWindowWrapper::modelMatrix() const {
|
||||
return sgct::Engine::instance()->getModelMatrix();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) {
|
||||
sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane);
|
||||
|
||||
@@ -75,6 +75,10 @@ bool WindowWrapper::isRegularRendering() const {
|
||||
glm::mat4 WindowWrapper::viewProjectionMatrix() const {
|
||||
return glm::mat4(1.f);
|
||||
}
|
||||
|
||||
glm::mat4 WindowWrapper::modelMatrix() const {
|
||||
return glm::mat4(1.f);
|
||||
}
|
||||
|
||||
void WindowWrapper::setNearFarClippingPlane(float near, float far) {}
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ void RenderEngine::render(const glm::mat4 &projectionMatrix, const glm::mat4 &vi
|
||||
}
|
||||
|
||||
for (auto screenSpaceRenderable : _screenSpaceRenderables) {
|
||||
if(screenSpaceRenderable->isEnabled())
|
||||
if (screenSpaceRenderable->isEnabled() && screenSpaceRenderable->isReady())
|
||||
screenSpaceRenderable->render();
|
||||
}
|
||||
}
|
||||
@@ -1476,11 +1476,14 @@ void RenderEngine::renderScreenLog() {
|
||||
}
|
||||
}
|
||||
|
||||
void RenderEngine::sortScreenspaceRenderables(){
|
||||
std::sort(_screenSpaceRenderables.begin(), _screenSpaceRenderables.end(),
|
||||
[](std::shared_ptr<ScreenSpaceRenderable> j, std::shared_ptr<ScreenSpaceRenderable> i){
|
||||
return i->depth() > j->depth();
|
||||
});
|
||||
void RenderEngine::sortScreenspaceRenderables() {
|
||||
std::sort(
|
||||
_screenSpaceRenderables.begin(),
|
||||
_screenSpaceRenderables.end(),
|
||||
[](auto j, auto i) {
|
||||
return i->depth() > j->depth();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
|
||||
@@ -21,20 +21,40 @@
|
||||
* 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/engine/openspaceengine.h>
|
||||
|
||||
#include <openspace/rendering/screenspacerenderable.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/wrapper/windowwrapper.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <sgct.h>
|
||||
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ScreenSpaceRenderable";
|
||||
|
||||
const std::string KeyType = "Type";
|
||||
const std::string KeyFlatScreen = "FlatScreen";
|
||||
const std::string KeyPosition = "Position";
|
||||
const std::string KeyScale = "Scale";
|
||||
const std::string KeyDepth = "Depth";
|
||||
const std::string KeyAlpha = "Alpha";
|
||||
|
||||
const float PlaneDepth = -2.f;
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
ScreenSpaceRenderable* ScreenSpaceRenderable::createFromDictionary(const ghoul::Dictionary& dictionary) {
|
||||
|
||||
ScreenSpaceRenderable* ScreenSpaceRenderable::createFromDictionary(
|
||||
const ghoul::Dictionary& dictionary)
|
||||
{
|
||||
std::string renderableType;
|
||||
bool success = dictionary.getValue(KeyType, renderableType);
|
||||
|
||||
@@ -43,11 +63,12 @@ ScreenSpaceRenderable* ScreenSpaceRenderable::createFromDictionary(const ghoul::
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ghoul::TemplateFactory<ScreenSpaceRenderable>* factory
|
||||
= FactoryManager::ref().factory<ScreenSpaceRenderable>();
|
||||
auto factory = FactoryManager::ref().factory<ScreenSpaceRenderable>();
|
||||
ScreenSpaceRenderable* result = factory->create(renderableType, dictionary);
|
||||
if (result == nullptr) {
|
||||
LERROR("Failed to create a ScreenSpaceRenderable object of type '" << renderableType << "'");
|
||||
LERROR("Failed to create a ScreenSpaceRenderable object of type '" <<
|
||||
renderableType << "'"
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -56,150 +77,167 @@ ScreenSpaceRenderable* ScreenSpaceRenderable::createFromDictionary(const ghoul::
|
||||
|
||||
|
||||
ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary)
|
||||
:_enabled("enabled", "Is Enabled", true)
|
||||
,_useFlatScreen("flatScreen", "Flat Screen", true)
|
||||
,_euclideanPosition("euclideanPosition", "Euclidean coordinates", glm::vec2(0),glm::vec2(-4),glm::vec2(4))
|
||||
,_sphericalPosition("sphericalPosition", "Spherical coordinates", glm::vec2(0, M_PI_2),glm::vec2(-M_PI),glm::vec2(M_PI))
|
||||
,_depth("depth", "Depth", 0, 0, 1)
|
||||
,_scale("scale", "Scale" , 0.25, 0, 2)
|
||||
,_alpha("alpha", "Alpha" , 1, 0, 1)
|
||||
,_delete("delete", "Delete")
|
||||
,_quad(0)
|
||||
,_vertexPositionBuffer(0)
|
||||
,_rendererPath("${SHADERS}/framebuffer/renderframebuffer.frag")
|
||||
,_vertexPath("${MODULE_BASE}/shaders/screnspace_vs.glsl")
|
||||
,_fragmentPath("${MODULE_BASE}/shaders/screnspace_fs.glsl")
|
||||
,_texture(nullptr)
|
||||
,_shader(nullptr)
|
||||
: _enabled("enabled", "Is Enabled", true)
|
||||
, _useFlatScreen("flatScreen", "Flat Screen", true)
|
||||
, _euclideanPosition(
|
||||
"euclideanPosition",
|
||||
"Euclidean coordinates",
|
||||
glm::vec2(0.f),
|
||||
glm::vec2(-4.f),
|
||||
glm::vec2(4.f)
|
||||
)
|
||||
, _sphericalPosition(
|
||||
"sphericalPosition",
|
||||
"Spherical coordinates",
|
||||
glm::vec2(0.f, M_PI_2),
|
||||
glm::vec2(-M_PI),
|
||||
glm::vec2(M_PI)
|
||||
)
|
||||
, _depth("depth", "Depth", 0.f, 0.f, 1.f)
|
||||
, _scale("scale", "Scale", 0.25f, 0.f, 2.f)
|
||||
, _alpha("alpha", "Alpha", 1.f, 0.f, 1.f)
|
||||
, _delete("delete", "Delete")
|
||||
, _quad(0)
|
||||
, _vertexPositionBuffer(0)
|
||||
, _texture(nullptr)
|
||||
, _shader(nullptr)
|
||||
, _radius(PlaneDepth)
|
||||
{
|
||||
addProperty(_enabled);
|
||||
addProperty(_useFlatScreen);
|
||||
addProperty(_euclideanPosition);
|
||||
addProperty(_sphericalPosition);
|
||||
addProperty(_depth);
|
||||
addProperty(_scale);
|
||||
addProperty(_alpha);
|
||||
addProperty(_delete);
|
||||
|
||||
_rendererData = ghoul::Dictionary();
|
||||
_rendererData.setValue("fragmentRendererPath", _rendererPath);
|
||||
_rendererData.setValue("windowWidth", OsEng.windowWrapper().currentWindowResolution().x);
|
||||
_rendererData.setValue("windowHeight", OsEng.windowWrapper().currentWindowResolution().y);
|
||||
|
||||
_radius = _planeDepth;
|
||||
|
||||
|
||||
if(dictionary.hasValue<bool>("FlatScreen")){
|
||||
bool useFlatScreen;
|
||||
dictionary.getValue("FlatScreen", useFlatScreen);
|
||||
|
||||
_useFlatScreen.setValue(useFlatScreen);
|
||||
}
|
||||
|
||||
useEuclideanCoordinates(_useFlatScreen.value());
|
||||
dictionary.getValue(KeyFlatScreen, _useFlatScreen);
|
||||
useEuclideanCoordinates(_useFlatScreen);
|
||||
|
||||
if(dictionary.hasValue<glm::vec2>("Position")){
|
||||
glm::vec2 pos;
|
||||
dictionary.getValue("Position", pos);
|
||||
if(_useFlatScreen)
|
||||
_euclideanPosition.setValue(pos);
|
||||
else
|
||||
_sphericalPosition.setValue(pos);
|
||||
}
|
||||
if (_useFlatScreen)
|
||||
dictionary.getValue(KeyPosition, _euclideanPosition);
|
||||
else
|
||||
dictionary.getValue(KeyPosition, _sphericalPosition);
|
||||
|
||||
if(dictionary.hasValue<float>("Scale")){
|
||||
float scale;
|
||||
dictionary.getValue("Scale", scale);
|
||||
_scale.setValue(scale);
|
||||
}
|
||||
|
||||
if(dictionary.hasValue<float>("Depth")){
|
||||
float depth;
|
||||
dictionary.getValue("Depth", depth);
|
||||
_depth.setValue(depth);
|
||||
}
|
||||
|
||||
if(dictionary.hasValue<float>("Alpha")){
|
||||
float alpha;
|
||||
dictionary.getValue("Scale", alpha);
|
||||
_alpha.setValue(alpha);
|
||||
}
|
||||
|
||||
dictionary.getValue(KeyScale, _scale);
|
||||
dictionary.getValue(KeyDepth, _depth);
|
||||
dictionary.getValue(KeyAlpha, _alpha);
|
||||
|
||||
// Setting spherical/euclidean onchange handler
|
||||
_useFlatScreen.onChange([this](){
|
||||
if(_useFlatScreen.value()){
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_euclideanPosition, &_useFlatScreen);
|
||||
if (_useFlatScreen) {
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(
|
||||
&_euclideanPosition,
|
||||
&_useFlatScreen
|
||||
);
|
||||
addProperty(_euclideanPosition);
|
||||
|
||||
OsEng.gui()._screenSpaceProperty.unregisterProperty(&_sphericalPosition);
|
||||
removeProperty(_sphericalPosition);
|
||||
} else {
|
||||
OsEng.gui()._screenSpaceProperty.unregisterProperty(&_euclideanPosition);
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_sphericalPosition, &_useFlatScreen);
|
||||
removeProperty(_euclideanPosition);
|
||||
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(
|
||||
&_sphericalPosition,
|
||||
&_useFlatScreen
|
||||
);
|
||||
addProperty(_sphericalPosition);
|
||||
}
|
||||
useEuclideanCoordinates(_useFlatScreen.value());
|
||||
useEuclideanCoordinates(_useFlatScreen);
|
||||
});
|
||||
|
||||
_delete.onChange([this](){
|
||||
std::string script = "openspace.unregisterScreenSpaceRenderable('" + name() + "');";
|
||||
std::string script =
|
||||
"openspace.unregisterScreenSpaceRenderable('" + name() + "');";
|
||||
OsEng.scriptEngine().queueScript(script);
|
||||
});
|
||||
}
|
||||
|
||||
ScreenSpaceRenderable::~ScreenSpaceRenderable(){}
|
||||
ScreenSpaceRenderable::~ScreenSpaceRenderable() {}
|
||||
|
||||
bool ScreenSpaceRenderable::isEnabled() const {
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
glm::vec3 ScreenSpaceRenderable::euclideanPosition() const {
|
||||
return glm::vec3(_euclideanPosition.value(), _depth.value());
|
||||
}
|
||||
|
||||
glm::vec3 ScreenSpaceRenderable::sphericalPosition() const {
|
||||
return glm::vec3(_sphericalPosition.value(), _depth.value());
|
||||
}
|
||||
|
||||
float ScreenSpaceRenderable::depth() const {
|
||||
return _depth;
|
||||
}
|
||||
|
||||
void ScreenSpaceRenderable::createPlane() {
|
||||
glGenVertexArrays(1, &_quad); // generate array
|
||||
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
|
||||
glGenVertexArrays(1, &_quad);
|
||||
glGenBuffers(1, &_vertexPositionBuffer);
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
const GLfloat vertex_data[] = {
|
||||
// x y z w s t
|
||||
-1, -1, 0.0f, 1, 0, 1,
|
||||
1, 1, 0.0f, 1, 1, 0,
|
||||
-1, 1, 0.0f, 1, 0, 0,
|
||||
-1, -1, 0.0f, 1, 0, 1,
|
||||
1, -1, 0.0f, 1, 1, 1,
|
||||
1, 1, 0.0f, 1, 1, 0,
|
||||
-1, -1, 0.0f, 1, 0, 0,
|
||||
1, 1, 0.0f, 1, 1, 1,
|
||||
-1, 1, 0.0f, 1, 0, 1,
|
||||
-1, -1, 0.0f, 1, 0, 0,
|
||||
1, -1, 0.0f, 1, 1, 0,
|
||||
1, 1, 0.0f, 1, 1, 1,
|
||||
};
|
||||
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); // bind buffer
|
||||
glBindVertexArray(_quad);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(0));
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
4,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<void*>(0)
|
||||
);
|
||||
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
glVertexAttribPointer(
|
||||
1,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<void*>(sizeof(GLfloat) * 4)
|
||||
);
|
||||
}
|
||||
|
||||
void ScreenSpaceRenderable::useEuclideanCoordinates(bool b){
|
||||
void ScreenSpaceRenderable::useEuclideanCoordinates(bool b) {
|
||||
_useEuclideanCoordinates = b;
|
||||
if(_useEuclideanCoordinates){
|
||||
_euclideanPosition.set(toEuclidean(_sphericalPosition.value(), _radius));
|
||||
if (_useEuclideanCoordinates) {
|
||||
_euclideanPosition = toEuclidean(_sphericalPosition.value(), _radius);
|
||||
} else {
|
||||
_sphericalPosition.set(toSpherical(_euclideanPosition.value()));
|
||||
_sphericalPosition = toSpherical(_euclideanPosition.value());
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec2 ScreenSpaceRenderable::toEuclidean(glm::vec2 polar, float r){
|
||||
float x = r*sin(polar[0])*sin(polar[1]);
|
||||
float y = r*cos(polar[1]);
|
||||
glm::vec2 ScreenSpaceRenderable::toEuclidean(const glm::vec2& spherical, float r) {
|
||||
float x = r * sin(spherical[0]) * sin(spherical[1]);
|
||||
float y = r * cos(spherical[1]);
|
||||
|
||||
return glm::vec2(x, y);
|
||||
}
|
||||
|
||||
glm::vec2 ScreenSpaceRenderable::toSpherical(glm::vec2 euclidean){
|
||||
_radius = -sqrt(pow(euclidean[0],2)+pow(euclidean[1],2)+pow(_planeDepth,2));
|
||||
float theta = atan2(-_planeDepth,euclidean[0])-M_PI/2.0;
|
||||
glm::vec2 ScreenSpaceRenderable::toSpherical(const glm::vec2& euclidean) {
|
||||
_radius = -sqrt(pow(euclidean[0],2)+pow(euclidean[1],2)+pow(PlaneDepth,2));
|
||||
float theta = atan2(-PlaneDepth,euclidean[0])-M_PI/2.0;
|
||||
float phi = acos(euclidean[1]/_radius);
|
||||
|
||||
return glm::vec2(theta, phi);
|
||||
}
|
||||
|
||||
void ScreenSpaceRenderable::registerProperties(){
|
||||
void ScreenSpaceRenderable::registerProperties() {
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_enabled);
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_useFlatScreen);
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_euclideanPosition);
|
||||
@@ -209,80 +247,98 @@ void ScreenSpaceRenderable::registerProperties(){
|
||||
OsEng.gui()._screenSpaceProperty.registerProperty(&_delete);
|
||||
}
|
||||
|
||||
void ScreenSpaceRenderable::unregisterProperties(){
|
||||
void ScreenSpaceRenderable::unregisterProperties() {
|
||||
OsEng.gui()._screenSpaceProperty.unregisterProperties(name());
|
||||
}
|
||||
|
||||
void ScreenSpaceRenderable::createShaders(){
|
||||
if(!_shader) {
|
||||
|
||||
void ScreenSpaceRenderable::createShaders() {
|
||||
if (!_shader) {
|
||||
ghoul::Dictionary dict = ghoul::Dictionary();
|
||||
|
||||
dict.setValue("rendererData", _rendererData);
|
||||
dict.setValue("fragmentPath", _fragmentPath);
|
||||
_shader = ghoul::opengl::ProgramObject::Build("ScreenSpaceProgram",
|
||||
_vertexPath,
|
||||
auto res = OsEng.windowWrapper().currentWindowResolution();
|
||||
ghoul::Dictionary rendererData = {
|
||||
{ "fragmentRendererPath", "${SHADERS}/framebuffer/renderframebuffer.frag" },
|
||||
{ "windowWidth" , res.x },
|
||||
{ "windowHeight" , res.y }
|
||||
};
|
||||
|
||||
dict.setValue("rendererData", rendererData);
|
||||
dict.setValue("fragmentPath", "${MODULE_BASE}/shaders/screenspace_fs.glsl");
|
||||
_shader = ghoul::opengl::ProgramObject::Build(
|
||||
"ScreenSpaceProgram",
|
||||
"${MODULE_BASE}/shaders/screenspace_vs.glsl",
|
||||
"${SHADERS}/render.frag",
|
||||
dict
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
glm::mat4 ScreenSpaceRenderable::scaleMatrix(){
|
||||
glm::mat4 scale(1.0);
|
||||
|
||||
glm::mat4 ScreenSpaceRenderable::scaleMatrix() {
|
||||
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
|
||||
|
||||
//to scale the plane
|
||||
float textureRatio = (float(_texture->height())/float(_texture->width()));
|
||||
float scalingRatioX = _originalViewportSize[0]/ resolution[0];
|
||||
float scalingRatioY = _originalViewportSize[1]/ resolution[1];
|
||||
scale = glm::scale(scale, glm::vec3(_scale.value() * scalingRatioX,
|
||||
_scale.value() * scalingRatioY * textureRatio,
|
||||
1));
|
||||
return scale;
|
||||
float textureRatio =
|
||||
static_cast<float>(_texture->height()) / static_cast<float>(_texture->width());
|
||||
|
||||
float scalingRatioX = _originalViewportSize.x / resolution.x;
|
||||
float scalingRatioY = _originalViewportSize.y / resolution.y;
|
||||
return glm::scale(
|
||||
glm::mat4(1.f),
|
||||
glm::vec3(
|
||||
_scale * scalingRatioX,
|
||||
_scale * scalingRatioY * textureRatio,
|
||||
1.f
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
glm::mat4 ScreenSpaceRenderable::rotationMatrix(){
|
||||
glm::mat4 ScreenSpaceRenderable::rotationMatrix() {
|
||||
// Get the scene transform
|
||||
glm::mat4 rotation = sgct::Engine::instance()->getModelMatrix();
|
||||
if(!_useEuclideanCoordinates){
|
||||
glm::mat4 rotation = OsEng.windowWrapper().modelMatrix();
|
||||
if (!_useEuclideanCoordinates) {
|
||||
glm::vec2 position = _sphericalPosition.value();
|
||||
|
||||
float theta = position.x;
|
||||
float phi = position.y - M_PI/2.0;
|
||||
float phi = position.y - M_PI_2;
|
||||
|
||||
rotation = glm::rotate(rotation, position.x, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
rotation = glm::rotate(rotation, (float) (position.y - M_PI/2.0) , glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
rotation = glm::rotate(rotation, position.x, glm::vec3(0.f, 1.f, 0.f));
|
||||
rotation = glm::rotate(
|
||||
rotation,
|
||||
static_cast<float>(position.y - M_PI_2),
|
||||
glm::vec3(1.f, 0.f, 0.f)
|
||||
);
|
||||
}
|
||||
|
||||
return rotation;
|
||||
}
|
||||
|
||||
|
||||
glm::mat4 ScreenSpaceRenderable::translationMatrix(){
|
||||
glm::mat4 ScreenSpaceRenderable::translationMatrix() {
|
||||
glm::mat4 translation(1.0);
|
||||
if(!_useEuclideanCoordinates){
|
||||
translation = glm::translate(translation, glm::vec3(0.0f, 0.0f, _planeDepth));
|
||||
}else{
|
||||
translation = glm::translate(glm::mat4(1.f), glm::vec3(_euclideanPosition.value(), _planeDepth));
|
||||
if (!_useEuclideanCoordinates) {
|
||||
translation = glm::translate(translation, glm::vec3(0.0f, 0.0f, PlaneDepth));
|
||||
} else {
|
||||
translation = glm::translate(
|
||||
glm::mat4(1.f),
|
||||
glm::vec3(_euclideanPosition.value(), PlaneDepth)
|
||||
);
|
||||
}
|
||||
|
||||
return translation;
|
||||
}
|
||||
|
||||
|
||||
void ScreenSpaceRenderable::draw(glm::mat4 modelTransform){
|
||||
float occlusionDepth = 1-_depth.value();
|
||||
|
||||
void ScreenSpaceRenderable::draw(glm::mat4 modelTransform) {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
_shader->activate();
|
||||
_shader->setUniform("OcclusionDepth", occlusionDepth);
|
||||
_shader->setUniform("OcclusionDepth", 1.f - _depth);
|
||||
_shader->setUniform("Alpha", _alpha);
|
||||
_shader->setUniform("ModelTransform",modelTransform);
|
||||
_shader->setUniform("ViewProjectionMatrix", OsEng.renderEngine().camera()->viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", modelTransform);
|
||||
_shader->setUniform(
|
||||
"ViewProjectionMatrix",
|
||||
OsEng.renderEngine().camera()->viewProjectionMatrix()
|
||||
);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
@@ -290,8 +346,10 @@ void ScreenSpaceRenderable::draw(glm::mat4 modelTransform){
|
||||
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
_shader->deactivate();
|
||||
}
|
||||
}// namespace openspace
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -296,14 +296,16 @@ float Histogram::entropy(){
|
||||
}
|
||||
|
||||
void Histogram::print() const {
|
||||
std::cout << "number of bins: " << _numBins << std::endl
|
||||
<< "range: " << _minValue << " - " << _maxValue << std::endl << std::endl;
|
||||
// std::cout << "number of bins: " << _numBins << std::endl
|
||||
// << "range: " << _minValue << " - " << _maxValue << std::endl << std::endl;
|
||||
for (int i = 0; i < _numBins; i++) {
|
||||
float low = _minValue + float(i) / _numBins * (_maxValue - _minValue);
|
||||
float high = low + (_maxValue - _minValue) / float(_numBins);
|
||||
std::cout << i << " [" << low << ", " << high << "]"
|
||||
<< " " << _data[i] << std::endl;
|
||||
// std::cout << i << " [" << low << ", " << high << "]"
|
||||
// << " " << _data[i] << std::endl;
|
||||
std::cout << _data[i]/(float)_numValues << ", ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
// std::cout << std::endl << std::endl << std::endl<< "==============" << std::endl;
|
||||
}
|
||||
|
||||
@@ -332,18 +334,16 @@ float Histogram::highestBinValue(bool equalized, int overBins){
|
||||
highestBin = i;
|
||||
highestValue = value;
|
||||
}
|
||||
|
||||
// if(_data[i] > _data[highestBin])
|
||||
// highestBin = i;
|
||||
}
|
||||
|
||||
float low = _minValue + float(highestBin) / _numBins * (_maxValue - _minValue);
|
||||
float high = low + (_maxValue - _minValue) / float(_numBins);
|
||||
|
||||
if(!equalized){
|
||||
float low = _minValue + float(highestBin) / _numBins * (_maxValue - _minValue);
|
||||
float high = low + (_maxValue - _minValue) / float(_numBins);
|
||||
return (high+low)/2.0;
|
||||
}else{
|
||||
return equalize((high+low)/2.0);
|
||||
return highestBin/(float)_numBins;
|
||||
// return equalize((high+low)/2.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
std::string to,
|
||||
double ephemerisTime) const
|
||||
{
|
||||
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
|
||||
ccmc::Position in0 = {1.f, 0.f, 0.f};
|
||||
ccmc::Position in1 = {0.f, 1.f, 0.f};
|
||||
ccmc::Position in2 = {0.f, 0.f, 1.f};
|
||||
@@ -70,7 +71,10 @@
|
||||
out0.c0 , out0.c1 , out0.c2,
|
||||
out1.c0 , out1.c1 , out1.c2,
|
||||
out2.c0 , out2.c1 , out2.c2
|
||||
);;
|
||||
);
|
||||
#else
|
||||
return glm::dmat3(0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
glm::dmat3 TransformationManager::frameTransformationMatrix(std::string from,
|
||||
|
||||
Reference in New Issue
Block a user