mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Merge branch 'solarsystem2' of openspace.itn.liu.se:/openspace into solarsystem2
This commit is contained in:
Submodule ext/ghoul updated: cec683e244...1f1386215e
@@ -91,8 +91,9 @@ public:
|
||||
* more <code>.</code>, the first part of the name will be recursively extracted and
|
||||
* used as a name for a sub-owner and only the last part of the identifier is
|
||||
* referring to a Property owned by PropertyOwner named by the second-but-last name.
|
||||
* \param URI The identifier of the Property that should be extracted. If the Property
|
||||
* cannot be found, <code>nullptr</code> is returned
|
||||
* \param URI The identifier of the Property that should be extracted
|
||||
* \return If the Property cannot be found, <code>nullptr</code> is returned,
|
||||
* otherwise the pointer to the Property is returned
|
||||
*/
|
||||
Property* property(const std::string& URI) const;
|
||||
|
||||
|
||||
70
include/openspace/rendering/renderableplane.h
Normal file
70
include/openspace/rendering/renderableplane.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef RENDERABLEPLANE_H_
|
||||
#define RENDERABLEPLANE_H_
|
||||
|
||||
// open space includes
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
// ghoul includes
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
|
||||
namespace openspace {
|
||||
struct LinePoint;
|
||||
|
||||
class RenderablePlane : public Renderable {
|
||||
|
||||
enum class Origin {
|
||||
LowerLeft, LowerRight, UpperLeft, UpperRight, Center
|
||||
};
|
||||
|
||||
public:
|
||||
RenderablePlane(const ghoul::Dictionary& dictionary);
|
||||
~RenderablePlane();
|
||||
|
||||
bool initialize();
|
||||
bool deinitialize();
|
||||
|
||||
void render(const RenderData& data) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
void loadTexture();
|
||||
|
||||
properties::StringProperty _texturePath;
|
||||
|
||||
glm::vec2 _size;
|
||||
Origin _origin;
|
||||
|
||||
ghoul::opengl::ProgramObject* _shader;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
GLuint _quad;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
#endif // RENDERABLEFIELDLINES_H_
|
||||
@@ -34,8 +34,6 @@ namespace openspace {
|
||||
class SpiceEphemeris : public Ephemeris {
|
||||
public:
|
||||
SpiceEphemeris(const ghoul::Dictionary& dictionary);
|
||||
~SpiceEphemeris();
|
||||
bool initialize();
|
||||
const psc& position() const;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
@@ -43,6 +41,7 @@ private:
|
||||
std::string _targetName;
|
||||
std::string _originName;
|
||||
psc _position;
|
||||
bool _kernelsLoadedSuccessfully;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace configurationmanager {
|
||||
|
||||
namespace scenegraph {
|
||||
const std::string keyPathScene = "ScenePath";
|
||||
const std::string keyCommonFolder = "CommonFolder";
|
||||
const std::string keyModules = "Modules";
|
||||
const std::string keyCamera = "Camera";
|
||||
const std::string keyFocusObject = "Focus";
|
||||
|
||||
@@ -73,8 +73,7 @@ public:
|
||||
* \param filePath The path to the kernel that should be loaded
|
||||
* \return The loaded kernel's unique identifier that can be used to unload the kernel
|
||||
*/
|
||||
KernelIdentifier loadKernel(std::string filePath);
|
||||
KernelIdentifier loadKernelExplicit(std::string filePath);
|
||||
KernelIdentifier loadKernel(const std::string& filePath);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,4 +5,4 @@ openspace.time.setTime("2007-02-26T17:00:00")
|
||||
--openspace.time.setDeltaTime(200000.0)
|
||||
openspace.time.setDeltaTime(2000.0)
|
||||
--openspace.time.setDeltaTime(30000.0)
|
||||
print(openspace.time.currentTimeUTC())
|
||||
-- print(openspace.time.currentTimeUTC())
|
||||
|
||||
57
shaders/plane_fs.glsl
Normal file
57
shaders/plane_fs.glsl
Normal file
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 430
|
||||
|
||||
uniform float time;
|
||||
uniform sampler2D texture1;
|
||||
|
||||
in vec2 vs_st;
|
||||
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;
|
||||
if(gl_FrontFacing)
|
||||
diffuse = texture(texture1, vs_st);
|
||||
else
|
||||
diffuse = texture(texture1, vec2(1-vs_st.s,vs_st.t));
|
||||
|
||||
//vec4 diffuse = vec4(1,vs_st,1);
|
||||
//vec4 diffuse = vec4(1,0,0,1);
|
||||
// if(position.w > 9.0) {
|
||||
// diffuse = vec4(1,0,0,1);
|
||||
// }
|
||||
|
||||
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
|
||||
addToBuffer(frag);
|
||||
|
||||
discard;
|
||||
}
|
||||
49
shaders/plane_vs.glsl
Normal file
49
shaders/plane_vs.glsl
Normal file
@@ -0,0 +1,49 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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 430
|
||||
|
||||
uniform mat4 ViewProjection;
|
||||
uniform mat4 ModelTransform;
|
||||
|
||||
layout(location = 0) in vec4 in_position;
|
||||
layout(location = 1) in vec2 in_st;
|
||||
|
||||
out vec2 vs_st;
|
||||
out vec4 vs_position;
|
||||
out float s;
|
||||
|
||||
#include "PowerScaling/powerScaling_vs.hglsl"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tmp = in_position;
|
||||
vec4 position = pscTransform(tmp, ModelTransform);
|
||||
|
||||
vs_position = tmp;
|
||||
vs_st = in_st;
|
||||
|
||||
position = ViewProjection * position;
|
||||
gl_Position = z_normalization(position);
|
||||
}
|
||||
@@ -242,13 +242,16 @@ bool OpenSpaceEngine::initialize()
|
||||
std::string timeKernel;
|
||||
bool success = OsEng.configurationManager().getValue(keySpiceTimeKernel, timeKernel);
|
||||
|
||||
std::cout << "timeKernel = " << timeKernel << std::endl;
|
||||
|
||||
if (!success) {
|
||||
LERROR("Configuration file does not contain a '" << keySpiceTimeKernel << "'");
|
||||
return false;
|
||||
}
|
||||
SpiceManager::ref().loadKernel(std::move(timeKernel));
|
||||
SpiceManager::KernelIdentifier id =
|
||||
SpiceManager::ref().loadKernel(timeKernel);
|
||||
if (id == SpiceManager::KernelFailed) {
|
||||
LERROR("Error loading time kernel '" << timeKernel << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
using constants::configurationmanager::keySpiceLeapsecondKernel;
|
||||
std::string leapSecondKernel;
|
||||
@@ -257,8 +260,11 @@ bool OpenSpaceEngine::initialize()
|
||||
LERROR("Configuration file does not contain a '" << keySpiceLeapsecondKernel << "'");
|
||||
return false;
|
||||
}
|
||||
std::cout << "leapSecondKernel : " << leapSecondKernel << std::endl;
|
||||
SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
|
||||
id = SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
|
||||
if (id == SpiceManager::KernelFailed) {
|
||||
LERROR("Error loading leap second kernel '" << leapSecondKernel << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/de413.bsp");
|
||||
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/jup260.bsp")
|
||||
|
||||
@@ -156,7 +156,7 @@ void InteractionHandler::orbit(const glm::quat &rotation) {
|
||||
|
||||
// should be changed to something more dynamic =)
|
||||
psc origin;
|
||||
if(node_) {
|
||||
if (node_) {
|
||||
origin = node_->worldPosition();
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ void InteractionHandler::orbit(const glm::quat &rotation) {
|
||||
//camera_->rotate(rotation);
|
||||
//camera_->setRotation(glm::mat4_cast(rotation));
|
||||
|
||||
glm::mat4 la = glm::lookAt(camera_->position().vec3(), node_->worldPosition().vec3(), glm::rotate(rotation, camera_->lookUpVector()));
|
||||
glm::mat4 la = glm::lookAt(camera_->position().vec3(), origin.vec3(), glm::rotate(rotation, camera_->lookUpVector()));
|
||||
camera_->setRotation(la);
|
||||
//camera_->setLookUpVector();
|
||||
|
||||
|
||||
16
src/main.cpp
16
src/main.cpp
@@ -113,18 +113,26 @@ int main(int argc, char** argv)
|
||||
|
||||
void mainInitFunc()
|
||||
{
|
||||
OsEng.initialize();
|
||||
OsEng.initializeGL();
|
||||
bool success = OsEng.initialize();
|
||||
if (success)
|
||||
success = OsEng.initializeGL();
|
||||
|
||||
if (!success) {
|
||||
LFATAL("Initializing OpenSpaceEngine failed");
|
||||
std::cout << "Press any key to continue...";
|
||||
std::cin.ignore(100);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void mainPreSyncFunc()
|
||||
{
|
||||
OsEng.preSynchronization();
|
||||
OsEng.preSynchronization();
|
||||
}
|
||||
|
||||
void mainPostSyncPreDrawFunc()
|
||||
{
|
||||
OsEng.postSynchronizationPreDraw();
|
||||
OsEng.postSynchronizationPreDraw();
|
||||
}
|
||||
|
||||
void mainRenderFunc()
|
||||
|
||||
@@ -77,8 +77,6 @@ Property* PropertyOwner::property(const std::string& id) const
|
||||
const size_t ownerSeparator = id.find(URISeparator);
|
||||
if (ownerSeparator == std::string::npos) {
|
||||
// if we do not own the property and there is no separator, it does not exist
|
||||
LERROR("The identifier '" << id << "' did not exist in PropertyOwner '" <<
|
||||
name() << "'");
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
@@ -87,8 +85,6 @@ Property* PropertyOwner::property(const std::string& id) const
|
||||
|
||||
PropertyOwner* owner = subOwner(ownerName);
|
||||
if (owner == nullptr) {
|
||||
LERROR("Sub PropertyOwner '" << owner
|
||||
<< "' did not exist for PropertyOwner '" << name() << "'");
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
|
||||
188
src/rendering/renderableplane.cpp
Normal file
188
src/rendering/renderableplane.cpp
Normal file
@@ -0,0 +1,188 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/rendering/renderableplane.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/util/constants.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
#include <ghoul/opengl/texturereader.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "RenderablePlane";
|
||||
|
||||
const std::string keyFieldlines = "Fieldlines";
|
||||
const std::string keyFilename = "File";
|
||||
const std::string keyHints = "Hints";
|
||||
const std::string keyShaders = "Shaders";
|
||||
const std::string keyVertexShader = "VertexShader";
|
||||
const std::string keyFragmentShader = "FragmentShader";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _texturePath("texture", "Texture")
|
||||
, _size(glm::vec2(1,1))
|
||||
, _origin(Origin::Center)
|
||||
, _shader(nullptr)
|
||||
, _texture(nullptr)
|
||||
, _quad(0)
|
||||
{
|
||||
|
||||
dictionary.getValue("Size", _size);
|
||||
|
||||
std::string origin;
|
||||
if (dictionary.getValue("Origin", origin)) {
|
||||
if (origin == "LowerLeft") {
|
||||
_origin = Origin::LowerLeft;
|
||||
}
|
||||
else if (origin == "LowerRight") {
|
||||
_origin = Origin::LowerRight;
|
||||
}
|
||||
else if (origin == "UpperLeft") {
|
||||
_origin = Origin::UpperLeft;
|
||||
}
|
||||
else if (origin == "UpperRight") {
|
||||
_origin = Origin::UpperRight;
|
||||
}
|
||||
else if (origin == "Center") {
|
||||
_origin = Origin::Center;
|
||||
}
|
||||
}
|
||||
|
||||
std::string texturePath = "";
|
||||
bool success = dictionary.getValue("Texture", texturePath);
|
||||
if (success)
|
||||
_texturePath = findPath(texturePath);
|
||||
|
||||
|
||||
addProperty(_texturePath);
|
||||
_texturePath.onChange(std::bind(&RenderablePlane::loadTexture, this));
|
||||
|
||||
setBoundingSphere(_size);
|
||||
}
|
||||
|
||||
RenderablePlane::~RenderablePlane() {
|
||||
}
|
||||
|
||||
bool RenderablePlane::initialize() {
|
||||
|
||||
// ============================
|
||||
// GEOMETRY (quad)
|
||||
// ============================
|
||||
const GLfloat size = _size[0];
|
||||
const GLfloat w = _size[1];
|
||||
LDEBUG("size:" << size);
|
||||
LDEBUG("w:" << w);
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
// x y z w s t
|
||||
-size, -size, 0.0f, w, 0,1,
|
||||
size, size, 0.0f, w, 1, 0,
|
||||
-size, size, 0.0f, w, 0, 0,
|
||||
-size, -size, 0.0f, w, 0, 1,
|
||||
size, -size, 0.0f, w, 1, 1,
|
||||
size, size, 0.0f, w, 1, 0,
|
||||
};
|
||||
|
||||
GLuint vertexPositionBuffer;
|
||||
glGenVertexArrays(1, &_quad); // generate array
|
||||
glBindVertexArray(_quad); // bind array
|
||||
glGenBuffers(1, &vertexPositionBuffer); // generate buffer
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertexPositionBuffer); // bind buffer
|
||||
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));
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 6, reinterpret_cast<void*>(sizeof(GLfloat) * 4));
|
||||
|
||||
OsEng.ref().configurationManager().getValue("PlaneProgram", _shader);
|
||||
assert(_shader);
|
||||
|
||||
loadTexture();
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderablePlane::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderablePlane::render(const RenderData& data) {
|
||||
|
||||
if (!_shader)
|
||||
return;
|
||||
if (!_texture)
|
||||
return;
|
||||
|
||||
glm::mat4 transform = glm::mat4(1.0);
|
||||
//transform = glm::scale(transform, glm::vec3(0.01));
|
||||
|
||||
// Activate shader
|
||||
_shader->activate();
|
||||
|
||||
_shader->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
|
||||
_shader->setUniform("ModelTransform", transform);
|
||||
setPscUniforms(_shader, &data.camera, data.position);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
unit.activate();
|
||||
_texture->bind();
|
||||
_shader->setUniform("texture1", unit);
|
||||
|
||||
glBindVertexArray(_quad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
_shader->deactivate();
|
||||
}
|
||||
|
||||
void RenderablePlane::update(const UpdateData& data) {
|
||||
}
|
||||
|
||||
void RenderablePlane::loadTexture()
|
||||
{
|
||||
LDEBUG("loadTexture");
|
||||
if (_texturePath.value() != "") {
|
||||
LDEBUG("loadTexture2");
|
||||
ghoul::opengl::Texture* texture = ghoul::opengl::loadTexture(absPath(_texturePath));
|
||||
if (texture) {
|
||||
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
|
||||
texture->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
|
||||
if (_texture)
|
||||
delete _texture;
|
||||
_texture = texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -55,6 +55,8 @@
|
||||
namespace {
|
||||
const std::string _loggerCat = "SceneGraph";
|
||||
const std::string _moduleExtension = ".mod";
|
||||
const std::string _defaultCommonDirectory = "common";
|
||||
const std::string _commonModuleToken = "${COMMON_MODULE}";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -223,6 +225,15 @@ bool SceneGraph::initialize()
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("GridProgram", tmpProgram);
|
||||
|
||||
// Plane program
|
||||
tmpProgram = ProgramObject::Build("Plane",
|
||||
"${SHADERS}/plane_vs.glsl",
|
||||
"${SHADERS}/plane_fs.glsl",
|
||||
cb);
|
||||
if (!tmpProgram) return false;
|
||||
_programs.push_back(tmpProgram);
|
||||
OsEng.ref().configurationManager().setValue("PlaneProgram", tmpProgram);
|
||||
|
||||
// Done building shaders
|
||||
double elapsed = std::chrono::duration_cast<second_>(clock_::now()-beginning).count();
|
||||
LINFO("Time to load shaders: " << elapsed);
|
||||
@@ -336,6 +347,10 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
|
||||
std::string moduleDirectory(".");
|
||||
dictionary.getValue(constants::scenegraph::keyPathScene, moduleDirectory);
|
||||
|
||||
std::string commonDirectory(_defaultCommonDirectory);
|
||||
dictionary.getValue(constants::scenegraph::keyCommonFolder, commonDirectory);
|
||||
FileSys.registerPathToken(_commonModuleToken, commonDirectory);
|
||||
|
||||
// The scene path could either be an absolute or relative path to the description
|
||||
// paths directory
|
||||
std::string&& relativeCandidate = sceneDescriptionDirectory +
|
||||
@@ -352,6 +367,9 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
LDEBUG("Loading common module folder '" << commonDirectory << "'");
|
||||
loadModule(FileSys.pathByAppendingComponent(moduleDirectory, commonDirectory));
|
||||
|
||||
Dictionary moduleDictionary;
|
||||
if (dictionary.getValue(constants::scenegraph::keyModules, moduleDictionary)) {
|
||||
std::vector<std::string> keys = moduleDictionary.keys();
|
||||
@@ -359,7 +377,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
|
||||
for (const std::string& key : keys) {
|
||||
std::string moduleFolder;
|
||||
if (moduleDictionary.getValue(key, moduleFolder))
|
||||
loadModule(moduleDirectory + "/" + moduleFolder);
|
||||
loadModule(FileSys.pathByAppendingComponent(moduleDirectory, moduleFolder));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +468,7 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
|
||||
|
||||
void SceneGraph::loadModule(const std::string& modulePath)
|
||||
{
|
||||
auto pos = modulePath.find_last_of("/");
|
||||
auto pos = modulePath.find_last_of(ghoul::filesystem::FileSystem::PathSeparator);
|
||||
if (pos == modulePath.npos) {
|
||||
LERROR("Bad format for module path: " << modulePath);
|
||||
return;
|
||||
|
||||
@@ -103,7 +103,8 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
|
||||
|
||||
std::string parentName;
|
||||
if (!dictionary.getValue(constants::scenegraphnode::keyParentName, parentName)) {
|
||||
LWARNING("Could not find 'Parent' key, using 'Root'.");
|
||||
LWARNING("Could not find '" << constants::scenegraphnode::keyParentName <<
|
||||
"' key, using 'Root'.");
|
||||
parentName = "Root";
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: _targetName("")
|
||||
, _originName("")
|
||||
, _position()
|
||||
, _kernelsLoadedSuccessfully(true)
|
||||
{
|
||||
const bool hasBody = dictionary.getValue(keyBody, _targetName);
|
||||
if (!hasBody)
|
||||
@@ -51,49 +52,32 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
|
||||
|
||||
ghoul::Dictionary kernels;
|
||||
dictionary.getValue(keyKernels, kernels);
|
||||
if (kernels.size() == 0)
|
||||
_kernelsLoadedSuccessfully = false;
|
||||
for (size_t i = 1; i <= kernels.size(); ++i) {
|
||||
std::string kernel;
|
||||
bool success = kernels.getValue(std::to_string(i), kernel);
|
||||
if (!success)
|
||||
LERROR("'" << keyKernels << "' has to be an array-style table");
|
||||
|
||||
SpiceManager::ref().loadKernel(kernel);
|
||||
SpiceManager::KernelIdentifier id = SpiceManager::ref().loadKernel(kernel);
|
||||
_kernelsLoadedSuccessfully &= (id != SpiceManager::KernelFailed);
|
||||
}
|
||||
}
|
||||
|
||||
SpiceEphemeris::~SpiceEphemeris() {}
|
||||
|
||||
bool SpiceEphemeris::initialize()
|
||||
{
|
||||
//if (!_targetName.empty() && !_originName.empty()) {
|
||||
// int bsuccess = 0;
|
||||
// int osuccess = 0;
|
||||
// Spice::ref().bod_NameToInt(_targetName, &_target, &bsuccess);
|
||||
// Spice::ref().bod_NameToInt(_originName, &_origin, &osuccess);
|
||||
//
|
||||
// if (bsuccess && osuccess)
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
const psc& SpiceEphemeris::position() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void SpiceEphemeris::update(const UpdateData& data) {
|
||||
double state[3];
|
||||
|
||||
glm::dvec3 position(0,0,0);
|
||||
if (!_kernelsLoadedSuccessfully)
|
||||
return;
|
||||
|
||||
glm::dvec3 position(0,0,0);
|
||||
double lightTime = 0.0;
|
||||
glm::dmat3 _stateMatrix;
|
||||
SpiceManager::ref().getTargetPosition(_targetName, _originName, "GALACTIC", "NONE", data.time, position, lightTime);
|
||||
_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
|
||||
_position[3] += 3;
|
||||
//_position[3] += 3;
|
||||
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <openspace/rendering/renderablefieldlines.h>
|
||||
#include <openspace/rendering/planets/renderableplanet.h>
|
||||
#include <openspace/rendering/renderablevolumeexpert.h>
|
||||
#include <openspace/rendering/renderablevolumecl.h>
|
||||
#include <openspace/rendering/renderableplane.h>
|
||||
#include <openspace/rendering/renderablevolumegl.h>
|
||||
#include <openspace/flare/flare.h>
|
||||
|
||||
@@ -81,6 +81,8 @@ void FactoryManager::initialize()
|
||||
"RenderableWavefrontObject");
|
||||
//_manager->factory<Renderable>()->registerClass<RenderableVolumeCL>(
|
||||
// "RenderableVolumeCL");
|
||||
_manager->factory<Renderable>()->registerClass<RenderablePlane>(
|
||||
"RenderablePlane");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableVolumeGL>(
|
||||
"RenderableVolumeGL");
|
||||
_manager->factory<Renderable>()->registerClass<RenderableFieldlines>("RenderableFieldlines");
|
||||
|
||||
@@ -197,7 +197,7 @@ float* KameleonWrapper::getUniformSampledValues(const std::string& var, glm::siz
|
||||
// }
|
||||
|
||||
int sum = 0;
|
||||
int stop;
|
||||
int stop = 0;
|
||||
const int sumuntil = size * truncLim;
|
||||
for(int i = 0; i < bins; ++i) {
|
||||
sum += histogram[i];
|
||||
|
||||
@@ -68,43 +68,15 @@ SpiceManager& SpiceManager::ref() {
|
||||
return *_manager;
|
||||
}
|
||||
|
||||
SpiceManager::KernelIdentifier SpiceManager::loadKernelExplicit(std::string filePath) {
|
||||
SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& filePath) {
|
||||
if (filePath.empty()) {
|
||||
LERROR("No filename provided");
|
||||
return KernelFailed;
|
||||
}
|
||||
|
||||
// I tried the *.cfg loading, didnt work. Im sorry but I just need this present right now.
|
||||
KernelIdentifier kernelId = ++_lastAssignedKernel;
|
||||
|
||||
// Load the kernel
|
||||
furnsh_c(filePath.c_str());
|
||||
|
||||
// Reset the current directory to the previous one
|
||||
std::cout << filePath.c_str() << std::endl;
|
||||
int failed = failed_c();
|
||||
if (failed) {
|
||||
char msg[1024];
|
||||
getmsg_c("LONG", 1024, msg);
|
||||
LERROR("Error loading kernel '" + filePath + "'");
|
||||
LERROR("Spice reported: " + std::string(msg));
|
||||
reset_c();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasError = checkForError("Error loading kernel '" + filePath + "'");
|
||||
if (hasError)
|
||||
return KernelFailed;
|
||||
else {
|
||||
KernelInformation&& info = { filePath, std::move(kernelId) };
|
||||
_loadedKernels.push_back(info);
|
||||
return kernelId;
|
||||
}
|
||||
}
|
||||
|
||||
SpiceManager::KernelIdentifier SpiceManager::loadKernel(std::string filePath) {
|
||||
if (filePath.empty()) {
|
||||
LERROR("No filename provided");
|
||||
std::string&& path = absPath(filePath);
|
||||
if (!FileSys.fileExists(path)) {
|
||||
LERROR("Kernel file '" << path << "' does not exist");
|
||||
return KernelFailed;
|
||||
}
|
||||
|
||||
@@ -113,10 +85,14 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(std::string filePath) {
|
||||
// We need to set the current directory as meta-kernels are usually defined relative
|
||||
// to the directory they reside in. The directory change is not necessary for regular
|
||||
// kernels
|
||||
std::string&& path = absPath(std::move(filePath));
|
||||
|
||||
ghoul::filesystem::Directory currentDirectory = FileSys.currentDirectory();
|
||||
std::string&& fileDirectory = ghoul::filesystem::File(path).directoryName();
|
||||
|
||||
if (!FileSys.directoryExists(fileDirectory)) {
|
||||
LERROR("Could not find directory for kernel '" << path << "'");
|
||||
return KernelFailed;
|
||||
}
|
||||
FileSys.setCurrentDirectory(fileDirectory);
|
||||
|
||||
// Load the kernel
|
||||
@@ -124,15 +100,14 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(std::string filePath) {
|
||||
|
||||
// Reset the current directory to the previous one
|
||||
FileSys.setCurrentDirectory(currentDirectory);
|
||||
std::cout << filePath.c_str() << std::endl;
|
||||
int failed = failed_c();
|
||||
if (failed) {
|
||||
char msg[1024];
|
||||
getmsg_c ( "LONG", 1024, msg );
|
||||
LERROR("Error loading kernel '" + filePath + "'");
|
||||
LERROR("Error loading kernel '" + path + "'");
|
||||
LERROR("Spice reported: " + std::string(msg));
|
||||
reset_c();
|
||||
return false;
|
||||
return KernelFailed;
|
||||
}
|
||||
|
||||
bool hasError = checkForError("Error loading kernel '" + path + "'");
|
||||
@@ -421,7 +396,7 @@ bool SpiceManager::getPositionTransformMatrix(const std::string& fromFrame,
|
||||
|
||||
bool hasError = checkForError("Error retrieving position transform matrix from "
|
||||
"frame '" + fromFrame + "' to frame '" + toFrame +
|
||||
"at time '" + std::to_string(ephemerisTime) + "'");
|
||||
"' at time '" + std::to_string(ephemerisTime) + "'");
|
||||
positionMatrix = glm::transpose(positionMatrix);
|
||||
|
||||
return !hasError;
|
||||
|
||||
Reference in New Issue
Block a user