expose camera mode as property and leverage in scripts

This commit is contained in:
Stephen Birarda 2014-11-04 10:41:13 -08:00
parent 81ef722ef8
commit fe0d593ac4
5 changed files with 18 additions and 14 deletions

View file

@ -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} ]; 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() { function saveCameraState() {
oldMode = Camera.getModeString(); oldMode = Camera.mode;
avatarPosition = MyAvatar.position; avatarPosition = MyAvatar.position;
Camera.setModeShiftPeriod(0.0); Camera.setModeShiftPeriod(0.0);
Camera.setModeString("independent"); Camera.mode = "independent";
} }
function restoreCameraState() { function restoreCameraState() {
Camera.stopLooking(); Camera.stopLooking();
Camera.setModeString(oldMode); Camera.mode = oldMode;
} }
function update(deltaTime) { function update(deltaTime) {
@ -52,7 +52,7 @@ function keyPressEvent(event) {
saveCameraState(); saveCameraState();
freeCamera = true; freeCamera = true;
} }
Camera.setModeString("independent"); Camera.mode = "independent";
Camera.setPosition(cameraLocations[choice - 1]); Camera.setPosition(cameraLocations[choice - 1]);
Camera.keepLookingAt(cameraLookAts[choice - 1]); Camera.keepLookingAt(cameraLookAts[choice - 1]);
} }

View file

@ -53,12 +53,12 @@ var lastYawTurned = 0.0;
var startPullbackPosition; var startPullbackPosition;
function saveCameraState() { function saveCameraState() {
oldMode = Camera.getModeString(); oldMode = Camera.mode;
Camera.setModeString("independent"); Camera.mode = "independent";
} }
function restoreCameraState() { function restoreCameraState() {
Camera.setModeString(oldMode); Camera.mode = oldMode;
} }
function activateWarp() { function activateWarp() {

View file

@ -118,14 +118,14 @@ function handlePanMode(dx, dy) {
} }
function saveCameraState() { function saveCameraState() {
oldMode = Camera.getModeString(); oldMode = Camera.mode;
var oldPosition = Camera.getPosition(); var oldPosition = Camera.getPosition();
Camera.setModeString("independent"); Camera.mode = "independent";
Camera.setPosition(oldPosition); Camera.setPosition(oldPosition);
} }
function restoreCameraState() { function restoreCameraState() {
Camera.setModeString(oldMode); Camera.mode = oldMode;
} }
function handleModes() { function handleModes() {

View file

@ -17,13 +17,13 @@
// //
var lookingAtSomething = false; var lookingAtSomething = false;
var oldMode = Camera.getModeString(); var oldMode = Camera.mode;
function cancelLookAt() { function cancelLookAt() {
if (lookingAtSomething) { if (lookingAtSomething) {
lookingAtSomething = false; lookingAtSomething = false;
Camera.stopLooking(); Camera.stopLooking();
Camera.setModeString(oldMode); Camera.mode = oldMode;
releaseMovementKeys(); releaseMovementKeys();
} }
} }
@ -65,13 +65,13 @@ function mousePressEvent(event) {
if (intersection.intersects) { if (intersection.intersects) {
// remember the old mode we were in // remember the old mode we were in
oldMode = Camera.getModeString(); oldMode = Camera.mode;
print("looking at intersection point: " + intersection.intersection.x + ", " print("looking at intersection point: " + intersection.intersection.x + ", "
+ intersection.intersection.y + ", " + intersection.intersection.z); + intersection.intersection.y + ", " + intersection.intersection.z);
// switch to independent mode // switch to independent mode
Camera.setModeString("independent"); Camera.mode = "independent";
// tell the camera to fix it's look at on the point we clicked // tell the camera to fix it's look at on the point we clicked
Camera.keepLookingAt(intersection.intersection); Camera.keepLookingAt(intersection.intersection);

View file

@ -32,6 +32,10 @@ static int cameraModeId = qRegisterMetaType<CameraMode>();
class Camera : public QObject { class Camera : public QObject {
Q_OBJECT 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: public:
Camera(); Camera();