tidied up the head class and fixed a negated pitch value in orientation

This commit is contained in:
Jeffrey Ventrella 2013-05-17 14:56:14 -07:00
parent 2c17f04d40
commit f2af37801e
2 changed files with 71 additions and 68 deletions

View file

@ -88,7 +88,7 @@ void Head::setNewTarget(float pitch, float yaw) {
void Head::simulate(float deltaTime, bool isMine) {
//generate orientation directions based on Euler angles...
_orientation.setToPitchYawRoll( _pitch, _bodyYaw + _yaw, _roll);
_orientation.setToPitchYawRoll( -_pitch, _bodyYaw + _yaw, _roll);
//calculate the eye positions (algorithm still being designed)
updateEyePositions();
@ -146,15 +146,21 @@ void Head::simulate(float deltaTime, bool isMine) {
if (randFloat() < 0.1) {
_eyeContactTarget = MOUTH;
} else {
if (randFloat() < 0.5) _eyeContactTarget = LEFT_EYE; else _eyeContactTarget = RIGHT_EYE;
if (randFloat() < 0.5) {
_eyeContactTarget = LEFT_EYE;
} else {
_eyeContactTarget = RIGHT_EYE;
}
}
}
// Set eyeball pitch and yaw to make contact
float eye_target_yaw_adjust = 0;
float eye_target_pitch_adjust = 0;
if (_eyeContactTarget == LEFT_EYE) eye_target_yaw_adjust = DEGREES_BETWEEN_VIEWER_EYES;
if (_eyeContactTarget == RIGHT_EYE) eye_target_yaw_adjust = -DEGREES_BETWEEN_VIEWER_EYES;
if (_eyeContactTarget == MOUTH) eye_target_pitch_adjust = DEGREES_TO_VIEWER_MOUTH;
float eye_target_yaw_adjust = 0.0f;
float eye_target_pitch_adjust = 0.0f;
if (_eyeContactTarget == LEFT_EYE ) { eye_target_yaw_adjust = DEGREES_BETWEEN_VIEWER_EYES; }
if (_eyeContactTarget == RIGHT_EYE) { eye_target_yaw_adjust = -DEGREES_BETWEEN_VIEWER_EYES; }
if (_eyeContactTarget == MOUTH ) { eye_target_pitch_adjust = DEGREES_TO_VIEWER_MOUTH; }
_eyeballPitch[0] = _eyeballPitch[1] = -_pitch + eye_target_pitch_adjust;
_eyeballYaw [0] = _eyeballYaw [1] = _yaw + eye_target_yaw_adjust;

View file

@ -16,34 +16,38 @@
#include "SerialInterface.h"
#include "Orientation.h"
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
enum eyeContactTargets
{
LEFT_EYE,
RIGHT_EYE,
MOUTH
};
class Head {
public:
Head();
void simulate(float deltaTime, bool isMine);
void setPositionRotationAndScale(glm::vec3 position, glm::vec3 rotation, float scale);
void render(bool lookingInMirror);
void setNewTarget(float, float);
void setSpringScale(float s) { _returnSpringScale = s; }
void setLookatPosition(glm::vec3 l ) { _lookatPosition = l; }
void setLooking(bool looking);
void setGravity(glm::vec3 gravity) { _gravity = gravity; }
void setBodyYaw(float y) { _bodyYaw = y; }
glm::vec3 getApproximateEyePosition();
// Do you want head to try to return to center (depends on interface detected)
void setReturnToCenter(bool returnHeadToCenter) { _returnHeadToCenter = returnHeadToCenter; }
const bool getReturnToCenter() const { return _returnHeadToCenter; }
float getAverageLoudness() {return _averageLoudness;};
void setAverageLoudness(float averageLoudness) { _averageLoudness = averageLoudness; }
void setSkinColor(glm::vec3 skinColor) { _skinColor = skinColor; }
void setAudioLoudness(float audioLoudness) { _audioLoudness = audioLoudness; }
void setLooking(bool looking);
void setPositionRotationAndScale(glm::vec3 position, glm::vec3 rotation, float scale);
void setNewTarget(float, float);
void setLookatPosition (glm::vec3 lookatPosition ) { _lookatPosition = lookatPosition; }
void setGravity (glm::vec3 gravity ) { _gravity = gravity; }
void setSkinColor (glm::vec3 skinColor ) { _skinColor = skinColor; }
void setBodyYaw (float bodyYaw ) { _bodyYaw = bodyYaw; }
void setSpringScale (float returnSpringScale ) { _returnSpringScale = returnSpringScale; }
void setAverageLoudness(float averageLoudness ) { _averageLoudness = averageLoudness; }
void setAudioLoudness (float audioLoudness ) { _audioLoudness = audioLoudness; }
void setReturnToCenter (bool returnHeadToCenter) { _returnHeadToCenter = returnHeadToCenter; }
glm::vec3 getApproximateEyePosition();
const bool getReturnToCenter() const { return _returnHeadToCenter; } // Do you want head to try to return to center (depends on interface detected)
float getAverageLoudness() {return _averageLoudness;};
//some public members (left-over from pulling Head out of Avatar - I may see about privatizing these later).
float yawRate;
float noise;
float leanForward;
@ -51,48 +55,41 @@ public:
private:
bool _returnHeadToCenter;
float _audioLoudness;
glm::vec3 _skinColor;
glm::vec3 _position;
glm::vec3 _rotation;
glm::vec3 _lookatPosition;
glm::vec3 _leftEyePosition;
glm::vec3 _rightEyePosition;
float _yaw;
float _pitch;
float _roll;
float _eyeballPitch[2];
float _eyeballYaw [2];
float _eyebrowPitch[2];
float _eyebrowRoll [2];
float _interBrowDistance;
float _mouthPitch;
float _mouthYaw;
float _mouthWidth;
float _mouthHeight;
float _pitchTarget;
float _yawTarget;
float _noiseEnvelope;
float _scale;
int _eyeContact;
float _browAudioLift;
eyeContactTargets _eyeContactTarget;
bool _returnHeadToCenter;
float _audioLoudness;
glm::vec3 _skinColor;
glm::vec3 _position;
glm::vec3 _rotation;
glm::vec3 _lookatPosition;
glm::vec3 _leftEyePosition;
glm::vec3 _rightEyePosition;
float _yaw;
float _pitch;
float _roll;
float _eyeballPitch[2];
float _eyeballYaw [2];
float _eyebrowPitch[2];
float _eyebrowRoll [2];
float _interBrowDistance;
float _mouthPitch;
float _mouthYaw;
float _mouthWidth;
float _mouthHeight;
float _pitchTarget;
float _yawTarget;
float _noiseEnvelope;
float _scale;
int _eyeContact;
float _browAudioLift;
bool _looking;
glm::vec3 _gravity;
float _lastLoudness;
float _averageLoudness;
float _audioAttack;
float _returnSpringScale; //strength of return springs
Orientation _orientation;
float _bodyYaw;
// Sound loudness information
float _lastLoudness;
float _averageLoudness;
float _audioAttack;
bool _looking;
glm::vec3 _gravity;
// Strength of return springs
float _returnSpringScale;
float _bodyYaw;
eyeContactTargets _eyeContactTarget;
// private methods
void renderEyeBalls();