mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 04:57:58 +02:00
fix use of PI constant after merge with upstream master
This commit is contained in:
parent
104fcd1289
commit
5a5b22db61
2 changed files with 195 additions and 203 deletions
|
@ -288,7 +288,7 @@ void Application::paintGL() {
|
|||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
_myCamera.setTightness (100.0f);
|
||||
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
||||
_myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
|
||||
_myCamera.setTargetRotation(_myAvatar.getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PIf, 0.0f)));
|
||||
|
||||
} else if (OculusManager::isConnected()) {
|
||||
_myCamera.setUpShift (0.0f);
|
||||
|
|
|
@ -62,32 +62,32 @@ float chatMessageScale = 0.0015;
|
|||
float chatMessageHeight = 0.20;
|
||||
|
||||
Avatar::Avatar(Agent* owningAgent) :
|
||||
AvatarData(owningAgent),
|
||||
_head(this),
|
||||
_TEST_bigSphereRadius(0.4f),
|
||||
_TEST_bigSpherePosition(5.0f, _TEST_bigSphereRadius, 5.0f),
|
||||
_mousePressed(false),
|
||||
_bodyPitchDelta(0.0f),
|
||||
_bodyYawDelta(0.0f),
|
||||
_bodyRollDelta(0.0f),
|
||||
_movedHandOffset(0.0f, 0.0f, 0.0f),
|
||||
_mode(AVATAR_MODE_STANDING),
|
||||
_cameraPosition(0.0f, 0.0f, 0.0f),
|
||||
_handHoldingPosition(0.0f, 0.0f, 0.0f),
|
||||
_velocity(0.0f, 0.0f, 0.0f),
|
||||
_thrust(0.0f, 0.0f, 0.0f),
|
||||
_speed(0.0f),
|
||||
_maxArmLength(0.0f),
|
||||
_pelvisStandingHeight(0.0f),
|
||||
_pelvisFloatingHeight(0.0f),
|
||||
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
||||
_gravity(0.0f, -1.0f, 0.0f),
|
||||
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
||||
_mouseRayOrigin(0.0f, 0.0f, 0.0f),
|
||||
_mouseRayDirection(0.0f, 0.0f, 0.0f),
|
||||
_interactingOther(NULL),
|
||||
_cumulativeMouseYaw(0.0f),
|
||||
_isMouseTurningRight(false)
|
||||
AvatarData(owningAgent),
|
||||
_head(this),
|
||||
_TEST_bigSphereRadius(0.4f),
|
||||
_TEST_bigSpherePosition(5.0f, _TEST_bigSphereRadius, 5.0f),
|
||||
_mousePressed(false),
|
||||
_bodyPitchDelta(0.0f),
|
||||
_bodyYawDelta(0.0f),
|
||||
_bodyRollDelta(0.0f),
|
||||
_movedHandOffset(0.0f, 0.0f, 0.0f),
|
||||
_mode(AVATAR_MODE_STANDING),
|
||||
_cameraPosition(0.0f, 0.0f, 0.0f),
|
||||
_handHoldingPosition(0.0f, 0.0f, 0.0f),
|
||||
_velocity(0.0f, 0.0f, 0.0f),
|
||||
_thrust(0.0f, 0.0f, 0.0f),
|
||||
_speed(0.0f),
|
||||
_maxArmLength(0.0f),
|
||||
_pelvisStandingHeight(0.0f),
|
||||
_pelvisFloatingHeight(0.0f),
|
||||
_distanceToNearestAvatar(std::numeric_limits<float>::max()),
|
||||
_gravity(0.0f, -1.0f, 0.0f),
|
||||
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
||||
_mouseRayOrigin(0.0f, 0.0f, 0.0f),
|
||||
_mouseRayDirection(0.0f, 0.0f, 0.0f),
|
||||
_interactingOther(NULL),
|
||||
_cumulativeMouseYaw(0.0f),
|
||||
_isMouseTurningRight(false)
|
||||
{
|
||||
|
||||
// give the pointer to our head to inherited _headData variable from AvatarData
|
||||
|
@ -157,11 +157,11 @@ void Avatar::initializeBodyBalls() {
|
|||
_bodyBall[ AVATAR_JOINT_RIGHT_TOES ].radius = 0.025;
|
||||
|
||||
/*
|
||||
// to aid in hand-shaking and hand-holding, the right hand is not collidable
|
||||
_bodyBall[ AVATAR_JOINT_RIGHT_ELBOW ].isCollidable = false;
|
||||
_bodyBall[ AVATAR_JOINT_RIGHT_WRIST ].isCollidable = false;
|
||||
_bodyBall[ AVATAR_JOINT_RIGHT_FINGERTIPS].isCollidable = false;
|
||||
*/
|
||||
// to aid in hand-shaking and hand-holding, the right hand is not collidable
|
||||
_bodyBall[ AVATAR_JOINT_RIGHT_ELBOW ].isCollidable = false;
|
||||
_bodyBall[ AVATAR_JOINT_RIGHT_WRIST ].isCollidable = false;
|
||||
_bodyBall[ AVATAR_JOINT_RIGHT_FINGERTIPS].isCollidable = false;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,8 +193,8 @@ void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterfa
|
|||
glm::vec3 headRotationRates(_head.getPitch(), _head.getYaw(), _head.getRoll());
|
||||
|
||||
glm::vec3 leaning = (serialInterface->getLastAcceleration() - serialInterface->getGravity())
|
||||
* LEAN_SENSITIVITY
|
||||
* (1.f - fminf(glm::length(headRotationRates), HEAD_RATE_MAX) / HEAD_RATE_MAX);
|
||||
* LEAN_SENSITIVITY
|
||||
* (1.f - fminf(glm::length(headRotationRates), HEAD_RATE_MAX) / HEAD_RATE_MAX);
|
||||
leaning.y = 0.f;
|
||||
if (glm::length(leaning) < LEAN_MAX) {
|
||||
_head.setLeanForward(_head.getLeanForward() * (1.f - LEAN_AVERAGING * deltaTime) +
|
||||
|
@ -353,16 +353,16 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
}
|
||||
if (transmitter->getTouchState()->state == 'D') {
|
||||
_thrust += THRUST_MAG *
|
||||
(float)(transmitter->getTouchState()->y - TOUCH_POSITION_RANGE_HALF) / TOUCH_POSITION_RANGE_HALF *
|
||||
TRANSMITTER_LIFT_SCALE *
|
||||
deltaTime *
|
||||
up;
|
||||
(float)(transmitter->getTouchState()->y - TOUCH_POSITION_RANGE_HALF) / TOUCH_POSITION_RANGE_HALF *
|
||||
TRANSMITTER_LIFT_SCALE *
|
||||
deltaTime *
|
||||
up;
|
||||
}
|
||||
}
|
||||
|
||||
// update body yaw by body yaw delta
|
||||
orientation = orientation * glm::quat(glm::radians(
|
||||
glm::vec3(_bodyPitchDelta, _bodyYawDelta, _bodyRollDelta) * deltaTime));
|
||||
glm::vec3(_bodyPitchDelta, _bodyYawDelta, _bodyRollDelta) * deltaTime));
|
||||
|
||||
// decay body rotation momentum
|
||||
float bodySpinMomentum = 1.0 - BODY_SPIN_FRICTION * deltaTime;
|
||||
|
@ -382,8 +382,8 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
const float BODY_ROLL_WHILE_TURNING = 0.2;
|
||||
float forwardComponentOfVelocity = glm::dot(getBodyFrontDirection(), _velocity);
|
||||
orientation = orientation * glm::quat(glm::radians(glm::vec3(
|
||||
BODY_PITCH_WHILE_WALKING * deltaTime * forwardComponentOfVelocity, 0.0f,
|
||||
BODY_ROLL_WHILE_TURNING * deltaTime * _speed * _bodyYawDelta)));
|
||||
BODY_PITCH_WHILE_WALKING * deltaTime * forwardComponentOfVelocity, 0.0f,
|
||||
BODY_ROLL_WHILE_TURNING * deltaTime * _speed * _bodyYawDelta)));
|
||||
|
||||
// these forces keep the body upright...
|
||||
const float BODY_UPRIGHT_FORCE = 10.0;
|
||||
|
@ -453,8 +453,8 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
if (USING_HEAD_LEAN) {
|
||||
if (fabs(_head.getLeanSideways() + _head.getLeanForward()) > 0.0f) {
|
||||
glm::vec3 headLean =
|
||||
right * _head.getLeanSideways() +
|
||||
front * _head.getLeanForward();
|
||||
right * _head.getLeanSideways() +
|
||||
front * _head.getLeanForward();
|
||||
|
||||
_bodyBall[ AVATAR_JOINT_TORSO ].position += headLean * 0.1f;
|
||||
_bodyBall[ AVATAR_JOINT_CHEST ].position += headLean * 0.4f;
|
||||
|
@ -473,7 +473,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
_bodyBall[ AVATAR_JOINT_RIGHT_WRIST ].position += headLean * 0.1f;
|
||||
_bodyBall[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position += headLean * 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set head lookat position
|
||||
if (!_owningAgent) {
|
||||
|
@ -595,21 +595,21 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
|
||||
glm::vec3 vectorFromMyHandToYourHand
|
||||
(
|
||||
_interactingOther->_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position -
|
||||
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
||||
);
|
||||
_interactingOther->_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position -
|
||||
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
||||
);
|
||||
|
||||
float distanceBetweenOurHands = glm::length(vectorFromMyHandToYourHand);
|
||||
|
||||
/*
|
||||
// if my arm can no longer reach the other hand, turn off hand-holding
|
||||
if (!_avatarTouch.getAbleToReachOtherAvatar()) {
|
||||
_avatarTouch.setHoldingHands(false);
|
||||
}
|
||||
if (distanceBetweenOurHands > _maxArmLength) {
|
||||
_avatarTouch.setHoldingHands(false);
|
||||
}
|
||||
*/
|
||||
// if my arm can no longer reach the other hand, turn off hand-holding
|
||||
if (!_avatarTouch.getAbleToReachOtherAvatar()) {
|
||||
_avatarTouch.setHoldingHands(false);
|
||||
}
|
||||
if (distanceBetweenOurHands > _maxArmLength) {
|
||||
_avatarTouch.setHoldingHands(false);
|
||||
}
|
||||
*/
|
||||
|
||||
// if neither of us are grasping, turn off hand-holding
|
||||
if ((_handState != HAND_STATE_GRASPING ) && (_interactingOther->_handState != HAND_STATE_GRASPING)) {
|
||||
|
@ -620,9 +620,9 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
if (_avatarTouch.getHoldingHands()) {
|
||||
_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position +=
|
||||
(
|
||||
_interactingOther->_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
||||
- _skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
||||
) * 0.5f;
|
||||
_interactingOther->_skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
||||
- _skeleton.joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].position
|
||||
) * 0.5f;
|
||||
|
||||
if (distanceBetweenOurHands > 0.3) {
|
||||
float force = 10.0f * deltaTime;
|
||||
|
@ -688,8 +688,8 @@ void Avatar::updateCollisionWithEnvironment() {
|
|||
float radius = _height * 0.125f;
|
||||
glm::vec3 penetration;
|
||||
if (Application::getInstance()->getEnvironment()->findCapsulePenetration(
|
||||
_position - up * (_pelvisFloatingHeight - radius),
|
||||
_position + up * (_height - _pelvisFloatingHeight - radius), radius, penetration)) {
|
||||
_position - up * (_pelvisFloatingHeight - radius),
|
||||
_position + up * (_height - _pelvisFloatingHeight - radius), radius, penetration)) {
|
||||
applyCollisionWithScene(penetration);
|
||||
}
|
||||
}
|
||||
|
@ -698,8 +698,8 @@ void Avatar::updateCollisionWithVoxels() {
|
|||
float radius = _height * 0.125f;
|
||||
glm::vec3 penetration;
|
||||
if (Application::getInstance()->getVoxels()->findCapsulePenetration(
|
||||
_position - glm::vec3(0.0f, _pelvisFloatingHeight - radius, 0.0f),
|
||||
_position + glm::vec3(0.0f, _height - _pelvisFloatingHeight - radius, 0.0f), radius, penetration)) {
|
||||
_position - glm::vec3(0.0f, _pelvisFloatingHeight - radius, 0.0f),
|
||||
_position + glm::vec3(0.0f, _height - _pelvisFloatingHeight - radius, 0.0f), radius, penetration)) {
|
||||
applyCollisionWithScene(penetration);
|
||||
}
|
||||
}
|
||||
|
@ -740,7 +740,7 @@ void Avatar::updateAvatarCollisions(float deltaTime) {
|
|||
|
||||
if (glm::length(vectorBetweenBoundingSpheres) < _height * ONE_HALF + otherAvatar->_height * ONE_HALF) {
|
||||
//apply forces from collision
|
||||
applyCollisionWithOtherAvatar(otherAvatar, deltaTime);
|
||||
applyCollisionWithOtherAvatar(otherAvatar, deltaTime);
|
||||
}
|
||||
|
||||
// test other avatar hand position for proximity
|
||||
|
@ -783,7 +783,7 @@ void Avatar::applyCollisionWithOtherAvatar(Avatar * otherAvatar, float deltaTime
|
|||
glm::vec3 ballPushForce = directionVector * COLLISION_BALL_FORCE * penetration * deltaTime;
|
||||
bodyPushForce += directionVector * COLLISION_BODY_FORCE * penetration * deltaTime;
|
||||
|
||||
_bodyBall[b].velocity += ballPushForce;
|
||||
_bodyBall[b].velocity += ballPushForce;
|
||||
otherAvatar->_bodyBall[o].velocity -= ballPushForce;
|
||||
|
||||
}// check for collision
|
||||
|
@ -857,16 +857,12 @@ void Avatar::render(bool lookingInMirror) {
|
|||
}
|
||||
glPushMatrix();
|
||||
|
||||
// extract the view direction from the modelview matrix: transform (0, 0, 1) by the
|
||||
// transpose of the modelview to get its direction in world space, then use the X/Z
|
||||
// components to determine the angle
|
||||
float modelview[16];
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
|
||||
glm::vec3 chatPosition = _bodyBall[AVATAR_JOINT_HEAD_BASE].position + getBodyUpDirection() * chatMessageHeight;
|
||||
glTranslatef(chatPosition.x, chatPosition.y, chatPosition.z);
|
||||
glm::quat chatRotation = Application::getInstance()->getCamera()->getRotation();
|
||||
glm::vec3 chatAxis = glm::axis(chatRotation);
|
||||
glRotatef(glm::angle(chatRotation), chatAxis.x, chatAxis.y, chatAxis.z);
|
||||
|
||||
glTranslatef(_joint[AVATAR_JOINT_HEAD_BASE].springyPosition.x,
|
||||
_joint[AVATAR_JOINT_HEAD_BASE].springyPosition.y + chatMessageHeight,
|
||||
_joint[AVATAR_JOINT_HEAD_BASE].springyPosition.z);
|
||||
glRotatef(atan2(-modelview[2], -modelview[10]) * 180 / PIf, 0, 1, 0);
|
||||
|
||||
glColor3f(0, 0.8, 0);
|
||||
glRotatef(180, 0, 1, 0);
|
||||
|
@ -945,11 +941,11 @@ void Avatar::updateBodyBalls(float deltaTime) {
|
|||
}
|
||||
|
||||
/*
|
||||
//apply forces from touch...
|
||||
if (_skeleton.joint[b].touchForce > 0.0) {
|
||||
_skeleton.joint[b].springyVelocity += _mouseRayDirection * _skeleton.joint[b].touchForce * 0.7f;
|
||||
}
|
||||
*/
|
||||
//apply forces from touch...
|
||||
if (_skeleton.joint[b].touchForce > 0.0) {
|
||||
_skeleton.joint[b].springyVelocity += _mouseRayDirection * _skeleton.joint[b].touchForce * 0.7f;
|
||||
}
|
||||
*/
|
||||
|
||||
//update position by velocity...
|
||||
_bodyBall[b].position += _bodyBall[b].velocity * deltaTime;
|
||||
|
@ -1018,7 +1014,7 @@ void Avatar::renderBody(bool lookingInMirror) {
|
|||
float distanceToCamera = glm::length(_cameraPosition - _skeleton.joint[b].position);
|
||||
|
||||
float alpha = lookingInMirror ? 1.0f : glm::clamp((distanceToCamera - RENDER_TRANSLUCENT_BEYOND) /
|
||||
(RENDER_OPAQUE_BEYOND - RENDER_TRANSLUCENT_BEYOND), 0.f, 1.f);
|
||||
(RENDER_OPAQUE_BEYOND - RENDER_TRANSLUCENT_BEYOND), 0.f, 1.f);
|
||||
|
||||
if (lookingInMirror || _owningAgent) {
|
||||
alpha = 1.0f;
|
||||
|
@ -1035,8 +1031,8 @@ void Avatar::renderBody(bool lookingInMirror) {
|
|||
|| b == AVATAR_JOINT_RIGHT_FINGERTIPS ) {
|
||||
// Render the sphere at the joint
|
||||
if (_owningAgent || b == AVATAR_JOINT_RIGHT_ELBOW
|
||||
|| b == AVATAR_JOINT_RIGHT_WRIST
|
||||
|| b == AVATAR_JOINT_RIGHT_FINGERTIPS ) {
|
||||
|| b == AVATAR_JOINT_RIGHT_WRIST
|
||||
|| b == AVATAR_JOINT_RIGHT_FINGERTIPS ) {
|
||||
glColor3f(SKIN_COLOR[0] + _bodyBall[b].touchForce * 0.3f,
|
||||
SKIN_COLOR[1] - _bodyBall[b].touchForce * 0.2f,
|
||||
SKIN_COLOR[2] - _bodyBall[b].touchForce * 0.1f);
|
||||
|
@ -1048,7 +1044,7 @@ void Avatar::renderBody(bool lookingInMirror) {
|
|||
}
|
||||
|
||||
if ((b != AVATAR_JOINT_HEAD_TOP )
|
||||
&& (b != AVATAR_JOINT_HEAD_BASE )) {
|
||||
&& (b != AVATAR_JOINT_HEAD_BASE )) {
|
||||
glPushMatrix();
|
||||
glTranslatef(_bodyBall[b].position.x, _bodyBall[b].position.y, _bodyBall[b].position.z);
|
||||
glutSolidSphere(_bodyBall[b].radius, 20.0f, 20.0f);
|
||||
|
@ -1058,14 +1054,14 @@ void Avatar::renderBody(bool lookingInMirror) {
|
|||
// Render the cone connecting this joint to its parent
|
||||
if (_skeleton.joint[b].parent != AVATAR_JOINT_NULL) {
|
||||
if ((b != AVATAR_JOINT_HEAD_TOP )
|
||||
&& (b != AVATAR_JOINT_HEAD_BASE )
|
||||
&& (b != AVATAR_JOINT_PELVIS )
|
||||
&& (b != AVATAR_JOINT_TORSO )
|
||||
&& (b != AVATAR_JOINT_CHEST )
|
||||
&& (b != AVATAR_JOINT_LEFT_COLLAR )
|
||||
&& (b != AVATAR_JOINT_LEFT_SHOULDER )
|
||||
&& (b != AVATAR_JOINT_RIGHT_COLLAR )
|
||||
&& (b != AVATAR_JOINT_RIGHT_SHOULDER)) {
|
||||
&& (b != AVATAR_JOINT_HEAD_BASE )
|
||||
&& (b != AVATAR_JOINT_PELVIS )
|
||||
&& (b != AVATAR_JOINT_TORSO )
|
||||
&& (b != AVATAR_JOINT_CHEST )
|
||||
&& (b != AVATAR_JOINT_LEFT_COLLAR )
|
||||
&& (b != AVATAR_JOINT_LEFT_SHOULDER )
|
||||
&& (b != AVATAR_JOINT_RIGHT_COLLAR )
|
||||
&& (b != AVATAR_JOINT_RIGHT_SHOULDER)) {
|
||||
glColor3fv(DARK_SKIN_COLOR);
|
||||
|
||||
float r1 = _bodyBall[_skeleton.joint[b].parent ].radius * 0.8;
|
||||
|
@ -1183,7 +1179,3 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
|
|||
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue