From fe0d593ac480bc8454dcd3a2684464e2fc7c2162 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 4 Nov 2014 10:41:13 -0800 Subject: [PATCH] expose camera mode as property and leverage in scripts --- examples/concertCamera_kyrs.js | 8 ++++---- examples/headMove.js | 6 +++--- examples/inspect.js | 6 +++--- examples/lookAtExample.js | 8 ++++---- interface/src/Camera.h | 4 ++++ 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/examples/concertCamera_kyrs.js b/examples/concertCamera_kyrs.js index 8d3a07934e..4c7c893783 100644 --- a/examples/concertCamera_kyrs.js +++ b/examples/concertCamera_kyrs.js @@ -20,15 +20,15 @@ var cameraLocations = [ {x: 2921.5, y: 251.3, z: 8254.8}, {x: 2921.5, y: 251.3, var cameraLookAts = [ {x: 2921.5, y: 251.3, z: 8255.7}, {x: 2921.5, y: 251.3, z: 8255.7}, {x: 2921.5, y: 251.3, z: 8255.7}, {x: 2921.5, y: 251.3, z: 8255.7}, {x: 2921.4 , y: 251.3, z: 8255.1} ]; function saveCameraState() { - oldMode = Camera.getModeString(); + oldMode = Camera.mode; avatarPosition = MyAvatar.position; Camera.setModeShiftPeriod(0.0); - Camera.setModeString("independent"); + Camera.mode = "independent"; } function restoreCameraState() { Camera.stopLooking(); - Camera.setModeString(oldMode); + Camera.mode = oldMode; } function update(deltaTime) { @@ -52,7 +52,7 @@ function keyPressEvent(event) { saveCameraState(); freeCamera = true; } - Camera.setModeString("independent"); + Camera.mode = "independent"; Camera.setPosition(cameraLocations[choice - 1]); Camera.keepLookingAt(cameraLookAts[choice - 1]); } diff --git a/examples/headMove.js b/examples/headMove.js index 0ace39e853..b1f1c4ab7d 100644 --- a/examples/headMove.js +++ b/examples/headMove.js @@ -53,12 +53,12 @@ var lastYawTurned = 0.0; var startPullbackPosition; function saveCameraState() { - oldMode = Camera.getModeString(); - Camera.setModeString("independent"); + oldMode = Camera.mode; + Camera.mode = "independent"; } function restoreCameraState() { - Camera.setModeString(oldMode); + Camera.mode = oldMode; } function activateWarp() { diff --git a/examples/inspect.js b/examples/inspect.js index 5742f84765..49ebc86de1 100644 --- a/examples/inspect.js +++ b/examples/inspect.js @@ -118,14 +118,14 @@ function handlePanMode(dx, dy) { } function saveCameraState() { - oldMode = Camera.getModeString(); + oldMode = Camera.mode; var oldPosition = Camera.getPosition(); - Camera.setModeString("independent"); + Camera.mode = "independent"; Camera.setPosition(oldPosition); } function restoreCameraState() { - Camera.setModeString(oldMode); + Camera.mode = oldMode; } function handleModes() { diff --git a/examples/lookAtExample.js b/examples/lookAtExample.js index 281ba59066..729281fa03 100644 --- a/examples/lookAtExample.js +++ b/examples/lookAtExample.js @@ -17,13 +17,13 @@ // var lookingAtSomething = false; -var oldMode = Camera.getModeString(); +var oldMode = Camera.mode; function cancelLookAt() { if (lookingAtSomething) { lookingAtSomething = false; Camera.stopLooking(); - Camera.setModeString(oldMode); + Camera.mode = oldMode; releaseMovementKeys(); } } @@ -65,13 +65,13 @@ function mousePressEvent(event) { if (intersection.intersects) { // remember the old mode we were in - oldMode = Camera.getModeString(); + oldMode = Camera.mode; print("looking at intersection point: " + intersection.intersection.x + ", " + intersection.intersection.y + ", " + intersection.intersection.z); // switch to independent mode - Camera.setModeString("independent"); + Camera.mode = "independent"; // tell the camera to fix it's look at on the point we clicked Camera.keepLookingAt(intersection.intersection); diff --git a/interface/src/Camera.h b/interface/src/Camera.h index 769797c3f0..e1f14a0a77 100644 --- a/interface/src/Camera.h +++ b/interface/src/Camera.h @@ -32,6 +32,10 @@ static int cameraModeId = qRegisterMetaType(); class Camera : public QObject { Q_OBJECT + + Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition) + Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation) + Q_PROPERTY(QString mode READ getModeString WRITE setModeString) public: Camera();