From 36dfff78e203d6d35d60b0f86db8fbf515c2eb72 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 30 Jun 2017 15:13:31 -0700 Subject: [PATCH] Emit qDebug() error when trying to change position or orientation while attachedEntityId is defined --- interface/src/SecondaryCamera.cpp | 20 +++++++++++++++++++- interface/src/SecondaryCamera.h | 8 ++++++-- scripts/system/spectatorCamera.js | 10 ++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index f5e7cca8f6..730733ad13 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -80,7 +80,7 @@ public: }); auto srcViewFrustum = args->getViewFrustum(); - if (_attachedEntityId != QUuid()) { + if (!_attachedEntityId.isNull()) { EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(_attachedEntityId, _attachedEntityPropertyFlags); srcViewFrustum.setPosition(entityProperties.getPosition()); srcViewFrustum.setOrientation(entityProperties.getRotation()); @@ -102,6 +102,24 @@ protected: RenderArgsPointer _cachedArgsPointer; }; +void SecondaryCameraJobConfig::setPosition(glm::vec3 pos) { + if (attachedEntityId.isNull()) { + position = pos; + emit dirty(); + } else { + qDebug() << "ERROR: Cannot set position of SecondaryCamera while attachedEntityId is set."; + } +} + +void SecondaryCameraJobConfig::setOrientation(glm::quat orient) { + if (attachedEntityId.isNull()) { + orientation = orient; + emit dirty(); + } else { + qDebug() << "ERROR: Cannot set orientation of SecondaryCamera while attachedEntityId is set."; + } +} + void SecondaryCameraJobConfig::enableSecondaryCameraRenderConfigs(bool enabled) { qApp->getRenderEngine()->getConfiguration()->getConfig()->setEnabled(enabled); setEnabled(enabled); diff --git a/interface/src/SecondaryCamera.h b/interface/src/SecondaryCamera.h index e06332f4e9..ac82290211 100644 --- a/interface/src/SecondaryCamera.h +++ b/interface/src/SecondaryCamera.h @@ -31,8 +31,8 @@ public: class SecondaryCameraJobConfig : public render::Task::Config { // Exposes secondary camera parameters to JavaScript. Q_OBJECT Q_PROPERTY(QUuid attachedEntityId MEMBER attachedEntityId NOTIFY dirty) // entity whose properties define camera position and orientation - Q_PROPERTY(glm::vec3 position MEMBER position NOTIFY dirty) // of viewpoint to render from - Q_PROPERTY(glm::quat orientation MEMBER orientation NOTIFY dirty) // of viewpoint to render from + Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition) // of viewpoint to render from + Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation) // of viewpoint to render from Q_PROPERTY(float vFoV MEMBER vFoV NOTIFY dirty) // Secondary camera's vertical field of view. In degrees. Q_PROPERTY(float nearClipPlaneDistance MEMBER nearClipPlaneDistance NOTIFY dirty) // Secondary camera's near clip plane distance. In meters. Q_PROPERTY(float farClipPlaneDistance MEMBER farClipPlaneDistance NOTIFY dirty) // Secondary camera's far clip plane distance. In meters. @@ -47,6 +47,10 @@ public: signals: void dirty(); public slots: + glm::vec3 getPosition() { return position; } + void setPosition(glm::vec3 pos); + glm::quat getOrientation() { return orientation; } + void setOrientation(glm::quat orient); void enableSecondaryCameraRenderConfigs(bool enabled); void resetSizeSpectatorCamera(int width, int height); }; diff --git a/scripts/system/spectatorCamera.js b/scripts/system/spectatorCamera.js index 00b774c483..3c011cad99 100644 --- a/scripts/system/spectatorCamera.js +++ b/scripts/system/spectatorCamera.js @@ -36,8 +36,14 @@ // // Relevant Variables: // -spectatorCameraConfig: The render configuration of the spectator camera - // render job. It controls the orientation and position of the secondary camera whose viewport is rendered to - // the texture, as well as the rendered texture size. + // render job. It controls various attributes of the Secondary Camera, such as: + // -The entity ID to follow + // -Position + // -Orientation + // -Rendered texture size + // -Vertical field of view + // -Near clip plane distance + // -Far clip plane distance // -viewFinderOverlay: The in-world overlay that displays the spectator camera's view. // -camera: The in-world entity that corresponds to the spectator camera. // -cameraIsDynamic: "false" for now while we figure out why dynamic, parented overlays