mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-07 04:53:28 +02:00
Merge pull request #9970 from Triplelexx/21223
21223 - Quat functions have naming inconsistencies
This commit is contained in:
commit
9a38b36f59
59 changed files with 112 additions and 108 deletions
|
@ -206,7 +206,7 @@ ScrollingWindow {
|
|||
print("Error: model cannot be both static mesh and dynamic. This should never happen.");
|
||||
} else if (url) {
|
||||
var name = assetProxyModel.data(treeView.selection.currentIndex);
|
||||
var addPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(MyAvatar.orientation)));
|
||||
var addPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getForward(MyAvatar.orientation)));
|
||||
var gravity;
|
||||
if (dynamic) {
|
||||
// Create a vector <0, -10, 0>. { x: 0, y: -10, z: 0 } won't work because Qt is dumb and this is a
|
||||
|
|
|
@ -2132,7 +2132,7 @@ void Application::paintGL() {
|
|||
PerformanceTimer perfTimer("CameraUpdates");
|
||||
|
||||
auto myAvatar = getMyAvatar();
|
||||
boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FRONT;
|
||||
boomOffset = myAvatar->getScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
|
||||
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
|
||||
|
@ -3955,7 +3955,7 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
auto lookingAtHead = static_pointer_cast<Avatar>(lookingAt)->getHead();
|
||||
|
||||
const float MAXIMUM_FACE_ANGLE = 65.0f * RADIANS_PER_DEGREE;
|
||||
glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FRONT;
|
||||
glm::vec3 lookingAtFaceOrientation = lookingAtHead->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD;
|
||||
glm::vec3 fromLookingAtToMe = glm::normalize(myAvatar->getHead()->getEyePosition()
|
||||
- lookingAtHead->getEyePosition());
|
||||
float faceAngle = glm::angle(lookingAtFaceOrientation, fromLookingAtToMe);
|
||||
|
|
|
@ -236,7 +236,6 @@ protected:
|
|||
|
||||
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||
glm::vec3 getBodyUpDirection() const { return getOrientation() * IDENTITY_UP; }
|
||||
glm::vec3 getBodyFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
||||
glm::quat computeRotationFromBodyToWorldUp(float proportion = 1.0f) const;
|
||||
void measureMotionDerivatives(float deltaTime);
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ void Head::applyEyelidOffset(glm::quat headOrientation) {
|
|||
return;
|
||||
}
|
||||
|
||||
glm::quat eyeRotation = rotationBetween(headOrientation * IDENTITY_FRONT, getLookAtPosition() - _eyePosition);
|
||||
glm::quat eyeRotation = rotationBetween(headOrientation * IDENTITY_FORWARD, getLookAtPosition() - _eyePosition);
|
||||
eyeRotation = eyeRotation * glm::angleAxis(safeEulerAngles(headOrientation).y, IDENTITY_UP); // Rotation w.r.t. head
|
||||
float eyePitch = safeEulerAngles(eyeRotation).x;
|
||||
|
||||
|
@ -375,7 +375,7 @@ glm::quat Head::getCameraOrientation() const {
|
|||
glm::quat Head::getEyeRotation(const glm::vec3& eyePosition) const {
|
||||
glm::quat orientation = getOrientation();
|
||||
glm::vec3 lookAtDelta = _lookAtPosition - eyePosition;
|
||||
return rotationBetween(orientation * IDENTITY_FRONT, lookAtDelta + glm::length(lookAtDelta) * _saccade) * orientation;
|
||||
return rotationBetween(orientation * IDENTITY_FORWARD, lookAtDelta + glm::length(lookAtDelta) * _saccade) * orientation;
|
||||
}
|
||||
|
||||
void Head::setFinalPitch(float finalPitch) {
|
||||
|
|
|
@ -58,14 +58,14 @@ public:
|
|||
const glm::vec3& getSaccade() const { return _saccade; }
|
||||
glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||
glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; }
|
||||
glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
||||
glm::vec3 getForwardDirection() const { return getOrientation() * IDENTITY_FORWARD; }
|
||||
|
||||
glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
|
||||
|
||||
const glm::vec3& getRightEyePosition() const { return _rightEyePosition; }
|
||||
const glm::vec3& getLeftEyePosition() const { return _leftEyePosition; }
|
||||
glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); }
|
||||
glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getFrontDirection() * -EYE_EAR_GAP); }
|
||||
glm::vec3 getRightEarPosition() const { return _rightEyePosition + (getRightDirection() * EYE_EAR_GAP) + (getForwardDirection() * -EYE_EAR_GAP); }
|
||||
glm::vec3 getLeftEarPosition() const { return _leftEyePosition + (getRightDirection() * -EYE_EAR_GAP) + (getForwardDirection() * -EYE_EAR_GAP); }
|
||||
glm::vec3 getMouthPosition() const { return _eyePosition - getUpDirection() * glm::length(_rightEyePosition - _leftEyePosition); }
|
||||
|
||||
bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected)
|
||||
|
|
|
@ -1068,7 +1068,7 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
_lookAtTargetAvatar.reset();
|
||||
_targetAvatarPosition = glm::vec3(0.0f);
|
||||
|
||||
glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FRONT;
|
||||
glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD;
|
||||
glm::vec3 cameraPosition = qApp->getCamera()->getPosition();
|
||||
|
||||
float smallestAngleTo = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES) / 2.0f;
|
||||
|
@ -1770,10 +1770,10 @@ void MyAvatar::updateActionMotor(float deltaTime) {
|
|||
}
|
||||
|
||||
// compute action input
|
||||
glm::vec3 front = (getDriveKey(TRANSLATE_Z)) * IDENTITY_FRONT;
|
||||
glm::vec3 forward = (getDriveKey(TRANSLATE_Z)) * IDENTITY_FORWARD;
|
||||
glm::vec3 right = (getDriveKey(TRANSLATE_X)) * IDENTITY_RIGHT;
|
||||
|
||||
glm::vec3 direction = front + right;
|
||||
glm::vec3 direction = forward + right;
|
||||
CharacterController::State state = _characterController.getState();
|
||||
if (state == CharacterController::State::Hover) {
|
||||
// we're flying --> support vertical motion
|
||||
|
@ -2053,7 +2053,7 @@ void MyAvatar::goToLocation(const glm::vec3& newPosition,
|
|||
|
||||
// move the user a couple units away
|
||||
const float DISTANCE_TO_USER = 2.0f;
|
||||
_goToPosition = newPosition - quatOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
|
||||
_goToPosition = newPosition - quatOrientation * IDENTITY_FORWARD * DISTANCE_TO_USER;
|
||||
}
|
||||
|
||||
_goToOrientation = quatOrientation;
|
||||
|
|
|
@ -558,15 +558,15 @@ static const std::vector<float> LATERAL_SPEEDS = { 0.2f, 0.65f }; // m/s
|
|||
|
||||
void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation, CharacterControllerState ccState) {
|
||||
|
||||
glm::vec3 front = worldRotation * IDENTITY_FRONT;
|
||||
glm::vec3 forward = worldRotation * IDENTITY_FORWARD;
|
||||
glm::vec3 workingVelocity = worldVelocity;
|
||||
|
||||
{
|
||||
glm::vec3 localVel = glm::inverse(worldRotation) * workingVelocity;
|
||||
|
||||
float forwardSpeed = glm::dot(localVel, IDENTITY_FRONT);
|
||||
float forwardSpeed = glm::dot(localVel, IDENTITY_FORWARD);
|
||||
float lateralSpeed = glm::dot(localVel, IDENTITY_RIGHT);
|
||||
float turningSpeed = glm::orientedAngle(front, _lastFront, IDENTITY_UP) / deltaTime;
|
||||
float turningSpeed = glm::orientedAngle(forward, _lastForward, IDENTITY_UP) / deltaTime;
|
||||
|
||||
// filter speeds using a simple moving average.
|
||||
_averageForwardSpeed.updateAverage(forwardSpeed);
|
||||
|
@ -852,7 +852,7 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
|||
_lastEnableInverseKinematics = _enableInverseKinematics;
|
||||
}
|
||||
|
||||
_lastFront = front;
|
||||
_lastForward = forward;
|
||||
_lastPosition = worldPosition;
|
||||
_lastVelocity = workingVelocity;
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ protected:
|
|||
int _rightElbowJointIndex { -1 };
|
||||
int _rightShoulderJointIndex { -1 };
|
||||
|
||||
glm::vec3 _lastFront;
|
||||
glm::vec3 _lastForward;
|
||||
glm::vec3 _lastPosition;
|
||||
glm::vec3 _lastVelocity;
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ glm::quat HeadData::getOrientation() const {
|
|||
void HeadData::setOrientation(const glm::quat& orientation) {
|
||||
// rotate body about vertical axis
|
||||
glm::quat bodyOrientation = _owningAvatar->getOrientation();
|
||||
glm::vec3 newFront = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FRONT);
|
||||
bodyOrientation = bodyOrientation * glm::angleAxis(atan2f(-newFront.x, -newFront.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
glm::vec3 newForward = glm::inverse(bodyOrientation) * (orientation * IDENTITY_FORWARD);
|
||||
bodyOrientation = bodyOrientation * glm::angleAxis(atan2f(-newForward.x, -newForward.z), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
_owningAvatar->setOrientation(bodyOrientation);
|
||||
|
||||
// the rest goes to the head
|
||||
|
|
|
@ -142,6 +142,6 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
|||
}
|
||||
|
||||
glm::vec3 OctreeQuery::calculateCameraDirection() const {
|
||||
glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FRONT, 0.0f));
|
||||
glm::vec3 direction = glm::vec3(_cameraOrientation * glm::vec4(IDENTITY_FORWARD, 0.0f));
|
||||
return direction;
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ void LightStage::Shadow::setKeylightFrustum(const ViewFrustum& viewFrustum, floa
|
|||
const auto& direction = glm::normalize(_light->getDirection());
|
||||
glm::quat orientation;
|
||||
if (direction == IDENTITY_UP) {
|
||||
orientation = glm::quat(glm::mat3(-IDENTITY_RIGHT, IDENTITY_FRONT, -IDENTITY_UP));
|
||||
orientation = glm::quat(glm::mat3(-IDENTITY_RIGHT, IDENTITY_FORWARD, -IDENTITY_UP));
|
||||
} else if (direction == -IDENTITY_UP) {
|
||||
orientation = glm::quat(glm::mat3(IDENTITY_RIGHT, IDENTITY_FRONT, IDENTITY_UP));
|
||||
orientation = glm::quat(glm::mat3(IDENTITY_RIGHT, IDENTITY_FORWARD, IDENTITY_UP));
|
||||
} else {
|
||||
auto side = glm::normalize(glm::cross(direction, IDENTITY_UP));
|
||||
auto up = glm::normalize(glm::cross(side, direction));
|
||||
|
|
|
@ -54,7 +54,7 @@ glm::mat4 Mat4::inverse(const glm::mat4& m) const {
|
|||
return glm::inverse(m);
|
||||
}
|
||||
|
||||
glm::vec3 Mat4::getFront(const glm::mat4& m) const {
|
||||
glm::vec3 Mat4::getForward(const glm::mat4& m) const {
|
||||
return glm::vec3(-m[0][2], -m[1][2], -m[2][2]);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,9 @@ public slots:
|
|||
|
||||
glm::mat4 inverse(const glm::mat4& m) const;
|
||||
|
||||
glm::vec3 getFront(const glm::mat4& m) const;
|
||||
// redundant, calls getForward which better describes the returned vector as a direction
|
||||
glm::vec3 getFront(const glm::mat4& m) const { return getForward(m); }
|
||||
glm::vec3 getForward(const glm::mat4& m) const;
|
||||
glm::vec3 getRight(const glm::mat4& m) const;
|
||||
glm::vec3 getUp(const glm::mat4& m) const;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ glm::quat Quat::inverse(const glm::quat& q) {
|
|||
return glm::inverse(q);
|
||||
}
|
||||
|
||||
glm::vec3 Quat::getFront(const glm::quat& orientation) {
|
||||
glm::vec3 Quat::getForward(const glm::quat& orientation) {
|
||||
return orientation * Vectors::FRONT;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,9 @@ public slots:
|
|||
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::vec3 getFront(const glm::quat& orientation);
|
||||
// redundant, calls getForward which better describes the returned vector as a direction
|
||||
glm::vec3 getFront(const glm::quat& orientation) { return getForward(orientation); }
|
||||
glm::vec3 getForward(const glm::quat& orientation);
|
||||
glm::vec3 getRight(const glm::quat& orientation);
|
||||
glm::vec3 getUp(const glm::quat& orientation);
|
||||
glm::vec3 safeEulerAngles(const glm::quat& orientation); // degrees
|
||||
|
|
|
@ -50,7 +50,7 @@ using glm::quat;
|
|||
// this is where the coordinate system is represented
|
||||
const glm::vec3 IDENTITY_RIGHT = glm::vec3( 1.0f, 0.0f, 0.0f);
|
||||
const glm::vec3 IDENTITY_UP = glm::vec3( 0.0f, 1.0f, 0.0f);
|
||||
const glm::vec3 IDENTITY_FRONT = glm::vec3( 0.0f, 0.0f,-1.0f);
|
||||
const glm::vec3 IDENTITY_FORWARD = glm::vec3( 0.0f, 0.0f,-1.0f);
|
||||
|
||||
glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) {
|
|||
_orientation = orientationAsQuaternion;
|
||||
_right = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_RIGHT, 0.0f));
|
||||
_up = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_UP, 0.0f));
|
||||
_direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FRONT, 0.0f));
|
||||
_direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FORWARD, 0.0f));
|
||||
_view = glm::translate(mat4(), _position) * glm::mat4_cast(_orientation);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ private:
|
|||
glm::quat _orientation; // orientation in world-frame
|
||||
|
||||
// calculated from orientation
|
||||
glm::vec3 _direction = IDENTITY_FRONT;
|
||||
glm::vec3 _direction = IDENTITY_FORWARD;
|
||||
glm::vec3 _up = IDENTITY_UP;
|
||||
glm::vec3 _right = IDENTITY_RIGHT;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ var uuid = Entities.addEntity({
|
|||
shape: "Icosahedron",
|
||||
dimensions: Vec3.HALF,
|
||||
script: Script.resolvePath('../../tutorials/entity_scripts/ambientSound.js'),
|
||||
position: Vec3.sum(Vec3.multiply(5, Quat.getFront(MyAvatar.orientation)), MyAvatar.position),
|
||||
position: Vec3.sum(Vec3.multiply(5, Quat.getForward(MyAvatar.orientation)), MyAvatar.position),
|
||||
userData: JSON.stringify({
|
||||
soundURL: WAVE,
|
||||
maxVolume: 0.1,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
orientation = Quat.safeEulerAngles(orientation);
|
||||
orientation.x = 0;
|
||||
orientation = Quat.fromVec3Degrees(orientation);
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation)));
|
||||
|
||||
// Math.random ensures no caching of script
|
||||
var SCRIPT_URL = Script.resolvePath("myEntityScript.js")
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
orientation = Quat.safeEulerAngles(orientation);
|
||||
orientation.x = 0;
|
||||
orientation = Quat.fromVec3Degrees(orientation);
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation)));
|
||||
|
||||
// Math.random ensures no caching of script
|
||||
var SCRIPT_URL = Script.resolvePath("batonSoundTestEntityScript.js")
|
||||
|
|
|
@ -4,7 +4,7 @@ var DIV = NUM_ENTITIES / Math.PI / 2;
|
|||
var PASS_SCRIPT_URL = Script.resolvePath('entityServerStampedeTest-entity.js');
|
||||
var FAIL_SCRIPT_URL = Script.resolvePath('entityStampedeTest-entity-fail.js');
|
||||
|
||||
var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getFront(MyAvatar.orientation)));
|
||||
var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getForward(MyAvatar.orientation)));
|
||||
origin.y += HMD.eyeHeight;
|
||||
|
||||
var uuids = [];
|
||||
|
|
|
@ -4,7 +4,7 @@ var DIV = NUM_ENTITIES / Math.PI / 2;
|
|||
var PASS_SCRIPT_URL = Script.resolvePath('').replace('.js', '-entity.js');
|
||||
var FAIL_SCRIPT_URL = Script.resolvePath('').replace('.js', '-entity-fail.js');
|
||||
|
||||
var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getFront(MyAvatar.orientation)));
|
||||
var origin = Vec3.sum(MyAvatar.position, Vec3.multiply(5, Quat.getForward(MyAvatar.orientation)));
|
||||
origin.y += HMD.eyeHeight;
|
||||
|
||||
var uuids = [];
|
||||
|
|
|
@ -19,7 +19,7 @@ var WIDTH = MAX_DIM * NUM_SPHERES;
|
|||
var entities = [];
|
||||
var right = Quat.getRight(Camera.orientation);
|
||||
// Starting position will be 30 meters in front of the camera
|
||||
var position = Vec3.sum(Camera.position, Vec3.multiply(30, Quat.getFront(Camera.orientation)));
|
||||
var position = Vec3.sum(Camera.position, Vec3.multiply(30, Quat.getForward(Camera.orientation)));
|
||||
position = Vec3.sum(position, Vec3.multiply(-WIDTH/2, right));
|
||||
|
||||
for (var i = 0; i < NUM_SPHERES; ++i) {
|
||||
|
|
|
@ -141,12 +141,12 @@ function testInverse() {
|
|||
assert(mat4FuzzyEqual(IDENTITY, Mat4.multiply(test2, Mat4.inverse(test2))));
|
||||
}
|
||||
|
||||
function testFront() {
|
||||
function testForward() {
|
||||
var test0 = IDENTITY;
|
||||
assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getFront(test0)));
|
||||
assert(mat4FuzzyEqual({x: 0, y: 0, z: -1}, Mat4.getForward(test0)));
|
||||
|
||||
var test1 = Mat4.createFromScaleRotAndTrans(ONE_HALF, ROT_Y_180, ONE_TWO_THREE);
|
||||
assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getFront(test1)));
|
||||
assert(mat4FuzzyEqual({x: 0, y: 0, z: 1}, Mat4.getForward(test1)));
|
||||
}
|
||||
|
||||
function testMat4() {
|
||||
|
@ -157,7 +157,7 @@ function testMat4() {
|
|||
testTransformPoint();
|
||||
testTransformVector();
|
||||
testInverse();
|
||||
testFront();
|
||||
testForward();
|
||||
|
||||
print("MAT4 TEST complete! (" + (testCount - failureCount) + "/" + testCount + ") tests passed!");
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ var HOW_FAR_UP = RANGE / 1.5; // higher (for uneven ground) above range/2 (for
|
|||
|
||||
var totalCreated = 0;
|
||||
var offset = Vec3.sum(Vec3.multiply(HOW_FAR_UP, Vec3.UNIT_Y),
|
||||
Vec3.multiply(HOW_FAR_IN_FRONT_OF_ME, Quat.getFront(Camera.orientation)));
|
||||
Vec3.multiply(HOW_FAR_IN_FRONT_OF_ME, Quat.getForward(Camera.orientation)));
|
||||
var center = Vec3.sum(MyAvatar.position, offset);
|
||||
|
||||
function randomVector(range) {
|
||||
|
|
|
@ -20,9 +20,9 @@ orientation = Quat.safeEulerAngles(orientation);
|
|||
orientation.x = 0;
|
||||
orientation = Quat.fromVec3Degrees(orientation);
|
||||
|
||||
var centerUp = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
|
||||
var centerUp = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation)));
|
||||
centerUp.y += 0.5;
|
||||
var centerDown = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
|
||||
var centerDown = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(orientation)));
|
||||
centerDown.y -= 0.5;
|
||||
|
||||
var ENTITY_SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/uniformTest.fs";
|
||||
|
|
|
@ -15,7 +15,7 @@ MyAvatar.orientation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
|||
orientation = Quat.safeEulerAngles(MyAvatar.orientation);
|
||||
orientation.x = 0;
|
||||
orientation = Quat.fromVec3Degrees(orientation);
|
||||
var tablePosition = Vec3.sum(MyAvatar.position, Quat.getFront(orientation));
|
||||
var tablePosition = Vec3.sum(MyAvatar.position, Quat.getForward(orientation));
|
||||
tablePosition.y += 0.5;
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ var UPDATE_HZ = 60; // standard script update rate
|
|||
var UPDATE_INTERVAL = 1000/UPDATE_HZ; // standard script update interval
|
||||
var UPDATE_WORK_EFFORT = 0; // 1000 is light work, 1000000 ~= 30ms
|
||||
|
||||
var basePosition = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
var basePosition = Vec3.sum(Camera.getPosition(), Quat.getForward(Camera.getOrientation()));
|
||||
|
||||
var timerBox = Entities.addEntity(
|
||||
{ type: "Box",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
describe('Entity', function() {
|
||||
var center = Vec3.sum(
|
||||
MyAvatar.position,
|
||||
Vec3.multiply(3, Quat.getFront(Camera.getOrientation()))
|
||||
Vec3.multiply(3, Quat.getForward(Camera.getOrientation()))
|
||||
);
|
||||
var boxEntity;
|
||||
var boxProps = {
|
||||
|
|
|
@ -24,10 +24,10 @@ var boxZAxis, boxYAxis;
|
|||
var prevThumbDown = false;
|
||||
|
||||
function init() {
|
||||
boxPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));
|
||||
var front = Quat.getFront(Camera.getOrientation());
|
||||
boxZAxis = Vec3.normalize(Vec3.cross(front, Y_AXIS));
|
||||
boxYAxis = Vec3.normalize(Vec3.cross(boxZAxis, front));
|
||||
boxPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getForward(Camera.getOrientation())));
|
||||
var forward = Quat.getForward(Camera.getOrientation());
|
||||
boxZAxis = Vec3.normalize(Vec3.cross(forward, Y_AXIS));
|
||||
boxYAxis = Vec3.normalize(Vec3.cross(boxZAxis, forward));
|
||||
|
||||
boxEntity = Entities.addEntity({
|
||||
type: "Box",
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
var PhotoBooth = {};
|
||||
PhotoBooth.init = function () {
|
||||
var success = Clipboard.importEntities(PHOTOBOOTH_SETUP_JSON_URL);
|
||||
var frontFactor = 10;
|
||||
var frontUnitVec = Vec3.normalize(Quat.getFront(MyAvatar.orientation));
|
||||
var frontOffset = Vec3.multiply(frontUnitVec,frontFactor);
|
||||
var forwardFactor = 10;
|
||||
var forwardUnitVector = Vec3.normalize(Quat.getForward(MyAvatar.orientation));
|
||||
var forwardOffset = Vec3.multiply(forwardUnitVector,forwardFactor);
|
||||
var rightFactor = 3;
|
||||
// TODO: rightUnitVec is unused and spawnLocation declaration is incorrect
|
||||
var rightUnitVec = Vec3.normalize(Quat.getRight(MyAvatar.orientation));
|
||||
var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,frontOffset),rightFactor);
|
||||
var spawnLocation = Vec3.sum(Vec3.sum(MyAvatar.position,forwardOffset),rightFactor);
|
||||
if (success) {
|
||||
this.pastedEntityIDs = Clipboard.pasteEntities(spawnLocation);
|
||||
this.processPastedEntities();
|
||||
|
|
|
@ -87,8 +87,8 @@ function moveCloserToCamera(positionAtHUD) {
|
|||
// we don't actually want to render at the slerped look at... instead, we want to render
|
||||
// slightly closer to the camera than that.
|
||||
var MOVE_CLOSER_TO_CAMERA_BY = -0.25;
|
||||
var cameraFront = Quat.getFront(Camera.orientation);
|
||||
var closerToCamera = Vec3.multiply(cameraFront, MOVE_CLOSER_TO_CAMERA_BY); // slightly closer to camera
|
||||
var cameraForward = Quat.getForward(Camera.orientation);
|
||||
var closerToCamera = Vec3.multiply(cameraForward, MOVE_CLOSER_TO_CAMERA_BY); // slightly closer to camera
|
||||
var slightlyCloserPosition = Vec3.sum(positionAtHUD, closerToCamera);
|
||||
|
||||
return slightlyCloserPosition;
|
||||
|
|
|
@ -463,7 +463,7 @@ Grabber.prototype.moveEvent = function(event) {
|
|||
var orientation = Camera.getOrientation();
|
||||
var dragOffset = Vec3.multiply(drag.x, Quat.getRight(orientation));
|
||||
dragOffset = Vec3.sum(dragOffset, Vec3.multiply(-drag.y, Quat.getUp(orientation)));
|
||||
var axis = Vec3.cross(dragOffset, Quat.getFront(orientation));
|
||||
var axis = Vec3.cross(dragOffset, Quat.getForward(orientation));
|
||||
axis = Vec3.normalize(axis);
|
||||
var ROTATE_STRENGTH = 0.4; // magic number tuned by hand
|
||||
var angle = ROTATE_STRENGTH * Math.sqrt((drag.x * drag.x) + (drag.y * drag.y));
|
||||
|
@ -487,7 +487,7 @@ Grabber.prototype.moveEvent = function(event) {
|
|||
|
||||
if (this.mode === "verticalCylinder") {
|
||||
// for this mode we recompute the plane based on current Camera
|
||||
var planeNormal = Quat.getFront(Camera.getOrientation());
|
||||
var planeNormal = Quat.getForward(Camera.getOrientation());
|
||||
planeNormal.y = 0;
|
||||
planeNormal = Vec3.normalize(planeNormal);
|
||||
var pointOnCylinder = Vec3.multiply(planeNormal, this.xzDistanceToGrab);
|
||||
|
|
|
@ -1481,7 +1481,7 @@ function MyController(hand) {
|
|||
var pickRay = {
|
||||
origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position,
|
||||
direction: PICK_WITH_HAND_RAY ? Quat.getUp(worldHandRotation) : Vec3.mix(Quat.getUp(worldHandRotation),
|
||||
Quat.getFront(Camera.orientation),
|
||||
Quat.getForward(Camera.orientation),
|
||||
HAND_HEAD_MIX_RATIO),
|
||||
length: PICK_MAX_DISTANCE
|
||||
};
|
||||
|
|
|
@ -174,7 +174,7 @@ function calculateRayUICollisionPoint(position, direction) {
|
|||
// interect HUD plane, 1m in front of camera, using formula:
|
||||
// scale = hudNormal dot (hudPoint - position) / hudNormal dot direction
|
||||
// intersection = postion + scale*direction
|
||||
var hudNormal = Quat.getFront(Camera.getOrientation());
|
||||
var hudNormal = Quat.getForward(Camera.getOrientation());
|
||||
var hudPoint = Vec3.sum(Camera.getPosition(), hudNormal); // must also scale if PLANAR_PERPENDICULAR_HUD_DISTANCE!=1
|
||||
var denominator = Vec3.dot(hudNormal, direction);
|
||||
if (denominator === 0) {
|
||||
|
|
|
@ -816,7 +816,7 @@ function mouseClickEvent(event) {
|
|||
if (0 < x && sizeOK) {
|
||||
selectedEntityID = foundEntity;
|
||||
orientation = MyAvatar.orientation;
|
||||
intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation));
|
||||
intersection = rayPlaneIntersection(pickRay, P, Quat.getForward(orientation));
|
||||
|
||||
|
||||
if (!event.isShifted) {
|
||||
|
@ -1338,12 +1338,12 @@ function handeMenuEvent(menuItem) {
|
|||
}
|
||||
function getPositionToCreateEntity() {
|
||||
var HALF_TREE_SCALE = 16384;
|
||||
var direction = Quat.getFront(MyAvatar.orientation);
|
||||
var direction = Quat.getForward(MyAvatar.orientation);
|
||||
var distance = 1;
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance));
|
||||
|
||||
if (Camera.mode === "entity" || Camera.mode === "independent") {
|
||||
position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance))
|
||||
position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), distance))
|
||||
}
|
||||
position.y += 0.5;
|
||||
if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) {
|
||||
|
@ -1355,13 +1355,13 @@ function getPositionToCreateEntity() {
|
|||
function getPositionToImportEntity() {
|
||||
var dimensions = Clipboard.getContentsDimensions();
|
||||
var HALF_TREE_SCALE = 16384;
|
||||
var direction = Quat.getFront(MyAvatar.orientation);
|
||||
var direction = Quat.getForward(MyAvatar.orientation);
|
||||
var longest = 1;
|
||||
longest = Math.sqrt(Math.pow(dimensions.x, 2) + Math.pow(dimensions.z, 2));
|
||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, longest));
|
||||
|
||||
if (Camera.mode === "entity" || Camera.mode === "independent") {
|
||||
position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), longest))
|
||||
position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), longest))
|
||||
}
|
||||
|
||||
if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) {
|
||||
|
|
|
@ -78,9 +78,9 @@ function calcSpawnInfo(hand, height) {
|
|||
rotation: lookAtRot
|
||||
};
|
||||
} else {
|
||||
var front = Quat.getFront(headRot);
|
||||
finalPosition = Vec3.sum(headPos, Vec3.multiply(0.6, front));
|
||||
var orientation = Quat.lookAt({x: 0, y: 0, z: 0}, front, {x: 0, y: 1, z: 0});
|
||||
var forward = Quat.getForward(headRot);
|
||||
finalPosition = Vec3.sum(headPos, Vec3.multiply(0.6, forward));
|
||||
var orientation = Quat.lookAt({x: 0, y: 0, z: 0}, forward, {x: 0, y: 1, z: 0});
|
||||
return {
|
||||
position: finalPosition,
|
||||
rotation: Quat.multiply(orientation, {x: 0, y: 1, z: 0, w: 0})
|
||||
|
|
|
@ -158,7 +158,7 @@ CameraManager = function() {
|
|||
that.zoomDistance = INITIAL_ZOOM_DISTANCE;
|
||||
that.targetZoomDistance = that.zoomDistance + 3.0;
|
||||
var focalPoint = Vec3.sum(Camera.getPosition(),
|
||||
Vec3.multiply(that.zoomDistance, Quat.getFront(Camera.getOrientation())));
|
||||
Vec3.multiply(that.zoomDistance, Quat.getForward(Camera.getOrientation())));
|
||||
|
||||
// Determine the correct yaw and pitch to keep the camera in the same location
|
||||
var dPos = Vec3.subtract(focalPoint, Camera.getPosition());
|
||||
|
@ -435,7 +435,7 @@ CameraManager = function() {
|
|||
});
|
||||
var q = Quat.multiply(yRot, xRot);
|
||||
|
||||
var pos = Vec3.multiply(Quat.getFront(q), that.zoomDistance);
|
||||
var pos = Vec3.multiply(Quat.getForward(q), that.zoomDistance);
|
||||
Camera.setPosition(Vec3.sum(that.focalPoint, pos));
|
||||
|
||||
yRot = Quat.angleAxis(that.yaw - 180, {
|
||||
|
|
|
@ -2517,7 +2517,7 @@ SelectionDisplay = (function() {
|
|||
onBegin: function(event) {
|
||||
pickRay = generalComputePickRay(event.x, event.y);
|
||||
|
||||
upDownPickNormal = Quat.getFront(lastCameraOrientation);
|
||||
upDownPickNormal = Quat.getForward(lastCameraOrientation);
|
||||
// Remove y component so the y-axis lies along the plane we picking on - this will
|
||||
// give movements that follow the mouse.
|
||||
upDownPickNormal.y = 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ SoundArray = function(audioOptions, autoUpdateAudioPosition) {
|
|||
};
|
||||
this.updateAudioPosition = function() {
|
||||
var position = MyAvatar.position;
|
||||
var forwardVector = Quat.getFront(MyAvatar.orientation);
|
||||
var forwardVector = Quat.getForward(MyAvatar.orientation);
|
||||
this.audioOptions.position = Vec3.sum(position, forwardVector);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -33,7 +33,7 @@ Script.setTimeout(function() {
|
|||
}, STARTUP_DELAY);
|
||||
|
||||
function addNameTag() {
|
||||
var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getFront(MyAvatar.orientation)));
|
||||
var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getForward(MyAvatar.orientation)));
|
||||
nameTagPosition.y += HEIGHT_ABOVE_HEAD;
|
||||
var nameTagProperties = {
|
||||
name: MyAvatar.displayName + ' Name Tag',
|
||||
|
@ -49,7 +49,7 @@ function addNameTag() {
|
|||
|
||||
function updateNameTag() {
|
||||
var nameTagProps = Entities.getEntityProperties(nameTagEntityID);
|
||||
var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getFront(MyAvatar.orientation)));
|
||||
var nameTagPosition = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(HEAD_OFFSET, Quat.getForward(MyAvatar.orientation)));
|
||||
nameTagPosition.y += HEIGHT_ABOVE_HEAD;
|
||||
|
||||
Entities.editEntity(nameTagEntityID, {
|
||||
|
|
|
@ -298,7 +298,7 @@ function populateUserList(selectData, oldAudioData) {
|
|||
verticalHalfAngle = filter && (frustum.fieldOfView / 2),
|
||||
horizontalHalfAngle = filter && (verticalHalfAngle * frustum.aspectRatio),
|
||||
orientation = filter && Camera.orientation,
|
||||
front = filter && Quat.getFront(orientation),
|
||||
forward = filter && Quat.getForward(orientation),
|
||||
verticalAngleNormal = filter && Quat.getRight(orientation),
|
||||
horizontalAngleNormal = filter && Quat.getUp(orientation);
|
||||
avatars.forEach(function (id) { // sorting the identifiers is just an aid for debugging
|
||||
|
@ -316,8 +316,8 @@ function populateUserList(selectData, oldAudioData) {
|
|||
return;
|
||||
}
|
||||
var normal = id && filter && Vec3.normalize(Vec3.subtract(avatar.position, myPosition));
|
||||
var horizontal = normal && angleBetweenVectorsInPlane(normal, front, horizontalAngleNormal);
|
||||
var vertical = normal && angleBetweenVectorsInPlane(normal, front, verticalAngleNormal);
|
||||
var horizontal = normal && angleBetweenVectorsInPlane(normal, forward, horizontalAngleNormal);
|
||||
var vertical = normal && angleBetweenVectorsInPlane(normal, forward, verticalAngleNormal);
|
||||
if (id && filter && ((Math.abs(horizontal) > horizontalHalfAngle) || (Math.abs(vertical) > verticalHalfAngle))) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ function addTerrainBlock() {
|
|||
if (alreadyThere) {
|
||||
// there is already a terrain block under MyAvatar.
|
||||
// try in front of the avatar.
|
||||
facingPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(8.0, Quat.getFront(Camera.getOrientation())));
|
||||
facingPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(8.0, Quat.getForward(Camera.getOrientation())));
|
||||
facingPosition = Vec3.sum(facingPosition, {
|
||||
x: 8,
|
||||
y: 8,
|
||||
|
|
|
@ -53,7 +53,7 @@ var deleteButton = toolBar.addOverlay("image", {
|
|||
});
|
||||
|
||||
function inFrontOfMe(distance) {
|
||||
return Vec3.sum(Camera.getPosition(), Vec3.multiply(distance, Quat.getFront(Camera.getOrientation())));
|
||||
return Vec3.sum(Camera.getPosition(), Vec3.multiply(distance, Quat.getForward(Camera.getOrientation())));
|
||||
}
|
||||
|
||||
function onButtonClick() {
|
||||
|
|
|
@ -44,8 +44,8 @@ var FIXED_LOCATION = false;
|
|||
|
||||
if (!FIXED_LOCATION) {
|
||||
var flockPosition = Vec3.sum(MyAvatar.position,Vec3.sum(
|
||||
Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_ABOVE_ME),
|
||||
Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_IN_FRONT_OF_ME)));
|
||||
Vec3.multiply(Quat.getForward(MyAvatar.orientation), DISTANCE_ABOVE_ME),
|
||||
Vec3.multiply(Quat.getForward(MyAvatar.orientation), DISTANCE_IN_FRONT_OF_ME)));
|
||||
} else {
|
||||
var flockPosition = { x: 4999.6, y: 4986.5, z: 5003.5 };
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ function updateButterflies(deltaTime) {
|
|||
var HORIZ_SCALE = 0.50;
|
||||
var VERT_SCALE = 0.50;
|
||||
var newHeading = Math.random() * 360.0;
|
||||
var newVelocity = Vec3.multiply(HORIZ_SCALE, Quat.getFront(Quat.fromPitchYawRollDegrees(0.0, newHeading, 0.0)));
|
||||
var newVelocity = Vec3.multiply(HORIZ_SCALE, Quat.getForward(Quat.fromPitchYawRollDegrees(0.0, newHeading, 0.0)));
|
||||
newVelocity.y = (Math.random() + 0.5) * VERT_SCALE;
|
||||
Entities.editEntity(butterflies[i], { rotation: Quat.fromPitchYawRollDegrees(-80 + Math.random() * 20, newHeading, (Math.random() - 0.5) * 10),
|
||||
velocity: newVelocity } );
|
||||
|
|
|
@ -18,7 +18,7 @@ var orientation = MyAvatar.orientation;
|
|||
orientation = Quat.safeEulerAngles(orientation);
|
||||
orientation.x = 0;
|
||||
orientation = Quat.fromVec3Degrees(orientation);
|
||||
var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getFront(orientation)));
|
||||
var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getForward(orientation)));
|
||||
|
||||
// An entity is described and created by specifying a map of properties
|
||||
var cow = Entities.addEntity({
|
||||
|
|
|
@ -127,8 +127,8 @@ function mousePressEvent(event) {
|
|||
deleteDice();
|
||||
} else if (clickedOverlay == diceButton) {
|
||||
var HOW_HARD = 2.0;
|
||||
var position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
var velocity = Vec3.multiply(HOW_HARD, Quat.getFront(Camera.getOrientation()));
|
||||
var position = Vec3.sum(Camera.getPosition(), Quat.getForward(Camera.getOrientation()));
|
||||
var velocity = Vec3.multiply(HOW_HARD, Quat.getForward(Camera.getOrientation()));
|
||||
shootDice(position, velocity);
|
||||
madeSound = false;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
|||
x: 0,
|
||||
y: 0.5,
|
||||
z: 0
|
||||
}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation())));
|
||||
}), Vec3.multiply(0.5, Quat.getForward(Camera.getOrientation())));
|
||||
|
||||
var flashlight = Entities.addEntity({
|
||||
type: "Model",
|
||||
|
|
|
@ -15,7 +15,7 @@ var orientation = MyAvatar.orientation;
|
|||
orientation = Quat.safeEulerAngles(orientation);
|
||||
orientation.x = 0;
|
||||
orientation = Quat.fromVec3Degrees(orientation);
|
||||
var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getFront(orientation)));
|
||||
var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getForward(orientation)));
|
||||
|
||||
var CLUB_MODEL = "http://hifi-production.s3.amazonaws.com/tutorials/golfClub/putter_VR.fbx";
|
||||
var CLUB_COLLISION_HULL = "http://hifi-production.s3.amazonaws.com/tutorials/golfClub/club_collision_hull.obj";
|
||||
|
|
|
@ -14,7 +14,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
|||
x: 0,
|
||||
y: 0.5,
|
||||
z: 0
|
||||
}), Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
||||
}), Vec3.multiply(1, Quat.getForward(Camera.getOrientation())));
|
||||
|
||||
// this is just a model exported from blender with a texture named 'Picture' on one face. also made it emissive so it doesn't require lighting.
|
||||
var MODEL_URL = "http://hifi-production.s3.amazonaws.com/tutorials/pictureFrame/finalFrame.fbx";
|
||||
|
|
|
@ -14,7 +14,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
|||
x: 0,
|
||||
y: 0.5,
|
||||
z: 0
|
||||
}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation())));
|
||||
}), Vec3.multiply(0.5, Quat.getForward(Camera.getOrientation())));
|
||||
|
||||
|
||||
var pingPongGunProperties = {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation())));
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getForward(Camera.getOrientation())));
|
||||
var SCRIPT_URL = "http://hifi-production.s3.amazonaws.com/tutorials/entity_scripts/pistol.js";
|
||||
var MODEL_URL = "http://hifi-production.s3.amazonaws.com/tutorials/pistol/gun.fbx";
|
||||
var COLLISION_SOUND_URL = 'http://hifi-production.s3.amazonaws.com/tutorials/pistol/drop.wav'
|
||||
|
|
|
@ -13,7 +13,7 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
|||
x: 0,
|
||||
y: 0.5,
|
||||
z: 0
|
||||
}), Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
||||
}), Vec3.multiply(1, Quat.getForward(Camera.getOrientation())));
|
||||
|
||||
function makeBell() {
|
||||
var soundMakerProperties = {
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
// Position yourself facing in the direction you were originally facing, but with a
|
||||
// point on the ground *away* meters from *position* and in front of you.
|
||||
|
||||
var offset = Quat.getFront(MyAvatar.orientation);
|
||||
var offset = Quat.getForward(MyAvatar.orientation);
|
||||
offset.y = 0.0;
|
||||
offset = Vec3.multiply(-away, Vec3.normalize(offset));
|
||||
var newAvatarPosition = Vec3.sum(position, offset);
|
||||
|
@ -72,7 +72,7 @@
|
|||
}
|
||||
|
||||
function inFrontOfMe() {
|
||||
return Vec3.sum(MyAvatar.position, Vec3.multiply(BALL_DROP_DISTANCE, Quat.getFront(MyAvatar.orientation)));
|
||||
return Vec3.sum(MyAvatar.position, Vec3.multiply(BALL_DROP_DISTANCE, Quat.getForward(MyAvatar.orientation)));
|
||||
}
|
||||
|
||||
function avatarHalfHeight() {
|
||||
|
|
|
@ -94,9 +94,9 @@
|
|||
},
|
||||
|
||||
shootBall: function(gunProperties) {
|
||||
var forwardVec = Quat.getFront(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0)));
|
||||
forwardVec = Vec3.normalize(forwardVec);
|
||||
forwardVec = Vec3.multiply(forwardVec, GUN_FORCE);
|
||||
var forwardVector = Quat.getForward(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0)));
|
||||
forwardVector = Vec3.normalize(forwardVector);
|
||||
forwardVector = Vec3.multiply(forwardVector, GUN_FORCE);
|
||||
|
||||
var properties = {
|
||||
name: 'Tutorial Ping Pong Ball',
|
||||
|
@ -111,7 +111,7 @@
|
|||
rotation: gunProperties.rotation,
|
||||
position: this.getGunTipPosition(gunProperties),
|
||||
gravity: PING_PONG_GUN_GRAVITY,
|
||||
velocity: forwardVec,
|
||||
velocity: forwardVector,
|
||||
lifetime: 10
|
||||
};
|
||||
|
||||
|
@ -131,12 +131,12 @@
|
|||
|
||||
getGunTipPosition: function(properties) {
|
||||
//the tip of the gun is going to be in a different place than the center, so we move in space relative to the model to find that position
|
||||
var frontVector = Quat.getFront(properties.rotation);
|
||||
var frontOffset = Vec3.multiply(frontVector, GUN_TIP_FWD_OFFSET);
|
||||
var forwardVector = Quat.getForward(properties.rotation);
|
||||
var forwardOffset = Vec3.multiply(forwardVector, GUN_TIP_FWD_OFFSET);
|
||||
var upVector = Quat.getUp(properties.rotation);
|
||||
var upOffset = Vec3.multiply(upVector, GUN_TIP_UP_OFFSET);
|
||||
|
||||
var gunTipPosition = Vec3.sum(properties.position, frontOffset);
|
||||
var gunTipPosition = Vec3.sum(properties.position, forwardOffset);
|
||||
gunTipPosition = Vec3.sum(gunTipPosition, upOffset);
|
||||
|
||||
return gunTipPosition;
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
var gunProps = Entities.getEntityProperties(this.entityID, ['position', 'rotation']);
|
||||
this.position = gunProps.position;
|
||||
this.rotation = gunProps.rotation;
|
||||
this.firingDirection = Quat.getFront(this.rotation);
|
||||
this.firingDirection = Quat.getForward(this.rotation);
|
||||
var upVec = Quat.getUp(this.rotation);
|
||||
this.barrelPoint = Vec3.sum(this.position, Vec3.multiply(upVec, this.laserOffsets.y));
|
||||
this.laserTip = Vec3.sum(this.barrelPoint, Vec3.multiply(this.firingDirection, this.laserLength));
|
||||
|
|
|
@ -34,12 +34,12 @@
|
|||
|
||||
var SCRIPT_URL = Script.resolvePath("./entity_scripts/magneticBlock.js");
|
||||
|
||||
var frontVector = Quat.getFront(MyAvatar.orientation);
|
||||
frontVector.y += VERTICAL_OFFSET;
|
||||
var forwardVector = Quat.getForward(MyAvatar.orientation);
|
||||
forwardVector.y += VERTICAL_OFFSET;
|
||||
for (var x = 0; x < COLUMNS; x++) {
|
||||
for (var y = 0; y < ROWS; y++) {
|
||||
|
||||
var frontOffset = {
|
||||
var forwardOffset = {
|
||||
x: 0,
|
||||
y: SIZE * y + SIZE,
|
||||
z: SIZE * x + SIZE
|
||||
|
@ -61,7 +61,7 @@
|
|||
cloneLimit: 9999
|
||||
}
|
||||
}),
|
||||
position: Vec3.sum(MyAvatar.position, Vec3.sum(frontOffset, frontVector)),
|
||||
position: Vec3.sum(MyAvatar.position, Vec3.sum(forwardOffset, forwardVector)),
|
||||
color: newColor(),
|
||||
script: SCRIPT_URL
|
||||
});
|
||||
|
|
|
@ -123,16 +123,16 @@ public:
|
|||
|
||||
void update(float deltaTime) {
|
||||
if (moving()) {
|
||||
glm::vec3 camFront = getOrientation() * Vectors::FRONT;
|
||||
glm::vec3 camForward = getOrientation() * Vectors::FRONT;
|
||||
glm::vec3 camRight = getOrientation() * Vectors::RIGHT;
|
||||
glm::vec3 camUp = getOrientation() * Vectors::UP;
|
||||
float moveSpeed = deltaTime * movementSpeed;
|
||||
|
||||
if (keys[FORWARD]) {
|
||||
position += camFront * moveSpeed;
|
||||
position += camForward * moveSpeed;
|
||||
}
|
||||
if (keys[BACK]) {
|
||||
position -= camFront * moveSpeed;
|
||||
position -= camForward * moveSpeed;
|
||||
}
|
||||
if (keys[LEFT]) {
|
||||
position -= camRight * moveSpeed;
|
||||
|
|
Loading…
Reference in a new issue