mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 14:29:35 +02:00
more work on avatar lookat
This commit is contained in:
parent
a5e696b696
commit
a0e8c0da74
6 changed files with 64 additions and 2070 deletions
|
@ -308,6 +308,7 @@ void Application::paintGL() {
|
|||
-_myAvatar.getHeadPitch(), _myAvatar.getHeadRoll());
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
_myCamera.setTightness (100.0f);
|
||||
_myCamera.setTargetPosition(_myAvatar.getSpringyHeadPosition());
|
||||
_myCamera.setTargetRotation(_myAvatar.getBodyYaw() - 180.0f, 0.0f, 0.0f);
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ Avatar::Avatar(bool isMine) {
|
|||
_mouseRayOrigin = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
_mouseRayDirection = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
_cameraPosition = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
_interactingOther = NULL;
|
||||
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) _driveKeys[i] = false;
|
||||
|
||||
|
@ -404,9 +405,6 @@ void Avatar::simulate(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Get head position data from network for other people
|
||||
if (!_isMine) {
|
||||
|
@ -439,7 +437,6 @@ void Avatar::simulate(float deltaTime) {
|
|||
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition += headLean * 0.0f;
|
||||
}
|
||||
|
||||
|
||||
// update head state
|
||||
_head.setPositionRotationAndScale(
|
||||
_joint[ AVATAR_JOINT_HEAD_BASE ].springyPosition,
|
||||
|
@ -447,6 +444,13 @@ void Avatar::simulate(float deltaTime) {
|
|||
_joint[ AVATAR_JOINT_HEAD_BASE ].radius
|
||||
);
|
||||
|
||||
if (_interactingOther) {
|
||||
_head.setLooking(true);
|
||||
_head.setLookatPosition(_interactingOther->getSpringyHeadPosition());
|
||||
} else {
|
||||
_head.setLooking(false);
|
||||
}
|
||||
|
||||
_head.setAudioLoudness(_audioLoudness);
|
||||
_head.setSkinColor(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
|
||||
_head.simulate(deltaTime, _isMine);
|
||||
|
@ -495,10 +499,11 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
|
||||
if (_isMine) {
|
||||
_avatarTouch.setMyBodyPosition(_position);
|
||||
|
||||
Avatar * _interactingOther = NULL;
|
||||
|
||||
float closestDistance = std::numeric_limits<float>::max();
|
||||
|
||||
|
||||
_interactingOther = NULL;
|
||||
|
||||
//loop through all the other avatars for potential interactions...
|
||||
AgentList* agentList = AgentList::getInstance();
|
||||
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
|
||||
|
@ -519,10 +524,8 @@ void Avatar::updateHandMovementAndTouching(float deltaTime) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_interactingOther) {
|
||||
|
||||
_head.setLookatPosition( _interactingOther->getSpringyHeadPosition());
|
||||
if (_interactingOther) {
|
||||
|
||||
_avatarTouch.setYourBodyPosition(_interactingOther->_position);
|
||||
_avatarTouch.setYourHandPosition(_interactingOther->_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition);
|
||||
|
|
|
@ -194,6 +194,7 @@ private:
|
|||
glm::vec3 _mouseRayOrigin;
|
||||
glm::vec3 _mouseRayDirection;
|
||||
glm::vec3 _cameraPosition;
|
||||
Avatar * _interactingOther;
|
||||
|
||||
// private methods...
|
||||
void initializeSkeleton();
|
||||
|
|
|
@ -16,8 +16,7 @@ using namespace std;
|
|||
|
||||
const float HEAD_MOTION_DECAY = 0.1;
|
||||
|
||||
const bool TESTING_LOOKAT = false;
|
||||
|
||||
//const bool TESTING_LOOKAT = true;
|
||||
|
||||
float _browColor [] = {210.0/255.0, 105.0/255.0, 30.0/255.0};
|
||||
float _mouthColor[] = {1, 0, 0};
|
||||
|
@ -226,6 +225,10 @@ void Head::simulate(float deltaTime, bool isMine) {
|
|||
|
||||
}
|
||||
|
||||
void Head::setLooking(bool l) {
|
||||
_looking = l;
|
||||
}
|
||||
|
||||
|
||||
void Head::setLookatPosition(glm::vec3 l) {
|
||||
lookatPosition = l;
|
||||
|
@ -324,7 +327,7 @@ void Head::render(bool lookingInMirror, float bodyYaw) {
|
|||
|
||||
glPopMatrix();
|
||||
|
||||
if (TESTING_LOOKAT) {
|
||||
if (_looking) {
|
||||
//the irises are special - they have the ability to look at specific targets in the world (code still not finished yet)
|
||||
renderIrises(bodyYaw + yaw);
|
||||
}
|
||||
|
@ -349,7 +352,7 @@ void Head::renderEyeBalls() {
|
|||
}
|
||||
glPopMatrix();
|
||||
|
||||
if (!TESTING_LOOKAT) {
|
||||
if (!_looking) {
|
||||
// Right Pupil
|
||||
if (sphere == NULL) {
|
||||
sphere = gluNewQuadric();
|
||||
|
@ -388,7 +391,7 @@ void Head::renderEyeBalls() {
|
|||
}
|
||||
glPopMatrix();
|
||||
|
||||
if (!TESTING_LOOKAT) {
|
||||
if (!_looking) {
|
||||
// Left Pupil
|
||||
glPushMatrix();
|
||||
{
|
||||
|
@ -449,8 +452,11 @@ void Head::renderIrises(float yaw) {
|
|||
glm::vec3 pitchRotationAxis = glm::cross(targetLookatAxis, orientation.getRight());
|
||||
glm::vec3 yawRotationAxis = glm::cross(targetLookatAxis, orientation.getUp());
|
||||
|
||||
glRotatef(90.0f, yawRotationAxis.x, yawRotationAxis.y, yawRotationAxis.z);
|
||||
glRotatef(90.0f, pitchRotationAxis.x, pitchRotationAxis.y, pitchRotationAxis.z);
|
||||
float yaw = angleBetween(targetLookatAxis, orientation.getUp());
|
||||
float pitch = angleBetween(targetLookatAxis, orientation.getRight());
|
||||
|
||||
glRotatef(yaw, yawRotationAxis.x, yawRotationAxis.y, yawRotationAxis.z);
|
||||
glRotatef(pitch, pitchRotationAxis.x, pitchRotationAxis.y, pitchRotationAxis.z);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(sphere, 0.01, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -468,8 +474,11 @@ void Head::renderIrises(float yaw) {
|
|||
glm::vec3 pitchRotationAxis = glm::cross(targetLookatAxis, orientation.getRight());
|
||||
glm::vec3 yawRotationAxis = glm::cross(targetLookatAxis, orientation.getUp());
|
||||
|
||||
glRotatef(90.0f, yawRotationAxis.x, yawRotationAxis.y, yawRotationAxis.z);
|
||||
glRotatef(90.0f, pitchRotationAxis.x, pitchRotationAxis.y, pitchRotationAxis.z);
|
||||
float yaw = angleBetween(targetLookatAxis, orientation.getUp());
|
||||
float pitch = angleBetween(targetLookatAxis, orientation.getRight());
|
||||
|
||||
glRotatef(yaw, yawRotationAxis.x, yawRotationAxis.y, yawRotationAxis.z);
|
||||
glRotatef(pitch, pitchRotationAxis.x, pitchRotationAxis.y, pitchRotationAxis.z);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(sphere, 0.01, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
void setNewTarget(float, float);
|
||||
void setSpringScale(float s) { returnSpringScale = s; }
|
||||
void setLookatPosition(glm::vec3 lookatPosition);
|
||||
void setLooking(bool looking);
|
||||
|
||||
// Do you want head to try to return to center (depends on interface detected)
|
||||
void setReturnToCenter(bool r) { returnHeadToCenter = r; }
|
||||
|
@ -84,6 +85,8 @@ public:
|
|||
float averageLoudness;
|
||||
float audioAttack;
|
||||
|
||||
bool _looking;
|
||||
|
||||
GLUquadric* sphere;
|
||||
|
||||
// Strength of return springs
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue