Merge branch 'develop' into bug/abuffershadersupdater

Conflicts:
	ext/ghoul
	openspace.cfg
	src/abuffer/abuffer.cpp
	src/engine/openspaceengine.cpp
	src/rendering/renderengine.cpp
This commit is contained in:
Jonas Strandstedt
2014-10-21 14:54:48 +02:00
55 changed files with 6964 additions and 332 deletions

View File

@@ -39,6 +39,8 @@ set(OPENSPACE_EXT_DIR "${OPENSPACE_BASE_DIR}/ext")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OPENSPACE_EXT_DIR})
#include(cotire)
# Make sure a build type is set. Default is Debug.
if(NOT CMAKE_BUILD_TYPE)
set( CMAKE_BUILD_TYPE Debug CACHE STRING

View File

@@ -15,7 +15,7 @@
<!-- <Size x="960" y="540" /> -->
<!-- <Size x="640" y="360" /> -->
<!--<Size x="640" y="310" />-->
<Pos x="1700" y="50.0" />
<Pos x="500" y="500.0" />
<Viewport>
<Pos x="0.0" y="0.0" />
<Size x="1.0" y="1.0" />

3551
ext/cotire.cmake Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -36,7 +36,6 @@
#include <openspace/engine/configurationmanager.h>
//#include <ghoul/misc/dictionary.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/opencl/clcontext.h>
#include <ghoul/opencl/clcommandqueue.h>
#include <ghoul/opencl/clprogram.h>
@@ -76,15 +75,15 @@ public:
InteractionHandler& interactionHandler();
RenderEngine& renderEngine();
scripting::ScriptEngine& scriptEngine();
ghoul::filesystem::CacheManager& cacheManager();
// SGCT callbacks
bool initializeGL();
void preSynchronization();
void postSynchronizationPreDraw();
void render();
void postDraw();
void keyboardCallback(int key, int action);
void postDraw();
void keyboardCallback(int key, int action);
void charCallback(unsigned int codepoint);
void mouseButtonCallback(int key, int action);
void mousePositionCallback(int x, int y);
void mouseScrollWheelCallback(int pos);
@@ -105,7 +104,6 @@ private:
InteractionHandler _interactionHandler;
RenderEngine _renderEngine;
scripting::ScriptEngine _scriptEngine;
ghoul::filesystem::CacheManager* _cacheManager;
ghoul::cmdparser::CommandlineParser _commandlineParser;
#ifdef OPENSPACE_VIDEO_EXPORT
bool _doVideoExport;
@@ -117,6 +115,16 @@ private:
ghoul::opencl::CLContext _context;
sgct::SharedVector<char> _synchronizationBuffer;
bool _inputCommand;
size_t _inputPosition;
std::vector<std::string> _commandsHistory;
size_t _activeCommand;
std::vector<std::string> _commands;
void renderActiveCommand();
void handleCommandInput(int key, int action);
void addToCommand(std::string c);
};
#define OsEng (openspace::OpenSpaceEngine::ref())

View File

@@ -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;

View File

@@ -0,0 +1,91 @@
/*****************************************************************************************
* *
* 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 __RENDERABLEEPHEMERIS_H__
#define __RENDERABLEEPHEMERIS_H__
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
//#include <openspace/util/runtimedata.h>
namespace openspace {
class RenderableEphemeris : public Renderable{
public:
RenderableEphemeris(const ghoul::Dictionary& dictionary);
~RenderableEphemeris();
bool initialize() override;
bool deinitialize() override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
properties::StringProperty _colorTexturePath; // not used now, will be later though.
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
void loadTexture();
typedef struct {
GLfloat location[4];
GLfloat velocity[4];
GLubyte padding[32]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
GLuint _vaoID = 6;
GLuint _vBufferID = 7;
GLuint _iBufferID = 8;
void nextIndex();
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
Vertex* _varray;
int* _iarray;
Vertex* batchArray;
bool* _updated;
psc _pscpos, _pscvel;
std::vector<std::pair<int, double>> _intervals;
double _increment;
// etc...
int _index[2];
int _prev[2];
int _delta;
double _time = 0;
double _previousTime = 0;
};
}
#endif

View File

@@ -0,0 +1,104 @@
/*****************************************************************************************
* *
* 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 __RenderableFov_H__
#define __RenderableFov_H__
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
//#include <openspace/util/runtimedata.h>
namespace openspace {
class RenderableFov : public Renderable{
public:
RenderableFov(const ghoul::Dictionary& dictionary);
~RenderableFov();
bool initialize() override;
bool deinitialize() override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
properties::StringProperty _colorTexturePath;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
void loadTexture();
void fullYearSweep();
// modfile reads
// spice
std::string _target;
std::string _observer;
std::string _frame;
// color
glm::vec3 _c;
double _r, _g, _b;
// orbit relational data
double _tropic;
double _ratio;
double _day;
// need to write robust method for vbo id selection
// (right now galactic grid has to be present) (why though?) solve later...
GLuint _vaoID ;
GLuint _vBufferID ;
GLuint _iBufferID;
void updateData();
void sendToGPU();
glm::dmat3 _stateMatrix;
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
unsigned int _vtotal;
unsigned int _stride;
double _startTrail;
//Vertex* _varray;
std::vector<float> _varray;
int* _iarray;
bool _once = false;
//used for update of trail
psc _pscpos, _pscvel;
double _increment;
double _time = 0;
double _oldTime = 0;
int _delta = 0;
int _dtprogress = 0;
};
}
#endif

View File

@@ -0,0 +1,93 @@
/*****************************************************************************************
* *
* 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 __RenderablePath_H__
#define __RenderablePath_H__
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
//#include <openspace/util/runtimedata.h>
namespace openspace {
class RenderablePath : public Renderable{
public:
RenderablePath(const ghoul::Dictionary& dictionary);
~RenderablePath();
bool initialize() override;
bool deinitialize() override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
properties::StringProperty _colorTexturePath;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
void loadTexture();
void fullYearSweep();
// modfile reads
// spice
std::string _target;
std::string _observer;
std::string _frame;
// color
glm::vec3 _c;
double _r, _g, _b;
// need to write robust method for vbo id selection
// (right now galactic grid has to be present) (why though?) solve later...
GLuint _vaoID;
GLuint _vBufferID;
GLuint _iBufferID;
void nextIndex();
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
unsigned int _vtotal;
unsigned int _stride;
//Vertex* _varray;
std::vector<float> _varray;
int* _iarray;
//used for update of trail
psc _pscpos, _pscvel;
double _increment;
double _time = 0;
double _oldTime = 0;
int _delta = 0;
int _dtprogress = 0;
};
}
#endif

View 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_

View File

@@ -0,0 +1,102 @@
/*****************************************************************************************
* *
* 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 __RENDERABLETRAIL_H__
#define __RENDERABLETRAIL_H__
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
//#include <openspace/util/runtimedata.h>
namespace openspace {
class RenderableTrail : public Renderable{
public:
RenderableTrail(const ghoul::Dictionary& dictionary);
~RenderableTrail();
bool initialize() override;
bool deinitialize() override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
private:
properties::StringProperty _colorTexturePath;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
void loadTexture();
void fullYearSweep();
// modfile reads
// spice
std::string _target;
std::string _observer;
std::string _frame;
// color
glm::vec3 _c;
double _r, _g, _b;
// orbit relational data
double _tropic;
double _ratio;
double _day;
// need to write robust method for vbo id selection
// (right now galactic grid has to be present) (why though?) solve later...
GLuint _vaoID ;
GLuint _vBufferID ;
GLuint _iBufferID;
void updateTrail();
void sendToGPU();
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
unsigned int _vtotal;
unsigned int _stride;
double _startTrail;
//Vertex* _varray;
std::vector<float> _varray;
int* _iarray;
bool _once = false;
//used for update of trail
psc _pscpos, _pscvel;
double _increment;
double _time = 0;
double _oldTime = 0;
int _delta = 0;
int _dtprogress = 0;
};
}
#endif

View File

@@ -0,0 +1,104 @@
/*****************************************************************************************
* *
* 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 __RENDERABLEWAVEFRONTOBJECT_H__
#define __RENDERABLEWAVEFRONTOBJECT_H__
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/util/updatestructures.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
namespace openspace {
class RenderableWavefrontObject : public Renderable {
public:
RenderableWavefrontObject(const ghoul::Dictionary& dictionary);
~RenderableWavefrontObject();
bool initialize() override;
bool deinitialize() override;
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
typedef struct
{
GLfloat location[4];
GLfloat tex[2];
GLfloat normal[3];
/* GLfloat color[4];
GLfloat attribute[3];
GLfloat float_attribute;*/
//GLubyte padding[4]; // Pads the struct out to 64 bytes for performance increase
} Vertex;
protected:
void loadTexture();
void loadObj(const char *filename);
private:
properties::StringProperty _colorTexturePath;
ghoul::opengl::ProgramObject* _programObject;
ghoul::opengl::Texture* _texture;
ghoul::opengl::ProgramObject* _fovProgram;
GLuint _vaoID = 6;
GLuint _vBufferID = 7;
GLuint _iBufferID = 8;
GLenum _mode;
unsigned int _isize;
unsigned int _vsize;
Vertex *_varray;
int *_iarray;
glm::dmat3 _stateMatrix; // might need this
std::string _target;
///NH FOV
GLuint _vaoFOV = 10;
GLuint _vboFOV = 11;
GLuint _iboFOV = 12;
unsigned int _isizeFOV;
unsigned int _vsizeFOV;
std::vector<float> _varrayFOV;
int *_iarrayFOV;
};
} // namespace openspace
#endif // __RENDERABLEWAVEFRONTOBJECT_H__

View File

