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