mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-19 19:39:30 -06:00
Send view scaling over parallel connection
This commit is contained in:
@@ -41,6 +41,7 @@ public:
|
||||
glm::dvec3 position;
|
||||
glm::quat rotation;
|
||||
std::string focusNode;
|
||||
float scale;
|
||||
bool followFocusNodeRotation;
|
||||
};
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ struct CameraKeyframe {
|
||||
glm::dquat _rotation;
|
||||
bool _followNodeRotation;
|
||||
std::string _focusNode;
|
||||
float _scale;
|
||||
|
||||
double _timestamp;
|
||||
|
||||
@@ -88,6 +89,12 @@ struct CameraKeyframe {
|
||||
_focusNode.data() + nodeNameLength
|
||||
);
|
||||
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<char*>(&_scale),
|
||||
reinterpret_cast<char*>(&_scale) + sizeof(_scale)
|
||||
);
|
||||
|
||||
// Add timestamp
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
@@ -124,6 +131,11 @@ struct CameraKeyframe {
|
||||
_focusNode = std::string(buffer.data() + offset, buffer.data() + offset + size);
|
||||
offset += size;
|
||||
|
||||
// Scale
|
||||
size = sizeof(_scale);
|
||||
memcpy(&_scale, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Timestamp
|
||||
size = sizeof(_timestamp);
|
||||
memcpy(&_timestamp, buffer.data() + offset, size);
|
||||
|
||||
@@ -116,6 +116,14 @@ void KeyframeNavigator::updateCamera(Camera& camera) {
|
||||
camera.setRotation(
|
||||
glm::slerp(prevKeyframeCameraRotation, nextKeyframeCameraRotation, t)
|
||||
);
|
||||
|
||||
// We want to affect view scaling, such that we achieve
|
||||
// logarithmic interpolation of distance to an imagined focus node.
|
||||
// To do this, we interpolate the scale reciprocal logarithmically.
|
||||
const float prevInvScaleExp = glm::log(1.0 / prevPose.scale);
|
||||
const float nextInvScaleExp = glm::log(1.0 / nextPose.scale);
|
||||
const float interpolatedInvScaleExp = prevInvScaleExp * (1 - t) + nextInvScaleExp * t;
|
||||
camera.setScaling(1.0 / glm::exp(interpolatedInvScaleExp));
|
||||
}
|
||||
|
||||
Timeline<KeyframeNavigator::CameraPose>& KeyframeNavigator::timeline() {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
namespace {
|
||||
const uint32_t ProtocolVersion = 3;
|
||||
const uint32_t ProtocolVersion = 4;
|
||||
const char* _loggerCat = "ParallelConnection";
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -287,6 +287,7 @@ void ParallelPeer::dataMessageReceived(const std::vector<char>& messageContent)
|
||||
pose.focusNode = kf._focusNode;
|
||||
pose.position = kf._position;
|
||||
pose.rotation = kf._rotation;
|
||||
pose.scale = kf._scale;
|
||||
pose.followFocusNodeRotation = kf._followNodeRotation;
|
||||
|
||||
OsEng.navigationHandler().keyframeNavigator().addKeyframe(kf._timestamp, pose);
|
||||
@@ -539,6 +540,7 @@ void ParallelPeer::sendCameraKeyframe() {
|
||||
}
|
||||
|
||||
kf._focusNode = focusNode->identifier();
|
||||
kf._scale = OsEng.navigationHandler().camera()->scaling();
|
||||
|
||||
// Timestamp as current runtime of OpenSpace instance
|
||||
kf._timestamp = OsEng.windowWrapper().applicationTime();
|
||||
|
||||
Reference in New Issue
Block a user