@@ -33,12 +33,15 @@
#include <string>
#include <openspace/abuffer/abuffer.h>
#include <openspace/util/screenlog.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/scalarproperty.h>
namespace openspace {
class Camera;
class RenderEngine {
class RenderEngine: public properties::PropertyOwner {
public:
RenderEngine();
~RenderEngine();
@@ -76,6 +79,11 @@ private:
Camera* _mainCamera;
SceneGraph* _sceneGraph;
ABuffer* _abuffer;
ScreenLog* _log;
properties::BoolProperty _showInfo;
properties::BoolProperty _showScreenLog;
bool _takeScreenshot;

View File

@@ -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

View File

@@ -111,12 +111,13 @@ public:
void setCameraDirection(glm::vec3 cameraDirection);
glm::vec3 cameraDirection() const;
const glm::mat4& viewRotationMatrix() const;
glm::mat4 viewRotationMatrix() const;
void compileViewRotationMatrix();
void rotate(const glm::quat& rotation);
void setRotation(glm::quat rotation);
const glm::quat& rotation() const;
// const glm::quat& rotation() const;
void setRotation(glm::mat4 rotation);
const glm::vec3& viewDirection() const;
@@ -140,7 +141,7 @@ private:
glm::vec3 _viewDirection;
glm::vec3 _cameraDirection;
glm::vec2 _scaling;
glm::quat _viewRotation;
// glm::quat _viewRotation;
glm::mat4 _viewRotationMatrix; // compiled from the quaternion
glm::vec3 _lookUp;

View File

@@ -30,6 +30,12 @@
namespace openspace {
namespace constants {
namespace fonts {
const std::string keySGCT = "SGCTFont";
const std::string keyMono = "UbuntuMono";
const std::string keyLight = "UbuntuLight";
} // namespace fonts
namespace configurationmanager {
const std::string keyPaths = "Paths";
const std::string keyConfigSgct = "SGCTConfig";
@@ -37,10 +43,12 @@ namespace configurationmanager {
const std::string keyStartupScript = "StartupScripts";
const std::string keySpiceTimeKernel = "SpiceKernel.Time";
const std::string keySpiceLeapsecondKernel = "SpiceKernel.LeapSecond";
const std::string keySpiceNewHorizons = "SpiceKernel.NewHorizons";
} // 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";
@@ -64,6 +72,14 @@ namespace renderableplanet {
const std::string keyFrame = "Frame";
} // namespace renderableplanet
namespace planetgeometry {
const std::string keyType = "Type";
} // namespace planetgeometry
namespace renderablewavefrontobject {
const std::string keyObjFile = "ObjFile";
} // namespace renderableplanet
namespace renderablestars {
const std::string keySpeckFile = "SpeckFile";
const std::string keyPathModule = "ModulePath";
@@ -79,10 +95,6 @@ namespace renderablevolumegl {
const std::string keyTransferFunctionName = "TransferFunctionName";
} // namespace renderablevolumegl
namespace planetgeometry {
const std::string keyType = "Type";
} // namespace planetgeometry
namespace renderablesphericalgrid {
const std::string gridType = "GridType";
const std::string gridColor = "GridColor";

View File

@@ -60,7 +60,7 @@ public:
enum class FieldlineEnd {
NORTH,
SOUTH,
OUT
FAROUT
};
KameleonWrapper(const std::string& filename, Model model);

View File

@@ -0,0 +1,67 @@
/*****************************************************************************************
* *
* 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 <ghoul/logging/log.h>
#include <vector>
#include <tuple>
#include <utility> // pair
namespace openspace {
class ScreenLog : public ghoul::logging::Log {
public:
//typedef std::tuple<ghoul::logging::LogManager::LogLevel, std::string, std::string> LogEntry;
struct LogEntry {
LogEntry(ghoul::logging::LogManager::LogLevel l, double t, std::string ts, std::string c, std::string m) : level(l), timeStamp(t), timeString(ts), category(c), message(m) {};
ghoul::logging::LogManager::LogLevel level;
double timeStamp;
std::string timeString;
std::string category;
std::string message;
};
typedef std::vector<LogEntry>::iterator iterator;
typedef std::vector<LogEntry>::const_iterator const_iterator;
typedef std::vector<LogEntry>::reverse_iterator reverse_iterator;
typedef std::vector<LogEntry>::const_reverse_iterator const_reverse_iterator;
typedef std::pair<reverse_iterator, reverse_iterator> range;
typedef std::pair<const_reverse_iterator, const_reverse_iterator> const_range;
const size_t MaximumSize = 1000;
ScreenLog();
virtual void log(ghoul::logging::LogManager::LogLevel level, const std::string& category,
const std::string& message);
const_range last(size_t n = 10);
private:
std::vector<LogEntry> _entries;
};
}

View File

@@ -27,12 +27,16 @@
#include "SpiceUsr.h"
#include <string>
#include <openspace/util/powerscaledcoordinate.h>
#include <ghoul/glm.h>
#include <glm/gtc/type_ptr.hpp>
#include <array>
#include <vector>
#include <map>
#include <string>
#include <vector>
namespace openspace {
@@ -69,7 +73,8 @@ 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 loadKernel(const std::string& filePath);
/**
* Unloads a SPICE kernel identified by the <code>kernelId</code> which was returned
@@ -277,6 +282,15 @@ public:
glm::dvec3& position,
double& lightTime) const;
bool getTargetPosition(const std::string& target,
const std::string& observer,
const std::string& referenceFrame,
const std::string& aberrationCorrection,
double ephemerisTime,
psc& position,
double& lightTime) const;
void getPointingAttitude();
/**
* Returns the state vector (<code>position</code> and <code>velocity</code>) of a
@@ -314,6 +328,15 @@ public:
glm::dvec3& velocity,
double& lightTime) const;
bool getTargetState(const std::string& target,
const std::string& observer,
const std::string& referenceFrame,
const std::string& aberrationCorrection,
double ephemerisTime,
PowerScaledCoordinate& position,
PowerScaledCoordinate& velocity,
double& lightTime) const;
/**
* Returns the state transformation matrix used to convert from one frame to another
* at a specified <code>ephemerisTime</code>. For further details, please refer to
@@ -352,6 +375,11 @@ public:
double ephemerisTime,
glm::dmat3& transformationMatrix) const;
bool getPositionPrimeMeridian(const std::string& sourceFrame,
const std::string& destinationFrame,
double ephemerisTime,
glm::dmat3& transformationMatrix) const;
/**
* Applies the <code>transformationMatrix</code> retrieved from
* getStateTransformMatrix to the <code>position</code> and <code>velocity</code>. The

View File

@@ -32,6 +32,7 @@ namespace openspace {
struct UpdateData {
double time;
double delta;
};
struct RenderData {

View File

@@ -7,11 +7,14 @@ return {
OPENSPACE_DATA = "${BASE_PATH}/openspace-data",
TESTDIR = "${BASE_PATH}/src/tests",
CONFIG = "${BASE_PATH}/config",
CACHE = "${BASE_PATH}/cache"
CACHE = "${BASE_PATH}/cache",
TEMPORARY = "${BASE_PATH}/tmp",
FONTS = "${OPENSPACE_DATA}/fonts"
},
SpiceKernel = {
Time = "${OPENSPACE_DATA}/spice/naif0010.tls",
LeapSecond = "${OPENSPACE_DATA}/spice/pck00010.tpc"
LeapSecond = "${OPENSPACE_DATA}/spice/pck00010.tpc",
NewHorizons = "${OPENSPACE_DATA}/spice/nhmeta.tm"
},
SGCTConfig = "${SGCT}/single.xml",
--SGCTConfig = "${SGCT}/two_nodes.xml",

View File

@@ -1,5 +1,8 @@
--openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png')
openspace.time.setTime("2000-01-01T00:00:00")
openspace.time.setDeltaTime(1.0)
openspace.time.setTime("2007-02-26T12:00:00")
--openspace.time.setTime("2006-08-22T20:00:00")
print(openspace.time.currentTimeUTC())
--openspace.time.setDeltaTime(200000.0)
openspace.time.setDeltaTime(0.0)
--openspace.time.setDeltaTime(30000.0)
-- print(openspace.time.currentTimeUTC())

43
shaders/ephemeris_fs.glsl Normal file
View File

@@ -0,0 +1,43 @@
/**
Copyright (C) 2012-2014 Jonas Strandstedt
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;
in vec4 vs_point_position;
in vec4 vs_point_velocity;
//out vec4 diffuse;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
void main()
{
vec4 position = vs_point_position;
float depth = pscDepth(position);
// set the depth
//gl_FragDepth = depth;
//float l = length(vs_point_velocity);
vec4 diffuse = vs_point_velocity;
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
discard;
}

75
shaders/ephemeris_vs.glsl Normal file
View File

@@ -0,0 +1,75 @@
/**
Copyright (C) 2012-2014 Jonas Strandstedt
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;
//uniform vec4 etColor;
uniform vec4 objectVelocity;
layout(location = 0) in vec4 in_point_position;
layout(location = 1) in vec4 in_point_velocity;
layout(location = 2) in vec2 in_point_timeindex;
out vec4 vs_point_position;
out vec4 vs_point_velocity;
#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
vs_point_velocity = in_point_velocity;
vec4 tmp = in_point_position;
vec4 position = pscTransform(tmp, ModelTransform);
vs_point_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
/*
//vs_point_position = objpos;
// rotate and scale vertex with model transform and add the translation
vec3 local_vertex_pos = mat3(ModelTransform) * in_point_position.xyz;
//vec4 lvp = ModelTransform * in_point_position;
// PSC addition; local vertex position and the object power scaled world position
vs_point_position = psc_addition(vec4(local_vertex_pos,in_point_position.w),objpos);
//vs_point_position = psc_addition(lvp,objpos);
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
vs_point_position = psc_addition(vs_point_position,vec4(-campos.xyz,campos.w));
// rotate the camera
local_vertex_pos = mat3(camrot) * vs_point_position.xyz;
vs_point_position = vec4(local_vertex_pos, vs_point_position.w);
//vs_point_position = camrot* vs_point_position;
// project using the rescaled coordinates,
//vec4 vs_point_position_rescaled = psc_scaling(vs_point_position, scaling);
vec4 vs_point_position_rescaled = psc_to_meter(vs_point_position, scaling);
//vs_point_position = vs_point_position_rescaled;
// project the position to view space
gl_Position = ViewProjection * vs_point_position_rescaled;
*/
}

57
shaders/plane_fs.glsl Normal file
View 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
View 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);
}

View File

@@ -24,6 +24,11 @@
#version 430
uniform vec4 campos;
uniform vec4 objpos;
//uniform vec3 camdir; // add this for specular
uniform float time;
uniform sampler2D texture1;
@@ -35,15 +40,38 @@ in vec4 vs_position;
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
//#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse = texture(texture1, vs_st);
// directional lighting
vec3 origin = vec3(0.0);
vec4 spec = vec4(0.0);
vec3 n = normalize(vs_normal.xyz);
//vec3 e = normalize(camdir);
vec3 l_pos = vec3(0.0); // sun.
vec3 l_dir = normalize(l_pos-objpos.xyz);
float intensity = min(max(5*dot(n,l_dir), 0.0), 1);
float shine = 0.0001;
vec4 specular = vec4(0.5);
vec4 ambient = vec4(0.0,0.0,0.0,1);
/*
if(intensity > 0.f){
// halfway vector
vec3 h = normalize(l_dir + e);
// specular factor
float intSpec = max(dot(h,n),0.0);
spec = specular * pow(intSpec, shine);
}
*/
diffuse = max(intensity * diffuse, ambient);
// if(position.w > 9.0) {
// diffuse = vec4(1,0,0,1);
// }
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);

View File

@@ -58,7 +58,7 @@ void main(void)
vec4 position = vs_position;
float depth = pscDepth(position);
gl_FragDepth = depth;
gl_FragDepth = 10.0;
//gl_FragDepth = 10.0;
//ABufferStruct_t frag = createGeometryFragment(vec4(1,0,0,1), position, depth);
//ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);

View File

@@ -148,6 +148,8 @@ include_directories("${HEADER_ROOT_DIR}")
add_executable(OpenSpace ${SOURCE_ROOT_DIR}/main.cpp ${OPENSPACE_HEADER} ${OPENSPACE_SOURCE})
target_link_libraries(OpenSpace ${DEPENDENT_LIBS})
# cotire(OpenSpace)
if (WIN32)
if (CMAKE_CL_64)
set(OPENSPACE_DLL_LIBS ${OPENSPACE_DLL_LIBS} ${GHOUL_ROOT_DIR}/ext/il/lib/win64/DevIL.dll)

View File

@@ -61,6 +61,96 @@ namespace {
struct {
std::string configurationName;
} commandlineArgumentPlaceholders;
// TODO: Put this functio nsomewhere appropriate
// get text from clipboard
std::string getClipboardText()
{
#ifdef WIN32
// Try opening the clipboard
if (!OpenClipboard(nullptr))
return "";
// Get handle of clipboard object for ANSI text
HANDLE hData = GetClipboardData(CF_TEXT);
if (hData == nullptr)
return "";
// Lock the handle to get the actual text pointer
char * pszText = static_cast<char*>(GlobalLock(hData));
if (pszText == nullptr)
return "";
// Save text in a string class instance
std::string text(pszText);
// Release the lock
GlobalUnlock(hData);
// Release the clipboard
CloseClipboard();
text.erase(std::remove(text.begin(), text.end(), '\r'), text.end());
return text;
#else
return "";
#endif
}
// TODO: Put this function somewhere appropriate
// set text to clipboard
bool setClipboardText(std::string text)
{
#ifdef WIN32
char *ptrData = nullptr;
HANDLE hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, text.length() + 1);
ptrData = (char*)GlobalLock(hData);
memcpy(ptrData, text.c_str(), text.length() + 1);
GlobalUnlock(hData);
if (!OpenClipboard(nullptr))
return false;
if (!EmptyClipboard())
return false;
SetClipboardData(CF_TEXT, hData);
CloseClipboard();
return true;
#else
return false;
#endif
}
std::string UnicodeToUTF8(unsigned int codepoint){
std::string out;
if (codepoint <= 0x7f)
out.append(1, static_cast<char>(codepoint));
else if (codepoint <= 0x7ff)
{
out.append(1, static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
}
else if (codepoint <= 0xffff)
{
out.append(1, static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
out.append(1, static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
}
else
{
out.append(1, static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
out.append(1, static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
out.append(1, static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
}
return out;
}
}
using namespace ghoul::cmdparser;
@@ -71,29 +161,27 @@ OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr;
OpenSpaceEngine::OpenSpaceEngine(std::string programName)
: _commandlineParser(programName, true)
, _cacheManager(nullptr)
, _inputCommand(false)
, _inputPosition(0)
, _activeCommand(0)
, _commands({""})
{
}
OpenSpaceEngine::~OpenSpaceEngine()
{
OpenSpaceEngine::~OpenSpaceEngine() {
SpiceManager::deinitialize();
Time::deinitialize();
DeviceIdentifier::deinit();
if (_cacheManager)
delete _cacheManager;
FileSystem::deinitialize();
LogManager::deinitialize();
}
OpenSpaceEngine& OpenSpaceEngine::ref()
{
OpenSpaceEngine& OpenSpaceEngine::ref() {
assert(_engine);
return *_engine;
}
bool OpenSpaceEngine::gatherCommandlineArguments()
{
bool OpenSpaceEngine::gatherCommandlineArguments() {
// TODO: Get commandline arguments from all modules
CommandlineCommand* configurationFileCommand = new SingleCommand<std::string>(
@@ -104,8 +192,7 @@ bool OpenSpaceEngine::gatherCommandlineArguments()
return true;
}
bool OpenSpaceEngine::findConfiguration(std::string& filename)
{
bool OpenSpaceEngine::findConfiguration(std::string& filename) {
using ghoul::filesystem::Directory;
Directory directory = FileSys.currentDirectory();
@@ -205,7 +292,7 @@ bool OpenSpaceEngine::create(int argc, char** argv,
}
// Create the cachemanager
_engine->_cacheManager = new ghoul::filesystem::CacheManager(absPath("${CACHE}"));
FileSys.createCacheManager("${CACHE}");
// Determining SGCT configuration file
LDEBUG("Determining SGCT configuration file");
@@ -222,18 +309,15 @@ bool OpenSpaceEngine::create(int argc, char** argv,
return true;
}
void OpenSpaceEngine::destroy()
{
void OpenSpaceEngine::destroy() {
delete _engine;
}
bool OpenSpaceEngine::isInitialized()
{
bool OpenSpaceEngine::isInitialized() {
return _engine != nullptr;
}
bool OpenSpaceEngine::initialize()
{
bool OpenSpaceEngine::initialize() {
// clear the screen so the user don't have to see old buffer contents from the
// graphics card
glClearColor(0, 0, 0, 0);
@@ -251,7 +335,7 @@ bool OpenSpaceEngine::initialize()
// Detect and log OpenCL and OpenGL versions and available devices
ghoul::systemcapabilities::SystemCapabilities::initialize();
SysCap.addComponent(new ghoul::systemcapabilities::CPUCapabilitiesComponent);
SysCap.addComponent(new ghoul::systemcapabilities::OpenCLCapabilitiesComponent);
//SysCap.addComponent(new ghoul::systemcapabilities::OpenCLCapabilitiesComponent);
SysCap.addComponent(new ghoul::systemcapabilities::OpenGLCapabilitiesComponent);
SysCap.detectCapabilities();
SysCap.logCapabilities();
@@ -259,24 +343,55 @@ bool OpenSpaceEngine::initialize()
// initialize OpenSpace helpers
SpiceManager::initialize();
Time::initialize();
// Load SPICE time kernel
using constants::configurationmanager::keySpiceTimeKernel;
std::string timeKernel;
bool success = OsEng.configurationManager().getValue(keySpiceTimeKernel, timeKernel);
bool success = configurationManager().getValue(keySpiceTimeKernel, timeKernel);
if (!success) {
LERROR("Configuration file does not contain a '" << keySpiceTimeKernel << "'");
return false;
}
SpiceManager::ref().loadKernel(std::move(timeKernel));
using constants::configurationmanager::keySpiceLeapsecondKernel;
std::string leapSecondKernel;
success = OsEng.configurationManager().getValue(keySpiceLeapsecondKernel, leapSecondKernel);
if (!success) {
LERROR("Configuration file does not contain a '" << keySpiceLeapsecondKernel << "'");
SpiceManager::KernelIdentifier id =
SpiceManager::ref().loadKernel(timeKernel);
if (id == SpiceManager::KernelFailed) {
LERROR("Error loading time kernel '" << timeKernel << "'");
return false;
}
SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
// Load SPICE leap second kernel
using constants::configurationmanager::keySpiceLeapsecondKernel;
std::string leapSecondKernel;
success = configurationManager().getValue(keySpiceLeapsecondKernel, leapSecondKernel);
if (!success) {
LERROR("Configuration file does not have a '" << keySpiceLeapsecondKernel << "'");
return false;
}
id = SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
if (id == SpiceManager::KernelFailed) {
LERROR("Error loading leap second kernel '" << leapSecondKernel << "'");
return false;
}
//// metakernel loading doesnt seem to work... it should. to tired to even
//// CK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/ck/merged_nhpc_2006_v011.bc");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/ck/merged_nhpc_2007_v006.bc");
//// FK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/fk/nh_v200.tf");
//// IK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/ik/nh_lorri_v100.ti");
//// LSK already loaded
////PCK
////SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/pck/pck00008.tpc");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/pck/new_horizons_413.tsc");
////SPK
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/de413.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/jup260.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/nh_nep_ura_000.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/nh_recon_e2j_v1.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/nh_recon_j2sep07_prelimv1.bsp");
//SpiceManager::ref().loadKernel("${OPENSPACE_DATA}/spice/JupiterNhKernels/spk/sb_2002jf56_2.bsp");
FactoryManager::initialize();
@@ -292,33 +407,24 @@ bool OpenSpaceEngine::initialize()
SceneGraph* sceneGraph = new SceneGraph;
_renderEngine.setSceneGraph(sceneGraph);
// initialize the RenderEngine, needs ${SCENEPATH} to be set
_renderEngine.initialize();
sceneGraph->initialize();
std::string sceneDescriptionPath;
success = OsEng.configurationManager().getValue(
success = configurationManager().getValue(
constants::configurationmanager::keyConfigScene, sceneDescriptionPath);
if (success)
sceneGraph->scheduleLoadSceneFile(sceneDescriptionPath);
//_renderEngine.setSceneGraph(sceneGraph);
#ifdef FLARE_ONLY
_flare = new Flare();
_flare->initialize();
#endif
// Initialize OpenSpace input devices
DeviceIdentifier::init();
DeviceIdentifier::ref().scanDevices();
_engine->_interactionHandler.connectDevices();
_interactionHandler.connectDevices();
// Run start up scripts
ghoul::Dictionary scripts;
success = _engine->configurationManager().getValue(
success = configurationManager().getValue(
constants::configurationmanager::keyStartupScript, scripts);
for (size_t i = 1; i <= scripts.size(); ++i) {
std::stringstream stream;
@@ -337,50 +443,42 @@ bool OpenSpaceEngine::initialize()
_engine->scriptEngine().runScriptFile(absoluteScriptPath);
}
#ifdef OPENSPACE_VIDEO_EXPORT
LINFO("OpenSpace compiled with video export; press Print Screen to start/stop recording");
#endif
// Load a light and a monospaced font
//sgct_text::FontManager::instance()->addFont(constants::fonts::keyMono, "ubuntu-font-family/UbuntuMono-R.ttf", absPath("${FONTS}/"));
//sgct_text::FontManager::instance()->addFont(constants::fonts::keyLight, "ubuntu-font-family/Ubuntu-L.ttf", absPath("${FONTS}/"));
sgct_text::FontManager::FontPath local = sgct_text::FontManager::FontPath::FontPath_Local;
sgct_text::FontManager::instance()->addFont(constants::fonts::keyMono, absPath("${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf"), local);
sgct_text::FontManager::instance()->addFont(constants::fonts::keyLight, absPath("${FONTS}/Roboto/Roboto-Regular.ttf"), local);
return true;
}
ConfigurationManager& OpenSpaceEngine::configurationManager()
{
ConfigurationManager& OpenSpaceEngine::configurationManager() {
return _configurationManager;
}
ghoul::opencl::CLContext& OpenSpaceEngine::clContext()
{
ghoul::opencl::CLContext& OpenSpaceEngine::clContext() {
return _context;
}
InteractionHandler& OpenSpaceEngine::interactionHandler()
{
InteractionHandler& OpenSpaceEngine::interactionHandler() {
return _interactionHandler;
}
RenderEngine& OpenSpaceEngine::renderEngine()
{
RenderEngine& OpenSpaceEngine::renderEngine() {
return _renderEngine;
}
ScriptEngine& OpenSpaceEngine::scriptEngine()
{
ScriptEngine& OpenSpaceEngine::scriptEngine() {
return _scriptEngine;
}
ghoul::filesystem::CacheManager& OpenSpaceEngine::cacheManager() {
assert(_cacheManager != nullptr);
return *_cacheManager;
}
bool OpenSpaceEngine::initializeGL()
{
return _renderEngine.initializeGL();
}
void OpenSpaceEngine::preSynchronization()
{
void OpenSpaceEngine::preSynchronization() {
#ifdef WIN32
// Sleeping for 0 milliseconds will trigger any pending asynchronous procedure calls
SleepEx(0, TRUE);
@@ -393,33 +491,65 @@ void OpenSpaceEngine::preSynchronization()
Time::ref().advanceTime(dt);
}
#ifdef FLARE_ONLY
_flare->preSync();
#endif
}
void OpenSpaceEngine::postSynchronizationPreDraw()
{
void OpenSpaceEngine::postSynchronizationPreDraw() {
_renderEngine.postSynchronizationPreDraw();
#ifdef FLARE_ONLY
_flare->postSyncPreDraw();
#endif
}
void OpenSpaceEngine::render()
{
#ifdef FLARE_ONLY
_flare->render();
#else
void OpenSpaceEngine::render() {
_renderEngine.render();
#endif
// If currently writing a command, render it to screen
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _inputCommand) {
renderActiveCommand();
}
}
void OpenSpaceEngine::postDraw()
{
if (sgct::Engine::instance()->isMaster()) {
void OpenSpaceEngine::renderActiveCommand() {
const int font_size = 10;
int x1, xSize, y1, ySize;
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
int startY = ySize - 2 * font_size;
startY = startY - font_size * 10 * 2;
const int font_with = font_size*0.7;
const glm::vec4 red(1, 0, 0, 1);
const glm::vec4 green(0, 1, 0, 1);
const glm::vec4 white(1, 1, 1, 1);
const sgct_text::Font* font = sgct_text::FontManager::instance()->getFont(constants::fonts::keyMono, font_size);
Freetype::print(font, 10, startY, red, "$");
Freetype::print(font, 10 + font_size, startY, white, "%s", _commands.at(_activeCommand).c_str());
size_t n = std::count(_commands.at(_activeCommand).begin(), _commands.at(_activeCommand).begin() + _inputPosition, '\n');
size_t p = _commands.at(_activeCommand).find_last_of('\n', _inputPosition);
size_t linepos = _inputPosition;
if (n>0) {
if (p == _inputPosition) {
p = _commands.at(_activeCommand).find_last_of('\n', _inputPosition - 1);
if (p != std::string::npos) {
linepos -= p + 1;
}
else {
linepos = _inputPosition - 1;
}
}
else{
linepos -= p + 1;
}
}
char buffer[10];
sprintf(buffer, "%%%is", linepos + 1);
Freetype::print(font, 10 + static_cast<float>(font_size)*0.5, startY - (font_size)*(n + 1)*3.0 / 2.0, green, buffer, "^");
}
void OpenSpaceEngine::postDraw() {
if (sgct::Engine::instance()->isMaster())
_interactionHandler.unlockControls();
}
#ifdef OPENSPACE_VIDEO_EXPORT
float speed = 0.01;
glm::vec3 euler(0.0, speed, 0.0);
@@ -431,7 +561,6 @@ void OpenSpaceEngine::postDraw()
if(_doVideoExport)
_renderEngine.takeScreenshot();
#endif
_renderEngine.postDraw();
#ifdef FLARE_ONLY
@@ -439,37 +568,150 @@ void OpenSpaceEngine::postDraw()
#endif
}
void OpenSpaceEngine::keyboardCallback(int key, int action)
{
if (sgct::Engine::instance()->isMaster()) {
_interactionHandler.keyboardCallback(key, action);
}
#ifdef OPENSPACE_VIDEO_EXPORT
if(action == SGCT_PRESS && key == SGCT_KEY_PRINT_SCREEN)
_doVideoExport = !_doVideoExport;
#endif
#ifdef FLARE_ONLY
_flare->keyboard(key, action);
#endif
void OpenSpaceEngine::addToCommand(std::string c) {
size_t length = c.length();
_commands.at(_activeCommand).insert(_inputPosition, c);
_inputPosition += length;
}
void OpenSpaceEngine::mouseButtonCallback(int key, int action)
{
if (sgct::Engine::instance()->isMaster()) {
void OpenSpaceEngine::keyboardCallback(int key, int action) {
if (sgct::Engine::instance()->isMaster()) {
if (key == SGCT_KEY_BACKSLASH && (action == SGCT_PRESS || action == SGCT_REPEAT)) {
_inputCommand = !_inputCommand;
}
if (!_inputCommand) {
_interactionHandler.keyboardCallback(key, action);
}
else {
handleCommandInput(key, action);
}
}
}
void OpenSpaceEngine::handleCommandInput(int key, int action) {
if (action == SGCT_PRESS || action == SGCT_REPEAT) {
const size_t windowIndex = sgct::Engine::instance()->getFocusedWindowIndex();
const bool mod_CONTROL = sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_LEFT_CONTROL) ||
sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_RIGHT_CONTROL);
const bool mod_SHIFT = sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_LEFT_SHIFT) ||
sgct::Engine::instance()->getKey(windowIndex, SGCT_KEY_RIGHT_SHIFT);
// Paste from clipboard
if (key == SGCT_KEY_V) {
if (mod_CONTROL) {
addToCommand(getClipboardText());
}
}
// Copy to clipboard
if (key == SGCT_KEY_C) {
if (mod_CONTROL) {
setClipboardText(_commands.at(_activeCommand));
}
}
// Go to the previous character
if (key == SGCT_KEY_LEFT) {
if (_inputPosition > 0)
_inputPosition -= 1;
}
// Go to the next character
if (key == SGCT_KEY_RIGHT) {
if (_inputPosition < _commands.at(_activeCommand).length())
++_inputPosition;
}
// Go to previous command
if (key == SGCT_KEY_UP) {
if (_activeCommand > 0)
--_activeCommand;
_inputPosition = _commands.at(_activeCommand).length();
}
// Go to next command (the last is empty)
if (key == SGCT_KEY_DOWN) {
if (_activeCommand < _commands.size()-1)
++_activeCommand;
_inputPosition = _commands.at(_activeCommand).length();
}
// Remove character before _inputPosition
if (key == SGCT_KEY_BACKSPACE) {
if (_inputPosition > 0) {
_commands.at(_activeCommand).erase(_inputPosition - 1, 1);
--_inputPosition;
}
}
// Remove character after _inputPosition
if (key == SGCT_KEY_DELETE) {
if (_inputPosition <= _commands.at(_activeCommand).size()) {
_commands.at(_activeCommand).erase(_inputPosition, 1);
}
}
// Go to the beginning of command string
if (key == SGCT_KEY_HOME) {
_inputPosition = 0;
}
// Go to the end of command string
if (key == SGCT_KEY_END) {
_inputPosition = _commands.at(_activeCommand).size();
}
if (key == SGCT_KEY_ENTER) {
// SHIFT+ENTER == new line
if (mod_SHIFT) {
addToCommand("\n");
}
// CTRL+ENTER == Debug print the command
else if (mod_CONTROL) {
LDEBUG("Active command from next line:\n" <<_activeCommand);
}
// ENTER == run lua script
else {
if (_commands.at(_activeCommand) != "") {
_scriptEngine.runScript(_commands.at(_activeCommand));
_commandsHistory.push_back(_commands.at(_activeCommand));
_commands = _commandsHistory;
_commands.push_back("");
_activeCommand = _commands.size() - 1;
_inputPosition = 0;
}
else {
_commands = _commandsHistory;
_commands.push_back("");
_inputCommand = false;
}
}
}
}
}
void OpenSpaceEngine::charCallback(unsigned int codepoint) {
// SGCT_KEY_BACKSLASH == 92 but that corresponds to codepoint 167
if (_inputCommand && codepoint != 167) {
addToCommand(UnicodeToUTF8(codepoint));
}
}
void OpenSpaceEngine::mouseButtonCallback(int key, int action) {
if (sgct::Engine::instance()->isMaster())
_interactionHandler.mouseButtonCallback(key, action);
}
#ifdef FLARE_ONLY
_flare->mouse(key, action);
#endif
}
void OpenSpaceEngine::mousePositionCallback(int x, int y)
{
void OpenSpaceEngine::mousePositionCallback(int x, int y) {
_interactionHandler.mousePositionCallback(x, y);
}
void OpenSpaceEngine::mouseScrollWheelCallback(int pos)
{
void OpenSpaceEngine::mouseScrollWheelCallback(int pos) {
_interactionHandler.mouseScrollWheelCallback(pos);
}

View File

@@ -10,6 +10,8 @@
#include <openspace/util/powerscaledcoordinate.h>
#include <glm/gtx/vector_angle.hpp>
#include <openspace/util/time.h>
// std includes
#include <cassert>
@@ -154,17 +156,24 @@ void InteractionHandler::orbit(const glm::quat &rotation) {
// should be changed to something more dynamic =)
psc origin;
if(node_) {
if (node_) {
origin = node_->worldPosition();
}
psc relative_origin_coordinate = relative - origin;
glm::mat4 rotation_matrix = glm::mat4_cast(rotation);
relative_origin_coordinate = relative_origin_coordinate * rotation_matrix;
//glm::mat4 rotation_matrix = glm::mat4_cast(glm::inverse(rotation));
//relative_origin_coordinate = relative_origin_coordinate.vec4() * glm::inverse(rotation);
relative_origin_coordinate = glm::inverse(rotation) * relative_origin_coordinate.vec4();
relative = relative_origin_coordinate + origin;
camera_->setPosition(relative);
//camera_->rotate(rotation);
//camera_->setRotation(glm::mat4_cast(rotation));
glm::mat4 la = glm::lookAt(camera_->position().vec3(), origin.vec3(), glm::rotate(rotation, camera_->lookUpVector()));
camera_->setRotation(la);
//camera_->setLookUpVector();
unlockControls();
}
@@ -266,7 +275,7 @@ void InteractionHandler::trackballRotate(int x, int y) {
glm::vec2 mousePos = glm::vec2((float)x/width, (float)y/height);
mousePos = glm::clamp(mousePos, -0.5, 1.5); // Ugly fix #1: Camera position becomes NaN on mouse values outside [-0.5, 1.5]
mousePos[1] = 0.5; // Ugly fix #2: Tempoarily only allow rotation around y
//mousePos[1] = 0.5; // Ugly fix #2: Tempoarily only allow rotation around y
glm::vec3 curTrackballPos = mapToTrackball(mousePos);
// LDEBUG(mousePos.x << ", " << mousePos.y << " = " << curTrackballPos.x << ", " << curTrackballPos.y << ", " << curTrackballPos.z);
@@ -293,19 +302,18 @@ void InteractionHandler::trackballRotate(int x, int y) {
glm::quat quaternion = glm::angleAxis(rotationAngle, rotationAxis);
// Apply quaternion to camera
orbit(glm::inverse(quaternion));
camera_->rotate(quaternion);
camera_->setLookUpVector(glm::rotate(quaternion, camera_->lookUpVector()));
orbit(quaternion);
_lastTrackballPos = curTrackballPos;
}
}
double acc = 1;
void InteractionHandler::keyboardCallback(int key, int action) {
// TODO package in script
const double speed = 2.75;
const double dt = getDt();
if(action == SGCT_PRESS || action == SGCT_REPEAT) {
if (action == SGCT_PRESS || action == SGCT_REPEAT) {
if (key == SGCT_KEY_S) {
glm::vec3 euler(speed * dt, 0.0, 0.0);
glm::quat rot = glm::quat(euler);
@@ -326,6 +334,9 @@ void InteractionHandler::keyboardCallback(int key, int action) {
glm::quat rot = glm::quat(euler);
orbit(rot);
}
if (key == SGCT_KEY_Q) {
Time::ref().advanceTime(dt);
}
if (key == 262) {
glm::vec3 euler(0.0, speed * dt, 0.0);
glm::quat rot = glm::quat(euler);
@@ -355,11 +366,12 @@ void InteractionHandler::keyboardCallback(int key, int action) {
distance(dist);
}
if (key == SGCT_KEY_T) {
PowerScaledScalar dist(-speed * 100.0 * dt, 0.0);
PowerScaledScalar dist(-speed * pow(10, 11) * dt, 0.0);
distance(dist);
}
if (key == SGCT_KEY_G) {
PowerScaledScalar dist(speed * 100.0 * dt, 0.0);
acc += 0.001;
PowerScaledScalar dist(speed * pow(10, 8 * acc) * dt, 0.0);
distance(dist);
}
if (key == SGCT_KEY_Y) {

View File

@@ -37,6 +37,7 @@ void mainPostSyncPreDrawFunc();
void mainRenderFunc();
void mainPostDrawFunc();
void mainKeyboardCallback(int key, int action);
void mainCharCallback(unsigned int codepoint);
void mainMouseButtonCallback(int key, int action);
void mainMousePosCallback(double x, double y);
void mainMouseScrollCallback(double posX, double posY);
@@ -77,8 +78,9 @@ int main(int argc, char** argv)
_sgctEngine->setKeyboardCallbackFunction(mainKeyboardCallback);
_sgctEngine->setMouseButtonCallbackFunction(mainMouseButtonCallback);
_sgctEngine->setMousePosCallbackFunction(mainMousePosCallback);
_sgctEngine->setMouseScrollCallbackFunction(mainMouseScrollCallback);
_sgctEngine->setExternalControlCallback(mainExternalControlCallback);
_sgctEngine->setMouseScrollCallbackFunction(mainMouseScrollCallback);
_sgctEngine->setExternalControlCallback(mainExternalControlCallback);
_sgctEngine->setCharCallbackFunction(mainCharCallback);
// set encode and decode functions
// NOTE: starts synchronizing before init functions
@@ -113,18 +115,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()
@@ -169,6 +179,12 @@ void mainMouseScrollCallback(double posX, double posY)
OsEng.mouseScrollWheelCallback(static_cast<int>(posY));
}
void mainCharCallback(unsigned int codepoint) {
if (_sgctEngine->isMaster())
OsEng.charCallback(codepoint);
}
void mainEncodeFun()
{
OsEng.encode();

View File

@@ -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 {

View File

@@ -64,8 +64,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
if (success) {
geometryDictionary.setValue(constants::scenegraphnode::keyName, name);
geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
_geometry
= planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
}
dictionary.getValue(constants::renderableplanet::keyFrame, _target);
@@ -123,8 +122,6 @@ void RenderablePlanet::render(const RenderData& data)
// activate shader
_programObject->activate();
PowerScaledScalar scaling = glm::vec2(1, -6);
// scale the planet to appropriate size since the planet is a unit sphere
glm::mat4 transform = glm::mat4(1);
@@ -138,8 +135,11 @@ void RenderablePlanet::render(const RenderData& data)
}
transform = transform* rot;
glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
glm::vec3 camSpaceEye = (-(modelview*data.position.vec4())).xyz;
// setup the data to the shader
// _programObject->setUniform("camdir", camSpaceEye);
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
@@ -158,11 +158,9 @@ void RenderablePlanet::render(const RenderData& data)
}
void RenderablePlanet::update(const UpdateData& data)
{
void RenderablePlanet::update(const UpdateData& data){
// set spice-orientation in accordance to timestamp
openspace::SpiceManager::ref().getPositionTransformMatrix("GALACTIC", "IAU_EARTH", data.time, _stateMatrix);
openspace::SpiceManager::ref().getPositionTransformMatrix(_target, "GALACTIC", data.time, _stateMatrix);
}
void RenderablePlanet::loadTexture()

View File

@@ -0,0 +1,315 @@
/*****************************************************************************************
* *
* 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/renderableephemeris.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/constants.h>
#include <ghoul/opengl/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/spicemanager.h>
#include <iomanip>
#include <utility> // std::move
namespace {
const std::string _loggerCat = "RenderableEphemeris";
}
namespace openspace{
RenderableEphemeris::RenderableEphemeris(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _texture(nullptr)
, _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
, _mode(GL_LINES){
double lightTime = 0.0;
double planetYear = 31536000;
SpiceManager::ref().getETfromDate("2005 nov 01 00:00:00", _time);
// -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
double et = _time - planetYear;
int segments = 365; // note to self: code not look nice. cleanup for clarity later.
int indx = 0;
psc pscpos, pscvel;
_isize = (segments)*2;
_vsize = (segments)*2;
_varray = new Vertex[_vsize];
_iarray = new int[_isize];
_updated = new bool[_vsize];
std::fill(_updated, _updated + _vsize, false);
static_assert(sizeof(Vertex) == 64, "The size of the Vertex needs to be 64 for performance");
// get first position, ephemeris start-point
SpiceManager::ref().getTargetState("EARTH", "SUN", "GALACTIC", "LT+S", et, pscpos, pscvel, lightTime);
memcpy(_varray[indx].location, glm::value_ptr(pscpos.vec4()), 4 * sizeof(double));
memcpy(_varray[indx].velocity, glm::value_ptr(glm::vec4(1, 1, 0, 1)), 4 * sizeof(double));
_intervals.push_back(std::pair<int, double>(indx, et));
_iarray[indx] = indx;
indx++;
_increment = planetYear / segments;
for (int i = 0; i < segments; i++){
et += _increment;
SpiceManager::ref().getTargetState("EARTH", "SUN", "GALACTIC", "LT+S", et, pscpos, pscvel, lightTime);
for (int k = 0; k < 2; k++){
if (i == segments - 1 && k == 1) { // do copy first to last
break;
}
memcpy(_varray[indx].location, glm::value_ptr(pscpos.vec4()), 4 * sizeof(double));
memcpy(_varray[indx].velocity, glm::value_ptr(glm::vec4(1, 1, 0, 1)), 4 * sizeof(double));
_intervals.push_back(std::pair<int, double>(indx, et));
_iarray[indx] = indx;
_index[k] = indx;
indx++;
}
}
_delta = _vsize;
/// testing std::move()
int array1[10] = { 10, 9, 8 , 7, 6, 5, 4, 3, 2 , 1 };
int size = sizeof(array1)/(sizeof(int));
std::cout << "before : ";
for (int i = 0; i < 10; i++){
std::cout << array1[i] << " ";
}
for (int i = size-1; i != 0; i--){
array1[i] = std::move(array1[i-1]);
if (i == 1){
array1[0] = 11;
}
}
std::cout << "after : ";
for (int i = 0; i < 10; i++){
std::cout << array1[i] << " ";
}
std::cout << std::endl;
}
RenderableEphemeris::~RenderableEphemeris(){
deinitialize();
}
bool RenderableEphemeris::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
loadTexture();
completeSuccess &= (_texture != nullptr);
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(Vertex), _varray);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<const GLvoid*>(offsetof(Vertex, velocity)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glBindVertexArray(0);
return completeSuccess;
}
bool RenderableEphemeris::deinitialize(){
delete _texture;
_texture = nullptr;
return true;
}
void RenderableEphemeris::nextIndex(){
if (_previousTime != _time){
int skip = _index[1] - _prev[1];
_prev[0] = _index[0];
_prev[1] = _index[1];
double t = _time - 31536000;
// Better optimization:
int x = (_index[0] > _index[1]) ? _index[0] : _index[1];
if (x >= _vsize - 1 || skip + x > _vsize ) x = 1;
for (x; x < _vsize; x++){
double t1 = _intervals[x - 1].second;
double t2 = _intervals[x].second;
if (t1 != t2 && t >= t1 && t <= t2){
_index[0] = (x - 2 < 0) ? _vsize - 1 : x - 2;
_index[1] = x - 1;
break;
}
}
}
_previousTime = _time;
}
void RenderableEphemeris::render(const RenderData& data){
assert(_programObject);
_programObject->activate();
// setup the data to the shader
//_programObject->setUniform("objectVelocity", pscvel.vec4());
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", glm::mat4(1));
setPscUniforms(_programObject, &data.camera, data.position);
nextIndex();
for (int i = 0; i < _vsize; i++){
_varray[i].velocity[0] -= 0.00008;
_varray[i].velocity[1] -= 0.00006;
_varray[i].velocity[2] -= 0.00004;
}
if (_delta > 0){
int i = _index[0];
int j = _index[1];
while (i != _prev[0]){
if (_updated[i] == false && _updated[j] == false){
_updated[i] = true;
_updated[j] = true;
_intervals[i].second += 31536000; // not the cleanest solution but works. need dt
_intervals[j].second += 31536000;
// DEBUGGING COLOR CODING
memcpy(_varray[i].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double)); // blue if updated
memcpy(_varray[j].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double));
}
i = (i - 2 < 0) ? _vsize - 1 : i - 2;
j = (j - 1 < 0) ? _vsize - 1 : j - 2;
std::cout << i << " " << j << std::endl;
}
}
/*
if (_updated[_index[1]] == false && _updated[_index[0]] == false){
_updated[_index[0]] = true;
_updated[_index[1]] = true;
_intervals[_index[0]].second = _time;
_intervals[_index[1]].second = _time;
memcpy(_varray[_index[0]].location, glm::value_ptr(_pscpos.vec4()), 4 * sizeof(double));
memcpy(_varray[_index[1]].location, glm::value_ptr(_pscpos.vec4()), 4 * sizeof(double));
// memcpy(_varray[_index[0]].velocity, glm::value_ptr(glm::vec4(1, 1, 1, 1)), 4 * sizeof(double));
// memcpy(_varray[_index[1]].velocity, glm::value_ptr(glm::vec4(1, 1, 1, 1)), 4 * sizeof(double));
// DEBUGGING COLOR CODING
memcpy(_varray[_index[0]].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double)); // blue if updated
memcpy(_varray[_index[1]].velocity, glm::value_ptr(glm::vec4(0, 0, 1, 1)), 4 * sizeof(double));
memcpy(_varray[_index[2]].velocity, glm::value_ptr(glm::vec4(1, 0, 0, 1)), 4 * sizeof(double)); // red
memcpy(_varray[_index[3]].velocity, glm::value_ptr(glm::vec4(1, 0, 0, 1)), 4 * sizeof(double));
_updated[_index[2]] = false;
_updated[_index[3]] = false;
}
*/
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(Vertex), _varray);
//psc pointPos(_varray[_index].location[0], _varray[_index].location[1], _varray[_index].location[2], _varray[_index].location[3]);
//std::cout << "dist, indx : " << distance(_pscpos, pointPos) << ", " << _index << std::endl;
glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, GL_UNSIGNED_INT);
glBindVertexArray(0);
glPointSize(2.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, GL_UNSIGNED_INT);
glBindVertexArray(0);
_programObject->deactivate();
}
void RenderableEphemeris::update(const UpdateData& data){
double lightTime;
_time = data.time;
SpiceManager::ref().getTargetState("EARTH", "SUN", "GALACTIC", "LT+S", data.time, _pscpos, _pscvel, lightTime);
}
void RenderableEphemeris::loadTexture()
{
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
}
}
}
}

View File

@@ -0,0 +1,253 @@
/*****************************************************************************************
* *
* 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/renderablefov.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/constants.h>
#include <ghoul/opengl/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/spicemanager.h>
#include <iomanip>
#include <utility>
namespace {
const std::string _loggerCat = "RenderableFov";
//constants
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
const std::string keyPathModule = "ModulePath";
const std::string keyColor = "RGB";
}
//#define DEBUG
namespace openspace{
RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _texture(nullptr)
, _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
, _mode(GL_LINE_STRIP){
assert(dictionary.getValue(keyBody , _target));
assert(dictionary.getValue(keyObserver , _observer));
assert(dictionary.getValue(keyFrame , _frame));
if (!dictionary.getValue(keyColor, _c)){
_c = glm::vec3(0.0);
}else{
_r = 1 / _c[0];
_g = 1 / _c[1];
_b = 1 / _c[2];
}
}
void RenderableFov::fullYearSweep(){
double lightTime = 0.0;
double et = _startTrail;
double planetYear = 31540000;
int segments = 2;
_increment = planetYear / 4;
_isize = (segments);
_vsize = (segments);
_iarray = new int[_isize];
SpiceManager::ref().getTargetState("NEW HORIZONS", "SUN", "GALACTIC", "LT+S", et, _pscpos, _pscvel, lightTime);
_pscpos[3] += 3;
_varray.push_back(_pscpos[0]);
_varray.push_back(_pscpos[1]);
_varray.push_back(_pscpos[2]);
_varray.push_back(_pscpos[3]);
_varray.push_back(1.f );
_varray.push_back(0.f );
_varray.push_back(0.f );
_varray.push_back(1.f );
_iarray[0] = 0;
glm::mat4 tmat = glm::mat4(1);
glm::mat4 rot_x = glm::rotate(tmat, 90.f, glm::vec3(1, 0, 0));
openspace::SpiceManager::ref().getPositionTransformMatrix("NH_SPACECRAFT", "GALACTIC", et, _stateMatrix);
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = _stateMatrix[i][j];
}
}
tmat *= tmp;
tmat *= rot_x;
std::string shape, name;
shape.resize(32);
name.resize(32);
std::vector<glm::dvec3> bounds;
glm::dvec3 boresight;
bool found = openspace::SpiceManager::ref().getFieldOfView("NH_LORRI", shape, name, boresight, bounds);
glm::vec4 bsight_t(boresight[0], boresight[1], boresight[2], 1);
//psc bor = PowerScaledCoordinate::CreatePowerScaledCoordinate(boresight[0], boresight[1], boresight[2]);
bsight_t = tmat*bsight_t;
_varray.push_back(bsight_t[0]);
_varray.push_back(bsight_t[1]);
_varray.push_back(bsight_t[2]);
_varray.push_back(2);
_varray.push_back(1.f);
_varray.push_back(0.f);
_varray.push_back(0.f);
_varray.push_back(1.f);
_iarray[1] = 1;
_stride = 8;
_vsize = _varray.size();
_vtotal = static_cast<int>(_vsize / _stride);
}
RenderableFov::~RenderableFov(){
deinitialize();
}
void RenderableFov::sendToGPU(){
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
GLsizei st = sizeof(GLfloat) * _stride;
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glBindVertexArray(0);
}
bool RenderableFov::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
_startTrail;
SpiceManager::ref().getETfromDate("2007 feb 26 12:00:00", _startTrail);
fullYearSweep();
sendToGPU();
return completeSuccess;
}
bool RenderableFov::deinitialize(){
delete _texture;
_texture = nullptr;
return true;
}
void RenderableFov::updateData(){
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
}
void RenderableFov::render(const RenderData& data){
assert(_programObject);
_programObject->activate();
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
glm::mat4 tmat = glm::mat4(1);
glm::mat4 rot_x = glm::rotate(tmat, 90.f, glm::vec3(1, 0, 0));
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = _stateMatrix[i][j];
}
}
tmat *= tmp;
tmat *= rot_x;
glm::mat4 transform(1);
// setup the data to the shader
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
//updateData();
glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, _vtotal);
glBindVertexArray(0);
_programObject->deactivate();
}
void RenderableFov::update(const UpdateData& data){
double lightTime;
_time = data.time;
_delta = data.delta;
openspace::SpiceManager::ref().getPositionTransformMatrix("NH_SPACECRAFT", "GALACTIC", data.time, _stateMatrix);
}
void RenderableFov::loadTexture()
{
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
}
}
}
}

View File

@@ -0,0 +1,232 @@
/*****************************************************************************************
* *
* 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/renderablepath.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/constants.h>
#include <ghoul/opengl/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/spicemanager.h>
#include <iomanip>
#include <utility>
namespace {
const std::string _loggerCat = "RenderablePath";
//constants
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
const std::string keyPathModule = "ModulePath";
const std::string keyColor = "RGB";
}
#define DEBUG
namespace openspace{
RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _texture(nullptr)
, _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
, _mode(GL_LINE_STRIP){
assert(dictionary.getValue(keyBody, _target));
assert(dictionary.getValue(keyObserver, _observer));
assert(dictionary.getValue(keyFrame, _frame));
/*assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
assert(dictionary.getValue(keyEarthOrbitRatio, _ratio));
assert(dictionary.getValue(keyDayLength, _day));//not used now, will be though.
// values in modfiles set from here*/
// http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
//white is default col
if (!dictionary.getValue(keyColor, _c)){
_c = glm::vec3(0.0);
}
else{
_r = 1 / _c[0];
_g = 1 / _c[1];
_b = 1 / _c[2];
}
}
void RenderablePath::fullYearSweep(){
double lightTime = 0.0;
SpiceManager::ref().getETfromDate("2006 jan 20 19:00:00", _time);
// -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
double et2 = 0;
//SpiceManager::ref().getETfromDate("2008 apr 01 00:00:00", et2);
//psc nhpos, nhvel;
//SpiceManager::ref().getTargetState("NEW HORIZONS", "SUN", "J2000", "LT+S", et2, _pscpos, _pscvel, lightTime);
double et = _time;
int segments = 200000;
_increment = 86400;
_isize = (segments + 2);
_vsize = (segments + 2);
_iarray = new int[_isize];
int indx = 0;
for (int i = 0; i < segments + 1; i++){
SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", et, _pscpos, _pscvel, lightTime);
if (_pscpos[0] != 0 && _pscpos[1] != 0 && _pscpos[2] != 0 && _pscpos[3] != 1){
_pscpos[3] += 3;
_varray.push_back(_pscpos[0]);
_varray.push_back(_pscpos[1]);
_varray.push_back(_pscpos[2]);
_varray.push_back(_pscpos[3]);
#ifndef DEBUG
_varray.push_back(1.f - ((double)i / _tropic * _r));
_varray.push_back(1.f - ((double)i / _tropic * _g));
_varray.push_back(1.f - ((double)i / _tropic * _b));
_varray.push_back(1.f - ((double)i / _tropic));
#else
_varray.push_back(1.f);
_varray.push_back(1.f);
_varray.push_back(1.f);
_varray.push_back(0.5f);
#endif
indx++;
_iarray[indx] = indx;
}
else{
std::string date;
SpiceManager::ref().getDateFromET(et, date);
std::cout << "STOPPED AT: " << date << std::endl;
break;
}
et += _increment;
}
_stride = 8;
_vsize = _varray.size();
_vtotal = static_cast<int>(_vsize / _stride);
}
RenderablePath::~RenderablePath(){
deinitialize();
}
bool RenderablePath::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
//TEXTURES DISABLED FOR NOW
//loadTexture();
completeSuccess &= (_texture != nullptr);
fullYearSweep();
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
GLsizei st = sizeof(GLfloat) * _stride;
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glBindVertexArray(0);
return completeSuccess;
}
bool RenderablePath::deinitialize(){
delete _texture;
_texture = nullptr;
return true;
}
void RenderablePath::render(const RenderData& data){
assert(_programObject);
_programObject->activate();
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
// PowerScaledScalar scaling = camera->scaling();
PowerScaledScalar scaling = glm::vec2(1, -6);
glm::mat4 transform = glm::mat4(1);
// setup the data to the shader
//_programObject->setUniform("objectVelocity", pscvel.vec4());
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
/* glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, _vtotal);
glBindVertexArray(0);
*/
glPointSize(2.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, _vtotal);
glBindVertexArray(0);
_programObject->deactivate();
}
void RenderablePath::update(const UpdateData& data){
double lightTime;
_time = data.time;
_delta = data.delta;
int newhorizons = 0;
SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", data.time, _pscpos, _pscvel, lightTime);
}
void RenderablePath::loadTexture()
{
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
}
}
}
}

View 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

View File

@@ -41,7 +41,7 @@ namespace {
namespace openspace {
// needs to be set from dictionary - REMEMBER
const PowerScaledScalar radius = PowerScaledScalar(1000.f, 6.f);
const PowerScaledScalar radius = PowerScaledScalar(1.f, 20.f);
RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
@@ -101,19 +101,6 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
if (round(y) == 0.0f) _varray[nr].tex[0] = -2;
_varray[nr].tex[1] = t2;
/* // we wont do this anymore, old code, now static grids. ignore or remove.
glm::mat4 rot = glm::rotate(glm::mat4(1), 90.f, glm::vec3(1, 0, 0));
glm::mat4 transform(1);
glm::dmat3 stateMatrix;
double initTime = 0;
openspace::SpiceManager::ref().getPositionTransformMatrixGLM("IAU_EARTH", "GALACTIC", 0, stateMatrix);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = stateMatrix[i][j];
}
}
*/
glm::vec4 tmp(x, y, z, 1);
glm::mat4 rot = glm::rotate(glm::mat4(1), 90.f, glm::vec3(1, 0, 0));
tmp = _gridMatrix*rot*tmp;
@@ -192,7 +179,7 @@ void RenderableSphericalGrid::render(const RenderData& data){
setPscUniforms(_gridProgram, &data.camera, data.position);
_gridProgram->setUniform("gridColor", _gridColor);
glLineWidth(1.0f);
//glLineWidth(1.0f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);

View File

@@ -0,0 +1,268 @@
/*****************************************************************************************
* *
* 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/renderabletrail.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/constants.h>
#include <ghoul/opengl/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/spicemanager.h>
#include <iomanip>
#include <utility>
namespace {
const std::string _loggerCat = "RenderableTrail";
//constants
const std::string keyBody = "Body";
const std::string keyObserver = "Observer";
const std::string keyFrame = "Frame";
const std::string keyPathModule = "ModulePath";
const std::string keyColor = "RGB";
const std::string keyTropicalOrbitPeriod = "TropicalOrbitPeriod";
const std::string keyEarthOrbitRatio = "EarthOrbitRatio";
const std::string keyDayLength = "DayLength";
}
//#define DEBUG
namespace openspace{
RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _texture(nullptr)
, _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
, _mode(GL_LINE_STRIP){
assert(dictionary.getValue(keyBody , _target));
assert(dictionary.getValue(keyObserver , _observer));
assert(dictionary.getValue(keyFrame , _frame));
assert(dictionary.getValue(keyTropicalOrbitPeriod, _tropic));
assert(dictionary.getValue(keyEarthOrbitRatio , _ratio));
assert(dictionary.getValue(keyDayLength , _day));//not used now, will be though.
// values in modfiles set from here
// http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html
//white is default col
if (!dictionary.getValue(keyColor, _c)){
_c = glm::vec3(0.0);
}else{
_r = 1 / _c[0];
_g = 1 / _c[1];
_b = 1 / _c[2];
}
}
void RenderableTrail::fullYearSweep(){
double lightTime = 0.0;
// -------------------------------------- ^ this has to be simulation start-time, not passed in here though --
if (_target == "JUPITER BARYCENTER"){
_tropic *= 20;
}
double et = _startTrail;
double planetYear = 31540000 * _ratio;
int segments = _tropic;
_increment = planetYear / _tropic;
_isize = (segments + 2);
_vsize = (segments + 2);
_iarray = new int[_isize];
double p = 1.0 / _tropic;
for (int i = 0; i < segments + 1; i++){
SpiceManager::ref().getTargetState(_target, _observer, _frame, "LT+S", et, _pscpos, _pscvel, lightTime);
_pscpos[3] += 3;
_varray.push_back(_pscpos[0]);
_varray.push_back(_pscpos[1]);
_varray.push_back(_pscpos[2]);
_varray.push_back(_pscpos[3]);
#ifndef DEBUG
_varray.push_back(1.f - ((double)i / _tropic * _r));
_varray.push_back(1.f - ((double)i / _tropic * _g));
_varray.push_back(1.f - ((double)i / _tropic * _b));
_varray.push_back(1.f - ((double)i / _tropic));
#else
_varray.push_back(1.f );
_varray.push_back(1.f );
_varray.push_back(1.f );
_varray.push_back(1.f );
#endif
_iarray[i] = i; // remove indx in this class at some point!
et -= _increment;
}
_stride = 8;
_vsize = _varray.size();
_vtotal = static_cast<int>(_vsize / _stride);
}
RenderableTrail::~RenderableTrail(){
deinitialize();
}
void RenderableTrail::sendToGPU(){
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(GLfloat), NULL, GL_STREAM_DRAW); // orphaning the buffer, sending NULL data.
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
GLsizei st = sizeof(GLfloat) * _stride;
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, st, (void*)(4 * sizeof(GLfloat)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glBindVertexArray(0);
}
bool RenderableTrail::initialize(){
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject);
//TEXTURES DISABLED FOR NOW
//loadTexture();
completeSuccess &= (_texture != nullptr);
_startTrail;
SpiceManager::ref().getETfromDate("2007 feb 26 12:00:00", _startTrail);
//SpiceManager::ref().getETfromDate("2006 aug 22 20:00:00", _startTrail);
fullYearSweep();
sendToGPU();
return completeSuccess;
}
bool RenderableTrail::deinitialize(){
delete _texture;
_texture = nullptr;
return true;
}
void RenderableTrail::updateTrail(){
if (_oldTime != _time){ // only update when time actually progresses
_dtprogress += _delta*sgct::Engine::instance()->getDt(); // compute how far time has progressed
if (_dtprogress > _increment){
//reset progress counter
_dtprogress = 0;
int m = 8;
for (int i = _vsize - 1; i + 1 - m != 0; i--){
_varray[i] = std::move(_varray[i - m]);
}
int n = 4;
while (n < _vsize - 8){
for (int i = 0; i < 4; i++){
_varray[n + i] = _varray[n + 8 + i];
}
n += 8;
}
//add last pt
_pscpos[3] += 3;
memcpy(&_varray[0], glm::value_ptr(_pscpos.vec4()), 4 * sizeof(double));
}
}_oldTime = _time;
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize * sizeof(GLfloat), &_varray[0]);
}
void RenderableTrail::render(const RenderData& data){
assert(_programObject);
_programObject->activate();
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
// PowerScaledScalar scaling = camera->scaling();
PowerScaledScalar scaling = glm::vec2(1, -6);
glm::mat4 transform = glm::mat4(1);
// setup the data to the shader
//_programObject->setUniform("objectVelocity", pscvel.vec4());
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
updateTrail();
glBindVertexArray(_vaoID);
glDrawArrays(_mode, 0, _vtotal);
glBindVertexArray(0);
/*
glPointSize(2.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, _vtotal);
glBindVertexArray(0);
*/
_programObject->deactivate();
}
void RenderableTrail::update(const UpdateData& data){
double lightTime;
_time = data.time;
_delta = data.delta;
SpiceManager::ref().getTargetState(_target, _observer, _frame, "NONE", data.time+_increment, _pscpos, _pscvel, lightTime);
}
void RenderableTrail::loadTexture()
{
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
}
}
}
}

View File

@@ -31,6 +31,7 @@
// ghoul includes
#include <ghoul/opengl/texturereader.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/cachemanager.h>
#include <iostream>
#include <iomanip>
@@ -150,7 +151,7 @@ ghoul::opengl::Texture* RenderableVolume::loadVolume(
ss << "." << dimensions[0] << "x" << dimensions[1] << "x" << dimensions[2] << "." << modelString << "." << variableCacheString << ".cache";
std::string cachepath; // = filepath + ss.str();
OsEng.cacheManager().getCachedFile(filepath, ss.str(), cachepath, true);
FileSys.cacheManager()->getCachedFile(filepath, ss.str(), cachepath, true);
if (cache && FileSys.fileExists(cachepath)) {
FILE* file = fopen (cachepath.c_str(), "rb");

View File

@@ -0,0 +1,406 @@
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
// temporary includes (will fix as soon as I figure out how class hierarchy should work,
// ie after I see model on screen)
#include<fstream>
// open space includes
#include <openspace/rendering/renderablewavefrontobject.h>
#include <openspace/util/constants.h>
#include <ghoul/opengl/texturereader.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/filesystem/filesystem.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include <openspace/engine/openspaceengine.h>
#include <sgct.h>
namespace {
const std::string _loggerCat = "RenderableWavefrontObject";
}
namespace openspace {
RenderableWavefrontObject::RenderableWavefrontObject(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _fovProgram(nullptr)
, _texture(nullptr)
{
std::string name;
bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
assert(success);
std::string path;
dictionary.getValue(constants::scenegraph::keyPathModule, path);
std::string texturePath = "";
if (dictionary.hasKey("Textures.Color")) {
dictionary.getValue("Textures.Color", texturePath);
_colorTexturePath = path + "/" + texturePath;
}
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableWavefrontObject::loadTexture, this));
_mode = GL_TRIANGLES;
std::string file;
dictionary.getValue(constants::renderablewavefrontobject::keyObjFile, file);
const std::string filename = FileSys.absolutePath(file);
std::cout << "OBJECT LOADER FILENAME : " << filename << std::endl;
std::ifstream ifile(filename.c_str());
if (ifile){
LDEBUG("Found file..\n");
ifile.close();
loadObj(filename.c_str());
}else {
LERROR("Did not find file..\n");
}
}
void RenderableWavefrontObject::loadObj(const char *filename){
// temporary
int vertexSize = 0;
int vertexNormalSize = 0;
int vertexTextureSize = 0;
int indicesSize = 0;
float f1, f2, f3;
int i1, i2, i3, i4, i5, i6, i7, i8, i9;
char line[150];
float maxtex = 0.0;
FILE *fi;
// START LINE COUNT
fi = fopen(filename, "r");
if (fi == NULL) {
LERROR("Null Object\n");
}
while (fgets(line, 150, fi) != NULL)
{
if (sscanf(line, "v %f%f%f", &f1, &f2, &f3)) {
vertexSize += 4;
}
if (sscanf(line, "vn %f%f%f", &f1, &f2, &f3)) {
vertexNormalSize += 3;
}
if (sscanf(line, "vt %f%f%f", &f1, &f2, &f3)) {
vertexTextureSize += 3;
}
if (vertexTextureSize > 0) {
if (sscanf(line, "f %i/%i/%i %i/%i/%i %i/%i/%i", &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)) {
indicesSize += 3;
}
}
else {
if (sscanf(line, "f %i//%i %i//%i %i//%i", &i1, &i2, &i3, &i4, &i5, &i6)) {
indicesSize += 3;
}
}
}
/* END LINE COUNT */
// allocate memory for all arrays
_isize = indicesSize;
_vsize = indicesSize;
// float arrays
float *tempVertexArray = (float*)malloc(vertexSize*sizeof(float));
float *tempVertexNormalArray = (float*)malloc(vertexNormalSize*sizeof(float));
float *tempVertexTextureArray = (float*)malloc(vertexTextureSize*sizeof(float));
_varray = (Vertex*)malloc(_vsize*sizeof(Vertex));
// int arrays
_iarray = (int*)malloc(_isize*sizeof(int));
int *tempNormalIndicesArray = (int*)malloc(_isize*sizeof(int));
int *tempTextureIndicesArray = (int*)malloc(_isize*sizeof(int));
// keeping track of the array indexes
unsigned int i = 0;
unsigned int n = 0;
unsigned int m = 0;
unsigned int w = 0;
// Go back to beginning of file
fseek(fi, 0, SEEK_SET);
while (fgets(line, 150, fi) != NULL){
if (sscanf(line, "v %f%f%f", &f1, &f2, &f3)){
(tempVertexArray)[i] = f1;
i++;
(tempVertexArray)[i] = f2;
i++;
(tempVertexArray)[i] = f3;
i++;
}
if (sscanf(line, "vn %f%f%f", &f1, &f2, &f3)){
(tempVertexNormalArray)[n] = f1;
n++;
(tempVertexNormalArray)[n] = f2;
n++;
(tempVertexNormalArray)[n] = f3;
n++;
}
if (sscanf(line, "vt %f%f%f", &f1, &f2, &f3)){
(tempVertexTextureArray)[w] = f1;
w++;
(tempVertexTextureArray)[w] = f2;
w++;
(tempVertexTextureArray)[w] = f3;
w++;
}
if (vertexTextureSize > 0){
if (sscanf(line, "f %i/%i/%i %i/%i/%i %i/%i/%i", &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)){
(_iarray)[m] = i1 - 1;
(tempTextureIndicesArray)[m] = i2 - 1;
(tempNormalIndicesArray)[m] = i3 - 1;
m++;
(_iarray)[m] = i4 - 1;
(tempTextureIndicesArray)[m] = i5 - 1;
(tempNormalIndicesArray)[m] = i6 - 1;
m++;
(_iarray)[m] = i7 - 1;
(tempTextureIndicesArray)[m] = i8 - 1;
(tempNormalIndicesArray)[m] = i9 - 1;
m++;
}
}
else{
if (sscanf(line, "f %i//%i %i//%i %i//%i", &i1, &i2, &i3, &i4, &i5, &i6)){
(_iarray)[m] = i1 - 1;
(tempNormalIndicesArray)[m] = i2 - 1;
m++;
(_iarray)[m] = i3 - 1;
(tempNormalIndicesArray)[m] = i4 - 1;
m++;
(_iarray)[m] = i5 - 1;
(tempNormalIndicesArray)[m] = i6 - 1;
m++;
}
}
}
fclose(fi);
// end of file read
// creating the vertex array
i = 0; n = 0; m = 0;
int normalIndex = 0;
int textureIndex = 0;
int vertexIndex = 0;
while (m < _vsize){
normalIndex = tempNormalIndicesArray[m] * 3;
textureIndex = tempTextureIndicesArray[m] * 3;
vertexIndex = _iarray[m] * 3;
_iarray[m] = m;
_varray[m].location[3] = 2;
int q = 0;
while (q < 3){
_varray[m].location[q] = tempVertexArray[vertexIndex + q];
_varray[m].normal[q] = tempVertexNormalArray[normalIndex + q];
q++;
}
if (vertexTextureSize > 0){
_varray[m].tex[0] = tempVertexTextureArray[textureIndex];
_varray[m].tex[1] = tempVertexTextureArray[textureIndex + 1];
}
else{
_varray[m].tex[0] = 1.0;
_varray[m].tex[1] = 1.0;
}
m++;
}
// free up memory
free(tempVertexArray);
free(tempVertexNormalArray);
free(tempNormalIndicesArray);
free(tempVertexTextureArray);
free(tempTextureIndicesArray);
}
RenderableWavefrontObject::~RenderableWavefrontObject(){
deinitialize();
}
bool RenderableWavefrontObject::initialize()
{
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess
&= OsEng.ref().configurationManager().getValue("pscShader", _programObject);
loadTexture();
completeSuccess &= (_texture != nullptr);
//completeSuccess &= _geometry->initialize(this);
PowerScaledScalar ps = PowerScaledScalar(1,2);
setBoundingSphere(ps);
GLuint errorID;
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vBufferID);
glGenBuffers(1, &_iBufferID);
glBindVertexArray(_vaoID);
glBindBuffer(GL_ARRAY_BUFFER, _vBufferID);
glBufferData(GL_ARRAY_BUFFER, _vsize * sizeof(Vertex), _varray, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, location)));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, tex)));
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
reinterpret_cast<const GLvoid*>(offsetof(Vertex, normal)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, _isize * sizeof(int), _iarray, GL_STATIC_DRAW);
glBindVertexArray(0);
errorID = glGetError();
if (errorID != GL_NO_ERROR) {
LERROR("OpenGL error: " << glewGetErrorString(errorID));
return false;
}
return completeSuccess;
}
bool RenderableWavefrontObject::deinitialize()
{
delete[] _varray;
delete[] _iarray;
glDeleteBuffers(1, &_vBufferID);
glDeleteBuffers(1, &_iBufferID);
glDeleteVertexArrays(1, &_vaoID);
delete _texture;
_texture = nullptr;
return true;
}
void RenderableWavefrontObject::render(const RenderData& data)
{
if (!_programObject)
return;
if (!_texture)
return;
// activate shader
_programObject->activate();
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = data.camera.viewRotationMatrix();
// PowerScaledScalar scaling = camera->scaling();
// scale the planet to appropriate size since the planet is a unit sphere
glm::mat4 transform = glm::mat4(1);
glm::mat4 scaler = glm::scale(transform, glm::vec3(0, 0, -1));
//earth needs to be rotated for that to work.
glm::mat4 rot_x = glm::rotate(transform, 90.f, glm::vec3(1, 0, 0));
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = _stateMatrix[i][j];
}
}
transform *= tmp;
transform *= rot_x;
glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
glm::vec4 camSpaceEye = -(modelview*currentPosition.vec4());
// setup the data to the shader
// _programObject->setUniform("camdir", camSpaceEye);
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
// Bind texture
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_programObject->setUniform("texture1", unit);
// render
glBindVertexArray(_vaoID); // select first VAO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _iBufferID);
glDrawElements(_mode, _isize, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
// disable shader
_programObject->deactivate();
std::string shape, name;
shape.resize(32);
name.resize(32);
std::vector<glm::dvec3> bounds;
glm::dvec3 boresight;
bool found = openspace::SpiceManager::ref().getFieldOfView("NH_LORRI", shape, name, boresight, bounds);
glm::vec4 a(boresight, 1);
a = transform*a;
//std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;
}
void RenderableWavefrontObject::update(const UpdateData& data)
{
glm::dvec3 position(0, 0, 0);
// set spice-orientation in accordance to timestamp
openspace::SpiceManager::ref().getPositionTransformMatrix("NH_SPACECRAFT", "GALACTIC", data.time, _stateMatrix);
}
void RenderableWavefrontObject::loadTexture()
{
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::opengl::loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
}
}
}
} // namespace openspace

View File

@@ -30,6 +30,7 @@
#include <openspace/util/time.h>
// We need to decide where this is set
#include <openspace/util/constants.h>
#include <openspace/util/time.h>
#include <openspace/util/spicemanager.h>
#include "sgct.h"
@@ -73,7 +74,11 @@ RenderEngine::RenderEngine()
, _sceneGraph(nullptr)
, _abuffer(nullptr)
, _takeScreenshot(false)
, _log(nullptr)
, _showInfo("info", "Display info", true)
, _showScreenLog("log", "Display screen log", true)
{
setName("renderEngine");
}
RenderEngine::~RenderEngine()
@@ -115,10 +120,10 @@ bool RenderEngine::initializeGL()
// set the close clip plane and the far clip plane to extreme values while in
// development
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f,100.0f);
sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 1000.00f);
sgct::Engine::instance()->setNearAndFarClippingPlanes(0.0001f, 100.0f);
sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 200.0f);
sgct::Engine::instance()->setNearAndFarClippingPlanes(0.01f,10000.0f);
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 1000.00f);
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.0001f, 100.0f);
// sgct::Engine::instance()->setNearAndFarClippingPlanes(0.1f, 200.0f);
// calculating the maximum field of view for the camera, used to
// determine visibility of objects in the scene graph
@@ -134,7 +139,8 @@ bool RenderEngine::initializeGL()
// set the tilted view and the FOV
_mainCamera->setCameraDirection(glm::vec3(viewdir[0], viewdir[1], viewdir[2]));
_mainCamera->setMaxFov(wPtr->getFisheyeFOV());
_mainCamera->setMaxFov(wPtr->getFisheyeFOV());
_mainCamera->setLookUpVector(glm::vec3(0.0, 1.0, 0.0));
} else {
// get corner positions, calculating the forth to easily calculate center
glm::vec3 corners[4];
@@ -178,6 +184,9 @@ bool RenderEngine::initializeGL()
_abuffer->initialize();
_log = new ScreenLog();
ghoul::logging::LogManager::ref().addLog(_log);
// successful init
return true;
}
@@ -199,12 +208,15 @@ void RenderEngine::postSynchronizationPreDraw()
// converts the quaternion used to rotation matrices
_mainCamera->compileViewRotationMatrix();
UpdateData a = { Time::ref().currentTime(), Time::ref().deltaTime() };
//std::cout << a.delta << std::endl;
// update and evaluate the scene starting from the root node
_sceneGraph->update({Time::ref().currentTime()});
_sceneGraph->update(a);
_mainCamera->setCameraDirection(glm::vec3(0, 0, -1));
_sceneGraph->evaluate(_mainCamera);
// clear the abuffer before rendering the scene
_abuffer->clear();
}
@@ -213,6 +225,7 @@ void RenderEngine::render()
// SGCT resets certain settings
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_BLEND);
// setup the camera for the current frame
const glm::vec3 eyePosition
@@ -237,66 +250,116 @@ void RenderEngine::render()
_abuffer->preRender();
_sceneGraph->render({*_mainCamera, psc()});
_abuffer->postRender();
_abuffer->resolve();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
_abuffer->resolve();
glDisable(GL_BLEND);
#ifndef OPENSPACE_VIDEO_EXPORT
// Print some useful information on the master viewport
if (sgct::Engine::instance()->isMaster()) {
// Apple usually has retina screens
#ifdef __APPLE__
#define FONT_SIZE 18
#else
#define FONT_SIZE 10
#endif
const glm::vec2 scaling = _mainCamera->scaling();
const glm::vec3 viewdirection = _mainCamera->viewDirection();
const psc position = _mainCamera->position();
const psc origin = OsEng.interactionHandler().getOrigin();
const PowerScaledScalar pssl = (position - origin).length();
/* GUI PRINT */
std::string&& time = Time::ref().currentTimeUTC().c_str();
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 18, "Date: %s", time.c_str()
);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 16, "Avg. Frametime: %.10f", sgct::Engine::instance()->getAvgDt()
);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 14, "Drawtime: %.10f", sgct::Engine::instance()->getDrawTime()
);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 12, "Frametime: %.10f", sgct::Engine::instance()->getDt()
);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 10, "Origin: (%.5f, %.5f, %.5f, %.5f)", origin[0],
origin[1], origin[2], origin[3]);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 8, "Camera position: (%.5f, %.5f, %.5f, %.5f)",
position[0], position[1], position[2], position[3]);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 6, "Distance to origin: (%.15f, %.2f)", pssl[0],
pssl[1]);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 4, "View direction: (%.3f, %.3f, %.3f)",
viewdirection[0], viewdirection[1], viewdirection[2]);
Freetype::print(
sgct_text::FontManager::instance()->getFont("SGCTFont", FONT_SIZE),
FONT_SIZE, FONT_SIZE * 2, "Scaling: (%.10f, %.2f)", scaling[0], scaling[1]);
}
sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr();
if (sgct::Engine::instance()->isMaster() && ! w->isUsingFisheyeRendering()) {
// TODO: Adjust font_size properly when using retina screen
const int font_size_mono = 10;
const int font_size_light = 8;
const int font_with_light = font_size_light*0.7;
const sgct_text::Font* fontLight = sgct_text::FontManager::instance()->getFont(constants::fonts::keyLight, font_size_light);
const sgct_text::Font* fontMono = sgct_text::FontManager::instance()->getFont(constants::fonts::keyMono, font_size_mono);
if (_showInfo) {
const sgct_text::Font* font = fontMono;
int x1, xSize, y1, ySize;
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
int startY = ySize - 2 * font_size_mono;
const glm::vec2 scaling = _mainCamera->scaling();
const glm::vec3 viewdirection = _mainCamera->viewDirection();
const psc position = _mainCamera->position();
const psc origin = OsEng.interactionHandler().getOrigin();
const PowerScaledScalar pssl = (position - origin).length();
// GUI PRINT
// Using a macro to shorten line length and increase readability
#define PrintText(i, format, ...) Freetype::print(font, 10, startY - font_size_mono * i * 2, format, __VA_ARGS__);
int i = 0;
PrintText(i++, "Date: %s", Time::ref().currentTimeUTC().c_str());
PrintText(i++, "Avg. Frametime: %.5f", sgct::Engine::instance()->getAvgDt());
PrintText(i++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime());
PrintText(i++, "Frametime: %.5f", sgct::Engine::instance()->getDt());
PrintText(i++, "Origin: (% .5f, % .5f, % .5f, % .5f)", origin[0], origin[1], origin[2], origin[3]);
PrintText(i++, "Cam pos: (% .5f, % .5f, % .5f, % .5f)", position[0], position[1], position[2], position[3]);
PrintText(i++, "View dir: (% .5f, % .5f, % .5f)", viewdirection[0], viewdirection[1], viewdirection[2]);
PrintText(i++, "Cam->origin: (% .15f, % .4f)", pssl[0], pssl[1]);
PrintText(i++, "Scaling: (% .5f, % .5f)", scaling[0], scaling[1]);
#undef PrintText
}
if (_showScreenLog)
{
const sgct_text::Font* font = fontLight;
const int max = 10;
const int category_length = 20;
const int msg_length = 140;
const double ttl = 15.0;
const double fade = 5.0;
auto entries = _log->last(max);
const glm::vec4 white(0.9, 0.9, 0.9, 1);
const glm::vec4 red(1, 0, 0, 1);
const glm::vec4 yellow(1, 1, 0, 1);
const glm::vec4 green(0, 1, 0, 1);
const glm::vec4 blue(0, 0, 1, 1);
size_t nr = 1;
for (auto it = entries.first; it != entries.second; ++it) {
const ScreenLog::LogEntry* e = &(*it);
const double t = sgct::Engine::instance()->getTime();
double diff = t - e->timeStamp;
// Since all log entries are ordered, once one is exceeding TTL, all have
if (diff > ttl)
break;
float alpha = 1;
float ttf = ttl - fade;
if (diff > ttf) {
diff = diff - ttf;
float p = 0.8 - diff / fade;
alpha = (p <= 0.0) ? 0.0 : pow(p, 0.3);
}
// Since all log entries are ordered, once one exceeds alpha, all have
if (alpha <= 0.0)
break;
std::string lvl = "(" + ghoul::logging::LogManager::stringFromLevel(e->level) + ")";
Freetype::print(font, 10, font_size_light * nr * 2, white*alpha,
"%-14s %s%s", // Format
e->timeString.c_str(), // Time string
e->category.substr(0, category_length).c_str(), // Category string (up to category_length)
e->category.length() > 20 ? "..." : ""); // Pad category with "..." if exceeds category_length
glm::vec4 color = white;
if (e->level == ghoul::logging::LogManager::LogLevel::Debug)
color = green;
if (e->level == ghoul::logging::LogManager::LogLevel::Warning)
color = yellow;
if (e->level == ghoul::logging::LogManager::LogLevel::Error)
color = red;
if (e->level == ghoul::logging::LogManager::LogLevel::Fatal)
color = blue;
Freetype::print(font, 10 + 39 * font_with_light, font_size_light * nr * 2, color*alpha, "%s", lvl.c_str());
Freetype::print(font, 10 + 53 * font_with_light, font_size_light * nr * 2, white*alpha, "%s", e->message.substr(0, msg_length).c_str());
++nr;
}
}
#endif
}
}

View File

@@ -57,7 +57,7 @@ int printOglError(char *file, int line){
#define GLSPRITES
#define GLPOINTS
//#define GLPOINTS
namespace {
const std::string _loggerCat = "RenderableStars";
@@ -101,21 +101,6 @@ std::ifstream& RenderableStars::skipToLine(std::ifstream& file, unsigned int num
return file;
}
//these two methods exist only to debug geom shaders code.
float log10(float x){ return log(x)/ log(10.f); }
psc psc_addition(psc v1, psc v2) {
float k = 10.f;
float ds = v2[3] - v1[3];
if (ds >= 0) {
float p = pow(k, -ds);
return psc(v1[0]*p + v2[0], v1[1]*p + v2[1], v1[2]*p + v2[2], v2[3]);
}
else {
float p = pow(k, ds);
return psc(v1[0] + v2[0]*p, v1[1] + v2[1]*p, v1[2] + v2[2]*p, v1[3]);
}
}
//#define ROTATESTARS
@@ -325,7 +310,6 @@ void RenderableStars::render(const RenderData& data){
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
//glBlendFunc(GL_ONE, GL_ONE_MINUS_DST_COLOR);
#ifdef GLSPRITES
glm::mat4 modelMatrix = data.camera.modelMatrix();
@@ -356,11 +340,11 @@ void RenderableStars::render(const RenderData& data){
_haloProgram->deactivate();
#ifdef GLPOINTS
/*
// ---------------------- RENDER POINTS -----------------------------
_pointProgram->activate();
_pointProgram->setUniform("ViewProjection", camera->viewProjectionMatrix());
_pointProgram->setUniform("ViewProjection", data.camera.viewProjectionMatrix);
_pointProgram->setUniform("ModelTransform", transform);
_pointProgram->setUniform("campos", campos.vec4());
_pointProgram->setUniform("objpos", currentPosition.vec4());
@@ -377,13 +361,10 @@ void RenderableStars::render(const RenderData& data){
glDisable(GL_BLEND);
_pointProgram->deactivate();
<<<<<<< HEAD
glEnable(GL_DEPTH_TEST);
=======
*/
//>>>>>>> develop
#endif
glDisable(GL_BLEND);
}
void RenderableStars::loadTexture(){

View File

@@ -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 {
@@ -175,6 +177,16 @@ bool SceneGraph::initialize()
_programs.push_back(tmpProgram);
OsEng.ref().configurationManager().setValue("pscShader", tmpProgram);
// pscstandard
tmpProgram = ProgramObject::Build("EphemerisProgram",
"${SHADERS}/ephemeris_vs.glsl",
"${SHADERS}/ephemeris_fs.glsl",
cb);
if (!tmpProgram) return false;
_programs.push_back(tmpProgram);
OsEng.ref().configurationManager().setValue("EphemerisProgram", tmpProgram);
// RaycastProgram
tmpProgram = ProgramObject::Build("RaycastProgram",
"${SHADERS}/exitpoints.vert",
@@ -213,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);
@@ -245,7 +266,6 @@ void SceneGraph::update(const UpdateData& data)
OsEng.renderEngine().abuffer()->invalidateABuffer();
}
for (auto node : _nodes)
node->update(data);
}
@@ -327,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 +
@@ -343,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();
@@ -350,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));
}
}
@@ -419,13 +446,15 @@ bool SceneGraph::loadSceneInternal(const std::string& sceneDescriptionFilePath)
const PowerScaledScalar bound = positionNode->calculateBoundingSphere();
// this part is full of magic!
glm::vec2 boundf = bound.vec2();
glm::vec2 boundf = bound.vec2();
glm::vec2 scaling{1.0f, -boundf[1]};
boundf[0] *= 5.0f;
psc cameraPosition = positionNode->position();
cameraPosition += psc(glm::vec4(0.f, 0.f, boundf));
cameraPosition = psc(glm::vec4(0.f, 0.f, 1.f,0.f));
c->setPosition(cameraPosition);
c->setCameraDirection(glm::vec3(0, 0, -1));
c->setScaling(scaling);
@@ -439,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;

