mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 23:15:30 +02:00
Merge pull request #6719 from ZappoMan/rightClickMenu
fix reticle drive
This commit is contained in:
commit
fc4ece5671
1 changed files with 23 additions and 20 deletions
|
@ -9,13 +9,14 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var whichHand = Controller.Standard.RightHand;
|
||||||
|
var whichTrigger = Controller.Standard.RT;
|
||||||
|
var DEBUGGING = false;
|
||||||
|
|
||||||
Math.clamp=function(a,b,c) {
|
Math.clamp=function(a,b,c) {
|
||||||
return Math.max(b,Math.min(c,a));
|
return Math.max(b,Math.min(c,a));
|
||||||
}
|
}
|
||||||
|
|
||||||
var whichHand = Controller.Standard.RightHand;
|
|
||||||
var whichTrigger = Controller.Standard.RT;
|
|
||||||
|
|
||||||
function length(posA, posB) {
|
function length(posA, posB) {
|
||||||
var dx = posA.x - posB.x;
|
var dx = posA.x - posB.x;
|
||||||
var dy = posA.y - posB.y;
|
var dy = posA.y - posB.y;
|
||||||
|
@ -61,35 +62,37 @@ mapping.from(whichHand).peek().to(function(pose) {
|
||||||
|
|
||||||
var rotated = Vec3.multiplyQbyV(pose.rotation, Vec3.UNIT_NEG_Y); //
|
var rotated = Vec3.multiplyQbyV(pose.rotation, Vec3.UNIT_NEG_Y); //
|
||||||
var absolutePitch = rotated.y; // from 1 down to -1 up ... but note: if you rotate down "too far" it starts to go up again...
|
var absolutePitch = rotated.y; // from 1 down to -1 up ... but note: if you rotate down "too far" it starts to go up again...
|
||||||
var absoluteYaw = rotated.z; // from -1 left to 1 right
|
var absoluteYaw = -rotated.x; // from -1 left to 1 right
|
||||||
//print("absolutePitch:" + absolutePitch);
|
|
||||||
//print("absoluteYaw:" + absoluteYaw);
|
if (DEBUGGING) {
|
||||||
//Vec3.print("rotated:", rotated);
|
print("absolutePitch:" + absolutePitch);
|
||||||
|
print("absoluteYaw:" + absoluteYaw);
|
||||||
|
Vec3.print("rotated:", rotated);
|
||||||
|
}
|
||||||
|
|
||||||
var ROTATION_BOUND = 0.6;
|
var ROTATION_BOUND = 0.6;
|
||||||
var clampYaw = Math.clamp(absoluteYaw, -ROTATION_BOUND, ROTATION_BOUND);
|
var clampYaw = Math.clamp(absoluteYaw, -ROTATION_BOUND, ROTATION_BOUND);
|
||||||
var clampPitch = Math.clamp(absolutePitch, -ROTATION_BOUND, ROTATION_BOUND);
|
var clampPitch = Math.clamp(absolutePitch, -ROTATION_BOUND, ROTATION_BOUND);
|
||||||
//var clampYaw = absoluteYaw;
|
if (DEBUGGING) {
|
||||||
//print("clampYaw:" + clampYaw);
|
print("clampYaw:" + clampYaw);
|
||||||
//print("clampPitch:" + clampPitch);
|
print("clampPitch:" + clampPitch);
|
||||||
|
}
|
||||||
|
|
||||||
// if using entire span...
|
// using only from -ROTATION_BOUND to ROTATION_BOUND
|
||||||
//var xRatio = (absoluteYaw + 1) / 2;
|
|
||||||
//var yRatio = (absolutePitch + 1) / 2;
|
|
||||||
|
|
||||||
// if using only from -0.5 to 0.5
|
|
||||||
var xRatio = (clampYaw + ROTATION_BOUND) / (2 * ROTATION_BOUND);
|
var xRatio = (clampYaw + ROTATION_BOUND) / (2 * ROTATION_BOUND);
|
||||||
var yRatio = (clampPitch + ROTATION_BOUND) / (2 * ROTATION_BOUND);
|
var yRatio = (clampPitch + ROTATION_BOUND) / (2 * ROTATION_BOUND);
|
||||||
|
|
||||||
//print("xRatio:" + xRatio);
|
if (DEBUGGING) {
|
||||||
//print("yRatio:" + yRatio);
|
print("xRatio:" + xRatio);
|
||||||
|
print("yRatio:" + yRatio);
|
||||||
//print("ratio x:" + xRatio + " y:" + yRatio);
|
}
|
||||||
|
|
||||||
var x = screenSizeX * xRatio;
|
var x = screenSizeX * xRatio;
|
||||||
var y = screenSizeY * yRatio;
|
var y = screenSizeY * yRatio;
|
||||||
|
|
||||||
//print("position x:" + x + " y:" + y);
|
if (DEBUGGING) {
|
||||||
|
print("position x:" + x + " y:" + y);
|
||||||
|
}
|
||||||
if (!(xRatio == 0.5 && yRatio == 0)) {
|
if (!(xRatio == 0.5 && yRatio == 0)) {
|
||||||
moveReticleAbsolute(x, y);
|
moveReticleAbsolute(x, y);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue