removed old cruft around mousePitch in Head and unified pitch

This commit is contained in:
ZappoMan 2014-01-29 02:09:49 -08:00
parent ecd2477007
commit b36cc0bcf9
6 changed files with 16 additions and 40 deletions

View file

@ -43,22 +43,12 @@ function mouseMoveEvent(event) {
}
function update() {
print("isMouseDown... attempting to change pitch...");
// rotate body yaw for yaw received from mouse
MyAvatar.orientation = Quat.multiply(MyAvatar.orientation, Quat.fromVec3( { x: 0, y: yawFromMouse, z: 0 } ));
yawFromMouse = 0;
// apply pitch from mouse
/**
_myAvatar.getHead().setMousePitch(_myAvatar.getHead().getMousePitch() +
_myAvatar.getHand().getPitchUpdate() +
pitchFromMouse);
**/
//_myAvatar.getHand().setPitchUpdate(0.f);
MyAvatar.headPitch = MyAvatar.headPitch + pitchFromMouse;
pitchFromMouse = 0;
}

View file

@ -2404,10 +2404,7 @@ void Application::updateAvatar(float deltaTime) {
_yawFromTouch = 0.f;
// apply pitch from touch
_myAvatar.getHead().setMousePitch(_myAvatar.getHead().getMousePitch() +
_myAvatar.getHand().getPitchUpdate() +
_pitchFromTouch);
_myAvatar.getHand().setPitchUpdate(0.f);
_myAvatar.getHead().setPitch(_myAvatar.getHead().getPitch() + _pitchFromTouch);
_pitchFromTouch = 0.0f;
// Update my avatar's state from gyros

View file

@ -37,8 +37,6 @@ Head::Head(Avatar* owningAvatar) :
_leftEyeBlinkVelocity(0.0f),
_rightEyeBlinkVelocity(0.0f),
_timeWithoutTalking(0.0f),
_cameraPitch(_pitch),
_mousePitch(0.f),
_cameraYaw(_yaw),
_isCameraMoving(false),
_faceModel(this)
@ -52,7 +50,6 @@ void Head::init() {
void Head::reset() {
_yaw = _pitch = _roll = 0.0f;
_mousePitch = 0.0f;
_leanForward = _leanSideways = 0.0f;
_faceModel.reset();
}
@ -186,13 +183,6 @@ void Head::setScale (float scale) {
_scale = scale;
}
void Head::setMousePitch(float mousePitch) {
const float MAX_PITCH = 90.0f;
_mousePitch = glm::clamp(mousePitch, -MAX_PITCH, MAX_PITCH);
}
glm::quat Head::getOrientation() const {
return glm::quat(glm::radians(_bodyRotation)) * glm::quat(glm::radians(glm::vec3(_pitch, _yaw, _roll)));
}
@ -200,7 +190,7 @@ glm::quat Head::getOrientation() const {
glm::quat Head::getCameraOrientation () const {
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
return owningAvatar->getWorldAlignedOrientation()
* glm::quat(glm::radians(glm::vec3(_cameraPitch + _mousePitch, _cameraYaw, 0.0f)));
* glm::quat(glm::radians(glm::vec3(_pitch, _cameraYaw, 0.0f)));
}
glm::quat Head::getEyeRotation(const glm::vec3& eyePosition) const {

View file

@ -46,9 +46,6 @@ public:
void setReturnToCenter (bool returnHeadToCenter) { _returnHeadToCenter = returnHeadToCenter; }
void setRenderLookatVectors(bool onOff) { _renderLookatVectors = onOff; }
float getMousePitch() const { return _mousePitch; }
void setMousePitch(float mousePitch);
glm::quat getOrientation() const;
glm::quat getCameraOrientation () const;
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
@ -99,8 +96,6 @@ private:
float _leftEyeBlinkVelocity;
float _rightEyeBlinkVelocity;
float _timeWithoutTalking;
float _cameraPitch; // Used to position the camera differently from the head
float _mousePitch;
float _cameraYaw;
bool _isCameraMoving;
FaceModel _faceModel;

View file

@ -238,7 +238,7 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
// Adjust body yaw by yaw from controller
setOrientation(glm::angleAxis(-euler.y, glm::vec3(0, 1, 0)) * getOrientation());
// Adjust head pitch from controller
getHead().setMousePitch(getHead().getMousePitch() - euler.x);
getHead().setPitch(getHead().getPitch() - euler.x);
_position += _velocity * deltaTime;
@ -284,8 +284,6 @@ void MyAvatar::updateFromGyros(bool turnWithHead) {
}
}
} else {
_head.setPitch(_head.getMousePitch());
// restore rotation, lean to neutral positions
const float RESTORE_RATE = 0.05f;
_head.setYaw(glm::mix(_head.getYaw(), 0.0f, RESTORE_RATE));
@ -434,7 +432,7 @@ void MyAvatar::saveData(QSettings* settings) {
settings->setValue("bodyPitch", _bodyPitch);
settings->setValue("bodyRoll", _bodyRoll);
settings->setValue("mousePitch", _head.getMousePitch());
settings->setValue("headPitch", _head.getPitch());
settings->setValue("position_x", _position.x);
settings->setValue("position_y", _position.y);
@ -456,7 +454,7 @@ void MyAvatar::loadData(QSettings* settings) {
_bodyPitch = loadSetting(settings, "bodyPitch", 0.0f);
_bodyRoll = loadSetting(settings, "bodyRoll", 0.0f);
_head.setMousePitch(loadSetting(settings, "mousePitch", 0.0f));
_head.setPitch(loadSetting(settings, "headPitch", 0.0f));
_position.x = loadSetting(settings, "position_x", 0.0f);
_position.y = loadSetting(settings, "position_y", 0.0f);
@ -497,9 +495,10 @@ void MyAvatar::orbit(const glm::vec3& position, int deltaX, int deltaY) {
setOrientation(orientation);
// then vertically
float oldMousePitch = _head.getMousePitch();
_head.setMousePitch(oldMousePitch + deltaY * -ANGULAR_SCALE);
rotation = glm::angleAxis(_head.getMousePitch() - oldMousePitch, orientation * IDENTITY_RIGHT);
float oldPitch = _head.getPitch();
_head.setPitch(oldPitch + deltaY * -ANGULAR_SCALE);
rotation = glm::angleAxis(_head.getPitch() - oldPitch, orientation * IDENTITY_RIGHT);
setPosition(position + rotation * (getPosition() - position));
}
@ -549,7 +548,7 @@ void MyAvatar::updateThrust(float deltaTime, Transmitter * transmitter) {
_thrust -= _driveKeys[DOWN] * _scale * THRUST_MAG_DOWN * _thrustMultiplier * deltaTime * up;
_bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_MAG * deltaTime;
_bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_MAG * deltaTime;
_head.setMousePitch(_head.getMousePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_MAG * deltaTime);
_head.setPitch(_head.getPitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_MAG * deltaTime);
// If thrust keys are being held down, slowly increase thrust to allow reaching great speeds
if (_driveKeys[FWD] || _driveKeys[BACK] || _driveKeys[RIGHT] || _driveKeys[LEFT] || _driveKeys[UP] || _driveKeys[DOWN]) {

View file

@ -71,6 +71,7 @@ class AvatarData : public NodeData {
Q_PROPERTY(QString chatMessage READ getQStringChatMessage WRITE setChatMessage)
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
Q_PROPERTY(float headPitch READ getHeadPitch WRITE setHeadPitch)
public:
AvatarData();
@ -96,6 +97,10 @@ public:
glm::quat getOrientation() const { return glm::quat(glm::radians(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll))); }
void setOrientation(const glm::quat& orientation);
// access to Head().set/getMousePitch
float getHeadPitch() const { return _headData->getPitch(); }
void setHeadPitch(float value) { _headData->setPitch(value); };
// Scale
float getTargetScale() const { return _targetScale; }
void setTargetScale(float targetScale) { _targetScale = targetScale; }