mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 11:09:37 -06:00
Merged with master to prepare for pull request
This commit is contained in:
@@ -8,6 +8,6 @@ The project stems from the same academic collaboration between Sweden’s [Link
|
||||
|
||||
OpenSpace requires graphics support for [OpenGL](https://www.opengl.org/) version 3.3.
|
||||
|
||||
This repository contains the source code and example scenes for OpenSpace, but does not contain any data. To build and install the client, we refer to the [OpenSpace Wiki](http://wiki.openspaceproject.com/), specifically [building](http://wiki.openspaceproject.com/developer/compiling/general) for [Windows](http://wiki.openspaceproject.com/developer/compiling/windows), [Linux (Ubuntu)](http://wiki.openspaceproject.com/developer/compiling/ubuntu), and [MacOS](http://wiki.openspaceproject.com/developer/compiling/macos). Required preexisting dependencies are: [Boost](http://www.boost.org/) and [Qt](http://www.qt.io/download). Feel free to create issues for missing features, bug reports, or compile problems or contact us via [email](mailto:alexander.bock@me.com?subject=OpenSpace:).
|
||||
This repository contains the source code and example scenes for OpenSpace, but does not contain any data. To build and install the client, we refer to the [OpenSpace Wiki](http://wiki.openspaceproject.com/), specifically [building](http://wiki.openspaceproject.com/docs/developers/compiling/general) for [Windows](http://wiki.openspaceproject.com/docs/developers/compiling/windows), [Linux (Ubuntu)](http://wiki.openspaceproject.com/docs/developers/compiling/ubuntu), and [MacOS](http://wiki.openspaceproject.com/docs/developers/compiling/macos). Required preexisting dependencies are: [Boost](http://www.boost.org/) and [Qt](http://www.qt.io/download). Feel free to create issues for missing features, bug reports, or compile problems or contact us via [email](mailto:alexander.bock@me.com?subject=OpenSpace:).
|
||||
|
||||
Regarding any issues, you are very welcome on our [Slack support channel](https://openspacesupport.slack.com) to which you can freely [sign-up](https://join.slack.com/t/openspacesupport/shared_invite/enQtMjUxNzUyMTQ1ODQxLTI4YjNmMTY3ZDI1N2Q1NWM1ZjQ1NTQyNzAxM2YyMGQ5Y2NmYWJiNjI1NjU4YTkyNTc5ZDE5NzdhNGM2YmUzYTk).
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <openspace/properties/scalar/doubleproperty.h>
|
||||
#include <openspace/properties/triggerproperty.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
@@ -143,8 +144,8 @@ private:
|
||||
properties::FloatProperty _followAnchorNodeRotationDistance;
|
||||
properties::FloatProperty _minimumAllowedDistance;
|
||||
properties::FloatProperty _flightDestinationDistance;
|
||||
properties::DoubleProperty _flightDestinationFactor;
|
||||
properties::BoolProperty _applyLinearFlight;
|
||||
|
||||
|
||||
properties::FloatProperty _velocitySensitivity;
|
||||
properties::FloatProperty _mouseSensitivity;
|
||||
|
||||
@@ -784,4 +784,22 @@ float RenderableLabels::unit(int unit) const {
|
||||
}
|
||||
}
|
||||
|
||||
std::string RenderableLabels::toString(int unit) const {
|
||||
switch (static_cast<Unit>(unit)) {
|
||||
case Meter: return MeterUnit;
|
||||
case Kilometer: return KilometerUnit;
|
||||
case Megameter: return MegameterUnit;
|
||||
case Gigameter: return GigameterUnit;
|
||||
case AU: return AstronomicalUnit;
|
||||
case Terameter: return TerameterUnit;
|
||||
case Petameter: return PetameterUnit;
|
||||
case Parsec: return ParsecUnit;
|
||||
case Kiloparsec: return KiloparsecUnit;
|
||||
case Megaparsec: return MegaparsecUnit;
|
||||
case Gigaparsec: return GigaparsecUnit;
|
||||
case GigalightYears: return GigalightyearUnit;
|
||||
default: throw std::logic_error("Missing case label");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -74,6 +74,8 @@ protected:
|
||||
|
||||
float unit(int unit) const;
|
||||
|
||||
std::string toString(int unit) const;
|
||||
|
||||
// Data may require some type of transformation prior the spice transformation being
|
||||
// applied.
|
||||
glm::dmat4 _transformationMatrix = glm::dmat4(1.0);
|
||||
|
||||
@@ -57,6 +57,8 @@ private:
|
||||
std::vector<unsigned int> _indexBufferData;
|
||||
};
|
||||
|
||||
static double importAngleValue(const std::string& angle);
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_MODULE_SPACE___RENDERABLESMALLBODY___H__
|
||||
|
||||
@@ -42,6 +42,20 @@ namespace {
|
||||
"Property to track a nodeline. When tracking the label text will be updating the "
|
||||
"distance from the nodeline start and end."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DistanceUnitInfo = {
|
||||
"DistanceUnit",
|
||||
"Distance Unit",
|
||||
"Property to define the unit in which the distance should be displayed."
|
||||
"Defaults to 'km' if not specified."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo CustomUnitDescriptorInfo = {
|
||||
"CustomUnitDescriptor",
|
||||
"Custom Unit Descriptor",
|
||||
"Property to define a custom unit descriptor to use to describe the distance value."
|
||||
"Defaults to the units SI descriptor if not specified."
|
||||
};
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -58,6 +72,18 @@ documentation::Documentation RenderableDistanceLabel::Documentation() {
|
||||
Optional::No,
|
||||
NodeLineInfo.description
|
||||
},
|
||||
{
|
||||
DistanceUnitInfo.identifier,
|
||||
new IntVerifier,
|
||||
Optional::Yes,
|
||||
DistanceUnitInfo.description
|
||||
},
|
||||
{
|
||||
CustomUnitDescriptorInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::Yes,
|
||||
CustomUnitDescriptorInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -65,6 +91,8 @@ documentation::Documentation RenderableDistanceLabel::Documentation() {
|
||||
RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictionary)
|
||||
: RenderableLabels(dictionary)
|
||||
, _nodelineId(NodeLineInfo)
|
||||
, _distanceUnit(DistanceUnitInfo, 1, 0, 11)
|
||||
, _customUnitDescriptor(CustomUnitDescriptorInfo)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
@@ -76,6 +104,16 @@ RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictio
|
||||
_nodelineId = dictionary.value<std::string>(NodeLineInfo.identifier);
|
||||
addProperty(_nodelineId);
|
||||
}
|
||||
if (dictionary.hasKey(DistanceUnitInfo.identifier)) {
|
||||
_distanceUnit = static_cast<int>(
|
||||
dictionary.value<double>(DistanceUnitInfo.identifier)
|
||||
);
|
||||
addProperty(_distanceUnit);
|
||||
}
|
||||
if (dictionary.hasKey(CustomUnitDescriptorInfo.identifier)) {
|
||||
_customUnitDescriptor = dictionary.value<std::string>(CustomUnitDescriptorInfo.identifier);
|
||||
addProperty(_customUnitDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableDistanceLabel::update(const UpdateData&) {
|
||||
@@ -87,7 +125,6 @@ void RenderableDistanceLabel::update(const UpdateData&) {
|
||||
|
||||
SceneGraphNode* nodelineNode = RE.scene()->sceneGraphNode(_nodelineId);
|
||||
if (nodelineNode) {
|
||||
// Calculate distance
|
||||
RenderableNodeLine* nodeline = dynamic_cast<RenderableNodeLine*>(
|
||||
nodelineNode->renderable()
|
||||
);
|
||||
@@ -97,15 +134,23 @@ void RenderableDistanceLabel::update(const UpdateData&) {
|
||||
return;
|
||||
}
|
||||
|
||||
double myDistance = nodeline->distance();
|
||||
// Get used unit scale
|
||||
const float scale = unit(_distanceUnit);
|
||||
|
||||
// Format string
|
||||
float scale = unit(Kilometer);
|
||||
std::string distanceText = std::to_string(std::round(myDistance / scale));
|
||||
// Get unit descriptor text
|
||||
std::string unitDescriptor = toString(_distanceUnit);
|
||||
if (!_customUnitDescriptor.value().empty()) {
|
||||
unitDescriptor = _customUnitDescriptor.value();
|
||||
}
|
||||
|
||||
// Get distance as string and remove fractional part
|
||||
std::string distanceText = std::to_string(std::round(nodeline->distance() / scale));
|
||||
int pos = static_cast<int>(distanceText.find("."));
|
||||
std::string subStr = distanceText.substr(pos);
|
||||
distanceText.erase(pos, subStr.size());
|
||||
std::string finalText = distanceText + " Km";
|
||||
|
||||
// Create final label text and set it
|
||||
const std::string finalText = distanceText + " " + unitDescriptor;
|
||||
setLabelText(finalText);
|
||||
|
||||
// Update placement of label with transformation matrix
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
private:
|
||||
|
||||
properties::StringProperty _nodelineId;
|
||||
properties::IntProperty _distanceUnit;
|
||||
properties::StringProperty _customUnitDescriptor;
|
||||
bool _errorThrown = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace {
|
||||
|
||||
constexpr const double AngleEpsilon = 1E-7;
|
||||
constexpr const double DistanceRatioAimThreshold = 1E-4;
|
||||
constexpr const double FlightDestinationFactor = 1E-4;
|
||||
|
||||
constexpr const openspace::properties::Property::PropertyInfo AnchorInfo = {
|
||||
"Anchor",
|
||||
@@ -155,6 +154,12 @@ namespace {
|
||||
"The final distance we want to fly to, with regards to the anchor node."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo FlightDestinationFactorInfo = {
|
||||
"FlightDestinationFactor",
|
||||
"Flight Destination Factor",
|
||||
"The minimal distance factor that we need to reach to end linear flight."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo
|
||||
StereoInterpolationTimeInfo = {
|
||||
"StereoInterpolationTime",
|
||||
@@ -232,6 +237,7 @@ OrbitalNavigator::OrbitalNavigator()
|
||||
, _velocitySensitivity(VelocityZoomControlInfo, 0.02f, 0.01f, 0.15f)
|
||||
, _applyLinearFlight(ApplyLinearFlightInfo, false)
|
||||
, _flightDestinationDistance(FlightDestinationDistanceInfo, 2e8f, 0.0f, 1e10f)
|
||||
, _flightDestinationFactor(FlightDestinationFactorInfo, 1E-4, 1E-6, 0.5)
|
||||
, _mouseSensitivity(MouseSensitivityInfo, 15.0f, 1.0f, 50.f)
|
||||
, _joystickSensitivity(JoystickSensitivityInfo, 10.0f, 1.0f, 50.f)
|
||||
, _websocketSensitivity(WebsocketSensitivityInfo, 10.0f, 1.0f, 50.f)
|
||||
@@ -362,6 +368,7 @@ OrbitalNavigator::OrbitalNavigator()
|
||||
addProperty(_minimumAllowedDistance);
|
||||
addProperty(_velocitySensitivity);
|
||||
addProperty(_flightDestinationDistance);
|
||||
addProperty(_flightDestinationFactor);
|
||||
addProperty(_applyLinearFlight);
|
||||
|
||||
addProperty(_useAdaptiveStereoscopicDepth);
|
||||
@@ -440,7 +447,7 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) {
|
||||
double distFromCameraToFocus = glm::distance(prevCameraPosition, anchorPos) - nodeRadius;
|
||||
|
||||
// Make the approximation delta size depending on the flight distance
|
||||
double arrivalThreshold = _flightDestinationDistance.value() * FlightDestinationFactor;
|
||||
double arrivalThreshold = _flightDestinationDistance.value() * _flightDestinationFactor;
|
||||
|
||||
// Fly towards the flight destination distance. When getting closer than arrivalThreshold terminate the flight
|
||||
if (abs(distFromCameraToFocus - _flightDestinationDistance.value()) > arrivalThreshold) {
|
||||
|
||||
Reference in New Issue
Block a user