mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Add Camera::modeUpdated()
This commit is contained in:
parent
28095e9972
commit
fde7b30501
3 changed files with 58 additions and 28 deletions
|
@ -33,7 +33,7 @@ Script.include("libraries/entityPropertyDialogBox.js");
|
|||
var entityPropertyDialogBox = EntityPropertyDialogBox;
|
||||
|
||||
Script.include("libraries/entityCameraTool.js");
|
||||
var entityCameraTool = new EntityCameraTool();
|
||||
var cameraManager = new CameraManager();
|
||||
|
||||
selectionManager.setEventListener(selectionDisplay.updateHandles);
|
||||
|
||||
|
@ -247,9 +247,9 @@ var toolBar = (function () {
|
|||
isActive = !isActive;
|
||||
if (!isActive) {
|
||||
selectionDisplay.unselectAll();
|
||||
entityCameraTool.disable();
|
||||
cameraManager.disable();
|
||||
} else {
|
||||
entityCameraTool.enable();
|
||||
cameraManager.enable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ function mousePressEvent(event) {
|
|||
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
|
||||
if (toolBar.mousePressEvent(event) || progressDialog.mousePressEvent(event)
|
||||
|| entityCameraTool.mousePressEvent(event) || selectionDisplay.mousePressEvent(event)) {
|
||||
|| cameraManager.mousePressEvent(event) || selectionDisplay.mousePressEvent(event)) {
|
||||
// Event handled; do nothing.
|
||||
return;
|
||||
} else {
|
||||
|
@ -482,8 +482,8 @@ function mouseMoveEvent(event) {
|
|||
return;
|
||||
}
|
||||
|
||||
// allow the selectionDisplay and entityCameraTool to handle the event first, if it doesn't handle it, then do our own thing
|
||||
if (selectionDisplay.mouseMoveEvent(event) || entityCameraTool.mouseMoveEvent(event)) {
|
||||
// allow the selectionDisplay and cameraManager to handle the event first, if it doesn't handle it, then do our own thing
|
||||
if (selectionDisplay.mouseMoveEvent(event) || cameraManager.mouseMoveEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ function mouseReleaseEvent(event) {
|
|||
if (entitySelected) {
|
||||
tooltip.show(false);
|
||||
}
|
||||
entityCameraTool.mouseReleaseEvent(event);
|
||||
cameraManager.mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
|
@ -652,7 +652,6 @@ Menu.menuItemEvent.connect(handeMenuEvent);
|
|||
|
||||
Controller.keyReleaseEvent.connect(function (event) {
|
||||
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
|
||||
print(event.text);
|
||||
if (event.text == "`") {
|
||||
handeMenuEvent("Edit Properties...");
|
||||
}
|
||||
|
@ -666,7 +665,11 @@ Controller.keyReleaseEvent.connect(function (event) {
|
|||
if (entitySelected) {
|
||||
// Get latest properties
|
||||
var properties = Entities.getEntityProperties(selectedEntityID);
|
||||
entityCameraTool.focus(properties);
|
||||
cameraManager.focus(properties);
|
||||
}
|
||||
} else if (event.text == '[') {
|
||||
if (isActive) {
|
||||
cameraManager.enable();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,6 +21,32 @@
|
|||
#include "devices/OculusManager.h"
|
||||
|
||||
|
||||
CameraMode stringToMode(const QString& mode) {
|
||||
if (mode == "third person") {
|
||||
return CAMERA_MODE_THIRD_PERSON;
|
||||
} else if (mode == "first person") {
|
||||
return CAMERA_MODE_FIRST_PERSON;
|
||||
} else if (mode == "mirror") {
|
||||
return CAMERA_MODE_MIRROR;
|
||||
} else if (mode == "independent") {
|
||||
return CAMERA_MODE_INDEPENDENT;
|
||||
}
|
||||
return CAMERA_MODE_NULL;
|
||||
}
|
||||
|
||||
QString modeToString(CameraMode mode) {
|
||||
if (mode == CAMERA_MODE_THIRD_PERSON) {
|
||||
return "third person";
|
||||
} else if (mode == CAMERA_MODE_FIRST_PERSON) {
|
||||
return "first person";
|
||||
} else if (mode == CAMERA_MODE_MIRROR) {
|
||||
return "mirror";
|
||||
} else if (mode == CAMERA_MODE_INDEPENDENT) {
|
||||
return "independent";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
Camera::Camera() :
|
||||
_mode(CAMERA_MODE_THIRD_PERSON),
|
||||
_position(0.0f, 0.0f, 0.0f),
|
||||
|
@ -48,6 +74,7 @@ float Camera::getFarClip() const {
|
|||
|
||||
void Camera::setMode(CameraMode m) {
|
||||
_mode = m;
|
||||
emit modeUpdated(m);
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,6 +97,7 @@ void Camera::setFarClip(float f) {
|
|||
CameraScriptableObject::CameraScriptableObject(Camera* camera, ViewFrustum* viewFrustum) :
|
||||
_camera(camera), _viewFrustum(viewFrustum)
|
||||
{
|
||||
connect(_camera, &Camera::modeUpdated, this, &CameraScriptableObject::onModeUpdated);
|
||||
}
|
||||
|
||||
PickRay CameraScriptableObject::computePickRay(float x, float y) {
|
||||
|
@ -86,24 +114,7 @@ PickRay CameraScriptableObject::computePickRay(float x, float y) {
|
|||
}
|
||||
|
||||
QString CameraScriptableObject::getMode() const {
|
||||
QString mode("unknown");
|
||||
switch(_camera->getMode()) {
|
||||
case CAMERA_MODE_THIRD_PERSON:
|
||||
mode = "third person";
|
||||
break;
|
||||
case CAMERA_MODE_FIRST_PERSON:
|
||||
mode = "first person";
|
||||
break;
|
||||
case CAMERA_MODE_MIRROR:
|
||||
mode = "mirror";
|
||||
break;
|
||||
case CAMERA_MODE_INDEPENDENT:
|
||||
mode = "independent";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return mode;
|
||||
return modeToString(_camera->getMode());
|
||||
}
|
||||
|
||||
void CameraScriptableObject::setMode(const QString& mode) {
|
||||
|
@ -131,5 +142,9 @@ void CameraScriptableObject::setMode(const QString& mode) {
|
|||
}
|
||||
}
|
||||
|
||||
void CameraScriptableObject::onModeUpdated(CameraMode m) {
|
||||
emit modeUpdated(modeToString(m));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -27,8 +27,11 @@ enum CameraMode
|
|||
NUM_CAMERA_MODES
|
||||
};
|
||||
|
||||
class Camera {
|
||||
Q_DECLARE_METATYPE(CameraMode);
|
||||
static int cameraModeId = qRegisterMetaType<CameraMode>();
|
||||
|
||||
class Camera : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Camera();
|
||||
|
||||
|
@ -63,6 +66,9 @@ public:
|
|||
const glm::vec3& getEyeOffsetPosition() const { return _eyeOffsetPosition; }
|
||||
const glm::quat& getEyeOffsetOrientation() const { return _eyeOffsetOrientation; }
|
||||
float getScale() const { return _scale; }
|
||||
|
||||
signals:
|
||||
void modeUpdated(CameraMode newMode);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -100,6 +106,12 @@ public slots:
|
|||
|
||||
PickRay computePickRay(float x, float y);
|
||||
|
||||
signals:
|
||||
void modeUpdated(const QString& newMode);
|
||||
|
||||
private slots:
|
||||
void onModeUpdated(CameraMode m);
|
||||
|
||||
private:
|
||||
Camera* _camera;
|
||||
ViewFrustum* _viewFrustum;
|
||||
|
|
Loading…
Reference in a new issue