View File

@@ -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";
}
@@ -216,7 +217,7 @@ void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition)
// evaluate all the children, tail-recursive function(?)
for (auto& child : _children) {
child->evaluate(camera, thisPosition);
child->evaluate(camera, psc());
}
}
@@ -283,7 +284,9 @@ const std::vector<SceneGraphNode*>& SceneGraphNode::children() const{
PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){
// set the bounding sphere to 0.0
_boundingSphere = 0.0;
//_boundingSphere = 1000.0;
_boundingSphere = 1000.0;
_boundingSphere = 0.0;
if (_children.size() > 0) { // node
PowerScaledScalar maxChild;
@@ -309,7 +312,7 @@ PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){
_boundingSphere = renderableBS;
}
LWARNING(name() << ": " << _boundingSphere);
return _boundingSphere;
}

View File

@@ -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,59 +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];
if (!_kernelsLoadedSuccessfully)
return;
glm::dvec3 position(0,0,0);
double lightTime = 0.0;
SpiceManager::ref().getTargetPosition(_targetName, _originName, "GALACTIC", "LT+S", data.time, position, lightTime);
/*
std::cout << _targetName << " (";
std::cout << position[0] << ", ";
std::cout << position[1] << ", ";
std::cout << position[2] << ")";
std::cout << std::endl;
assert(_targetName != "JUPITER");
*/
SpiceManager::ref().getTargetPosition(_targetName, _originName, "GALACTIC", "NONE", data.time, position, lightTime);
_position = psc::CreatePowerScaledCoordinate(position.x, position.y, position.z);
_position[3] -= 0.01;
//_position[3] += 1;
//_position[3] += 3;
_position[3] += 3;
}
} // namespace openspace

