cleaned up some code

This commit is contained in:
Jeffrey Ventrella 2013-05-10 22:31:51 -07:00
parent f1346604f4
commit ab9fa0a556
4 changed files with 31 additions and 34 deletions

View file

@ -460,6 +460,7 @@ void Avatar::simulate(float deltaTime) {
_joint[ AVATAR_JOINT_RIGHT_WRIST ].springyPosition += headLean * 0.1f; _joint[ AVATAR_JOINT_RIGHT_WRIST ].springyPosition += headLean * 0.1f;
_joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition += headLean * 0.0f; _joint[ AVATAR_JOINT_RIGHT_FINGERTIPS ].springyPosition += headLean * 0.0f;
} }
// update head state // update head state
_head.setPositionRotationAndScale( _head.setPositionRotationAndScale(
@ -880,7 +881,6 @@ void Avatar::render(bool lookingInMirror, glm::vec3 cameraPosition) {
// render head // render head
if (_displayingHead) { if (_displayingHead) {
//renderHead(lookingInMirror);
_head.render(lookingInMirror, _bodyYaw); _head.render(lookingInMirror, _bodyYaw);
} }

View file

@ -3,10 +3,8 @@
// hifi // hifi
// //
// Created by Jeffrey on May, 10, 2013 // Created by Jeffrey on May, 10, 2013
// Copyright (c) 2013 Physical, Inc.. All rights reserved.
// //
// To avoid code bloat in Avatar.cpp, and to keep all head-related code in one place,
// I have started moving the head code over to its own class. But it's gonna require
// some work - so this is not done yet.
#include "Head.h" #include "Head.h"
#include <vector> #include <vector>

View file

@ -3,10 +3,8 @@
// hifi // hifi
// //
// Created by Jeffrey on May, 10, 2013 // Created by Jeffrey on May, 10, 2013
// Copyright (c) 2013 Physical, Inc.. All rights reserved.
// //
// To avoid code bloat in Avatar.cpp, and to keep all head-related code in one place,
// I have started moving the head code over to its own class. But it's gonna require
// some work - so this is not done yet.
#ifndef hifi_Head_h #ifndef hifi_Head_h
#define hifi_Head_h #define hifi_Head_h
@ -18,7 +16,6 @@
#include "InterfaceConfig.h" #include "InterfaceConfig.h"
#include "SerialInterface.h" #include "SerialInterface.h"
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH}; enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
class Head { class Head {
@ -88,8 +85,7 @@ public:
float audioAttack; float audioAttack;
GLUquadric* sphere; GLUquadric* sphere;
// Strength of return springs // Strength of return springs
float returnSpringScale; float returnSpringScale;
}; };

View file

@ -105,6 +105,7 @@ int HEIGHT = 800;
int fullscreen = 0; int fullscreen = 0;
float aspectRatio = 1.0f; float aspectRatio = 1.0f;
bool USING_MOUSE_VIEW_SHIFT = false;
float MOUSE_VIEW_SHIFT_RATE = 40.0f; float MOUSE_VIEW_SHIFT_RATE = 40.0f;
float MOUSE_VIEW_SHIFT_YAW_MARGIN = (float)(WIDTH * 0.2f); float MOUSE_VIEW_SHIFT_YAW_MARGIN = (float)(WIDTH * 0.2f);
float MOUSE_VIEW_SHIFT_PITCH_MARGIN = (float)(HEIGHT * 0.2f); float MOUSE_VIEW_SHIFT_PITCH_MARGIN = (float)(HEIGHT * 0.2f);
@ -417,30 +418,32 @@ void updateAvatar(float deltaTime) {
} }
//make it so that when your mouse hits the edge of the screen, the camera shifts if (USING_MOUSE_VIEW_SHIFT)
float rightBoundary = (float)WIDTH - MOUSE_VIEW_SHIFT_YAW_MARGIN; {
float bottomBoundary = (float)HEIGHT - MOUSE_VIEW_SHIFT_PITCH_MARGIN; //make it so that when your mouse hits the edge of the screen, the camera shifts
float rightBoundary = (float)WIDTH - MOUSE_VIEW_SHIFT_YAW_MARGIN;
if (mouseX > rightBoundary) { float bottomBoundary = (float)HEIGHT - MOUSE_VIEW_SHIFT_PITCH_MARGIN;
float f = (mouseX - rightBoundary) / ( (float)WIDTH - rightBoundary);
mouseViewShiftYaw += MOUSE_VIEW_SHIFT_RATE * f * deltaTime; if (mouseX > rightBoundary) {
if (mouseViewShiftYaw > MOUSE_VIEW_SHIFT_YAW_LIMIT) { mouseViewShiftYaw = MOUSE_VIEW_SHIFT_YAW_LIMIT; } float f = (mouseX - rightBoundary) / ( (float)WIDTH - rightBoundary);
} else if (mouseX < MOUSE_VIEW_SHIFT_YAW_MARGIN) { mouseViewShiftYaw += MOUSE_VIEW_SHIFT_RATE * f * deltaTime;
float f = 1.0 - (mouseX / MOUSE_VIEW_SHIFT_YAW_MARGIN); if (mouseViewShiftYaw > MOUSE_VIEW_SHIFT_YAW_LIMIT) { mouseViewShiftYaw = MOUSE_VIEW_SHIFT_YAW_LIMIT; }
mouseViewShiftYaw -= MOUSE_VIEW_SHIFT_RATE * f * deltaTime; } else if (mouseX < MOUSE_VIEW_SHIFT_YAW_MARGIN) {
if (mouseViewShiftYaw < -MOUSE_VIEW_SHIFT_YAW_LIMIT) { mouseViewShiftYaw = -MOUSE_VIEW_SHIFT_YAW_LIMIT; } float f = 1.0 - (mouseX / MOUSE_VIEW_SHIFT_YAW_MARGIN);
mouseViewShiftYaw -= MOUSE_VIEW_SHIFT_RATE * f * deltaTime;
if (mouseViewShiftYaw < -MOUSE_VIEW_SHIFT_YAW_LIMIT) { mouseViewShiftYaw = -MOUSE_VIEW_SHIFT_YAW_LIMIT; }
}
if (mouseY < MOUSE_VIEW_SHIFT_PITCH_MARGIN) {
float f = 1.0 - (mouseY / MOUSE_VIEW_SHIFT_PITCH_MARGIN);
mouseViewShiftPitch += MOUSE_VIEW_SHIFT_RATE * f * deltaTime;
if ( mouseViewShiftPitch > MOUSE_VIEW_SHIFT_PITCH_LIMIT ) { mouseViewShiftPitch = MOUSE_VIEW_SHIFT_PITCH_LIMIT; }
}
else if (mouseY > bottomBoundary) {
float f = (mouseY - bottomBoundary) / ((float)HEIGHT - bottomBoundary);
mouseViewShiftPitch -= MOUSE_VIEW_SHIFT_RATE * f * deltaTime;
if (mouseViewShiftPitch < -MOUSE_VIEW_SHIFT_PITCH_LIMIT) { mouseViewShiftPitch = -MOUSE_VIEW_SHIFT_PITCH_LIMIT; }
}
} }
if (mouseY < MOUSE_VIEW_SHIFT_PITCH_MARGIN) {
float f = 1.0 - (mouseY / MOUSE_VIEW_SHIFT_PITCH_MARGIN);
mouseViewShiftPitch += MOUSE_VIEW_SHIFT_RATE * f * deltaTime;
if ( mouseViewShiftPitch > MOUSE_VIEW_SHIFT_PITCH_LIMIT ) { mouseViewShiftPitch = MOUSE_VIEW_SHIFT_PITCH_LIMIT; }
}
else if (mouseY > bottomBoundary) {
float f = (mouseY - bottomBoundary) / ((float)HEIGHT - bottomBoundary);
mouseViewShiftPitch -= MOUSE_VIEW_SHIFT_RATE * f * deltaTime;
if (mouseViewShiftPitch < -MOUSE_VIEW_SHIFT_PITCH_LIMIT) { mouseViewShiftPitch = -MOUSE_VIEW_SHIFT_PITCH_LIMIT; }
}
if (OculusManager::isConnected()) { if (OculusManager::isConnected()) {
float yaw, pitch, roll; float yaw, pitch, roll;
@ -1814,7 +1817,7 @@ void idle(void) {
// walking triggers the handControl to stop // walking triggers the handControl to stop
if (myAvatar.getMode() == AVATAR_MODE_WALKING) { if (myAvatar.getMode() == AVATAR_MODE_WALKING) {
handControl.stop(); handControl.stop();
mouseViewShiftYaw *= 0.9; mouseViewShiftYaw *= 0.9;
mouseViewShiftPitch *= 0.9; mouseViewShiftPitch *= 0.9;
} }