mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 14:27:04 +02:00
Merge pull request #2315 from ZappoMan/fix_lookWithTouch_and_more
fix JS radians vs degrees issues
This commit is contained in:
commit
37ae5142a6
10 changed files with 26 additions and 16 deletions
|
@ -74,7 +74,7 @@ function checkCamera(deltaTime) {
|
||||||
if (yaw < -360) {
|
if (yaw < -360) {
|
||||||
yaw += 360;
|
yaw += 360;
|
||||||
}
|
}
|
||||||
var orientation = Quat.fromPitchYawRoll(pitch, yaw, roll);
|
var orientation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll);
|
||||||
Camera.setOrientation(orientation);
|
Camera.setOrientation(orientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@ var cumulativeTime = 0.0;
|
||||||
|
|
||||||
Script.update.connect(function(deltaTime) {
|
Script.update.connect(function(deltaTime) {
|
||||||
cumulativeTime += deltaTime;
|
cumulativeTime += deltaTime;
|
||||||
MyAvatar.setJointData("joint_R_hip", Quat.fromPitchYawRoll(0.0, 0.0, AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY)));
|
MyAvatar.setJointData("joint_R_hip", Quat.fromPitchYawRollDegrees(0.0, 0.0, AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY)));
|
||||||
MyAvatar.setJointData("joint_L_hip", Quat.fromPitchYawRoll(0.0, 0.0, -AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY)));
|
MyAvatar.setJointData("joint_L_hip", Quat.fromPitchYawRollDegrees(0.0, 0.0, -AMPLITUDE * Math.sin(cumulativeTime * FREQUENCY)));
|
||||||
MyAvatar.setJointData("joint_R_knee", Quat.fromPitchYawRoll(0.0, 0.0,
|
MyAvatar.setJointData("joint_R_knee", Quat.fromPitchYawRollDegrees(0.0, 0.0,
|
||||||
AMPLITUDE * (1.0 + Math.sin(cumulativeTime * FREQUENCY))));
|
AMPLITUDE * (1.0 + Math.sin(cumulativeTime * FREQUENCY))));
|
||||||
MyAvatar.setJointData("joint_L_knee", Quat.fromPitchYawRoll(0.0, 0.0,
|
MyAvatar.setJointData("joint_L_knee", Quat.fromPitchYawRollDegrees(0.0, 0.0,
|
||||||
AMPLITUDE * (1.0 - Math.sin(cumulativeTime * FREQUENCY))));
|
AMPLITUDE * (1.0 - Math.sin(cumulativeTime * FREQUENCY))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,7 @@ function update(deltaTime) {
|
||||||
|
|
||||||
// Check for mouseLook movement, update rotation
|
// Check for mouseLook movement, update rotation
|
||||||
// rotate body yaw for yaw received from mouse
|
// rotate body yaw for yaw received from mouse
|
||||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMouse, z: 0 } ));
|
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMouse, z: 0 } ));
|
||||||
MyAvatar.orientation = newOrientation;
|
MyAvatar.orientation = newOrientation;
|
||||||
yawFromMouse = 0;
|
yawFromMouse = 0;
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ function flyWithHydra(deltaTime) {
|
||||||
|
|
||||||
// change the body yaw based on our x controller
|
// change the body yaw based on our x controller
|
||||||
var orientation = MyAvatar.orientation;
|
var orientation = MyAvatar.orientation;
|
||||||
var deltaOrientation = Quat.fromPitchYawRoll(0, (-1 * viewJoystickPosition.x * JOYSTICK_YAW_MAG * deltaTime), 0);
|
var deltaOrientation = Quat.fromPitchYawRollDegrees(0, (-1 * viewJoystickPosition.x * JOYSTICK_YAW_MAG * deltaTime), 0);
|
||||||
MyAvatar.orientation = Quat.multiply(orientation, deltaOrientation);
|
MyAvatar.orientation = Quat.multiply(orientation, deltaOrientation);
|
||||||
|
|
||||||
// change the headPitch based on our x controller
|
// change the headPitch based on our x controller
|
||||||
|
|
|
@ -54,7 +54,7 @@ function update(deltaTime) {
|
||||||
print("update()...");
|
print("update()...");
|
||||||
}
|
}
|
||||||
// rotate body yaw for yaw received from mouse
|
// rotate body yaw for yaw received from mouse
|
||||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMouse, z: 0 } ));
|
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMouse, z: 0 } ));
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
print("changing orientation"
|
print("changing orientation"
|
||||||
+ " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
|
+ " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
|
||||||
|
|
|
@ -45,7 +45,7 @@ function touchUpdateEvent(event) {
|
||||||
|
|
||||||
function update(deltaTime) {
|
function update(deltaTime) {
|
||||||
// rotate body yaw for yaw received from mouse
|
// rotate body yaw for yaw received from mouse
|
||||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMouse, z: 0 } ));
|
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromMouse, 0));
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
print("changing orientation"
|
print("changing orientation"
|
||||||
+ " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
|
+ " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
|
||||||
|
|
|
@ -92,7 +92,7 @@ Controller.touchEndEvent.connect(touchEndEvent);
|
||||||
|
|
||||||
function update(deltaTime) {
|
function update(deltaTime) {
|
||||||
// rotate body yaw for yaw received from multitouch rotate
|
// rotate body yaw for yaw received from multitouch rotate
|
||||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMultiTouch, z: 0 } ));
|
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3Radians( { x: 0, y: yawFromMultiTouch, z: 0 } ));
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
print("changing orientation"
|
print("changing orientation"
|
||||||
+ " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
|
+ " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
|
||||||
|
|
|
@ -17,7 +17,7 @@ var yawMin = 20;
|
||||||
var isLocal = false;
|
var isLocal = false;
|
||||||
|
|
||||||
// set up our VoxelViewer with a position and orientation
|
// set up our VoxelViewer with a position and orientation
|
||||||
var orientation = Quat.fromPitchYawRoll(0, yaw, 0);
|
var orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0);
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (isLocal) {
|
if (isLocal) {
|
||||||
|
@ -40,7 +40,7 @@ function keepLooking(deltaTime) {
|
||||||
count++;
|
count++;
|
||||||
if (count % 10 == 0) {
|
if (count % 10 == 0) {
|
||||||
yaw += yawDirection;
|
yaw += yawDirection;
|
||||||
orientation = Quat.fromPitchYawRoll(0, yaw, 0);
|
orientation = Quat.fromPitchYawRollDegrees(0, yaw, 0);
|
||||||
if (yaw > yawMax || yaw < yawMin) {
|
if (yaw > yawMax || yaw < yawMin) {
|
||||||
yawDirection = yawDirection * -1;
|
yawDirection = yawDirection * -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,22 @@ glm::quat Quat::multiply(const glm::quat& q1, const glm::quat& q2) {
|
||||||
return q1 * q2;
|
return q1 * q2;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Quat::fromVec3(const glm::vec3& eulerAngles) {
|
glm::quat Quat::fromVec3Degrees(const glm::vec3& eulerAngles) {
|
||||||
return glm::quat(glm::radians(eulerAngles));
|
return glm::quat(glm::radians(eulerAngles));
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Quat::fromPitchYawRoll(float pitch, float yaw, float roll) {
|
glm::quat Quat::fromVec3Radians(const glm::vec3& eulerAngles) {
|
||||||
|
return glm::quat(eulerAngles);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::quat Quat::fromPitchYawRollDegrees(float pitch, float yaw, float roll) {
|
||||||
return glm::quat(glm::radians(glm::vec3(pitch, yaw, roll)));
|
return glm::quat(glm::radians(glm::vec3(pitch, yaw, roll)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::quat Quat::fromPitchYawRollRadians(float pitch, float yaw, float roll) {
|
||||||
|
return glm::quat(glm::vec3(pitch, yaw, roll));
|
||||||
|
}
|
||||||
|
|
||||||
glm::quat Quat::inverse(const glm::quat& q) {
|
glm::quat Quat::inverse(const glm::quat& q) {
|
||||||
return glm::inverse(q);
|
return glm::inverse(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,10 @@ class Quat : public QObject {
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
glm::quat multiply(const glm::quat& q1, const glm::quat& q2);
|
glm::quat multiply(const glm::quat& q1, const glm::quat& q2);
|
||||||
glm::quat fromVec3(const glm::vec3& vec3);
|
glm::quat fromVec3Degrees(const glm::vec3& vec3); // degrees
|
||||||
glm::quat fromPitchYawRoll(float pitch, float yaw, float roll); // degrees
|
glm::quat fromVec3Radians(const glm::vec3& vec3); // radians
|
||||||
|
glm::quat fromPitchYawRollDegrees(float pitch, float yaw, float roll); // degrees
|
||||||
|
glm::quat fromPitchYawRollRadians(float pitch, float yaw, float roll); // radians
|
||||||
glm::quat inverse(const glm::quat& q);
|
glm::quat inverse(const glm::quat& q);
|
||||||
glm::vec3 getFront(const glm::quat& orientation);
|
glm::vec3 getFront(const glm::quat& orientation);
|
||||||
glm::vec3 getRight(const glm::quat& orientation);
|
glm::vec3 getRight(const glm::quat& orientation);
|
||||||
|
|
Loading…
Reference in a new issue