View File

@@ -37,7 +37,8 @@ namespace openspace {
Camera::Camera()
: _cameraDirection(0.f, 0.f, 0.f)
, _scaling(1.f, 0.f)
, _viewRotation(glm::quat(glm::vec3(0.f, 0.f, 0.f)))
//, _viewRotation(glm::quat(glm::vec3(0.f, 0.f, 0.f)))
, _viewRotationMatrix(1.f)
{
}
@@ -99,37 +100,46 @@ glm::vec3 Camera::cameraDirection() const
return _cameraDirection;
}
const glm::mat4& Camera::viewRotationMatrix() const
glm::mat4 Camera::viewRotationMatrix() const
{
return _viewRotationMatrix;
return glm::mat4(_viewRotationMatrix);
}
void Camera::compileViewRotationMatrix()
{
// convert from quaternion to rotation matrix using glm
_viewRotationMatrix = glm::mat4_cast(_viewRotation);
//_viewRotationMatrix = glm::mat4_cast(_viewRotation);
// the camera matrix needs to be rotated inverse to the world
_viewDirection = glm::rotate(glm::inverse(_viewRotation), _cameraDirection);
// _viewDirection = glm::rotate(glm::inverse(_viewRotation), _cameraDirection);
_viewDirection = (glm::inverse(_viewRotationMatrix) * glm::vec4(_cameraDirection, 0.f)).xyz;
_viewDirection = glm::normalize(_viewDirection);
}
void Camera::rotate(const glm::quat& rotation)
{
_viewRotation = rotation * _viewRotation;
_viewRotation = glm::normalize(_viewRotation);
glm::mat4 tmp = glm::mat4_cast(rotation);
_viewRotationMatrix = _viewRotationMatrix * tmp;
//_viewRotation = rotation * _viewRotation;
//_viewRotation = glm::normalize(_viewRotation);
}
void Camera::setRotation(glm::quat rotation)
{
_viewRotation = glm::normalize(std::move(rotation));
//_viewRotation = glm::normalize(std::move(rotation));
_viewRotationMatrix = glm::mat4_cast(rotation);
}
const glm::quat& Camera::rotation() const
void Camera::setRotation(glm::mat4 rotation)
{
return _viewRotation;
_viewRotationMatrix = std::move(rotation);
}
//const glm::quat& Camera::rotation() const
//{
// return _viewRotation;
//}
const glm::vec3& Camera::viewDirection() const
{
return _viewDirection;

View File

@@ -27,12 +27,18 @@
#include <cassert>
// renderables
#include <openspace/rendering/renderablewavefrontobject.h>
#include <openspace/rendering/stars/renderablestars.h>
#include <openspace/rendering/renderableephemeris.h>
#include <openspace/rendering/renderabletrail.h>
#include <openspace/rendering/renderablepath.h>
#include <openspace/rendering/renderablefov.h>
#include <openspace/rendering/renderablesphericalgrid.h>
#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>
@@ -60,10 +66,23 @@ void FactoryManager::initialize()
"RenderablePlanet");
_manager->factory<Renderable>()->registerClass<RenderableStars>(
"RenderableStars");
_manager->factory<Renderable>()->registerClass<RenderableEphemeris>(
"RenderableEphemeris");
//will replace ephemeris class soon...
_manager->factory<Renderable>()->registerClass<RenderablePath>(
"RenderablePath");
_manager->factory<Renderable>()->registerClass<RenderableTrail>(
"RenderableTrail");
_manager->factory<Renderable>()->registerClass<RenderableFov>(
"RenderableFov");
_manager->factory<Renderable>()->registerClass<RenderableSphericalGrid>(
"RenderableSphericalGrid");
_manager->factory<Renderable>()->registerClass<RenderableWavefrontObject>(
"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");

