mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
allow hydra mouse to know the correct size of screen to target
This commit is contained in:
parent
dd8e5fd199
commit
d1e1067e5a
3 changed files with 25 additions and 6 deletions
|
@ -53,8 +53,9 @@ Script.update.connect(function(deltaTime) {
|
||||||
var poseLeft = Controller.getPoseValue(Controller.Standard.LeftHand);
|
var poseLeft = Controller.getPoseValue(Controller.Standard.LeftHand);
|
||||||
|
|
||||||
// NOTE: hack for now
|
// NOTE: hack for now
|
||||||
var screenSizeX = 1920;
|
var screenSize = Reticle.maximumPosition;
|
||||||
var screenSizeY = 1080;
|
var screenSizeX = screenSize.x;
|
||||||
|
var screenSizeY = screenSize.y;
|
||||||
|
|
||||||
var rotatedRight = Vec3.multiplyQbyV(poseRight.rotation, Vec3.UNIT_NEG_Y);
|
var rotatedRight = Vec3.multiplyQbyV(poseRight.rotation, Vec3.UNIT_NEG_Y);
|
||||||
var rotatedLeft = Vec3.multiplyQbyV(poseLeft.rotation, Vec3.UNIT_NEG_Y);
|
var rotatedLeft = Vec3.multiplyQbyV(poseLeft.rotation, Vec3.UNIT_NEG_Y);
|
||||||
|
|
|
@ -401,6 +401,18 @@ void ApplicationCompositor::setReticlePosition(glm::vec2 position, bool sendFake
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
|
||||||
|
glm::vec2 ApplicationCompositor::getReticleMaximumPosition() const {
|
||||||
|
glm::vec2 result;
|
||||||
|
if (qApp->isHMDMode()) {
|
||||||
|
result = glm::vec2(VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y);
|
||||||
|
} else {
|
||||||
|
QRect rec = QApplication::desktop()->screenGeometry();
|
||||||
|
result = glm::vec2(rec.right(), rec.bottom());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME - this probably is hella buggy and probably doesn't work correctly
|
// FIXME - this probably is hella buggy and probably doesn't work correctly
|
||||||
// we should kill it asap.
|
// we should kill it asap.
|
||||||
|
@ -571,7 +583,7 @@ glm::vec2 ApplicationCompositor::screenToSpherical(const glm::vec2& screenPos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 ApplicationCompositor::sphericalToScreen(const glm::vec2& sphericalPos) {
|
glm::vec2 ApplicationCompositor::sphericalToScreen(const glm::vec2& sphericalPos) {
|
||||||
glm::uvec2 screenSize { VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y }; // = qApp->getCanvasSize();
|
glm::uvec2 screenSize { VIRTUAL_SCREEN_SIZE_X, VIRTUAL_SCREEN_SIZE_Y };
|
||||||
glm::vec2 result = sphericalPos;
|
glm::vec2 result = sphericalPos;
|
||||||
result.x *= -1.0f;
|
result.x *= -1.0f;
|
||||||
result /= MOUSE_RANGE;
|
result /= MOUSE_RANGE;
|
||||||
|
|
|
@ -96,6 +96,8 @@ public:
|
||||||
Q_INVOKABLE glm::vec2 getReticlePosition();
|
Q_INVOKABLE glm::vec2 getReticlePosition();
|
||||||
Q_INVOKABLE void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
|
Q_INVOKABLE void setReticlePosition(glm::vec2 position, bool sendFakeEvent = true);
|
||||||
|
|
||||||
|
Q_INVOKABLE glm::vec2 getReticleMaximumPosition() const;
|
||||||
|
|
||||||
ReticleInterface* getReticleInterface() { return _reticleInterface; }
|
ReticleInterface* getReticleInterface() { return _reticleInterface; }
|
||||||
|
|
||||||
/// return value - true means the caller should not process the event further
|
/// return value - true means the caller should not process the event further
|
||||||
|
@ -160,9 +162,11 @@ private:
|
||||||
// Scripting interface available to control the Reticle
|
// Scripting interface available to control the Reticle
|
||||||
class ReticleInterface : public QObject {
|
class ReticleInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition)
|
Q_PROPERTY(glm::vec2 position READ getPosition WRITE setPosition)
|
||||||
Q_PROPERTY(bool visible READ getVisible WRITE setVisible)
|
Q_PROPERTY(bool visible READ getVisible WRITE setVisible)
|
||||||
Q_PROPERTY(float depth READ getDepth WRITE setDepth)
|
Q_PROPERTY(float depth READ getDepth WRITE setDepth)
|
||||||
|
Q_PROPERTY(glm::vec2 maximumPosition READ getMaximumPosition)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ReticleInterface(ApplicationCompositor* outer) : QObject(outer), _compositor(outer) {}
|
ReticleInterface(ApplicationCompositor* outer) : QObject(outer), _compositor(outer) {}
|
||||||
|
|
||||||
|
@ -174,6 +178,8 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec2 getPosition() { return _compositor->getReticlePosition(); }
|
Q_INVOKABLE glm::vec2 getPosition() { return _compositor->getReticlePosition(); }
|
||||||
Q_INVOKABLE void setPosition(glm::vec2 position) { _compositor->setReticlePosition(position); }
|
Q_INVOKABLE void setPosition(glm::vec2 position) { _compositor->setReticlePosition(position); }
|
||||||
|
|
||||||
|
Q_INVOKABLE glm::vec2 getMaximumPosition() { return _compositor->getReticleMaximumPosition(); }
|
||||||
private:
|
private:
|
||||||
ApplicationCompositor* _compositor;
|
ApplicationCompositor* _compositor;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue