mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 10:06:57 +02:00
Display mini tablet only if camera is also looking at the hand
This commit is contained in:
parent
846f38584f
commit
2c389af751
1 changed files with 23 additions and 21 deletions
|
@ -124,6 +124,29 @@
|
||||||
|
|
||||||
// #region State Machine ===================================================================================================
|
// #region State Machine ===================================================================================================
|
||||||
|
|
||||||
|
function shouldShowProxy(hand) {
|
||||||
|
// Should show tablet proxy if hand is oriented toward the camera and the camera is oriented toward the proxy tablet.
|
||||||
|
var pose,
|
||||||
|
jointIndex,
|
||||||
|
handPosition,
|
||||||
|
handOrientation,
|
||||||
|
cameraToHandDirection;
|
||||||
|
|
||||||
|
pose = Controller.getPoseValue(hand === LEFT_HAND ? Controller.Standard.LeftHand : Controller.Standard.RightHand);
|
||||||
|
if (!pose.valid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
jointIndex = handJointIndex(hand);
|
||||||
|
handPosition = Vec3.sum(MyAvatar.position,
|
||||||
|
Vec3.multiplyQbyV(MyAvatar.orientation, MyAvatar.getAbsoluteJointTranslationInObjectFrame(jointIndex)));
|
||||||
|
handOrientation = Quat.multiply(MyAvatar.orientation, MyAvatar.getAbsoluteJointRotationInObjectFrame(jointIndex));
|
||||||
|
cameraToHandDirection = Vec3.normalize(Vec3.subtract(handPosition, Camera.position));
|
||||||
|
|
||||||
|
return Vec3.dot(cameraToHandDirection, Quat.getForward(handOrientation)) > MIN_HAND_CAMERA_ANGLE_COS
|
||||||
|
&& Vec3.dot(cameraToHandDirection, Quat.getForward(Camera.orientation)) > MIN_HAND_CAMERA_ANGLE_COS;
|
||||||
|
}
|
||||||
|
|
||||||
function enterProxyHidden() {
|
function enterProxyHidden() {
|
||||||
if (proxyOverlay) {
|
if (proxyOverlay) {
|
||||||
Overlays.deleteOverlay(proxyOverlay);
|
Overlays.deleteOverlay(proxyOverlay);
|
||||||
|
@ -287,27 +310,6 @@
|
||||||
|
|
||||||
// #region Events ==========================================================================================================
|
// #region Events ==========================================================================================================
|
||||||
|
|
||||||
function shouldShowProxy(hand) {
|
|
||||||
// Should show tablet proxy if hand is oriented towards the camera.
|
|
||||||
var pose,
|
|
||||||
jointIndex,
|
|
||||||
handPosition,
|
|
||||||
handOrientation;
|
|
||||||
|
|
||||||
pose = Controller.getPoseValue(hand === LEFT_HAND ? Controller.Standard.LeftHand : Controller.Standard.RightHand);
|
|
||||||
if (!pose.valid) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
jointIndex = handJointIndex(hand);
|
|
||||||
handPosition = Vec3.sum(MyAvatar.position,
|
|
||||||
Vec3.multiplyQbyV(MyAvatar.orientation, MyAvatar.getAbsoluteJointTranslationInObjectFrame(jointIndex)));
|
|
||||||
handOrientation = Quat.multiply(MyAvatar.orientation, MyAvatar.getAbsoluteJointRotationInObjectFrame(jointIndex));
|
|
||||||
|
|
||||||
return Vec3.dot(Vec3.normalize(Vec3.subtract(handPosition, Camera.position)), Quat.getForward(handOrientation))
|
|
||||||
> MIN_HAND_CAMERA_ANGLE_COS;
|
|
||||||
}
|
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
// Assumes that is HMD.mounted.
|
// Assumes that is HMD.mounted.
|
||||||
updateState();
|
updateState();
|
||||||
|
|
Loading…
Reference in a new issue