View File

@@ -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];
@@ -467,7 +467,7 @@ std::vector<glm::vec3> KameleonWrapper::traceCartesianFieldline(
else if (pos.z < 0.0 && (pos.x*pos.x + pos.y*pos.y + pos.z*pos.z < 1.0))
end = FieldlineEnd::SOUTH;
else
end = FieldlineEnd::OUT;
end = FieldlineEnd::FAROUT;
return line;
}
@@ -610,15 +610,15 @@ glm::vec4 KameleonWrapper::classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEn
&& (bEnd == FieldlineEnd::NORTH || bEnd == FieldlineEnd::SOUTH)) {
// closed
color = glm::vec4(1.0, 0.0, 0.0, 1.0);
} else if ((fEnd == FieldlineEnd::OUT && bEnd == FieldlineEnd::NORTH)
|| (bEnd == FieldlineEnd::OUT && fEnd == FieldlineEnd::NORTH)) {
} else if ((fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::NORTH)
|| (bEnd == FieldlineEnd::FAROUT && fEnd == FieldlineEnd::NORTH)) {
// north
color = glm::vec4(1.0, 1.0, 0.0, 1.0);
} else if ((fEnd == FieldlineEnd::OUT && bEnd == FieldlineEnd::SOUTH)
|| (bEnd == FieldlineEnd::OUT && fEnd == FieldlineEnd::SOUTH)) {
} else if ((fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::SOUTH)
|| (bEnd == FieldlineEnd::FAROUT && fEnd == FieldlineEnd::SOUTH)) {
// south
color = glm::vec4(0.0, 1.0, 0.0, 1.0);
} else if (fEnd == FieldlineEnd::OUT && bEnd == FieldlineEnd::OUT) {
} else if (fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::FAROUT) {
// solar wind
color = glm::vec4(0.0, 0.0, 1.0, 1.0);
}

