Merge pull request #668 from Atlante45/the_midget_are_coming

The midget are coming
This commit is contained in:
ZappoMan 2013-07-15 12:43:54 -07:00
commit 4f0e472868
13 changed files with 296 additions and 128 deletions

View file

@ -1182,6 +1182,24 @@ void Application::setRenderThirdPerson(bool thirdPerson) {
} }
} }
void Application::increaseAvatarSize() {
if (5.0f < _myAvatar.getScale() + 0.05f) {
return;
}
_myAvatar.setScale(_myAvatar.getScale() + 0.05f);
_myCamera.setScale(_myAvatar.getScale() + 0.05f);
}
void Application::decreaseAvatarSize() {
if (_myAvatar.getScale() - 0.05f < 0.15f) {
return;
}
_myAvatar.setScale(_myAvatar.getScale() - 0.05f);
_myCamera.setScale(_myAvatar.getScale() - 0.05f);
}
void Application::setFrustumOffset(bool frustumOffset) { void Application::setFrustumOffset(bool frustumOffset) {
// reshape so that OpenGL will get the right lens details for the camera of choice // reshape so that OpenGL will get the right lens details for the camera of choice
resizeGL(_glWidget->width(), _glWidget->height()); resizeGL(_glWidget->width(), _glWidget->height());
@ -1555,7 +1573,7 @@ void Application::initMenu() {
_renderAvatarsOn->setChecked(true); _renderAvatarsOn->setChecked(true);
(_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true); (_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true);
_renderAvatarBalls->setChecked(false); _renderAvatarBalls->setChecked(false);
renderMenu->addAction("Cycle Voxeltar Mode", _myAvatar.getVoxels(), SLOT(cycleMode())); renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
(_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true); (_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
_renderFrameTimerOn->setChecked(false); _renderFrameTimerOn->setChecked(false);
(_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true); (_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);
@ -1564,6 +1582,9 @@ void Application::initMenu() {
"First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true); "First Person", this, SLOT(setRenderFirstPerson(bool)), Qt::Key_P))->setCheckable(true);
(_manualThirdPerson = renderMenu->addAction( (_manualThirdPerson = renderMenu->addAction(
"Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true); "Third Person", this, SLOT(setRenderThirdPerson(bool))))->setCheckable(true);
renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::SHIFT | Qt::Key_Plus);
renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::SHIFT | Qt::Key_Minus);
QMenu* toolsMenu = menuBar->addMenu("Tools"); QMenu* toolsMenu = menuBar->addMenu("Tools");
(_renderStatsOn = toolsMenu->addAction("Stats"))->setCheckable(true); (_renderStatsOn = toolsMenu->addAction("Stats"))->setCheckable(true);

View file

@ -118,6 +118,8 @@ private slots:
void setRenderFirstPerson(bool firstPerson); void setRenderFirstPerson(bool firstPerson);
void setRenderThirdPerson(bool thirdPerson); void setRenderThirdPerson(bool thirdPerson);
void increaseAvatarSize();
void decreaseAvatarSize();
void renderThrustAtVoxel(const glm::vec3& thrust); void renderThrustAtVoxel(const glm::vec3& thrust);
void renderLineToTouchedVoxel(); void renderLineToTouchedVoxel();

View file

@ -86,6 +86,7 @@ Avatar::Avatar(Node* owningNode) :
_leanScale(0.5f), _leanScale(0.5f),
_pelvisStandingHeight(0.0f), _pelvisStandingHeight(0.0f),
_pelvisFloatingHeight(0.0f), _pelvisFloatingHeight(0.0f),
_scale(1.0f),
_distanceToNearestAvatar(std::numeric_limits<float>::max()), _distanceToNearestAvatar(std::numeric_limits<float>::max()),
_gravity(0.0f, -1.0f, 0.0f), _gravity(0.0f, -1.0f, 0.0f),
_worldUpDirection(DEFAULT_UP_DIRECTION), _worldUpDirection(DEFAULT_UP_DIRECTION),
@ -111,9 +112,9 @@ Avatar::Avatar(Node* owningNode) :
_skeleton.initialize(); _skeleton.initialize();
initializeBodyBalls(); initializeBodyBalls();
_height = _skeleton.getHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius + _bodyBall[ BODY_BALL_HEAD_BASE ].radius; _height = _skeleton.getHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius + _bodyBall[ BODY_BALL_HEAD_BASE ].radius;
_maxArmLength = _skeleton.getArmLength(); _maxArmLength = _skeleton.getArmLength();
_pelvisStandingHeight = _skeleton.getPelvisStandingHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius; _pelvisStandingHeight = _skeleton.getPelvisStandingHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius;
_pelvisFloatingHeight = _skeleton.getPelvisFloatingHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius; _pelvisFloatingHeight = _skeleton.getPelvisFloatingHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius;
@ -145,32 +146,32 @@ void Avatar::initializeBodyBalls() {
} }
// specify the radius of each ball // specify the radius of each ball
_bodyBall[ BODY_BALL_PELVIS ].radius = 0.07; _bodyBall[ BODY_BALL_PELVIS ].radius = BODY_BALL_RADIUS_PELVIS;
_bodyBall[ BODY_BALL_TORSO ].radius = 0.065; _bodyBall[ BODY_BALL_TORSO ].radius = BODY_BALL_RADIUS_TORSO;
_bodyBall[ BODY_BALL_CHEST ].radius = 0.08; _bodyBall[ BODY_BALL_CHEST ].radius = BODY_BALL_RADIUS_CHEST;
_bodyBall[ BODY_BALL_NECK_BASE ].radius = 0.03; _bodyBall[ BODY_BALL_NECK_BASE ].radius = BODY_BALL_RADIUS_NECK_BASE;
_bodyBall[ BODY_BALL_HEAD_BASE ].radius = 0.07; _bodyBall[ BODY_BALL_HEAD_BASE ].radius = BODY_BALL_RADIUS_HEAD_BASE;
_bodyBall[ BODY_BALL_LEFT_COLLAR ].radius = 0.04; _bodyBall[ BODY_BALL_LEFT_COLLAR ].radius = BODY_BALL_RADIUS_LEFT_COLLAR;
_bodyBall[ BODY_BALL_LEFT_SHOULDER ].radius = 0.03; _bodyBall[ BODY_BALL_LEFT_SHOULDER ].radius = BODY_BALL_RADIUS_LEFT_SHOULDER;
_bodyBall[ BODY_BALL_LEFT_ELBOW ].radius = 0.02; _bodyBall[ BODY_BALL_LEFT_ELBOW ].radius = BODY_BALL_RADIUS_LEFT_ELBOW;
_bodyBall[ BODY_BALL_LEFT_WRIST ].radius = 0.02; _bodyBall[ BODY_BALL_LEFT_WRIST ].radius = BODY_BALL_RADIUS_LEFT_WRIST;
_bodyBall[ BODY_BALL_LEFT_FINGERTIPS ].radius = 0.01; _bodyBall[ BODY_BALL_LEFT_FINGERTIPS ].radius = BODY_BALL_RADIUS_LEFT_FINGERTIPS;
_bodyBall[ BODY_BALL_RIGHT_COLLAR ].radius = 0.04; _bodyBall[ BODY_BALL_RIGHT_COLLAR ].radius = BODY_BALL_RADIUS_RIGHT_COLLAR;
_bodyBall[ BODY_BALL_RIGHT_SHOULDER ].radius = 0.03; _bodyBall[ BODY_BALL_RIGHT_SHOULDER ].radius = BODY_BALL_RADIUS_RIGHT_SHOULDER;
_bodyBall[ BODY_BALL_RIGHT_ELBOW ].radius = 0.02; _bodyBall[ BODY_BALL_RIGHT_ELBOW ].radius = BODY_BALL_RADIUS_RIGHT_ELBOW;
_bodyBall[ BODY_BALL_RIGHT_WRIST ].radius = 0.02; _bodyBall[ BODY_BALL_RIGHT_WRIST ].radius = BODY_BALL_RADIUS_RIGHT_WRIST;
_bodyBall[ BODY_BALL_RIGHT_FINGERTIPS ].radius = 0.01; _bodyBall[ BODY_BALL_RIGHT_FINGERTIPS ].radius = BODY_BALL_RADIUS_RIGHT_FINGERTIPS;
_bodyBall[ BODY_BALL_LEFT_HIP ].radius = 0.04; _bodyBall[ BODY_BALL_LEFT_HIP ].radius = BODY_BALL_RADIUS_LEFT_HIP;
//_bodyBall[ BODY_BALL_LEFT_MID_THIGH ].radius = 0.03; //_bodyBall[ BODY_BALL_LEFT_MID_THIGH ].radius = BODY_BALL_RADIUS_LEFT_MID_THIGH;
_bodyBall[ BODY_BALL_LEFT_KNEE ].radius = 0.025; _bodyBall[ BODY_BALL_LEFT_KNEE ].radius = BODY_BALL_RADIUS_LEFT_KNEE;
_bodyBall[ BODY_BALL_LEFT_HEEL ].radius = 0.025; _bodyBall[ BODY_BALL_LEFT_HEEL ].radius = BODY_BALL_RADIUS_LEFT_HEEL;
_bodyBall[ BODY_BALL_LEFT_TOES ].radius = 0.025; _bodyBall[ BODY_BALL_LEFT_TOES ].radius = BODY_BALL_RADIUS_LEFT_TOES;
_bodyBall[ BODY_BALL_RIGHT_HIP ].radius = 0.04; _bodyBall[ BODY_BALL_RIGHT_HIP ].radius = BODY_BALL_RADIUS_RIGHT_HIP;
_bodyBall[ BODY_BALL_RIGHT_KNEE ].radius = 0.025; _bodyBall[ BODY_BALL_RIGHT_KNEE ].radius = BODY_BALL_RADIUS_RIGHT_KNEE;
_bodyBall[ BODY_BALL_RIGHT_HEEL ].radius = 0.025; _bodyBall[ BODY_BALL_RIGHT_HEEL ].radius = BODY_BALL_RADIUS_RIGHT_HEEL;
_bodyBall[ BODY_BALL_RIGHT_TOES ].radius = 0.025; _bodyBall[ BODY_BALL_RIGHT_TOES ].radius = BODY_BALL_RADIUS_RIGHT_TOES;
// specify the parent joint for each ball // specify the parent joint for each ball
@ -331,7 +332,7 @@ void Avatar::updateFromGyrosAndOrWebcam(bool gyroLook,
_head.setCameraFollowsHead(gyroLook); _head.setCameraFollowsHead(gyroLook);
// Update torso lean distance based on accelerometer data // Update torso lean distance based on accelerometer data
const float TORSO_LENGTH = 0.5f; const float TORSO_LENGTH = _scale * 0.5f;
const float MAX_LEAN = 45.0f; const float MAX_LEAN = 45.0f;
_head.setLeanSideways(glm::clamp(glm::degrees(atanf(estimatedPosition.x * _leanScale / TORSO_LENGTH)), _head.setLeanSideways(glm::clamp(glm::degrees(atanf(estimatedPosition.x * _leanScale / TORSO_LENGTH)),
-MAX_LEAN, MAX_LEAN)); -MAX_LEAN, MAX_LEAN));
@ -378,18 +379,18 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) {
const float THRUST_JUMP = 120.f; const float THRUST_JUMP = 120.f;
// Add Thrusts from keyboard // Add Thrusts from keyboard
if (_driveKeys[FWD ]) {_thrust += THRUST_MAG_FWD * deltaTime * front;} if (_driveKeys[FWD ]) {_thrust += _scale * THRUST_MAG_FWD * deltaTime * front;}
if (_driveKeys[BACK ]) {_thrust -= THRUST_MAG_BACK * deltaTime * front;} if (_driveKeys[BACK ]) {_thrust -= _scale * THRUST_MAG_BACK * deltaTime * front;}
if (_driveKeys[RIGHT ]) {_thrust += THRUST_MAG_LATERAL * deltaTime * right;} if (_driveKeys[RIGHT ]) {_thrust += _scale * THRUST_MAG_LATERAL * deltaTime * right;}
if (_driveKeys[LEFT ]) {_thrust -= THRUST_MAG_LATERAL * deltaTime * right;} if (_driveKeys[LEFT ]) {_thrust -= _scale * THRUST_MAG_LATERAL * deltaTime * right;}
if (_driveKeys[UP ]) {_thrust += THRUST_MAG_UP * deltaTime * up;} if (_driveKeys[UP ]) {_thrust += _scale * THRUST_MAG_UP * deltaTime * up;}
if (_driveKeys[DOWN ]) {_thrust -= THRUST_MAG_DOWN * deltaTime * up;} if (_driveKeys[DOWN ]) {_thrust -= _scale * THRUST_MAG_DOWN * deltaTime * up;}
if (_driveKeys[ROT_RIGHT]) {_bodyYawDelta -= YAW_MAG * deltaTime;} if (_driveKeys[ROT_RIGHT]) {_bodyYawDelta -= YAW_MAG * deltaTime;}
if (_driveKeys[ROT_LEFT ]) {_bodyYawDelta += YAW_MAG * deltaTime;} if (_driveKeys[ROT_LEFT ]) {_bodyYawDelta += YAW_MAG * deltaTime;}
// Add one time jumping force if requested // Add one time jumping force if requested
if (_shouldJump) { if (_shouldJump) {
_thrust += THRUST_JUMP * up; _thrust += _scale * THRUST_JUMP * up;
_shouldJump = false; _shouldJump = false;
} }
@ -424,8 +425,7 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) {
} }
// Update speed brake status // Update speed brake status
const float MIN_SPEED_BRAKE_VELOCITY = _scale * 0.4f;
const float MIN_SPEED_BRAKE_VELOCITY = 0.4f;
if ((glm::length(_thrust) == 0.0f) && _isThrustOn && (glm::length(_velocity) > MIN_SPEED_BRAKE_VELOCITY)) { if ((glm::length(_thrust) == 0.0f) && _isThrustOn && (glm::length(_velocity) > MIN_SPEED_BRAKE_VELOCITY)) {
_speedBrakes = true; _speedBrakes = true;
} }
@ -434,7 +434,6 @@ void Avatar::updateThrust(float deltaTime, Transmitter * transmitter) {
_speedBrakes = false; _speedBrakes = false;
} }
_isThrustOn = (glm::length(_thrust) > EPSILON); _isThrustOn = (glm::length(_thrust) > EPSILON);
} }
void Avatar::simulate(float deltaTime, Transmitter* transmitter) { void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
@ -443,6 +442,11 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
glm::vec3 front = orientation * IDENTITY_FRONT; glm::vec3 front = orientation * IDENTITY_FRONT;
glm::vec3 right = orientation * IDENTITY_RIGHT; glm::vec3 right = orientation * IDENTITY_RIGHT;
//
if (!isMyAvatar() && _scale != _newScale) {
setScale(_newScale);
}
// Update movement timers // Update movement timers
if (isMyAvatar()) { if (isMyAvatar()) {
_elapsedTimeSinceCollision += deltaTime; _elapsedTimeSinceCollision += deltaTime;
@ -528,16 +532,17 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
//update the movement of the hand and process handshaking with other avatars... //update the movement of the hand and process handshaking with other avatars...
updateHandMovementAndTouching(deltaTime, enableHandMovement); updateHandMovementAndTouching(deltaTime, enableHandMovement);
_avatarTouch.simulate(deltaTime); _avatarTouch.simulate(deltaTime);
if (isMyAvatar()) { if (isMyAvatar()) {
// apply gravity // apply gravity
if (USING_AVATAR_GRAVITY) { if (USING_AVATAR_GRAVITY) {
// For gravity, always move the avatar by the amount driven by gravity, so that the collision // For gravity, always move the avatar by the amount driven by gravity, so that the collision
// routines will detect it and collide every frame when pulled by gravity to a surface // routines will detect it and collide every frame when pulled by gravity to a surface
// //
_velocity += _gravity * (GRAVITY_EARTH * deltaTime);
_position += _gravity * (GRAVITY_EARTH * deltaTime) * deltaTime; _velocity += _scale * _gravity * (GRAVITY_EARTH * deltaTime);
_position += _scale * _gravity * (GRAVITY_EARTH * deltaTime) * deltaTime;
} }
updateCollisionWithEnvironment(); updateCollisionWithEnvironment();
@ -571,11 +576,11 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
_bodyRollDelta *= bodySpinMomentum; _bodyRollDelta *= bodySpinMomentum;
const float MAX_STATIC_FRICTION_VELOCITY = 0.5f; const float MAX_STATIC_FRICTION_VELOCITY = 0.5f;
const float STATIC_FRICTION_STRENGTH = 20.f; const float STATIC_FRICTION_STRENGTH = _scale * 20.f;
applyStaticFriction(deltaTime, _velocity, MAX_STATIC_FRICTION_VELOCITY, STATIC_FRICTION_STRENGTH); applyStaticFriction(deltaTime, _velocity, MAX_STATIC_FRICTION_VELOCITY, STATIC_FRICTION_STRENGTH);
const float LINEAR_DAMPING_STRENGTH = 1.0f; const float LINEAR_DAMPING_STRENGTH = 1.0f;
const float SPEED_BRAKE_POWER = 10.0f; const float SPEED_BRAKE_POWER = _scale * 10.0f;
const float SQUARED_DAMPING_STRENGTH = 0.2f; const float SQUARED_DAMPING_STRENGTH = 0.2f;
if (_speedBrakes) { if (_speedBrakes) {
applyDamping(deltaTime, _velocity, LINEAR_DAMPING_STRENGTH * SPEED_BRAKE_POWER, SQUARED_DAMPING_STRENGTH * SPEED_BRAKE_POWER); applyDamping(deltaTime, _velocity, LINEAR_DAMPING_STRENGTH * SPEED_BRAKE_POWER, SQUARED_DAMPING_STRENGTH * SPEED_BRAKE_POWER);
@ -592,7 +597,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
BODY_ROLL_WHILE_TURNING * deltaTime * _speed * _bodyYawDelta))); BODY_ROLL_WHILE_TURNING * deltaTime * _speed * _bodyYawDelta)));
// these forces keep the body upright... // these forces keep the body upright...
const float BODY_UPRIGHT_FORCE = 10.0; const float BODY_UPRIGHT_FORCE = _scale * 10.0;
float tiltDecay = BODY_UPRIGHT_FORCE * deltaTime; float tiltDecay = BODY_UPRIGHT_FORCE * deltaTime;
if (tiltDecay > 1.0f) {tiltDecay = 1.0f;} if (tiltDecay > 1.0f) {tiltDecay = 1.0f;}
@ -662,7 +667,7 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
_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);
_head.setScale (_bodyBall[ BODY_BALL_HEAD_BASE ].radius); _head.setScale(_scale);
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2])); _head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
_head.simulate(deltaTime, isMyAvatar()); _head.simulate(deltaTime, isMyAvatar());
@ -748,7 +753,7 @@ void Avatar::updateHandMovementAndTouching(float deltaTime, bool enableHandMovem
if (distance < closestDistance) { if (distance < closestDistance) {
closestDistance = distance; closestDistance = distance;
if (distance < PERIPERSONAL_RADIUS) { if (distance < _scale * PERIPERSONAL_RADIUS) {
_interactingOther = otherAvatar; _interactingOther = otherAvatar;
} }
} }
@ -1017,7 +1022,7 @@ void Avatar::render(bool lookingInMirror, bool renderAvatarBalls) {
} }
// render a simple round on the ground projected down from the avatar's position // render a simple round on the ground projected down from the avatar's position
renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), 0.1f, 0.2f); renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), _scale * 0.1f, 0.2f);
// render body // render body
renderBody(lookingInMirror, renderAvatarBalls); renderBody(lookingInMirror, renderAvatarBalls);
@ -1091,7 +1096,7 @@ void Avatar::resetBodyBalls() {
void Avatar::updateBodyBalls(float deltaTime) { void Avatar::updateBodyBalls(float deltaTime) {
// Check for a large repositioning, and re-initialize balls if this has happened // Check for a large repositioning, and re-initialize balls if this has happened
const float BEYOND_BODY_SPRING_RANGE = 2.f; const float BEYOND_BODY_SPRING_RANGE = _scale * 2.f;
if (glm::length(_position - _bodyBall[BODY_BALL_PELVIS].position) > BEYOND_BODY_SPRING_RANGE) { if (glm::length(_position - _bodyBall[BODY_BALL_PELVIS].position) > BEYOND_BODY_SPRING_RANGE) {
resetBodyBalls(); resetBodyBalls();
} }
@ -1222,8 +1227,8 @@ glm::quat Avatar::computeRotationFromBodyToWorldUp(float proportion) const {
} }
float Avatar::getBallRenderAlpha(int ball, bool lookingInMirror) const { float Avatar::getBallRenderAlpha(int ball, bool lookingInMirror) const {
const float RENDER_OPAQUE_OUTSIDE = 0.25f; // render opaque if greater than this distance const float RENDER_OPAQUE_OUTSIDE = _scale * 0.25f; // render opaque if greater than this distance
const float DO_NOT_RENDER_INSIDE = 0.25f; // do not render if less than this distance const float DO_NOT_RENDER_INSIDE = _scale * 0.25f; // do not render if less than this distance
float distanceToCamera = glm::length(Application::getInstance()->getCamera()->getPosition() - _bodyBall[ball].position); float distanceToCamera = glm::length(Application::getInstance()->getCamera()->getPosition() - _bodyBall[ball].position);
return (lookingInMirror || !isMyAvatar()) ? 1.0f : glm::clamp( return (lookingInMirror || !isMyAvatar()) ? 1.0f : glm::clamp(
(distanceToCamera - DO_NOT_RENDER_INSIDE) / (RENDER_OPAQUE_OUTSIDE - DO_NOT_RENDER_INSIDE), 0.f, 1.f); (distanceToCamera - DO_NOT_RENDER_INSIDE) / (RENDER_OPAQUE_OUTSIDE - DO_NOT_RENDER_INSIDE), 0.f, 1.f);
@ -1390,3 +1395,47 @@ void Avatar::renderJointConnectingCone(glm::vec3 position1, glm::vec3 position2,
glEnd(); glEnd();
} }
void Avatar::setScale(const float scale) {
_scale = scale;
_newScale = _scale;
_skeleton.setScale(_scale);
// specify the new radius of each ball
_bodyBall[ BODY_BALL_PELVIS ].radius = _scale * BODY_BALL_RADIUS_PELVIS;
_bodyBall[ BODY_BALL_TORSO ].radius = _scale * BODY_BALL_RADIUS_TORSO;
_bodyBall[ BODY_BALL_CHEST ].radius = _scale * BODY_BALL_RADIUS_CHEST;
_bodyBall[ BODY_BALL_NECK_BASE ].radius = _scale * BODY_BALL_RADIUS_NECK_BASE;
_bodyBall[ BODY_BALL_HEAD_BASE ].radius = _scale * BODY_BALL_RADIUS_HEAD_BASE;
_bodyBall[ BODY_BALL_LEFT_COLLAR ].radius = _scale * BODY_BALL_RADIUS_LEFT_COLLAR;
_bodyBall[ BODY_BALL_LEFT_SHOULDER ].radius = _scale * BODY_BALL_RADIUS_LEFT_SHOULDER;
_bodyBall[ BODY_BALL_LEFT_ELBOW ].radius = _scale * BODY_BALL_RADIUS_LEFT_ELBOW;
_bodyBall[ BODY_BALL_LEFT_WRIST ].radius = _scale * BODY_BALL_RADIUS_LEFT_WRIST;
_bodyBall[ BODY_BALL_LEFT_FINGERTIPS ].radius = _scale * BODY_BALL_RADIUS_LEFT_FINGERTIPS;
_bodyBall[ BODY_BALL_RIGHT_COLLAR ].radius = _scale * BODY_BALL_RADIUS_RIGHT_COLLAR;
_bodyBall[ BODY_BALL_RIGHT_SHOULDER ].radius = _scale * BODY_BALL_RADIUS_RIGHT_SHOULDER;
_bodyBall[ BODY_BALL_RIGHT_ELBOW ].radius = _scale * BODY_BALL_RADIUS_RIGHT_ELBOW;
_bodyBall[ BODY_BALL_RIGHT_WRIST ].radius = _scale * BODY_BALL_RADIUS_RIGHT_WRIST;
_bodyBall[ BODY_BALL_RIGHT_FINGERTIPS ].radius = _scale * BODY_BALL_RADIUS_RIGHT_FINGERTIPS;
_bodyBall[ BODY_BALL_LEFT_HIP ].radius = _scale * BODY_BALL_RADIUS_LEFT_HIP;
//_bodyBall[ BODY_BALL_LEFT_MID_THIGH ].radius = _scale * BODY_BALL_RADIUS_LEFT_MID_THIGH;
_bodyBall[ BODY_BALL_LEFT_KNEE ].radius = _scale * BODY_BALL_RADIUS_LEFT_KNEE;
_bodyBall[ BODY_BALL_LEFT_HEEL ].radius = _scale * BODY_BALL_RADIUS_LEFT_HEEL;
_bodyBall[ BODY_BALL_LEFT_TOES ].radius = _scale * BODY_BALL_RADIUS_LEFT_TOES;
_bodyBall[ BODY_BALL_RIGHT_HIP ].radius = _scale * BODY_BALL_RADIUS_RIGHT_HIP;
_bodyBall[ BODY_BALL_RIGHT_KNEE ].radius = _scale * BODY_BALL_RADIUS_RIGHT_KNEE;
_bodyBall[ BODY_BALL_RIGHT_HEEL ].radius = _scale * BODY_BALL_RADIUS_RIGHT_HEEL;
_bodyBall[ BODY_BALL_RIGHT_TOES ].radius = _scale * BODY_BALL_RADIUS_RIGHT_TOES;
_height = _skeleton.getHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius + _bodyBall[ BODY_BALL_HEAD_BASE ].radius;
_maxArmLength = _skeleton.getArmLength();
_pelvisStandingHeight = _skeleton.getPelvisStandingHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius;
_pelvisFloatingHeight = _skeleton.getPelvisFloatingHeight() + _bodyBall[ BODY_BALL_LEFT_HEEL ].radius;
_pelvisToHeadLength = _skeleton.getPelvisToHeadLength();
_avatarTouch.setReachableRadius(_scale * PERIPERSONAL_RADIUS);
}

View file

@ -23,6 +23,30 @@
#include "Skeleton.h" #include "Skeleton.h"
#include "Transmitter.h" #include "Transmitter.h"
const float BODY_BALL_RADIUS_PELVIS = 0.07;
const float BODY_BALL_RADIUS_TORSO = 0.065;
const float BODY_BALL_RADIUS_CHEST = 0.08;
const float BODY_BALL_RADIUS_NECK_BASE = 0.03;
const float BODY_BALL_RADIUS_HEAD_BASE = 0.07;
const float BODY_BALL_RADIUS_LEFT_COLLAR = 0.04;
const float BODY_BALL_RADIUS_LEFT_SHOULDER = 0.03;
const float BODY_BALL_RADIUS_LEFT_ELBOW = 0.02;
const float BODY_BALL_RADIUS_LEFT_WRIST = 0.02;
const float BODY_BALL_RADIUS_LEFT_FINGERTIPS = 0.01;
const float BODY_BALL_RADIUS_RIGHT_COLLAR = 0.04;
const float BODY_BALL_RADIUS_RIGHT_SHOULDER = 0.03;
const float BODY_BALL_RADIUS_RIGHT_ELBOW = 0.02;
const float BODY_BALL_RADIUS_RIGHT_WRIST = 0.02;
const float BODY_BALL_RADIUS_RIGHT_FINGERTIPS = 0.01;
const float BODY_BALL_RADIUS_LEFT_HIP = 0.04;
const float BODY_BALL_RADIUS_LEFT_MID_THIGH = 0.03;
const float BODY_BALL_RADIUS_LEFT_KNEE = 0.025;
const float BODY_BALL_RADIUS_LEFT_HEEL = 0.025;
const float BODY_BALL_RADIUS_LEFT_TOES = 0.025;
const float BODY_BALL_RADIUS_RIGHT_HIP = 0.04;
const float BODY_BALL_RADIUS_RIGHT_KNEE = 0.025;
const float BODY_BALL_RADIUS_RIGHT_HEEL = 0.025;
const float BODY_BALL_RADIUS_RIGHT_TOES = 0.025;
enum AvatarBodyBallID enum AvatarBodyBallID
{ {
@ -105,6 +129,7 @@ public:
void setGravity (glm::vec3 gravity); void setGravity (glm::vec3 gravity);
void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction); void setMouseRay (const glm::vec3 &origin, const glm::vec3 &direction);
void setOrientation (const glm::quat& orientation); void setOrientation (const glm::quat& orientation);
void setScale (const float scale);
//getters //getters
bool isInitialized () const { return _initialized;} bool isInitialized () const { return _initialized;}
@ -118,6 +143,7 @@ public:
glm::vec3 getBodyRightDirection () const { return getOrientation() * IDENTITY_RIGHT; } glm::vec3 getBodyRightDirection () const { return getOrientation() * IDENTITY_RIGHT; }
glm::vec3 getBodyUpDirection () const { return getOrientation() * IDENTITY_UP; } glm::vec3 getBodyUpDirection () const { return getOrientation() * IDENTITY_UP; }
glm::vec3 getBodyFrontDirection () const { return getOrientation() * IDENTITY_FRONT; } glm::vec3 getBodyFrontDirection () const { return getOrientation() * IDENTITY_FRONT; }
float getScale () const { return _scale;}
const glm::vec3& getVelocity () const { return _velocity;} const glm::vec3& getVelocity () const { return _velocity;}
float getSpeed () const { return _speed;} float getSpeed () const { return _speed;}
float getHeight () const { return _height;} float getHeight () const { return _height;}
@ -200,6 +226,7 @@ private:
float _pelvisStandingHeight; float _pelvisStandingHeight;
float _pelvisFloatingHeight; float _pelvisFloatingHeight;
float _pelvisToHeadLength; float _pelvisToHeadLength;
float _scale;
float _height; float _height;
Balls* _balls; Balls* _balls;
AvatarTouch _avatarTouch; AvatarTouch _avatarTouch;

View file

@ -50,6 +50,7 @@ Camera::Camera() {
_targetPosition = glm::vec3(0.0f, 0.0f, 0.0f); _targetPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_position = glm::vec3(0.0f, 0.0f, 0.0f); _position = glm::vec3(0.0f, 0.0f, 0.0f);
_idealPosition = glm::vec3(0.0f, 0.0f, 0.0f); _idealPosition = glm::vec3(0.0f, 0.0f, 0.0f);
_scale = 1.0f;
} }
void Camera::update(float deltaTime) { void Camera::update(float deltaTime) {
@ -91,14 +92,14 @@ void Camera::updateFollowMode(float deltaTime) {
if (_needsToInitialize || (_tightness == 0.0f)) { if (_needsToInitialize || (_tightness == 0.0f)) {
_rotation = _targetRotation; _rotation = _targetRotation;
_idealPosition = _targetPosition + _rotation * glm::vec3(0.0f, _upShift, _distance); _idealPosition = _targetPosition + _scale * (_rotation * glm::vec3(0.0f, _upShift, _distance));
_position = _idealPosition; _position = _idealPosition;
_needsToInitialize = false; _needsToInitialize = false;
} else { } else {
// pull rotation towards ideal // pull rotation towards ideal
_rotation = safeMix(_rotation, _targetRotation, t); _rotation = safeMix(_rotation, _targetRotation, t);
_idealPosition = _targetPosition + _rotation * glm::vec3(0.0f, _upShift, _distance); _idealPosition = _targetPosition + _scale * (_rotation * glm::vec3(0.0f, _upShift, _distance));
_position += (_idealPosition - _position) * t; _position += (_idealPosition - _position) * t;
} }
} }
@ -174,6 +175,12 @@ void Camera::setEyeOffsetOrientation (const glm::quat& o) {
_frustumNeedsReshape = true; _frustumNeedsReshape = true;
} }
void Camera::setScale(float s) {
_scale = s;
_needsToInitialize = true;
_frustumNeedsReshape = true;
}
void Camera::initialize() { void Camera::initialize() {
_needsToInitialize = true; _needsToInitialize = true;
_modeShift = 0.0; _modeShift = 0.0;

View file

@ -46,6 +46,7 @@ public:
void setFarClip ( float f ); void setFarClip ( float f );
void setEyeOffsetPosition ( const glm::vec3& p ); void setEyeOffsetPosition ( const glm::vec3& p );
void setEyeOffsetOrientation( const glm::quat& o ); void setEyeOffsetOrientation( const glm::quat& o );
void setScale ( const float s );
const glm::vec3& getTargetPosition () { return _targetPosition; } const glm::vec3& getTargetPosition () { return _targetPosition; }
const glm::vec3& getPosition () { return _position; } const glm::vec3& getPosition () { return _position; }
@ -54,10 +55,11 @@ public:
CameraMode getMode () { return _mode; } CameraMode getMode () { return _mode; }
float getFieldOfView () { return _fieldOfView; } float getFieldOfView () { return _fieldOfView; }
float getAspectRatio () { return _aspectRatio; } float getAspectRatio () { return _aspectRatio; }
float getNearClip () { return _nearClip; } float getNearClip () { return _scale * _nearClip; }
float getFarClip () { return _farClip; } float getFarClip () { return _scale * _farClip; }
const glm::vec3& getEyeOffsetPosition () { return _eyeOffsetPosition; } const glm::vec3& getEyeOffsetPosition () { return _eyeOffsetPosition; }
const glm::quat& getEyeOffsetOrientation () { return _eyeOffsetOrientation; } const glm::quat& getEyeOffsetOrientation () { return _eyeOffsetOrientation; }
float getScale () { return _scale; }
bool getFrustumNeedsReshape(); // call to find out if the view frustum needs to be reshaped bool getFrustumNeedsReshape(); // call to find out if the view frustum needs to be reshaped
void setFrustumWasReshaped(); // call this after reshaping the view frustum. void setFrustumWasReshaped(); // call this after reshaping the view frustum.
@ -90,6 +92,7 @@ private:
float _modeShift; float _modeShift;
float _linearModeShift; float _linearModeShift;
float _modeShiftRate; float _modeShiftRate;
float _scale;
void updateFollowMode( float deltaTime ); void updateFollowMode( float deltaTime );
}; };

View file

@ -128,9 +128,9 @@ void Head::resetHairPhysics() {
glm::vec3 up = getUpDirection(); glm::vec3 up = getUpDirection();
for (int t = 0; t < NUM_HAIR_TUFTS; t ++) { for (int t = 0; t < NUM_HAIR_TUFTS; t ++) {
_hairTuft[t].length = HAIR_LENGTH; _hairTuft[t].length = _scale * HAIR_LENGTH;
_hairTuft[t].thickness = HAIR_THICKNESS; _hairTuft[t].thickness = _scale * HAIR_THICKNESS;
_hairTuft[t].basePosition = _position + up * _scale * 0.9f; _hairTuft[t].basePosition = _position + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * 0.9f;
_hairTuft[t].midPosition = _hairTuft[t].basePosition + up * _hairTuft[t].length * ONE_HALF; _hairTuft[t].midPosition = _hairTuft[t].basePosition + up * _hairTuft[t].length * ONE_HALF;
_hairTuft[t].endPosition = _hairTuft[t].midPosition + up * _hairTuft[t].length * ONE_HALF; _hairTuft[t].endPosition = _hairTuft[t].midPosition + up * _hairTuft[t].length * ONE_HALF;
_hairTuft[t].midVelocity = glm::vec3(0.0f, 0.0f, 0.0f); _hairTuft[t].midVelocity = glm::vec3(0.0f, 0.0f, 0.0f);
@ -261,13 +261,13 @@ void Head::calculateGeometry() {
//calculate the eye positions //calculate the eye positions
_leftEyePosition = _position _leftEyePosition = _position
- right * _scale * EYE_RIGHT_OFFSET - right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_RIGHT_OFFSET
+ up * _scale * EYE_UP_OFFSET + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET
+ front * _scale * EYE_FRONT_OFFSET; + front * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_FRONT_OFFSET;
_rightEyePosition = _position _rightEyePosition = _position
+ right * _scale * EYE_RIGHT_OFFSET + right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_RIGHT_OFFSET
+ up * _scale * EYE_UP_OFFSET + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_UP_OFFSET
+ front * _scale * EYE_FRONT_OFFSET; + front * _scale * BODY_BALL_RADIUS_HEAD_BASE * EYE_FRONT_OFFSET;
_eyeLevelPosition = _position + up * _scale * EYE_UP_OFFSET; _eyeLevelPosition = _position + up * _scale * EYE_UP_OFFSET;
@ -276,12 +276,12 @@ void Head::calculateGeometry() {
_rightEyeBrowPosition = _rightEyePosition; _rightEyeBrowPosition = _rightEyePosition;
//calculate the ear positions //calculate the ear positions
_leftEarPosition = _position - right * _scale * EAR_RIGHT_OFFSET; _leftEarPosition = _position - right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EAR_RIGHT_OFFSET;
_rightEarPosition = _position + right * _scale * EAR_RIGHT_OFFSET; _rightEarPosition = _position + right * _scale * BODY_BALL_RADIUS_HEAD_BASE * EAR_RIGHT_OFFSET;
//calculate the mouth position //calculate the mouth position
_mouthPosition = _position + up * _scale * MOUTH_UP_OFFSET _mouthPosition = _position + up * _scale * BODY_BALL_RADIUS_HEAD_BASE * MOUTH_UP_OFFSET
+ front * _scale; + front * _scale * BODY_BALL_RADIUS_HEAD_BASE;
} }
@ -296,16 +296,25 @@ void Head::render(float alpha) {
renderMohawk(); renderMohawk();
renderHeadSphere(); renderHeadSphere();
renderEyeBalls(); renderEyeBalls();
renderEars(); renderEars();
renderMouth(); renderMouth();
renderEyeBrows(); renderEyeBrows();
if (_renderLookatVectors) { if (_renderLookatVectors) {
renderLookatVectors(_leftEyePosition, _rightEyePosition, _lookAtPosition); renderLookatVectors(_leftEyePosition, _rightEyePosition, _lookAtPosition);
} }
} }
void Head::setScale (float scale) {
_scale = scale;
delete[] _mohawkTriangleFan;
delete[] _mohawkColors;
createMohawk();
resetHairPhysics();
}
void Head::createMohawk() { void Head::createMohawk() {
uint16_t nodeId = 0; uint16_t nodeId = 0;
@ -318,7 +327,7 @@ void Head::createMohawk() {
} }
} }
srand(nodeId); srand(nodeId);
float height = 0.08f + randFloat() * 0.05f; float height = _scale * (0.08f + randFloat() * 0.05f);
float variance = 0.03 + randFloat() * 0.03f; float variance = 0.03 + randFloat() * 0.03f;
const float RAD_PER_TRIANGLE = (2.3f + randFloat() * 0.2f) / (float)MOHAWK_TRIANGLES; const float RAD_PER_TRIANGLE = (2.3f + randFloat() * 0.2f) / (float)MOHAWK_TRIANGLES;
_mohawkTriangleFan = new glm::vec3[MOHAWK_TRIANGLES]; _mohawkTriangleFan = new glm::vec3[MOHAWK_TRIANGLES];
@ -326,7 +335,7 @@ void Head::createMohawk() {
_mohawkTriangleFan[0] = glm::vec3(0, 0, 0); _mohawkTriangleFan[0] = glm::vec3(0, 0, 0);
glm::vec3 basicColor(randFloat(), randFloat(), randFloat()); glm::vec3 basicColor(randFloat(), randFloat(), randFloat());
_mohawkColors[0] = basicColor; _mohawkColors[0] = basicColor;
for (int i = 1; i < MOHAWK_TRIANGLES; i++) { for (int i = 1; i < MOHAWK_TRIANGLES; i++) {
_mohawkTriangleFan[i] = glm::vec3((randFloat() - 0.5f) * variance, _mohawkTriangleFan[i] = glm::vec3((randFloat() - 0.5f) * variance,
height * cosf(i * RAD_PER_TRIANGLE - PIf / 2.f) height * cosf(i * RAD_PER_TRIANGLE - PIf / 2.f)
@ -404,7 +413,9 @@ glm::quat Head::getCameraOrientation () const {
void Head::renderHeadSphere() { void Head::renderHeadSphere() {
glPushMatrix(); glPushMatrix();
glTranslatef(_position.x, _position.y, _position.z); //translate to head position glTranslatef(_position.x, _position.y, _position.z); //translate to head position
glScalef(_scale, _scale, _scale); //scale to head size glScalef(_scale * BODY_BALL_RADIUS_HEAD_BASE,
_scale * BODY_BALL_RADIUS_HEAD_BASE,
_scale * BODY_BALL_RADIUS_HEAD_BASE); //scale to head size
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha); glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
glutSolidSphere(1, 30, 30); glutSolidSphere(1, 30, 30);
glPopMatrix(); glPopMatrix();
@ -415,13 +426,13 @@ void Head::renderEars() {
glPushMatrix(); glPushMatrix();
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha); glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
glTranslatef(_leftEarPosition.x, _leftEarPosition.y, _leftEarPosition.z); glTranslatef(_leftEarPosition.x, _leftEarPosition.y, _leftEarPosition.z);
glutSolidSphere(0.02, 30, 30); glutSolidSphere(_scale * 0.02, 30, 30);
glPopMatrix(); glPopMatrix();
glPushMatrix(); glPushMatrix();
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha); glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
glTranslatef(_rightEarPosition.x, _rightEarPosition.y, _rightEarPosition.z); glTranslatef(_rightEarPosition.x, _rightEarPosition.y, _rightEarPosition.z);
glutSolidSphere(0.02, 30, 30); glutSolidSphere(_scale * 0.02, 30, 30);
glPopMatrix(); glPopMatrix();
} }
@ -434,9 +445,9 @@ void Head::renderMouth() {
glm::vec3 up = orientation * IDENTITY_UP; glm::vec3 up = orientation * IDENTITY_UP;
glm::vec3 front = orientation * IDENTITY_FRONT; glm::vec3 front = orientation * IDENTITY_FRONT;
glm::vec3 r = right * _scale * (0.30f + s * 0.0014f ); glm::vec3 r = right * _scale * BODY_BALL_RADIUS_HEAD_BASE * (0.30f + s * 0.0014f );
glm::vec3 u = up * _scale * (0.05f + s * 0.0040f ); glm::vec3 u = up * _scale * BODY_BALL_RADIUS_HEAD_BASE * (0.05f + s * 0.0040f );
glm::vec3 f = front * _scale * 0.09f; glm::vec3 f = front * _scale * BODY_BALL_RADIUS_HEAD_BASE * 0.09f;
glm::vec3 middle = _mouthPosition; glm::vec3 middle = _mouthPosition;
glm::vec3 leftCorner = _mouthPosition - r * 1.0f; glm::vec3 leftCorner = _mouthPosition - r * 1.0f;
@ -449,7 +460,7 @@ void Head::renderMouth() {
// constrain all mouth vertices to a sphere slightly larger than the head... // constrain all mouth vertices to a sphere slightly larger than the head...
const float MOUTH_OFFSET_OFF_FACE = 0.003f; const float MOUTH_OFFSET_OFF_FACE = 0.003f;
float constrainedRadius = _scale + MOUTH_OFFSET_OFF_FACE; float constrainedRadius = _scale * BODY_BALL_RADIUS_HEAD_BASE + MOUTH_OFFSET_OFF_FACE;
middle = _position + glm::normalize(middle - _position) * constrainedRadius; middle = _position + glm::normalize(middle - _position) * constrainedRadius;
leftCorner = _position + glm::normalize(leftCorner - _position) * constrainedRadius; leftCorner = _position + glm::normalize(leftCorner - _position) * constrainedRadius;
rightCorner = _position + glm::normalize(rightCorner - _position) * constrainedRadius; rightCorner = _position + glm::normalize(rightCorner - _position) * constrainedRadius;
@ -484,9 +495,9 @@ void Head::renderMouth() {
void Head::renderEyeBrows() { void Head::renderEyeBrows() {
float height = _scale * 0.3f + _browAudioLift; float height = _scale * BODY_BALL_RADIUS_HEAD_BASE * 0.3f + _browAudioLift;
float length = _scale * 0.2f; float length = _scale * BODY_BALL_RADIUS_HEAD_BASE * 0.2f;
float width = _scale * 0.07f; float width = _scale * BODY_BALL_RADIUS_HEAD_BASE * 0.07f;
glColor3f(0.3f, 0.25f, 0.2f); glColor3f(0.3f, 0.25f, 0.2f);
@ -505,7 +516,7 @@ void Head::renderEyeBrows() {
glm::vec3 r = right * length; glm::vec3 r = right * length;
glm::vec3 u = up * height; glm::vec3 u = up * height;
glm::vec3 t = up * (height + width); glm::vec3 t = up * (height + width);
glm::vec3 f = front * _scale * -0.1f; glm::vec3 f = front * _scale * BODY_BALL_RADIUS_HEAD_BASE * -0.1f;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
@ -553,14 +564,14 @@ void Head::renderEyeBalls() {
glPushMatrix(); glPushMatrix();
glColor3fv(EYEBALL_COLOR); glColor3fv(EYEBALL_COLOR);
glTranslatef(_leftEyePosition.x, _leftEyePosition.y, _leftEyePosition.z); glTranslatef(_leftEyePosition.x, _leftEyePosition.y, _leftEyePosition.z);
glutSolidSphere(EYEBALL_RADIUS, 30, 30); glutSolidSphere(_scale * EYEBALL_RADIUS, 30, 30);
glPopMatrix(); glPopMatrix();
//render white ball of right eyeball //render white ball of right eyeball
glPushMatrix(); glPushMatrix();
glColor3fv(EYEBALL_COLOR); glColor3fv(EYEBALL_COLOR);
glTranslatef(_rightEyePosition.x, _rightEyePosition.y, _rightEyePosition.z); glTranslatef(_rightEyePosition.x, _rightEyePosition.y, _rightEyePosition.z);
glutSolidSphere(EYEBALL_RADIUS, 30, 30); glutSolidSphere(_scale * EYEBALL_RADIUS, 30, 30);
glPopMatrix(); glPopMatrix();
_irisProgram->bind(); _irisProgram->bind();
@ -580,13 +591,15 @@ void Head::renderEyeBalls() {
glm::vec3 rotationAxis = glm::axis(rotation); glm::vec3 rotationAxis = glm::axis(rotation);
glRotatef(glm::angle(rotation), rotationAxis.x, rotationAxis.y, rotationAxis.z); glRotatef(glm::angle(rotation), rotationAxis.x, rotationAxis.y, rotationAxis.z);
glTranslatef(0.0f, 0.0f, -IRIS_PROTRUSION); glTranslatef(0.0f, 0.0f, -IRIS_PROTRUSION);
glScalef(IRIS_RADIUS * 2.0f, IRIS_RADIUS * 2.0f, IRIS_RADIUS); // flatten the iris glScalef(_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS); // flatten the iris
// this ugliness is simply to invert the model transform and get the eye position in model space // this ugliness is simply to invert the model transform and get the eye position in model space
_irisProgram->setUniform(_eyePositionLocation, (glm::inverse(rotation) * _irisProgram->setUniform(_eyePositionLocation, (glm::inverse(rotation) *
(Application::getInstance()->getCamera()->getPosition() - _leftEyePosition) + (Application::getInstance()->getCamera()->getPosition() - _leftEyePosition) +
glm::vec3(0.0f, 0.0f, IRIS_PROTRUSION)) * glm::vec3(1.0f / (IRIS_RADIUS * 2.0f), glm::vec3(0.0f, 0.0f, _scale * IRIS_PROTRUSION)) * glm::vec3(1.0f / (_scale * IRIS_RADIUS * 2.0f),
1.0f / (IRIS_RADIUS * 2.0f), 1.0f / IRIS_RADIUS)); 1.0f / (_scale * IRIS_RADIUS * 2.0f), 1.0f / _scale * IRIS_RADIUS));
glutSolidSphere(0.5f, 15, 15); glutSolidSphere(0.5f, 15, 15);
} }
@ -602,13 +615,15 @@ void Head::renderEyeBalls() {
glm::vec3 rotationAxis = glm::axis(rotation); glm::vec3 rotationAxis = glm::axis(rotation);
glRotatef(glm::angle(rotation), rotationAxis.x, rotationAxis.y, rotationAxis.z); glRotatef(glm::angle(rotation), rotationAxis.x, rotationAxis.y, rotationAxis.z);
glTranslatef(0.0f, 0.0f, -IRIS_PROTRUSION); glTranslatef(0.0f, 0.0f, -IRIS_PROTRUSION);
glScalef(IRIS_RADIUS * 2.0f, IRIS_RADIUS * 2.0f, IRIS_RADIUS); // flatten the iris glScalef(_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS); // flatten the iris
// this ugliness is simply to invert the model transform and get the eye position in model space // this ugliness is simply to invert the model transform and get the eye position in model space
_irisProgram->setUniform(_eyePositionLocation, (glm::inverse(rotation) * _irisProgram->setUniform(_eyePositionLocation, (glm::inverse(rotation) *
(Application::getInstance()->getCamera()->getPosition() - _rightEyePosition) + (Application::getInstance()->getCamera()->getPosition() - _rightEyePosition) +
glm::vec3(0.0f, 0.0f, IRIS_PROTRUSION)) * glm::vec3(1.0f / (IRIS_RADIUS * 2.0f), glm::vec3(0.0f, 0.0f, _scale * IRIS_PROTRUSION)) * glm::vec3(1.0f / (_scale * IRIS_RADIUS * 2.0f),
1.0f / (IRIS_RADIUS * 2.0f), 1.0f / IRIS_RADIUS)); 1.0f / (_scale * IRIS_RADIUS * 2.0f), 1.0f / _scale * IRIS_RADIUS));
glutSolidSphere(0.5f, 15, 15); glutSolidSphere(0.5f, 15, 15);
} }
@ -626,7 +641,7 @@ void Head::renderEyeBalls() {
glTranslatef(_leftEyePosition.x, _leftEyePosition.y, _leftEyePosition.z); //translate to eyeball position glTranslatef(_leftEyePosition.x, _leftEyePosition.y, _leftEyePosition.z); //translate to eyeball position
glm::vec3 rotationAxis = glm::axis(orientation); glm::vec3 rotationAxis = glm::axis(orientation);
glRotatef(glm::angle(orientation), rotationAxis.x, rotationAxis.y, rotationAxis.z); glRotatef(glm::angle(orientation), rotationAxis.x, rotationAxis.y, rotationAxis.z);
glScalef(EYELID_RADIUS, EYELID_RADIUS, EYELID_RADIUS); glScalef(_scale * EYELID_RADIUS, _scale * EYELID_RADIUS, _scale * EYELID_RADIUS);
glRotatef(-40 - 50 * _leftEyeBlink, 1, 0, 0); glRotatef(-40 - 50 * _leftEyeBlink, 1, 0, 0);
Application::getInstance()->getGeometryCache()->renderHemisphere(15, 10); Application::getInstance()->getGeometryCache()->renderHemisphere(15, 10);
glRotatef(180 * _leftEyeBlink, 1, 0, 0); glRotatef(180 * _leftEyeBlink, 1, 0, 0);
@ -639,7 +654,7 @@ void Head::renderEyeBalls() {
glTranslatef(_rightEyePosition.x, _rightEyePosition.y, _rightEyePosition.z); //translate to eyeball position glTranslatef(_rightEyePosition.x, _rightEyePosition.y, _rightEyePosition.z); //translate to eyeball position
glm::vec3 rotationAxis = glm::axis(orientation); glm::vec3 rotationAxis = glm::axis(orientation);
glRotatef(glm::angle(orientation), rotationAxis.x, rotationAxis.y, rotationAxis.z); glRotatef(glm::angle(orientation), rotationAxis.x, rotationAxis.y, rotationAxis.z);
glScalef(EYELID_RADIUS, EYELID_RADIUS, EYELID_RADIUS); glScalef(_scale * EYELID_RADIUS, _scale * EYELID_RADIUS, _scale * EYELID_RADIUS);
glRotatef(-40 - 50 * _rightEyeBlink, 1, 0, 0); glRotatef(-40 - 50 * _rightEyeBlink, 1, 0, 0);
Application::getInstance()->getGeometryCache()->renderHemisphere(15, 10); Application::getInstance()->getGeometryCache()->renderHemisphere(15, 10);
glRotatef(180 * _rightEyeBlink, 1, 0, 0); glRotatef(180 * _rightEyeBlink, 1, 0, 0);
@ -682,7 +697,7 @@ void Head::updateHairPhysics(float deltaTime) {
= front * sinf(radian) = front * sinf(radian)
+ up * cosf(radian); + up * cosf(radian);
_hairTuft[t].basePosition = _position + _scale * 0.9f * baseDirection; _hairTuft[t].basePosition = _position + _scale * BODY_BALL_RADIUS_HEAD_BASE * 0.9f * baseDirection;
glm::vec3 midAxis = _hairTuft[t].midPosition - _hairTuft[t].basePosition; glm::vec3 midAxis = _hairTuft[t].midPosition - _hairTuft[t].basePosition;
glm::vec3 endAxis = _hairTuft[t].endPosition - _hairTuft[t].midPosition; glm::vec3 endAxis = _hairTuft[t].endPosition - _hairTuft[t].midPosition;

View file

@ -38,7 +38,7 @@ public:
void render(float alpha); void render(float alpha);
void renderMohawk(); void renderMohawk();
void setScale (float scale ) { _scale = scale; } void setScale (float scale );
void setPosition (glm::vec3 position ) { _position = position; } void setPosition (glm::vec3 position ) { _position = position; }
void setBodyRotation (glm::vec3 bodyRotation ) { _bodyRotation = bodyRotation; } void setBodyRotation (glm::vec3 bodyRotation ) { _bodyRotation = bodyRotation; }
void setGravity (glm::vec3 gravity ) { _gravity = gravity; } void setGravity (glm::vec3 gravity ) { _gravity = gravity; }

View file

@ -11,10 +11,39 @@
const float BODY_SPRING_DEFAULT_TIGHTNESS = 1000.0f; const float BODY_SPRING_DEFAULT_TIGHTNESS = 1000.0f;
const float FLOATING_HEIGHT = 0.13f; const float FLOATING_HEIGHT = 0.13f;
Skeleton::Skeleton() { const glm::vec3 AVATAR_JOINT_POSITION_PELVIS = glm::vec3(0.0, 0.0, 0.0 );
const glm::vec3 AVATAR_JOINT_POSITION_TORSO = glm::vec3( 0.0, 0.09, -0.01);
const glm::vec3 AVATAR_JOINT_POSITION_CHEST = glm::vec3( 0.0, 0.09, -0.01);
const glm::vec3 AVATAR_JOINT_POSITION_NECK_BASE = glm::vec3( 0.0, 0.14, 0.01);
const glm::vec3 AVATAR_JOINT_POSITION_HEAD_BASE = glm::vec3( 0.0, 0.04, 0.00);
const glm::vec3 AVATAR_JOINT_POSITION_HEAD_TOP = glm::vec3( 0.0, 0.04, 0.00);
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_COLLAR = glm::vec3(-0.06, 0.04, 0.01);
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_SHOULDER = glm::vec3(-0.05, 0.0 , 0.01);
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_ELBOW = glm::vec3(-0.16, 0.0 , 0.0 );
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_WRIST = glm::vec3(-0.12, 0.0 , 0.0 );
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_FINGERTIPS = glm::vec3(-0.1, 0.0 , 0.0 );
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_COLLAR = glm::vec3( 0.06, 0.04, 0.01);
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_SHOULDER = glm::vec3( 0.05, 0.0 , 0.01);
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_ELBOW = glm::vec3( 0.16, 0.0 , 0.0 );
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_WRIST = glm::vec3( 0.12, 0.0 , 0.0 );
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_FINGERTIPS = glm::vec3( 0.1, 0.0 , 0.0 );
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_HIP = glm::vec3(-0.05, 0.0 , 0.02);
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_KNEE = glm::vec3( 0.00, -0.25, 0.00);
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_HEEL = glm::vec3( 0.00, -0.23, 0.00);
const glm::vec3 AVATAR_JOINT_POSITION_LEFT_TOES = glm::vec3( 0.00, 0.00, -0.06);
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_HIP = glm::vec3( 0.05, 0.0 , 0.02);
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_KNEE = glm::vec3( 0.00, -0.25, 0.00);
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_HEEL = glm::vec3( 0.00, -0.23, 0.00);
const glm::vec3 AVATAR_JOINT_POSITION_RIGHT_TOES = glm::vec3( 0.00, 0.00, -0.06);
Skeleton::Skeleton() : _floatingHeight(FLOATING_HEIGHT){
} }
void Skeleton::initialize() { void Skeleton::initialize() {
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) { for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
joint[b].parent = AVATAR_JOINT_NULL; joint[b].parent = AVATAR_JOINT_NULL;
@ -60,35 +89,39 @@ void Skeleton::initialize() {
joint[ AVATAR_JOINT_RIGHT_HEEL ].parent = AVATAR_JOINT_RIGHT_KNEE; joint[ AVATAR_JOINT_RIGHT_HEEL ].parent = AVATAR_JOINT_RIGHT_KNEE;
joint[ AVATAR_JOINT_RIGHT_TOES ].parent = AVATAR_JOINT_RIGHT_HEEL; joint[ AVATAR_JOINT_RIGHT_TOES ].parent = AVATAR_JOINT_RIGHT_HEEL;
setScale(1.0f);
}
void Skeleton::setScale(float scale) {
// specify the bind pose position // specify the bind pose position
joint[ AVATAR_JOINT_PELVIS ].bindPosePosition = glm::vec3( 0.0, 0.0, 0.0 ); joint[ AVATAR_JOINT_PELVIS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_PELVIS;
joint[ AVATAR_JOINT_TORSO ].bindPosePosition = glm::vec3( 0.0, 0.09, -0.01 ); joint[ AVATAR_JOINT_TORSO ].bindPosePosition = scale * AVATAR_JOINT_POSITION_TORSO;
joint[ AVATAR_JOINT_CHEST ].bindPosePosition = glm::vec3( 0.0, 0.09, -0.01 ); joint[ AVATAR_JOINT_CHEST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_CHEST;
joint[ AVATAR_JOINT_NECK_BASE ].bindPosePosition = glm::vec3( 0.0, 0.14, 0.01 ); joint[ AVATAR_JOINT_NECK_BASE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_NECK_BASE;
joint[ AVATAR_JOINT_HEAD_BASE ].bindPosePosition = glm::vec3( 0.0, 0.04, 0.00 ); joint[ AVATAR_JOINT_HEAD_BASE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_HEAD_BASE;
joint[ AVATAR_JOINT_HEAD_TOP ].bindPosePosition = glm::vec3( 0.0, 0.04, 0.00 ); joint[ AVATAR_JOINT_HEAD_TOP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_HEAD_TOP;
joint[ AVATAR_JOINT_LEFT_COLLAR ].bindPosePosition = glm::vec3( -0.06, 0.04, 0.01 ); joint[ AVATAR_JOINT_LEFT_COLLAR ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_COLLAR;
joint[ AVATAR_JOINT_LEFT_SHOULDER ].bindPosePosition = glm::vec3( -0.05, 0.0, 0.01 ); joint[ AVATAR_JOINT_LEFT_SHOULDER ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_SHOULDER;
joint[ AVATAR_JOINT_LEFT_ELBOW ].bindPosePosition = glm::vec3( -0.16, 0.0, 0.0 ); joint[ AVATAR_JOINT_LEFT_ELBOW ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_ELBOW;
joint[ AVATAR_JOINT_LEFT_WRIST ].bindPosePosition = glm::vec3( -0.12, 0.0, 0.0 ); joint[ AVATAR_JOINT_LEFT_WRIST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_WRIST;
joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].bindPosePosition = glm::vec3( -0.1, 0.0, 0.0 ); joint[ AVATAR_JOINT_LEFT_FINGERTIPS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_FINGERTIPS;
joint[ AVATAR_JOINT_RIGHT_COLLAR ].bindPosePosition = glm::vec3( 0.06, 0.04, 0.01 ); joint[ AVATAR_JOINT_RIGHT_COLLAR ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_COLLAR;
joint[ AVATAR_JOINT_RIGHT_SHOULDER ].bindPosePosition = glm::vec3( 0.05, 0.0, 0.01 ); joint[ AVATAR_JOINT_RIGHT_SHOULDER ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_SHOULDER;
joint[ AVATAR_JOINT_RIGHT_ELBOW ].bindPosePosition = glm::vec3( 0.16, 0.0, 0.0 ); joint[ AVATAR_JOINT_RIGHT_ELBOW ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_ELBOW;
joint[ AVATAR_JOINT_RIGHT_WRIST ].bindPosePosition = glm::vec3( 0.12, 0.0, 0.0 ); joint[ AVATAR_JOINT_RIGHT_WRIST ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_WRIST;
joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].bindPosePosition = glm::vec3( 0.1, 0.0, 0.0 ); joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_FINGERTIPS;
joint[ AVATAR_JOINT_LEFT_HIP ].bindPosePosition = glm::vec3( -0.05, 0.0, 0.02 ); joint[ AVATAR_JOINT_LEFT_HIP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_HIP;
joint[ AVATAR_JOINT_LEFT_KNEE ].bindPosePosition = glm::vec3( 0.00, -0.25, 0.00 ); joint[ AVATAR_JOINT_LEFT_KNEE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_KNEE;
joint[ AVATAR_JOINT_LEFT_HEEL ].bindPosePosition = glm::vec3( 0.00, -0.23, 0.00 ); joint[ AVATAR_JOINT_LEFT_HEEL ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_HEEL;
joint[ AVATAR_JOINT_LEFT_TOES ].bindPosePosition = glm::vec3( 0.00, 0.00, -0.06 ); joint[ AVATAR_JOINT_LEFT_TOES ].bindPosePosition = scale * AVATAR_JOINT_POSITION_LEFT_TOES;
joint[ AVATAR_JOINT_RIGHT_HIP ].bindPosePosition = glm::vec3( 0.05, 0.0, 0.02 ); joint[ AVATAR_JOINT_RIGHT_HIP ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_HIP;
joint[ AVATAR_JOINT_RIGHT_KNEE ].bindPosePosition = glm::vec3( 0.00, -0.25, 0.00 ); joint[ AVATAR_JOINT_RIGHT_KNEE ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_KNEE;
joint[ AVATAR_JOINT_RIGHT_HEEL ].bindPosePosition = glm::vec3( 0.00, -0.23, 0.00 ); joint[ AVATAR_JOINT_RIGHT_HEEL ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_HEEL;
joint[ AVATAR_JOINT_RIGHT_TOES ].bindPosePosition = glm::vec3( 0.00, 0.00, -0.06 ); joint[ AVATAR_JOINT_RIGHT_TOES ].bindPosePosition = scale * AVATAR_JOINT_POSITION_RIGHT_TOES;
// calculate bone length, absolute bind positions/rotations // calculate bone length, absolute bind positions/rotations
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) { for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
@ -99,12 +132,14 @@ void Skeleton::initialize() {
joint[b].absoluteBindPoseRotation = glm::quat(); joint[b].absoluteBindPoseRotation = glm::quat();
} else { } else {
joint[b].absoluteBindPosePosition = joint[ joint[b].parent ].absoluteBindPosePosition + joint[b].absoluteBindPosePosition = joint[ joint[b].parent ].absoluteBindPosePosition +
joint[b].bindPosePosition; joint[b].bindPosePosition;
glm::vec3 parentDirection = joint[ joint[b].parent ].absoluteBindPoseRotation * JOINT_DIRECTION; glm::vec3 parentDirection = joint[ joint[b].parent ].absoluteBindPoseRotation * JOINT_DIRECTION;
joint[b].absoluteBindPoseRotation = rotationBetween(parentDirection, joint[b].bindPosePosition) * joint[b].absoluteBindPoseRotation = rotationBetween(parentDirection, joint[b].bindPosePosition) *
joint[ joint[b].parent ].absoluteBindPoseRotation; joint[ joint[b].parent ].absoluteBindPoseRotation;
} }
} }
_floatingHeight = scale * FLOATING_HEIGHT;
} }
// calculate positions and rotations of all bones by traversing the skeleton tree: // calculate positions and rotations of all bones by traversing the skeleton tree:
@ -151,7 +186,7 @@ float Skeleton::getPelvisStandingHeight() {
float Skeleton::getPelvisFloatingHeight() { float Skeleton::getPelvisFloatingHeight() {
return joint[ AVATAR_JOINT_LEFT_HEEL ].length + return joint[ AVATAR_JOINT_LEFT_HEEL ].length +
joint[ AVATAR_JOINT_LEFT_KNEE ].length + joint[ AVATAR_JOINT_LEFT_KNEE ].length +
FLOATING_HEIGHT; _floatingHeight;
} }
float Skeleton::getPelvisToHeadLength() { float Skeleton::getPelvisToHeadLength() {

View file

@ -49,6 +49,7 @@ public:
Skeleton(); Skeleton();
void initialize(); void initialize();
void setScale(float scale);
void update(float deltaTime, const glm::quat&, glm::vec3 position); void update(float deltaTime, const glm::quat&, glm::vec3 position);
void render(); void render();
@ -72,7 +73,8 @@ public:
float length; // the length of vector connecting the joint and its parent float length; // the length of vector connecting the joint and its parent
}; };
AvatarJoint joint[ NUM_AVATAR_JOINTS ]; AvatarJoint joint[ NUM_AVATAR_JOINTS ];
}; float _floatingHeight;
};
#endif #endif

View file

@ -24,6 +24,7 @@ AvatarData::AvatarData(Node* owningNode) :
_bodyYaw(-90.0), _bodyYaw(-90.0),
_bodyPitch(0.0), _bodyPitch(0.0),
_bodyRoll(0.0), _bodyRoll(0.0),
_newScale(1.0f),
_handState(0), _handState(0),
_cameraPosition(0,0,0), _cameraPosition(0,0,0),
_cameraOrientation(), _cameraOrientation(),
@ -71,6 +72,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes) // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _headData->_yaw);
@ -197,7 +199,8 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyYaw); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyYaw);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyPitch); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyPitch);
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyRoll); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyRoll);
sourceBuffer += unpackFloatRatioFromTwoByte( sourceBuffer, _newScale);
// Head rotation (NOTE: This needs to become a quaternion to save two bytes) // Head rotation (NOTE: This needs to become a quaternion to save two bytes)
float headYaw, headPitch, headRoll; float headYaw, headPitch, headRoll;
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &headYaw);

View file

@ -112,6 +112,7 @@ protected:
float _bodyYaw; float _bodyYaw;
float _bodyPitch; float _bodyPitch;
float _bodyRoll; float _bodyRoll;
float _newScale;
// Hand state (are we grabbing something or not) // Hand state (are we grabbing something or not)
char _handState; char _handState;

View file

@ -13,6 +13,9 @@
PACKET_VERSION versionForPacketType(PACKET_TYPE type) { PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
switch (type) { switch (type) {
case PACKET_TYPE_HEAD_DATA:
return 1;
break;
default: default:
return 0; return 0;
break; break;
@ -60,4 +63,4 @@ int numBytesForPacketHeader(unsigned char* packetHeader) {
// currently this need not be dynamic - there are 2 bytes for each packet header // currently this need not be dynamic - there are 2 bytes for each packet header
return 2; return 2;
} }