Merge branch 'develop' into stars

Conflicts:
	include/openspace/util/constants.h
	shaders/pscstandard_fs.glsl
	shaders/pscstandard_vs.glsl
	src/interaction/interactionhandler.cpp
	src/main.cpp
	src/rendering/renderengine.cpp
	src/scenegraph/scenegraph.cpp
	src/scenegraph/scenegraphnode.cpp
	src/util/factorymanager.cpp
This commit is contained in:
Jonas Strandstedt
2014-09-24 15:39:22 +02:00
135 changed files with 10844 additions and 3182 deletions

View File

@@ -34,6 +34,8 @@ namespace openspaceengine {
const std::string keyPathScene = "Paths.SCENEPATH";
const std::string keyConfigSgct = "SGCTConfig";
const std::string keyConfigScene = "Scene";
const std::string keyStartupScript = "StartupScripts";
const std::string keyConfigTimekernel = "SpiceTimeKernel";
} // namespace openspaceengine
namespace scenegraph {
@@ -64,16 +66,33 @@ namespace renderablestars {
const std::string keyPathModule = "ModulePath";
} // namespace renderablestars
namespace renderablevolumegl {
const std::string keyVolume = "Volume";
const std::string keyHints = "Hints";
const std::string keyTransferFunction = "TransferFunction";
const std::string keySampler = "Sampler";
const std::string keyBoxScaling = "BoxScaling";
const std::string keyVolumeName = "VolumeName";
const std::string keyTransferFunctionName = "TransferFunctionName";
} // namespace renderablevolumegl
namespace planetgeometry {
const std::string keyType = "Type";
} // namespace planetgeometry
namespace ephemeris {
const std::string keyType = "Type";
} // namespace ephemeris
namespace staticephemeris {
const std::string keyPosition = "Position";
} // namespace staticephemeris
namespace spiceephemeris {
const std::string keyBody = "Body";
const std::string keyOrigin = "Observer";
} // namespace spiceephemeris
} // namespace constants
} // namespace openspace

View File

@@ -25,7 +25,6 @@
#ifndef KAMELEONWRAPPER_H_
#define KAMELEONWRAPPER_H_
#include <glm/glm.hpp>
#include <glm/gtx/std_based_type.hpp>
namespace ccmc {
@@ -35,6 +34,16 @@ namespace ccmc {
namespace openspace {
struct LinePoint {
glm::vec3 position;
glm::vec4 color;
LinePoint(glm::vec3 pos, glm::vec4 col) {
position = pos;
color = col;
}
};
class KameleonWrapper {
public:
@@ -43,14 +52,58 @@ public:
BATSRUS // Magnetosphere
};
enum class TraceDirection {
FORWARD = 1,
BACK = -1
};
enum class FieldlineEnd {
NORTH,
SOUTH,
OUT
};
KameleonWrapper(const std::string& filename, Model model);
~KameleonWrapper();
float* getUniformSampledValues(const std::string& var, glm::size3_t outDimensions);
float* getUniformSampledVectorValues(const std::string& xVar, const std::string& yVar,
const std::string& zVar, glm::size3_t outDimensions);
std::vector<std::vector<LinePoint> > getClassifiedFieldLines(const std::string& xVar,
const std::string& yVar, const std::string& zVar,
std::vector<glm::vec3> seedPoints, float stepSize);
std::vector<std::vector<LinePoint> > getFieldLines(const std::string& xVar,
const std::string& yVar, const std::string& zVar,
std::vector<glm::vec3> seedPoints, float stepSize, glm::vec4 color);
std::vector<std::vector<LinePoint> > getLorentzTrajectories(std::vector<glm::vec3> seedPoints,
glm::vec4 color, float stepsize);
glm::vec3 getModelBarycenterOffset();
private:
std::vector<glm::vec3> traceCartesianFieldline(const std::string& xVar,
const std::string& yVar, const std::string& zVar, glm::vec3 seedPoint,
float stepSize, TraceDirection direction, FieldlineEnd& end);
std::vector<glm::vec3> traceLorentzTrajectory(glm::vec3 seedPoint,
float stepsize, float eCharge);
void getGridVariables(std::string& x, std::string& y, std::string& z);
void progressBar(int current, int end);
glm::vec4 classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEnd);
ccmc::Model* _model;
Model _type;
ccmc::Interpolator* _interpolator;
// Model parameters
float _xMin, _xMax, _yMin, _yMax, _zMin, _zMax;
std::string _xCoordVar, _yCoordVar, _zCoordVar;
// For progressbar
int _lastiProgress;
};
} // namespace openspace

View File

