increased YAW_MAG (faster turning), redesigned the concept of avatar position, and reset Eve's position accordingly. Also added _frustumNeedsReshape in camera in anticipation of fixing problem where setting fov doesn't reshape the frustum.

This commit is contained in:
Jeffrey Ventrella 2013-04-25 13:51:20 -07:00
parent 9a4d27c0b5
commit 5a0a1c1cec
6 changed files with 70 additions and 41 deletions

View file

@ -113,9 +113,8 @@ int main(int argc, const char* argv[]) {
// move eve away from the origin
// pick a random point inside a 10x10 grid
eve.setPosition(glm::vec3(randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION),
0,
randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION)));
eve.setPosition(glm::vec3(randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION), 0.4,
randFloatInRange(-RANDOM_POSITION_MAX_DIMENSION, RANDOM_POSITION_MAX_DIMENSION)));
// face any instance of eve down the z-axis
eve.setBodyYaw(0);

View file

@ -59,8 +59,7 @@ Avatar::Avatar(bool isMine) {
//_transmitterTimer = 0;
_transmitterHz = 0.0;
_transmitterPackets = 0;
initializeSkeleton();
_pelvisStandingHeight = 0.0f;
_TEST_bigSphereRadius = 0.3f;
_TEST_bigSpherePosition = glm::vec3( 0.0f, _TEST_bigSphereRadius, 2.0f );
@ -117,6 +116,8 @@ Avatar::Avatar(bool isMine) {
_handHolding.velocity = glm::vec3( 0.0, 0.0, 0.0 );
_handHolding.force = 10.0f;
initializeSkeleton();
if (iris_texture.size() == 0) {
switchToResourcesParentIfRequired();
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
@ -127,7 +128,6 @@ Avatar::Avatar(bool isMine) {
}
Avatar::Avatar(const Avatar &otherAvatar) {
_velocity = otherAvatar._velocity;
@ -156,8 +156,6 @@ Avatar::Avatar(const Avatar &otherAvatar) {
_orientation.set( otherAvatar._orientation );
_sphere = NULL;
initializeSkeleton();
for (int i = 0; i < MAX_DRIVE_KEYS; i++) _driveKeys[i] = otherAvatar._driveKeys[i];
@ -198,6 +196,9 @@ Avatar::Avatar(const Avatar &otherAvatar) {
_head.browAudioLift = otherAvatar._head.browAudioLift;
_head.noise = otherAvatar._head.noise;
initializeSkeleton();
if (iris_texture.size() == 0) {
switchToResourcesParentIfRequired();
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
@ -315,7 +316,7 @@ void Avatar::simulate(float deltaTime) {
// check for collisions with other avatars and respond
updateAvatarCollisionDetectionAndResponse
(
otherAvatar->getBonePosition( AVATAR_BONE_PELVIS_SPINE ),
otherAvatar->getPosition(),
0.1,
0.1,
otherAvatar->getBodyUpDirection(),
@ -327,7 +328,7 @@ void Avatar::simulate(float deltaTime) {
v -= otherAvatar->getBonePosition( AVATAR_BONE_RIGHT_HAND );
float distance = glm::length( v );
if ( distance < _maxArmLength ) {
if ( distance < _maxArmLength + _maxArmLength ) {
//if ( distance < closestDistance ) { // perhaps I don't need this if we want to allow multi-avatar interactions
{
@ -376,6 +377,19 @@ void Avatar::simulate(float deltaTime) {
);
}
if ( AVATAR_GRAVITY ) {
if ( _position.y > _pelvisStandingHeight + 0.01 ) {
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
}
else {
if ( _position.y < _pelvisStandingHeight ) {
_position.y = _pelvisStandingHeight;
_velocity.y = 0.0;
}
}
}
/*
if ( AVATAR_GRAVITY ) {
if ( _position.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
@ -387,6 +401,8 @@ void Avatar::simulate(float deltaTime) {
}
}
}
*/
// update body springs
updateBodySprings( deltaTime );
@ -612,6 +628,7 @@ void Avatar::updateAvatarCollisionDetectionAndResponse
void Avatar::render(bool lookingInMirror) {
/*
// show avatar position
glColor4f( 0.5f, 0.5f, 0.5f, 0.6 );
glPushMatrix();
@ -619,6 +636,7 @@ void Avatar::render(bool lookingInMirror) {
glScalef( 0.03, 0.03, 0.03 );
glutSolidSphere( 1, 10, 10 );
glPopMatrix();
*/
if ( usingBigSphereCollisionTest ) {
@ -884,7 +902,7 @@ void Avatar::initializeSkeleton() {
_bone[ AVATAR_BONE_RIGHT_FOOT ].parent = AVATAR_BONE_RIGHT_SHIN;
// specify the default pose position
_bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.3, 0.0 );
_bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
_bone[ AVATAR_BONE_MID_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 );
_bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
_bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
@ -907,8 +925,7 @@ void Avatar::initializeSkeleton() {
_bone[ AVATAR_BONE_RIGHT_THIGH ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
_bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
_bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
_bone[ AVATAR_BONE_PELVIS_SPINE ].radius = 0.05;
_bone[ AVATAR_BONE_MID_SPINE ].radius = 0.06;
_bone[ AVATAR_BONE_CHEST_SPINE ].radius = 0.03;
@ -935,6 +952,13 @@ void Avatar::initializeSkeleton() {
// calculate bone length
calculateBoneLengths();
_pelvisStandingHeight =
_bone[ AVATAR_BONE_PELVIS_SPINE ].length +
_bone[ AVATAR_BONE_LEFT_THIGH ].length +
_bone[ AVATAR_BONE_LEFT_SHIN ].length +
_bone[ AVATAR_BONE_LEFT_FOOT ].length +
_bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
// generate world positions
updateSkeleton();

View file

@ -25,7 +25,7 @@
const bool AVATAR_GRAVITY = true;
const float DECAY = 0.1;
const float THRUST_MAG = 10.0;
const float YAW_MAG = 300.0;
const float YAW_MAG = 500.0; //JJV - changed from 300.0;
const float TEST_YAW_DECAY = 5.0;
const float LIN_VEL_DECAY = 5.0;
@ -246,6 +246,7 @@ class Avatar : public AvatarData {
int _transmitterPackets;
Avatar* _interactingOther;
bool _interactingOtherIsNearby;
float _pelvisStandingHeight;
// private methods...
void initializeSkeleton();

View file

@ -11,21 +11,22 @@
#include "Camera.h"
Camera::Camera() {
_mode = CAMERA_MODE_THIRD_PERSON;
_tightness = 10.0; // default
_fieldOfView = 60.0; // default
_nearClip = 0.08; // default
_farClip = 50.0; // default
_yaw = 0.0;
_pitch = 0.0;
_roll = 0.0;
_upShift = 0.0;
_rightShift = 0.0;
_distance = 0.0;
_idealYaw = 0.0;
_targetPosition = glm::vec3( 0.0, 0.0, 0.0 );
_position = glm::vec3( 0.0, 0.0, 0.0 );
_idealPosition = glm::vec3( 0.0, 0.0, 0.0 );
_frustumNeedsReshape = false;
_mode = CAMERA_MODE_THIRD_PERSON;
_tightness = 10.0; // default
_fieldOfView = 60.0; // default
_nearClip = 0.08; // default
_farClip = 50.0; // default
_yaw = 0.0;
_pitch = 0.0;
_roll = 0.0;
_upShift = 0.0;
_rightShift = 0.0;
_distance = 0.0;
_idealYaw = 0.0;
_targetPosition = glm::vec3( 0.0, 0.0, 0.0 );
_position = glm::vec3( 0.0, 0.0, 0.0 );
_idealPosition = glm::vec3( 0.0, 0.0, 0.0 );
_orientation.setToIdentity();
}

View file

@ -39,10 +39,10 @@ public:
void setPosition ( glm::vec3 p ) { _position = p; }
void setOrientation ( Orientation o ) { _orientation.set(o); }
void setTightness ( float t ) { _tightness = t; }
void setFieldOfView ( float f ) { _fieldOfView = f; }
void setAspectRatio ( float a ) { _aspectRatio = a; }
void setNearClip ( float n ) { _nearClip = n; }
void setFarClip ( float f ) { _farClip = f; }
void setFieldOfView ( float f ) { _fieldOfView = f; _frustumNeedsReshape = true; }
void setAspectRatio ( float a ) { _aspectRatio = a; _frustumNeedsReshape = true; }
void setNearClip ( float n ) { _nearClip = n; _frustumNeedsReshape = true; }
void setFarClip ( float f ) { _farClip = f; _frustumNeedsReshape = true; }
float getYaw () { return _yaw; }
float getPitch () { return _pitch; }
@ -57,6 +57,7 @@ public:
private:
bool _frustumNeedsReshape;
CameraMode _mode;
glm::vec3 _position;
glm::vec3 _idealPosition;

View file

@ -810,6 +810,7 @@ void display(void)
myCamera.setUpShift ( 0.0 );
myCamera.setDistance ( 0.2 );
myCamera.setTightness ( 100.0f );
myCamera.setFieldOfView ( 60.0f ); //this doesn't seem to be doing anything?
myCamera.update ( 1.f/FPS );
} else {
@ -817,15 +818,17 @@ void display(void)
bool firstPerson = false;
if ( firstPerson ) {
myCamera.setPitch (15.0f ); // temporarily, this must be 0.0 or else bad juju
myCamera.setUpShift (0.0f );
myCamera.setDistance (0.0f );
myCamera.setTightness (100.0f);
myCamera.setPitch (15.0f ); // temporarily, this must be 0.0 or else bad juju
myCamera.setUpShift (0.0f );
myCamera.setDistance (0.0f );
myCamera.setTightness (100.0f);
myCamera.setFieldOfView(60.0f ); //this doesn't seem to be doing anything?
} else {
myCamera.setPitch (0.0f ); // temporarily, this must be 0.0 or else bad juju
myCamera.setUpShift (-0.1f);
myCamera.setDistance (1.0f );
myCamera.setTightness (8.0f );
myCamera.setPitch (0.0f ); // temporarily, this must be 0.0 or else bad juju
myCamera.setUpShift (-0.1f);
myCamera.setDistance (1.0f );
myCamera.setTightness (8.0f );
myCamera.setFieldOfView(60.0f); //this doesn't seem to be doing anything?
}
myCamera.setTargetPosition( myAvatar.getHeadPosition() );