Merged master into NewAtmosphere.

This commit is contained in:
Jonathas Costa
2017-05-24 16:53:34 -04:00
72 changed files with 1457 additions and 733 deletions
@@ -93,6 +93,8 @@ public:
/// The key that stores the verbosity (None, Minimal, Default, Full) of the system
/// capabilities components
static const std::string PartCapabilitiesVerbosity;
/// The key that stores the settings for determining Launcher-related settings
static const std::string KeyLauncher;
/// The full key that stores the verbosity of the system capabilities component
static const std::string KeyCapabilitiesVerbosity;
/// The key that stores the time (in seconds) that the application will wait before
@@ -65,7 +65,6 @@ public:
// Interaction mode setters
void setCameraStateFromDictionary(const ghoul::Dictionary& cameraDict);
void setInteractionMode(const std::string& interactionModeKey);
InteractionMode* interactionMode();
void goToChunk(int x, int y, int level);
@@ -73,9 +72,10 @@ public:
void resetKeyBindings();
void addKeyframe(const datamessagestructures::CameraKeyframe &kf);
void addKeyframe(double timestamp, KeyframeInteractionMode::CameraPose pose);
void removeKeyframesAfter(double timestamp);
void clearKeyframes();
size_t nKeyframes() const;
const std::vector<datamessagestructures::CameraKeyframe>& keyframes() const;
void bindKeyLocal(
@@ -134,7 +134,7 @@ private:
std::string generateJson() const override;
void setInteractionMode(std::shared_ptr<InteractionMode> interactionMode);
void setInteractionMode(InteractionMode* interactionMode);
bool _cameraUpdatedFromScript = false;
@@ -143,14 +143,18 @@ private:
std::unique_ptr<InputState> _inputState;
Camera* _camera;
std::shared_ptr<InteractionMode> _currentInteractionMode;
InteractionMode* _currentInteractionMode;
std::map<std::string, std::shared_ptr<InteractionMode>> _interactionModes;
std::shared_ptr<OrbitalInteractionMode::MouseStates> _mouseStates;
std::unique_ptr<OrbitalInteractionMode> _orbitalInteractionMode;
std::unique_ptr<GlobeBrowsingInteractionMode> _globeBrowsingInteractionMode;
std::unique_ptr<KeyframeInteractionMode> _keyframeInteractionMode;
// Properties
properties::StringProperty _origin;
properties::OptionProperty _interactionModeOption;
properties::BoolProperty _rotationalFriction;
properties::BoolProperty _horizontalFriction;
properties::BoolProperty _verticalFriction;
+10 -13
View File
@@ -28,6 +28,7 @@
#include <openspace/network/parallelconnection.h>
#include <openspace/util/mouse.h>
#include <openspace/util/keys.h>
#include <openspace/util/timeline.h>
#ifdef OPENSPACE_MODULE_GLOBEBROWSING_ENABLED
#include <modules/globebrowsing/tile/tileindex.h>
@@ -80,14 +81,6 @@ namespace interaction {
void mousePositionCallback(double mouseX, double mouseY);
void mouseScrollWheelCallback(double mouseScrollDelta);
// Mutators
void addKeyframe(const datamessagestructures::CameraKeyframe &kf);
void removeKeyframesAfter(double timestamp);
void clearKeyframes();
void clearOldKeyframes();
static bool compareKeyframeTimes(const datamessagestructures::CameraKeyframe& a, const datamessagestructures::CameraKeyframe& b);
// Accessors
const std::list<std::pair<Key, KeyModifier> >& getPressedKeys() const;
const std::list<MouseButton>& getPressedMouseButtons() const;
@@ -104,9 +97,6 @@ namespace interaction {
std::list<MouseButton> _mouseButtonsDown;
glm::dvec2 _mousePosition;
double _mouseScrollDelta;
// Remote input via keyframes
std::vector<datamessagestructures::CameraKeyframe> _keyframes;
};
@@ -194,16 +184,23 @@ protected:
class KeyframeInteractionMode : public InteractionMode
{
public:
struct CameraPose {
glm::dvec3 position;
glm::quat rotation;
std::string focusNode;
bool followFocusNodeRotation;
};
KeyframeInteractionMode();
~KeyframeInteractionMode();
virtual void updateMouseStatesFromInput(const InputState& inputState, double deltaTime);
virtual void updateCameraStateFromMouseStates(Camera& camera, double deltaTime);
bool followingNodeRotation() const override;
Timeline<CameraPose>& timeline();
private:
std::vector<datamessagestructures::CameraKeyframe> _keyframes;
double _currentKeyframeTime;
Timeline<CameraPose> _cameraPoseTimeline;
};
class GlobeBrowsingInteractionMode;
@@ -28,12 +28,19 @@
#include <openspace/network/parallelconnection.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/vector/vec4property.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/util/keys.h>
#include <string>
#include <vector>
namespace ghoul {
namespace opengl {
class ProgramObject;
} // namespace opengl
} // namespace ghoul
namespace openspace {
class LuaConsole : public properties::PropertyOwner {
@@ -46,7 +53,9 @@ public:
bool keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
void charCallback(unsigned int codepoint, KeyModifier modifier);
void update();
void render();
float currentHeight() const;
private:
void parallelConnectionChanged(const ParallelConnection::Status& status);
@@ -55,6 +64,14 @@ private:
properties::BoolProperty _isVisible;
properties::BoolProperty _remoteScripting;
properties::Vec4Property _backgroundColor;
properties::Vec4Property _highlightColor;
properties::Vec4Property _separatorColor;
properties::Vec4Property _entryTextColor;
properties::Vec4Property _historyTextColor;
properties::IntProperty _historyLength;
size_t _inputPosition;
std::vector<std::string> _commandsHistory;
size_t _activeCommand;
@@ -65,6 +82,17 @@ private:
bool hasInitialValue;
std::string initialValue;
} _autoCompleteInfo;
float _currentHeight;
float _targetHeight;
float _fullHeight;
std::shared_ptr<ghoul::fontrendering::Font> _font;
std::shared_ptr<ghoul::fontrendering::Font> _historyFont;
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
GLuint _vao;
GLuint _vbo;
};
} // namespace openspace
+22 -14
View File
@@ -68,9 +68,9 @@ public:
*/
enum class Visibility {
All = 3, ///< Visible for all types, no matter what
Developer = 2, ///< Visible in Developer mode
User = 1, ///< Visible in User mode
Hidden = 0 ///< Never visible
Hidden = 2, ///< Never visible
Developer = 1, ///< Visible in Developer mode
User = 0 ///< Visible in User mode
};
/**
@@ -292,6 +292,18 @@ public:
*/
void setReadOnly(bool state);
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are: Property::ViewOptions::Color = <code>color</code>,
* Property::ViewOptions::LightPosition = <code>lightPosition</code>,
* Property::ViewOptions::PowerScaledScalar = <code>powerScaledScalar</code>, and
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
*/
struct ViewOptions {
static const char* Color;
static const char* LightPosition;
};
/**
* This method allows the developer to give hints to the GUI about different
* representations for the GUI. The same Property (for example Vec4Property) can be
@@ -307,18 +319,14 @@ public:
void setViewOption(std::string option, bool value = true);
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are: Property::ViewOptions::Color = <code>color</code>,
* Property::ViewOptions::LightPosition = <code>lightPosition</code>,
* Property::ViewOptions::PowerScaledScalar = <code>powerScaledScalar</code>, and
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
* This method returns the state of a \p option hint. See Property::ViewOptions for a
* default list of possible options. As these are only hints, the GUI is free to
* ignore any suggestion by the developer.
* \param option The view option that should be retrieved
* \param defaultValue The value that is returned if the \p option was not set
* \return The view option's value
*/
struct ViewOptions {
static const char* Color;
static const char* LightPosition;
static const char* PowerScaledScalar;
static const char* PowerScaledCoordinate;
};
bool viewOption(const std::string& option, bool defaultValue = false) const;
/**
* Returns the metaData that contains all information for external applications to
+3 -24
View File
@@ -55,8 +55,6 @@ namespace openspace {
* The synchronization of the simulation time requires
*/
class SyncBuffer;
class Time {
public:
/**
@@ -90,20 +88,6 @@ public:
static Time now();
/**
* Returns the reference to the Time singleton object.
* \return The reference to the Time singleton object
* \pre The Time singleton must have been initialized
*/
static Time& ref();
/**
* 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
@@ -210,15 +194,10 @@ public:
*/
static scripting::LuaLibrary luaLibrary();
std::vector<Syncable*> getSyncables();
private:
static Time* _instance; ///< The singleton instance
SyncData<double> _time;
SyncData<double> _dt;
SyncData<bool> _timeJumped;
double _time;
double _dt;
bool _timeJumped;
bool _timePaused = false;
};
+96
View File
@@ -0,0 +1,96 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 __OPENSPACE_CORE___TIMELINE___H__
#define __OPENSPACE_CORE___TIMELINE___H__
#include <algorithm>
#include <deque>
#include <cstddef>
namespace openspace {
/**
* Base class for keyframes
*/
struct KeyframeBase {
size_t id;
double timestamp;
};
/**
* Templated class for keyframes containing data
*/
template <typename T>
struct Keyframe : public KeyframeBase {
Keyframe(size_t i, double t, T p)
: KeyframeBase{i, t}
, data(p)
{}
T data;
};
/**
* Templated class for timelines
*/
template <typename T>
class Timeline {
public:
Timeline();
virtual ~Timeline();
void addKeyframe(double time, T data);
void clearKeyframes();
void removeKeyframe(size_t id);
void removeKeyframesBefore(double timestamp, bool inclusive = false);
void removeKeyframesAfter(double timestamp, bool inclusive = false);
void removeKeyframesBetween(double begin, double end, bool inclusiveBegin = false, bool inclusiveEnd = false);
size_t nKeyframes() const;
const Keyframe<T>* firstKeyframeAfter(double timestamp, bool inclusive = false) const;
const Keyframe<T>* lastKeyframeBefore(double timestamp, bool inclusive = false) const;
const std::deque<Keyframe<T>>& keyframes() const;
private:
size_t _nextKeyframeId;
std::deque<Keyframe<T>> _keyframes;
};
/**
* Return true if the timestamp of a is smaller the timestamp of b.
*/
bool compareKeyframeTimes(const KeyframeBase& a, const KeyframeBase& b);
/**
* Return true if a is smaller than the timestamp of b.
*/
bool compareTimeWithKeyframeTime(double a, const KeyframeBase& b);
/**
* Return true if the timestamp of a is smaller than b.
*/
bool compareKeyframeTimeWithTime(const KeyframeBase& a, double b);
} // namespace openspace
#include <openspace/util/timeline.inl>;
#endif // __OPENSPACE_CORE___TIMELINE___H__
+121
View File
@@ -0,0 +1,121 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 {
template <typename T>
Timeline<T>::Timeline()
: _nextKeyframeId(1)
{}
template <typename T>
Timeline<T>::~Timeline() {}
template <typename T>
void Timeline<T>::addKeyframe(double timestamp, T data) {
Keyframe<T> keyframe(++_nextKeyframeId, timestamp, data);
auto iter = std::upper_bound(_keyframes.begin(), _keyframes.end(), keyframe, &compareKeyframeTimes);
_keyframes.insert(iter, keyframe);
}
template <typename T>
void Timeline<T>::removeKeyframesAfter(double timestamp, bool inclusive) {
auto iter = inclusive
? std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime)
: std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime);
_keyframes.erase(iter, _keyframes.end());
}
template <typename T>
void Timeline<T>::removeKeyframesBefore(double timestamp, bool inclusive) {
auto iter = inclusive
? std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime)
: std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime);
_keyframes.erase(_keyframes.begin(), iter);
}
template <typename T>
void Timeline<T>::removeKeyframesBetween(double begin, double end, bool inclusiveBegin, bool inclusiveEnd) {
auto beginIter = inclusiveBegin
? std::lower_bound(_keyframes.begin(), _keyframes.end(), begin, &compareKeyframeTimeWithTime)
: std::upper_bound(_keyframes.begin(), _keyframes.end(), begin, &compareTimeWithKeyframeTime);
auto endIter = inclusiveEnd
? std::upper_bound(beginIter, _keyframes.end(), end, &compareTimeWithKeyframeTime)
: std::lower_bound(beginIter, _keyframes.end(), end, &compareKeyframeTimeWithTime);
_keyframes.erase(beginIter, endIter);
}
template <typename T>
void Timeline<T>::clearKeyframes() {
_keyframes.clear();
}
template <typename T>
void Timeline<T>::removeKeyframe(size_t id) {
_keyframes.erase(std::remove_if(_keyframes.begin(), _keyframes.end(), [id] (Keyframe<T> keyframe) {
return keyframe.id == id;
}), _keyframes.end());
}
template <typename T>
size_t Timeline<T>::nKeyframes() const {
return _keyframes.size();
}
template <typename T>
const Keyframe<T>* Timeline<T>::firstKeyframeAfter(double timestamp, bool inclusive) const {
auto it = inclusive
? std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime)
: std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime);
if (it == _keyframes.end()) {
return nullptr;
}
return &(*it);
}
template <typename T>
const Keyframe<T>* Timeline<T>::lastKeyframeBefore(double timestamp, bool inclusive) const {
auto it = inclusive
? std::upper_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareTimeWithKeyframeTime)
: std::lower_bound(_keyframes.begin(), _keyframes.end(), timestamp, &compareKeyframeTimeWithTime);
if (it == _keyframes.begin()) {
return nullptr;
}
it--;
return &(*it);
}
template<typename T>
const std::deque<Keyframe<T>>& Timeline<T>::keyframes() const {
return _keyframes;
}
}
+9 -7
View File
@@ -27,24 +27,26 @@
#include <vector>
#include <deque>
#include <openspace/network/messagestructures.h>
#include <openspace/util/timeline.h>
#include <openspace/util/time.h>
#include <openspace/util/syncdata.h>
namespace openspace {
class TimeManager {
public:
Time& time();
std::vector<Syncable*> getSyncables();
void preSynchronization(double dt);
void addKeyframe(const datamessagestructures::TimeKeyframe& kf);
void addKeyframe(double timestamp, Time kf);
void removeKeyframesBefore(double timestamp);
void removeKeyframesAfter(double timestamp);
void clearKeyframes();
const std::deque<datamessagestructures::TimeKeyframe>& keyframes() const;
size_t nKeyframes() const;
private:
Timeline<Time> _timeline;
SyncData<Time> _currentTime;
void consumeKeyframes(double dt);
std::deque<datamessagestructures::TimeKeyframe> _keyframes;
static bool compareKeyframeTimes(
const datamessagestructures::TimeKeyframe& a,
const datamessagestructures::TimeKeyframe& b);
double _latestConsumedTimestamp;
};
+4 -5
View File
@@ -27,6 +27,7 @@
#include <openspace/util/camera.h>
#include <openspace/util/powerscaledcoordinate.h>
#include <openspace/util/time.h>
namespace openspace {
@@ -45,11 +46,8 @@ struct TransformData {
struct UpdateData {
TransformData modelTransform;
double time;
double delta;
bool timePaused;
bool isTimeJump;
bool doPerformanceMeasurement;
const Time time;
const bool doPerformanceMeasurement;
};
@@ -58,6 +56,7 @@ struct RenderData {
// psc position to be removed in favor of the double precision position defined in
// the translation in transform.
psc position;
const Time time;
bool doPerformanceMeasurement;
int renderBinMask;
TransformData modelTransform;