@@ -0,0 +1,60 @@
/*****************************************************************************************
* *
* 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 __SHADERCREATOR_H__
#define __SHADERCREATOR_H__
#include <ghoul/opengl/programobject.h>
#include <string>
namespace openspace {
class ShaderCreator {
public:
ShaderCreator();
~ShaderCreator();
void createSourceFile(bool b);
void sourceFileExtension(const std::string& extension);
void sourceFileHeader(const std::string& header);
ghoul::opengl::ProgramObject* buildShader(const std::string& name, const std::string& vpath, const std::string& fpath, const std::string& gpath = "");
private:
void _generateSource(const std::string& filename);
std::string _loadSource(const std::string& filename, unsigned int depth = 0);
std::string _generateFilename(const std::string& filename);
bool _createSourceFile;
std::string _sourceFileExtension;
std::string _sourceFileHeader;
unsigned int _maxDepth;
};
}
#endif

View File

@@ -92,19 +92,19 @@ public:
* \param kernelPoolValueName Item for which values are desired. ("RADII", "NUT_PREC_ANGLES", etc. )
* \return Whether the function succeeded or not
*/
bool SpiceManager::getValueFromID(const std::string& bodyname,
bool getValueFromID(const std::string& bodyname,
const std::string& kernelPoolValueName,
double& value) const;
/* Overloaded method for 3dim vectors, see above specification.*/
bool SpiceManager::getValueFromID(const std::string& bodyname,
bool getValueFromID(const std::string& bodyname,
const std::string& kernelPoolValueName,
glm::dvec3& value) const;
/* Overloaded method for 4dim vectors, see above specification.*/
bool SpiceManager::getValueFromID(const std::string& bodyname,
bool getValueFromID(const std::string& bodyname,
const std::string& kernelPoolValueName,
glm::dvec4& value) const;
/* Overloaded method for Ndim vectors, see above specification.*/
bool SpiceManager::getValueFromID(const std::string& bodyname,
bool getValueFromID(const std::string& bodyname,
const std::string& kernelPoolValueName,
std::vector<double>& values, unsigned int num) const;
@@ -119,7 +119,19 @@ public:
* \param epochString, A string representing an epoch.
* \return Corresponding ephemeris time, equivalent value in seconds past J2000, TDB.
*/
double stringToEphemerisTime(const std::string& epochString) const;
double convertStringToTdbSeconds(const std::string& epochString) const;
/**
* Convert the number of TDB seconds past the J2000 epoch into a human readable
* string representation. Fur further details, please refer to 'timout_c' in SPICE
* Documentation
*
* \param seconds The number of seconds that have passed since the J2000 epoch
* \param format The output format of the string
* (see ftp://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html)
* \return The formatted date string
*/
std::string convertTdbSecondsToString(double seconds, const std::string& format) const;
// Computing Positions of Spacecraft and Natural Bodies(SPK) ---------------------------- //
@@ -337,7 +349,7 @@ private:
struct spiceKernel {
std::string path;
std::string name;
int id;
unsigned int id;
};
std::vector<spiceKernel> _loadedKernels;
unsigned int _kernelCount = 0;
@@ -382,6 +394,21 @@ public:
data = new double[N*N];
empty = true;
}
void transform(glm::dvec3& position) {
assert(!empty); // transformation matrix is empty
double *state;
double *state_t;
state = new double[N];
state_t = new double[N];
COPY(state, &position);
mxvg_c(data, state, N, N, state_t);
COPY(&position, state_t);
}
/** As the spice function mxvg_c requires a 6dim vector
* the two 3dim state vectors are packed into 'state'.
* Transformed values are then copied back from state_t
@@ -394,8 +421,8 @@ public:
* the method ignores its second argument.
*/
void transform(glm::dvec3& position,
glm::dvec3& velocity = glm::dvec3()){
assert(("transformation matrix is empty", !empty));
glm::dvec3& velocity) {
assert(!empty); // transformation matrix is empty
double *state;
double *state_t;
@@ -414,7 +441,7 @@ public:
* asserts matrix has been filled
*/
inline double operator()(int i, int j) const{
assert(("transformation matrix is empty", !empty));
assert(!empty); // transformation matrix is empty
return data[j + i*N];
}
};

View File

@@ -1,31 +1,167 @@
#ifndef ENGINETIME_H
#define ENGINETIME_H
/*****************************************************************************************
* *
* 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. *
****************************************************************************************/
namespace openspace
{
#ifndef __TIME_H__
#define __TIME_H__
#include <openspace/scripting/scriptengine.h>
#include <string>
namespace openspace {
/**
* This singleton class represents the current simulation time in OpenSpace. It
* internally stores the time and provides methods to set the time directly
* (setTime(double), setTime(std::string)) using a <code>double</code> value using the
* number of seconds passed since the J2000 epoch or a <code>string</code> that denotes
* a valid date string in accordance to the Spice library
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html). The time can
* be retrieved as the number of seconds since the J2000 epoch with currentTime() or as a
* UTC string following ISO 8601 with the method currentTimeUTC().
*
* In addition to the time itself, it also stores a delta time value. This value denotes
* the number of seconds that pass for each real-time second. This value is set with
* setDeltaTime(double), retrieved with deltaTime() and solely used in the
* advanceTime(double), which takes a <code>tickTime</code> parameter. The value of the
* parameter is dependent on the usage of the class and must be equal to the real-world
* time that has passed since the last call to the method. For example, if the
* advanceTime(double) method is called each frame, the <code>tickTime</code> has to be
* equal to the frame time.
*/
class Time {
public:
virtual ~Time();
/**
* Initializes the Time singleton and loads an LSK spice kernel with the provided
* name.
* \param lskKernel The name of the kernel that should be loaded during the
* initialization. If the parameter is empty, no kernel will be loaded
* \return <code>true</code> if the initialization succeeded, <code>false</code>
* otherwise
*/
static bool initialize(const std::string& lskKernel = "");
static void init();
static void deinit();
/**
* Deinitializes the Time singleton. This method will not unload the kernel that was
* possibly loaded during the initialize method.
*/
static void deinitialize();
/**
* Returns the reference to the Time singleton object.
* \return The reference to the Time singleton object
*/
static Time& ref();
static bool isInitialized();
void setTime(const char* stringTime);
double getTime();
/**
* Returns <code>true</code> if the singleton has been successfully initialized,
* <code>false</code> otherwise
* \return <code>true</code> if the singleton has been successfully initialized,
* <code>false</code> otherwise
*/
static bool isInitialized();
/**
* Sets the current time to the specified value in seconds past the J2000 epoch. This
* value can be negative to represent dates before the epoch.
* \param The number of seconds after the J2000 epoch
*/
void setTime(double value);
/**
* Sets the current time to the specified value given as a Spice compliant string as
* described in the Spice documentation
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html)
* \param time The time to be set as a date string
*/
void setTime(std::string time);
/**
* Returns the current time as the number of seconds past the J2000 epoch. If the
* current time is a date before that epoch, the returned value will be negative.
* \return The current time as the number of seconds past the J2000 epoch
*/
double currentTime() const;
/**
* Returns the current time as a formatted date string compliant with ISO 8601 and
* thus also compliant with the Spice library.
* \return The current time as a formatted date string
*/
std::string currentTimeUTC() const;
/**
* Sets the delta time value that is the number of seconds that should pass for each
* real-time second. This value is used in the advanceTime(double) method to easily
* advance the simulation time.
* \param deltaT The number of seconds that should pass for each real-time second
*/
void setDeltaTime(double deltaT);
/**
* Returns the delta time, that is the number of seconds that pass in the simulation
* for each real-time second
* \return The number of seconds that pass for each real-time second
*/
double deltaTime() const;
/**
* Advances the simulation time using the deltaTime() and the <code>tickTime</code>.
* The deltaTime() is the number of simulation seconds that pass for each real-time
* second. <code>tickTime</code> is the number of real-time seconds that passed since
* the last call to this method. If this method is called in the render loop, the
* <code>tickTime</code> should be equivalent to the frame time.
* \param tickTime The number of real-time seconds that passed since the last call
* to this method
* \return The new time value after advancing the time
*/
double advanceTime(double tickTime);
/**
* Returns the Lua library that contains all Lua functions available to change the
* current time, retrieve the current time etc. The functions contained are
* - openspace::luascriptfunctions::time_setDeltaTime
* - openspace::luascriptfunctions::time_deltaTime
* - openspace::luascriptfunctions::time_setTime
* - openspace::luascriptfunctions::time_currentTime
* - openspace::luascriptfunctions::time_currentTimeUTC
* \return The Lua library that contains all Lua functions available to change the
* Time singleton
*/
static scripting::ScriptEngine::LuaLibrary luaLibrary();
private:
static Time* this_;
Time(void);
Time(const Time& src);
Time& operator=(const Time& rhs);
/// Creates the time object. Only used in the initialize() method
Time();
Time(const Time& src) = delete;
Time& operator=(const Time& rhs) = delete;
double time_;
static Time* _instance; ///< The singleton instance
double _time; ///< The time stored as the number of seconds past the J2000 epoch
double _deltaTimePerSecond; ///< The delta time that is used to advance the time
};
} // namespace openspace
#endif
#endif // __TIME_H__