mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 00:02:39 +02:00
expose camera mode as property and leverage in scripts
This commit is contained in:
parent
81ef722ef8
commit
fe0d593ac4
5 changed files with 18 additions and 14 deletions
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -32,6 +32,10 @@ static int cameraModeId = qRegisterMetaType<CameraMode>();
|
|||
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue