mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 23:46:26 +02:00
Basic random eye movements added, and fixation on camera in mirror mode.
This commit is contained in:
parent
b85f91a7d4
commit
e32f9f387a
6 changed files with 32 additions and 29 deletions
|
@ -2042,7 +2042,12 @@ void Application::displaySide(Camera& whichCamera) {
|
||||||
}
|
}
|
||||||
agentList->unlock();
|
agentList->unlock();
|
||||||
|
|
||||||
// Render my own Avatar
|
// Render my own Avatar
|
||||||
|
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||||
|
_myAvatar.getHead().setLookAtPosition(_myCamera.getPosition());
|
||||||
|
} else {
|
||||||
|
_myAvatar.getHead().setLookAtPosition(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
|
}
|
||||||
_myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked());
|
_myAvatar.render(_lookingInMirror->isChecked(), _renderAvatarBalls->isChecked());
|
||||||
_myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked());
|
_myAvatar.setDisplayingLookatVectors(_renderLookatOn->isChecked());
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,13 +616,14 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set head lookat position
|
// set head lookat position
|
||||||
|
/*
|
||||||
if (!_owningAgent) {
|
if (!_owningAgent) {
|
||||||
if (_interactingOther) {
|
if (_interactingOther) {
|
||||||
_head.setLookAtPosition(_interactingOther->calculateAverageEyePosition());
|
_head.setLookAtPosition(_interactingOther->calculateAverageEyePosition());
|
||||||
} else {
|
} else {
|
||||||
_head.setLookAtPosition(glm::vec3(0.0f, 0.0f, 0.0f)); // 0,0,0 represents NOT looking at anything
|
_head.setLookAtPosition(glm::vec3(0.0f, 0.0f, 0.0f)); // 0,0,0 represents NOT looking at anything
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
_head.setBodyRotation (glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
_head.setBodyRotation (glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
||||||
_head.setPosition(_bodyBall[ BODY_BALL_HEAD_BASE ].position);
|
_head.setPosition(_bodyBall[ BODY_BALL_HEAD_BASE ].position);
|
||||||
|
|
|
@ -67,7 +67,9 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
_lookingInMirror(false),
|
_lookingInMirror(false),
|
||||||
_renderLookatVectors(false),
|
_renderLookatVectors(false),
|
||||||
_mohawkTriangleFan(NULL),
|
_mohawkTriangleFan(NULL),
|
||||||
_mohawkColors(NULL)
|
_mohawkColors(NULL),
|
||||||
|
_saccade(0.0f, 0.0f, 0.0f),
|
||||||
|
_saccadeTarget(0.0f, 0.0f, 0.0f)
|
||||||
{
|
{
|
||||||
if (USING_PHYSICAL_MOHAWK) {
|
if (USING_PHYSICAL_MOHAWK) {
|
||||||
resetHairPhysics();
|
resetHairPhysics();
|
||||||
|
@ -102,32 +104,19 @@ void Head::resetHairPhysics() {
|
||||||
|
|
||||||
|
|
||||||
void Head::simulate(float deltaTime, bool isMine) {
|
void Head::simulate(float deltaTime, bool isMine) {
|
||||||
|
|
||||||
const float HEAD_MOTION_DECAY = 0.00;
|
|
||||||
|
|
||||||
/*
|
// Update eye saccades
|
||||||
// Decay head back to center if turned on
|
const float AVERAGE_MICROSACCADE_INTERVAL = 0.50f;
|
||||||
if (isMine && _returnHeadToCenter) {
|
const float AVERAGE_SACCADE_INTERVAL = 4.0f;
|
||||||
|
const float MICROSACCADE_MAGNITUDE = 0.002f;
|
||||||
|
const float SACCADE_MAGNITUDE = 0.04;
|
||||||
|
|
||||||
// Decay rotation back toward center
|
if (randFloat() < deltaTime / AVERAGE_MICROSACCADE_INTERVAL) {
|
||||||
_pitch *= (1.0f - HEAD_MOTION_DECAY * _returnSpringScale * deltaTime);
|
_saccadeTarget = MICROSACCADE_MAGNITUDE * randVector();
|
||||||
_yaw *= (1.0f - HEAD_MOTION_DECAY * _returnSpringScale * deltaTime);
|
} else if (randFloat() < deltaTime / AVERAGE_SACCADE_INTERVAL) {
|
||||||
_roll *= (1.0f - HEAD_MOTION_DECAY * _returnSpringScale * deltaTime);
|
_saccadeTarget = SACCADE_MAGNITUDE * randVector();
|
||||||
}
|
}
|
||||||
|
_saccade += (_saccadeTarget - _saccade) * 0.50f;
|
||||||
// For invensense gyro, decay only slightly when near center (until we add fusion)
|
|
||||||
if (isMine) {
|
|
||||||
const float RETURN_RANGE = 15.0;
|
|
||||||
const float RETURN_STRENGTH = 0.5;
|
|
||||||
if (fabs(_pitch) < RETURN_RANGE) { _pitch *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
|
||||||
if (fabs(_yaw ) < RETURN_RANGE) { _yaw *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
|
||||||
if (fabs(_roll ) < RETURN_RANGE) { _roll *= (1.0f - RETURN_STRENGTH * deltaTime); }
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// decay lean
|
|
||||||
_leanForward *= (1.f - HEAD_MOTION_DECAY * 30 * deltaTime);
|
|
||||||
_leanSideways *= (1.f - HEAD_MOTION_DECAY * 30 * deltaTime);
|
|
||||||
|
|
||||||
// Update audio trailing average for rendering facial animations
|
// Update audio trailing average for rendering facial animations
|
||||||
const float AUDIO_AVERAGING_SECS = 0.05;
|
const float AUDIO_AVERAGING_SECS = 0.05;
|
||||||
|
@ -504,8 +493,7 @@ void Head::renderEyeBalls() {
|
||||||
if (_lookingAtSomething) {
|
if (_lookingAtSomething) {
|
||||||
|
|
||||||
//rotate the eyeball to aim towards the lookat position
|
//rotate the eyeball to aim towards the lookat position
|
||||||
glm::vec3 targetLookatAxis = glm::normalize(_lookAtPosition - _leftEyePosition); // the lookat direction
|
glm::vec3 targetLookatAxis = glm::normalize(_lookAtPosition + _saccade - _leftEyePosition); glm::vec3 rotationAxis = glm::cross(targetLookatAxis, IDENTITY_UP);
|
||||||
glm::vec3 rotationAxis = glm::cross(targetLookatAxis, IDENTITY_UP);
|
|
||||||
float angle = 180.0f - angleBetween(targetLookatAxis, IDENTITY_UP);
|
float angle = 180.0f - angleBetween(targetLookatAxis, IDENTITY_UP);
|
||||||
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||||
glRotatef(180.0, 0.0f, 1.0f, 0.0f); //adjust roll to correct after previous rotations
|
glRotatef(180.0, 0.0f, 1.0f, 0.0f); //adjust roll to correct after previous rotations
|
||||||
|
@ -548,7 +536,7 @@ void Head::renderEyeBalls() {
|
||||||
if (_lookingAtSomething) {
|
if (_lookingAtSomething) {
|
||||||
|
|
||||||
//rotate the eyeball to aim towards the lookat position
|
//rotate the eyeball to aim towards the lookat position
|
||||||
glm::vec3 targetLookatAxis = glm::normalize(_lookAtPosition - _rightEyePosition);
|
glm::vec3 targetLookatAxis = glm::normalize(_lookAtPosition + _saccade - _rightEyePosition);
|
||||||
glm::vec3 rotationAxis = glm::cross(targetLookatAxis, IDENTITY_UP);
|
glm::vec3 rotationAxis = glm::cross(targetLookatAxis, IDENTITY_UP);
|
||||||
float angle = 180.0f - angleBetween(targetLookatAxis, IDENTITY_UP);
|
float angle = 180.0f - angleBetween(targetLookatAxis, IDENTITY_UP);
|
||||||
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
glRotatef(angle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||||
|
|
|
@ -103,6 +103,8 @@ private:
|
||||||
HairTuft _hairTuft[NUM_HAIR_TUFTS];
|
HairTuft _hairTuft[NUM_HAIR_TUFTS];
|
||||||
glm::vec3* _mohawkTriangleFan;
|
glm::vec3* _mohawkTriangleFan;
|
||||||
glm::vec3* _mohawkColors;
|
glm::vec3* _mohawkColors;
|
||||||
|
glm::vec3 _saccade;
|
||||||
|
glm::vec3 _saccadeTarget;
|
||||||
|
|
||||||
// private methods
|
// private methods
|
||||||
void createMohawk();
|
void createMohawk();
|
||||||
|
|
|
@ -267,6 +267,11 @@ double diffclock(timeval *clock1,timeval *clock2)
|
||||||
return diffms;
|
return diffms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a random vector of average length 1
|
||||||
|
const glm::vec3 randVector() {
|
||||||
|
return glm::vec3(randFloat() - 0.5f, randFloat() - 0.5f, randFloat() - 0.5f) * 2.f;
|
||||||
|
}
|
||||||
|
|
||||||
static TextRenderer* textRenderer(int mono) {
|
static TextRenderer* textRenderer(int mono) {
|
||||||
static TextRenderer* monoRenderer = new TextRenderer(MONO_FONT_FAMILY);
|
static TextRenderer* monoRenderer = new TextRenderer(MONO_FONT_FAMILY);
|
||||||
static TextRenderer* proportionalRenderer = new TextRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT);
|
static TextRenderer* proportionalRenderer = new TextRenderer(SANS_FONT_FAMILY, -1, -1, false, TextRenderer::SHADOW_EFFECT);
|
||||||
|
|
|
@ -32,6 +32,8 @@ float azimuth_to(glm::vec3 head_pos, glm::vec3 source_pos);
|
||||||
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw);
|
float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float head_yaw);
|
||||||
|
|
||||||
float randFloat();
|
float randFloat();
|
||||||
|
const glm::vec3 randVector();
|
||||||
|
|
||||||
void render_world_box();
|
void render_world_box();
|
||||||
int widthText(float scale, int mono, char const* string);
|
int widthText(float scale, int mono, char const* string);
|
||||||
float widthChar(float scale, int mono, char ch);
|
float widthChar(float scale, int mono, char ch);
|
||||||
|
|
Loading…
Reference in a new issue