Avatar resizing final commit

This commit is contained in:
atlante45 2013-07-15 12:04:24 -07:00
parent 078a47b006
commit bf3c4fa1f8
5 changed files with 17 additions and 17 deletions

View file

@ -1183,21 +1183,21 @@ void Application::setRenderThirdPerson(bool thirdPerson) {
} }
void Application::increaseAvatarSize() { void Application::increaseAvatarSize() {
if (3.0f < _myAvatar.getScale() + 0.25f) { if (5.0f < _myAvatar.getScale() + 0.05f) {
return; return;
} }
_myAvatar.setScale(_myAvatar.getScale() + 0.25f); _myAvatar.setScale(_myAvatar.getScale() + 0.05f);
_myCamera.setScale(_myAvatar.getScale() + 0.25f); _myCamera.setScale(_myAvatar.getScale() + 0.05f);
} }
void Application::decreaseAvatarSize() { void Application::decreaseAvatarSize() {
if (_myAvatar.getScale() + 0.25f < 0.25f) { if (_myAvatar.getScale() - 0.05f < 0.15f) {
return; return;
} }
_myAvatar.setScale(_myAvatar.getScale() - 0.25f); _myAvatar.setScale(_myAvatar.getScale() - 0.05f);
_myCamera.setScale(_myAvatar.getScale() - 0.25f); _myCamera.setScale(_myAvatar.getScale() - 0.05f);
} }
void Application::setFrustumOffset(bool frustumOffset) { void Application::setFrustumOffset(bool frustumOffset) {

View file

@ -575,13 +575,13 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
_bodyYawDelta *= bodySpinMomentum; _bodyYawDelta *= bodySpinMomentum;
_bodyRollDelta *= bodySpinMomentum; _bodyRollDelta *= bodySpinMomentum;
const float MAX_STATIC_FRICTION_VELOCITY = _scale * 0.5f; const float MAX_STATIC_FRICTION_VELOCITY = 0.5f;
const float STATIC_FRICTION_STRENGTH = _scale * 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 = _scale * 10.0f; const float SPEED_BRAKE_POWER = _scale * 10.0f;
const float SQUARED_DAMPING_STRENGTH = _scale * 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);
} else { } else {

View file

@ -92,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;
} }
} }
@ -124,18 +124,18 @@ void Camera::setMode(CameraMode m) {
_previousTightness = _tightness; _previousTightness = _tightness;
if (_mode == CAMERA_MODE_THIRD_PERSON) { if (_mode == CAMERA_MODE_THIRD_PERSON) {
_newUpShift = _scale * CAMERA_THIRD_PERSON_MODE_UP_SHIFT; _newUpShift = CAMERA_THIRD_PERSON_MODE_UP_SHIFT;
_newDistance = _scale * CAMERA_THIRD_PERSON_MODE_DISTANCE; _newDistance = CAMERA_THIRD_PERSON_MODE_DISTANCE;
_newTightness = CAMERA_THIRD_PERSON_MODE_TIGHTNESS; _newTightness = CAMERA_THIRD_PERSON_MODE_TIGHTNESS;
} else if (_mode == CAMERA_MODE_FIRST_PERSON) { } else if (_mode == CAMERA_MODE_FIRST_PERSON) {
_newUpShift = _scale * CAMERA_FIRST_PERSON_MODE_UP_SHIFT; _newUpShift = CAMERA_FIRST_PERSON_MODE_UP_SHIFT;
_newDistance = _scale * CAMERA_FIRST_PERSON_MODE_DISTANCE; _newDistance = CAMERA_FIRST_PERSON_MODE_DISTANCE;
_newTightness = CAMERA_FIRST_PERSON_MODE_TIGHTNESS; _newTightness = CAMERA_FIRST_PERSON_MODE_TIGHTNESS;
} else if (_mode == CAMERA_MODE_MIRROR) { } else if (_mode == CAMERA_MODE_MIRROR) {
_newUpShift = _scale * CAMERA_MIRROR_MODE_UP_SHIFT; _newUpShift = CAMERA_MIRROR_MODE_UP_SHIFT;
_newDistance = _scale * CAMERA_MIRROR_MODE_DISTANCE; _newDistance = CAMERA_MIRROR_MODE_DISTANCE;
_newTightness = CAMERA_MIRROR_MODE_TIGHTNESS; _newTightness = CAMERA_MIRROR_MODE_TIGHTNESS;
} }
} }

View file

@ -59,6 +59,7 @@ public:
float getFarClip () { return _scale * _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.

View file

@ -200,7 +200,6 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
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); sourceBuffer += unpackFloatRatioFromTwoByte( sourceBuffer, _newScale);
std::cout << "New Scale : " << _newScale << std::endl;
// 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;