View File

@@ -71,7 +71,7 @@ PowerScaledCoordinate::PowerScaledCoordinate(const PowerScaledCoordinate& rhs) {
PowerScaledCoordinate
PowerScaledCoordinate::CreatePowerScaledCoordinate(double d1, double d2, double d3)
{
char buff[30];
char buff[600];
// find the number with maximum number of digits
double ad1 = abs(d1);
@@ -84,6 +84,8 @@ PowerScaledCoordinate
sprintf(buff, "%.0f", max);
unsigned int digits = static_cast<unsigned int>(strlen(buff));
//digits += 3;
// rescale and return
double tp = 1.0 / pow(k, digits);
return PowerScaledCoordinate(d1 * tp, d2 * tp, d3 * tp, digits);

View File

@@ -77,6 +77,8 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen
const float t1 = fj / fsegments;
const float t2 = fi / fsegments;
double tp = 1.0 / pow(10, static_cast<GLfloat>(radius[1]));
_varray[nr].location[0] = x;
_varray[nr].location[1] = y;
_varray[nr].location[2] = z;
@@ -85,6 +87,7 @@ PowerScaledSphere::PowerScaledSphere(const PowerScaledScalar& radius, int segmen
_varray[nr].normal[1] = normal[1];
_varray[nr].normal[2] = normal[2];
//std::cout << _varray[nr].location[0] << " " << _varray[nr].location[1] << " " << _varray[nr].location[2] << " " << _varray[nr].location[3] << std::endl;
_varray[nr].tex[0] = t1;
_varray[nr].tex[1] = t2;
++nr;

51
src/util/screenlog.cpp Normal file
View File

@@ -0,0 +1,51 @@
/*****************************************************************************************
* *
* 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/util/screenlog.h>
#include <sgct.h> // sgct::Engine::instance()->getTime()
namespace openspace {
ScreenLog::ScreenLog() {}
void ScreenLog::log(ghoul::logging::LogManager::LogLevel level, const std::string& category, const std::string& message) {
if (level >= ghoul::logging::LogManager::LogLevel::Info)
_entries.emplace_back(level, sgct::Engine::instance()->getTime(), Log::getTimeString(), category, message);
// Once reaching maximum size, reduce to half
if (_entries.size() > MaximumSize) {
_entries.erase(_entries.begin(), _entries.begin() + MaximumSize / 2);
}
}
ScreenLog::const_range ScreenLog::last(size_t n) {
if (_entries.size() > n) {
return std::make_pair(_entries.rbegin(), _entries.rbegin() + n);
} else {
return std::make_pair(_entries.rbegin(), _entries.rend());
}
}
}

View File

@@ -31,6 +31,7 @@
#include <algorithm>
namespace {
const std::string _loggerCat = "SpiceManager";
}
@@ -67,20 +68,31 @@ SpiceManager& SpiceManager::ref() {
return *_manager;
}
SpiceManager::KernelIdentifier SpiceManager::loadKernel(std::string filePath) {
SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& filePath) {
if (filePath.empty()) {
LERROR("No filename provided");
return KernelFailed;
}
std::string&& path = absPath(filePath);
if (!FileSys.fileExists(path)) {
LERROR("Kernel file '" << path << "' does not exist");
return KernelFailed;
}
KernelIdentifier kernelId = ++_lastAssignedKernel;
// 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
@@ -88,6 +100,15 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(std::string filePath) {
// Reset the current directory to the previous one
FileSys.setCurrentDirectory(currentDirectory);
int failed = failed_c();
if (failed) {
char msg[1024];
getmsg_c ( "LONG", 1024, msg );
LERROR("Error loading kernel '" + path + "'");
LERROR("Spice reported: " + std::string(msg));
reset_c();
return KernelFailed;
}
bool hasError = checkForError("Error loading kernel '" + path + "'");
if (hasError)
@@ -268,6 +289,27 @@ bool SpiceManager::getTargetPosition(const std::string& target,
return !hasError;
}
bool SpiceManager::getTargetPosition(const std::string& target,
const std::string& observer,
const std::string& referenceFrame,
const std::string& aberrationCorrection,
double ephemerisTime,
psc& position,
double& lightTime) const
{
double pos[3] = { NULL, NULL, NULL };
spkpos_c(target.c_str(), ephemerisTime, referenceFrame.c_str(),
aberrationCorrection.c_str(), observer.c_str(), pos, &lightTime);
if (pos[0] == NULL || pos[1] == NULL || pos[2] == NULL)
return false;
position = PowerScaledCoordinate::CreatePowerScaledCoordinate(pos[0], pos[1], pos[2]);
return true;
}
bool SpiceManager::getTargetState(const std::string& target,
const std::string& observer,
const std::string& referenceFrame,
@@ -293,6 +335,27 @@ bool SpiceManager::getTargetState(const std::string& target,
return !hasError;
}
bool SpiceManager::getTargetState(const std::string& target,
const std::string& observer,
const std::string& referenceFrame,
const std::string& aberrationCorrection,
double ephemerisTime,
PowerScaledCoordinate& position,
PowerScaledCoordinate& velocity,
double& lightTime) const
{
double state[6];
std::fill_n(state, 6, NULL);
spkezr_c(target.c_str(), ephemerisTime, referenceFrame.c_str(),
aberrationCorrection.c_str(), observer.c_str(), state, &lightTime);
position = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[0], state[1], state[2]);
velocity = PowerScaledCoordinate::CreatePowerScaledCoordinate(state[3], state[4], state[5]);
return true;
}
bool SpiceManager::getStateTransformMatrix(const std::string& fromFrame,
const std::string& toFrame,
double ephemerisTime,
@@ -307,6 +370,23 @@ bool SpiceManager::getStateTransformMatrix(const std::string& fromFrame,
return !hasError;
}
bool SpiceManager::getPositionPrimeMeridian(const std::string& fromFrame,
const std::string& body,
double ephemerisTime,
glm::dmat3& positionMatrix) const{
int id;
getNaifId(body.c_str(), id);
tipbod_c(fromFrame.c_str(), id, ephemerisTime, (double(*)[3])glm::value_ptr(positionMatrix));
bool hasError = checkForError("Error retrieving position transform matrix from "
"frame '" + fromFrame + "' to frame '" + body +
"at time '" + std::to_string(ephemerisTime) + "'");
positionMatrix = glm::transpose(positionMatrix);
return !hasError;
}
bool SpiceManager::getPositionTransformMatrix(const std::string& fromFrame,
const std::string& toFrame,
double ephemerisTime,
@@ -316,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;
@@ -334,6 +414,7 @@ bool SpiceManager::getFieldOfView(const std::string& instrument, std::string& fo
return getFieldOfView(id, fovShape, frameName, boresightVector, bounds);
}
bool SpiceManager::getFieldOfView(int instrument,
std::string& fovShape,
std::string& frameName,