mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-05 02:55:11 +02:00
added back transitions to first person
This commit is contained in:
parent
f866f39ac4
commit
8b49cfbf93
4 changed files with 74 additions and 35 deletions
|
@ -131,6 +131,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_viewFrustumOffsetUp(0.0),
|
||||
_audioScope(256, 200, true),
|
||||
_myAvatar(true),
|
||||
_manualFirstPerson(false),
|
||||
_mouseX(0),
|
||||
_mouseY(0),
|
||||
_mousePressed(false),
|
||||
|
@ -956,9 +957,44 @@ void Application::idle() {
|
|||
_myAvatar.simulate(deltaTime, &_myTransmitter);
|
||||
} else {
|
||||
_myAvatar.simulate(deltaTime, NULL);
|
||||
|
||||
}
|
||||
|
||||
if (_myCamera.getMode() != CAMERA_MODE_MIRROR) {
|
||||
if (_manualFirstPerson) {
|
||||
if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON ) {
|
||||
Camera::CameraFollowingAttributes a;
|
||||
a.upShift = 0.0f;
|
||||
a.distance = 0.0f;
|
||||
a.tightness = 100.0f;
|
||||
_myCamera.setMode(CAMERA_MODE_FIRST_PERSON, a);
|
||||
_myAvatar.setDisplayingHead(true);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (_myAvatar.getIsNearInteractingOther()) {
|
||||
if (_myCamera.getMode() != CAMERA_MODE_FIRST_PERSON) {
|
||||
|
||||
Camera::CameraFollowingAttributes a;
|
||||
a.upShift = 0.0f;
|
||||
a.distance = 0.0f;
|
||||
a.tightness = 100.0f;
|
||||
_myCamera.setMode(CAMERA_MODE_FIRST_PERSON, a);
|
||||
_myAvatar.setDisplayingHead(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (_myCamera.getMode() != CAMERA_MODE_THIRD_PERSON) {
|
||||
Camera::CameraFollowingAttributes a;
|
||||
a.upShift = -0.2f;
|
||||
a.distance = 1.5f;
|
||||
a.tightness = 8.0f;
|
||||
_myCamera.setMode(CAMERA_MODE_THIRD_PERSON, a);
|
||||
_myAvatar.setDisplayingHead(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update audio stats for procedural sounds
|
||||
#ifndef _WIN32
|
||||
_audio.setLastAcceleration(_myAvatar.getThrust());
|
||||
|
@ -1018,6 +1054,10 @@ void Application::setFullscreen(bool fullscreen) {
|
|||
}
|
||||
|
||||
void Application::setRenderFirstPerson(bool firstPerson) {
|
||||
|
||||
_manualFirstPerson = firstPerson;
|
||||
|
||||
/*
|
||||
if (firstPerson) {
|
||||
Camera::CameraFollowingAttributes a;
|
||||
a.upShift = 0.0f;
|
||||
|
@ -1034,6 +1074,8 @@ void Application::setRenderFirstPerson(bool firstPerson) {
|
|||
_myCamera.setMode(CAMERA_MODE_THIRD_PERSON, a);
|
||||
_myAvatar.setDisplayingHead(true);
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void Application::setOculus(bool oculus) {
|
||||
|
@ -1701,7 +1743,6 @@ void Application::displaySide(Camera& whichCamera) {
|
|||
|
||||
// Render my own Avatar
|
||||
_myAvatar.render(_lookingInMirror->isChecked(), _myCamera.getPosition());
|
||||
|
||||
_myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked());
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,6 @@ private slots:
|
|||
void setFullscreen(bool fullscreen);
|
||||
|
||||
void setRenderFirstPerson(bool firstPerson);
|
||||
//void setRenderLookatVectors(bool lookatVectors);
|
||||
void setOculus(bool oculus);
|
||||
|
||||
void setFrustumOffset(bool frustumOffset);
|
||||
|
@ -204,6 +203,7 @@ private:
|
|||
Environment _environment;
|
||||
|
||||
int _headMouseX, _headMouseY;
|
||||
bool _manualFirstPerson;
|
||||
|
||||
HandControl _handControl;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ const float PERIPERSONAL_RADIUS = 1.0f;
|
|||
const float AVATAR_BRAKING_STRENGTH = 40.0f;
|
||||
const float JOINT_TOUCH_RANGE = 0.0005f;
|
||||
const float ANGULAR_RIGHTING_SPEED = 45.0f;
|
||||
const bool USING_HEAD_LEAN = false;
|
||||
|
||||
const float LEAN_SENSITIVITY = 0.15;
|
||||
const float LEAN_MAX = 0.45;
|
||||
|
@ -387,30 +388,29 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
}
|
||||
|
||||
//apply the head lean values to the springy position...
|
||||
if (fabs(_head.getLeanSideways() + _head.getLeanForward()) > 0.0f) {
|
||||
|
||||
glm::vec3 headLean =
|
||||
_orientation.getRight() * _head.getLeanSideways() +
|
||||
_orientation.getFront() * _head.getLeanForward();
|
||||
|
||||
// this is not a long-term solution, but it works ok for initial purposes of making the avatar lean
|
||||
|
||||
_joint[ AVATAR_JOINT_TORSO ].springyPosition += headLean * 0.1f;
|
||||
_joint[ AVATAR_JOINT_CHEST ].springyPosition += headLean * 0.4f;
|
||||
_joint[ AVATAR_JOINT_NECK_BASE ].springyPosition += headLean * 0.7f;
|
||||
_joint[ AVATAR_JOINT_HEAD_BASE ].springyPosition += headLean * 1.0f;
|
||||
|
||||
_joint[ AVATAR_JOINT_LEFT_COLLAR ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_LEFT_SHOULDER ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_LEFT_ELBOW ].springyPosition += headLean * 0.2f;
|
||||
_joint[ AVATAR_JOINT_LEFT_WRIST ].springyPosition += headLean * 0.1f;
|
||||
_joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].springyPosition += headLean * 0.0f;
|
||||
|
||||
_joint[ AVATAR_JOINT_RIGHT_COLLAR ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_SHOULDER ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_ELBOW ].springyPosition += headLean * 0.2f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_WRIST ].springyPosition += headLean * 0.1f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition += headLean * 0.0f;
|
||||
if (USING_HEAD_LEAN) {
|
||||
if (fabs(_head.getLeanSideways() + _head.getLeanForward()) > 0.0f) {
|
||||
glm::vec3 headLean =
|
||||
_orientation.getRight() * _head.getLeanSideways() +
|
||||
_orientation.getFront() * _head.getLeanForward();
|
||||
|
||||
_joint[ AVATAR_JOINT_TORSO ].springyPosition += headLean * 0.1f;
|
||||
_joint[ AVATAR_JOINT_CHEST ].springyPosition += headLean * 0.4f;
|
||||
_joint[ AVATAR_JOINT_NECK_BASE ].springyPosition += headLean * 0.7f;
|
||||
_joint[ AVATAR_JOINT_HEAD_BASE ].springyPosition += headLean * 1.0f;
|
||||
|
||||
_joint[ AVATAR_JOINT_LEFT_COLLAR ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_LEFT_SHOULDER ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_LEFT_ELBOW ].springyPosition += headLean * 0.2f;
|
||||
_joint[ AVATAR_JOINT_LEFT_WRIST ].springyPosition += headLean * 0.1f;
|
||||
_joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].springyPosition += headLean * 0.0f;
|
||||
|
||||
_joint[ AVATAR_JOINT_RIGHT_COLLAR ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_SHOULDER ].springyPosition += headLean * 0.6f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_ELBOW ].springyPosition += headLean * 0.2f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_WRIST ].springyPosition += headLean * 0.1f;
|
||||
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition += headLean * 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// set head lookat position
|
||||
|
|
|
@ -15,7 +15,7 @@ const float EYE_RIGHT_OFFSET = 0.27f;
|
|||
const float EYE_UP_OFFSET = 0.36f;
|
||||
const float EYE_FRONT_OFFSET = 0.8f;
|
||||
const float EAR_RIGHT_OFFSET = 1.0;
|
||||
const float MOUTH_FRONT_OFFSET = 1.0f;
|
||||
const float MOUTH_FRONT_OFFSET = 0.9f;
|
||||
const float MOUTH_UP_OFFSET = -0.3f;
|
||||
const float HEAD_MOTION_DECAY = 0.1;
|
||||
const float MINIMUM_EYE_ROTATION_DOT = 0.5f; // based on a dot product: 1.0 is straight ahead, 0.0 is 90 degrees off
|
||||
|
@ -139,13 +139,14 @@ void Head::calculateGeometry(bool lookingInMirror) {
|
|||
roll = _roll;
|
||||
}
|
||||
|
||||
|
||||
_orientation.setToPitchYawRoll
|
||||
(
|
||||
_bodyRotation.x + pitch,
|
||||
_bodyRotation.y + yaw,
|
||||
_bodyRotation.z + roll
|
||||
);
|
||||
|
||||
|
||||
//calculate the eye positions
|
||||
_leftEyePosition = _position
|
||||
- _orientation.getRight() * _scale * EYE_RIGHT_OFFSET
|
||||
|
@ -220,14 +221,14 @@ void Head::renderMouth() {
|
|||
|
||||
glm::vec3 r = _orientation.getRight() * _scale * (0.30f + s * 0.0014f );
|
||||
glm::vec3 u = _orientation.getUp () * _scale * (0.05f + s * 0.0040f );
|
||||
glm::vec3 f = _orientation.getFront() * _scale * 0.1f;
|
||||
glm::vec3 f = _orientation.getFront() * _scale * 0.09f;
|
||||
|
||||
glm::vec3 leftCorner = _mouthPosition - r * 1.0f;
|
||||
glm::vec3 rightCorner = _mouthPosition + r * 1.0f;
|
||||
glm::vec3 leftTop = _mouthPosition - r * 0.4f + u * 0.7f + f;
|
||||
glm::vec3 rightTop = _mouthPosition + r * 0.4f + u * 0.7f + f;
|
||||
glm::vec3 leftBottom = _mouthPosition - r * 0.4f - u * 1.0f + f;
|
||||
glm::vec3 rightBottom = _mouthPosition + r * 0.4f - u * 1.0f + f;
|
||||
glm::vec3 leftBottom = _mouthPosition - r * 0.4f - u * 1.0f + f * 0.7f;
|
||||
glm::vec3 rightBottom = _mouthPosition + r * 0.4f - u * 1.0f + f * 0.7f;
|
||||
|
||||
glColor3f(0.2f, 0.0f, 0.0f);
|
||||
|
||||
|
@ -247,8 +248,6 @@ void Head::renderMouth() {
|
|||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Head::renderEyeBrows() {
|
||||
|
||||
float height = _scale * 0.3f + _browAudioLift;
|
||||
|
@ -308,7 +307,6 @@ void Head::renderEyeBrows() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Head::renderEyeBalls() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue