mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-05 02:25:56 +02:00
Merge remote-tracking branch 'upstream/master' into avatar-from-mixer
This commit is contained in:
commit
8a3135a084
7 changed files with 175 additions and 188 deletions
|
@ -35,9 +35,7 @@ float browThickness = 0.16;
|
|||
|
||||
bool usingBigSphereCollisionTest = true;
|
||||
|
||||
const float DECAY = 0.1;
|
||||
const float THRUST_MAG = 10.0;
|
||||
const float YAW_MAG = 300.0;
|
||||
|
||||
|
||||
char iris_texture_file[] = "resources/images/green_eye.png";
|
||||
|
||||
|
@ -115,8 +113,7 @@ Head::Head(bool isMine) {
|
|||
_head.noise = 0;
|
||||
|
||||
_movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_usingBodySprings = true;
|
||||
//_usingBodySprings = false;
|
||||
_usingBodySprings = true;
|
||||
_springForce = 6.0f;
|
||||
_springVelocityDecay = 16.0f;
|
||||
_renderYaw = 0.0;
|
||||
|
@ -152,7 +149,7 @@ Head::Head(const Head &otherAvatar) {
|
|||
_bodyPitch = otherAvatar._bodyPitch;
|
||||
_bodyRoll = otherAvatar._bodyRoll;
|
||||
_bodyYawDelta = otherAvatar._bodyYawDelta;
|
||||
_mousePressed = otherAvatar._mousePressed;
|
||||
_mousePressed = otherAvatar._mousePressed;
|
||||
_mode = otherAvatar._mode;
|
||||
_isMine = otherAvatar._isMine;
|
||||
_renderYaw = otherAvatar._renderYaw;
|
||||
|
@ -168,11 +165,7 @@ Head::Head(const Head &otherAvatar) {
|
|||
_springForce = otherAvatar._springForce;
|
||||
_springVelocityDecay = otherAvatar._springVelocityDecay;
|
||||
_orientation.set( otherAvatar._orientation );
|
||||
|
||||
//for (int o=0;o<NUM_OTHER_AVATARS; o++) {
|
||||
// _DEBUG_otherAvatarListPosition[o] = otherAvatar._DEBUG_otherAvatarListPosition[o];
|
||||
//}
|
||||
|
||||
|
||||
_sphere = NULL;
|
||||
|
||||
initializeSkeleton();
|
||||
|
@ -312,7 +305,6 @@ void Head::setMousePressed( bool d ) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
void Head::simulate(float deltaTime) {
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
@ -386,7 +378,19 @@ void Head::simulate(float deltaTime) {
|
|||
//--------------------------------------------------------------
|
||||
updateBigSphereCollisionTest(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
if ( AVATAR_GRAVITY ) {
|
||||
if ( _bodyPosition.y > _bone[ AVATAR_BONE_RIGHT_FOOT ].radius * 2.0 ) {
|
||||
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * ( 6.0 * deltaTime );
|
||||
}
|
||||
else {
|
||||
if ( _bodyPosition.y < _bone[ AVATAR_BONE_RIGHT_FOOT ].radius ) {
|
||||
_bodyPosition.y = _bone[ AVATAR_BONE_RIGHT_FOOT ].radius;
|
||||
_velocity.y = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// update avatar skeleton
|
||||
//------------------------
|
||||
|
@ -466,7 +470,6 @@ void Head::simulate(float deltaTime) {
|
|||
//----------------------------------------------------------
|
||||
// decay body yaw delta
|
||||
//----------------------------------------------------------
|
||||
const float TEST_YAW_DECAY = 5.0;
|
||||
_bodyYawDelta *= (1.0 - TEST_YAW_DECAY * deltaTime);
|
||||
|
||||
//----------------------------------------------------------
|
||||
|
@ -482,7 +485,6 @@ void Head::simulate(float deltaTime) {
|
|||
//----------------------------------------------------------
|
||||
// decay velocity
|
||||
//----------------------------------------------------------
|
||||
const float LIN_VEL_DECAY = 5.0;
|
||||
_velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime );
|
||||
|
||||
if (!_head.noise) {
|
||||
|
@ -591,18 +593,22 @@ void Head::updateBigSphereCollisionTest( float deltaTime ) {
|
|||
{
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++)
|
||||
{
|
||||
glm::vec3 vectorFromJointToBigSphere(_bone[b].position - _TEST_bigSpherePosition);
|
||||
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphere);
|
||||
glm::vec3 vectorFromJointToBigSphereCenter(_bone[b].springyPosition - _TEST_bigSpherePosition);
|
||||
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphereCenter);
|
||||
float combinedRadius = _bone[b].radius + _TEST_bigSphereRadius;
|
||||
if ( distanceToBigSphereCenter < combinedRadius )
|
||||
{
|
||||
jointCollision = true;
|
||||
if (distanceToBigSphereCenter > 0.0)
|
||||
{
|
||||
float amp = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
||||
glm::vec3 collisionForce = vectorFromJointToBigSphere * amp;
|
||||
_bone[b].springyVelocity += collisionForce * 8.0f * deltaTime;
|
||||
_velocity += collisionForce * 18.0f * deltaTime;
|
||||
glm::vec3 directionVector = vectorFromJointToBigSphereCenter / distanceToBigSphereCenter;
|
||||
|
||||
float penetration = 1.0 - (distanceToBigSphereCenter / combinedRadius);
|
||||
glm::vec3 collisionForce = vectorFromJointToBigSphereCenter * penetration;
|
||||
|
||||
_bone[b].springyVelocity += collisionForce * 30.0f * deltaTime;
|
||||
_velocity += collisionForce * 100.0f * deltaTime;
|
||||
_bone[b].springyPosition = _TEST_bigSpherePosition + directionVector * combinedRadius;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -611,22 +617,7 @@ void Head::updateBigSphereCollisionTest( float deltaTime ) {
|
|||
if (!_usingBodySprings) {
|
||||
_usingBodySprings = true;
|
||||
initializeBodySprings();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// add gravity to velocity
|
||||
//----------------------------------------------------------
|
||||
_velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * 0.05;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// ground collisions
|
||||
//----------------------------------------------------------
|
||||
if ( _bodyPosition.y < 0.0 ) {
|
||||
_bodyPosition.y = 0.0;
|
||||
if ( _velocity.y < 0.0 ) {
|
||||
_velocity.y *= -0.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -658,12 +649,7 @@ void Head::render(int faceToFace) {
|
|||
glutSolidSphere( 1, 20, 20 );
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// show avatar orientation
|
||||
//---------------------------------------------------
|
||||
renderOrientationDirections( _bone[ AVATAR_BONE_HEAD ].position, _bone[ AVATAR_BONE_HEAD ].orientation, 0.2f );
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// render body
|
||||
//---------------------------------------------------
|
||||
|
@ -679,6 +665,7 @@ void Head::render(int faceToFace) {
|
|||
//---------------------------------------------------------------------------
|
||||
if ( _isMine )
|
||||
{
|
||||
/*
|
||||
//---------------------------------------------------
|
||||
// render other avatars (DEBUG TEST)
|
||||
//---------------------------------------------------
|
||||
|
@ -689,6 +676,7 @@ void Head::render(int faceToFace) {
|
|||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
}
|
||||
*/
|
||||
|
||||
if (_usingBodySprings) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
|
@ -715,6 +703,11 @@ void Head::renderHead(int faceToFace) {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
||||
//---------------------------------------------------
|
||||
// show head orientation
|
||||
//---------------------------------------------------
|
||||
//renderOrientationDirections( _bone[ AVATAR_BONE_HEAD ].position, _bone[ AVATAR_BONE_HEAD ].orientation, 0.2f );
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
if (_usingBodySprings) {
|
||||
|
@ -858,7 +851,6 @@ void Head::renderHead(int faceToFace) {
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
void Head::startHandMovement() {
|
||||
|
||||
if (!_usingBodySprings) {
|
||||
|
@ -892,7 +884,7 @@ void Head::initializeSkeleton() {
|
|||
_bone[b].pitch = 0.0;
|
||||
_bone[b].roll = 0.0;
|
||||
_bone[b].length = 0.0;
|
||||
_bone[b].radius = 0.02; //default
|
||||
_bone[b].radius = 0.0;
|
||||
_bone[b].springBodyTightness = 4.0;
|
||||
_bone[b].orientation.setToIdentity();
|
||||
}
|
||||
|
@ -900,45 +892,25 @@ void Head::initializeSkeleton() {
|
|||
//----------------------------------------------------------------------------
|
||||
// parental hierarchy
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// spine and head
|
||||
//----------------------------------------------------------------------------
|
||||
_bone[ AVATAR_BONE_PELVIS_SPINE ].parent = AVATAR_BONE_NULL;
|
||||
_bone[ AVATAR_BONE_MID_SPINE ].parent = AVATAR_BONE_PELVIS_SPINE;
|
||||
_bone[ AVATAR_BONE_CHEST_SPINE ].parent = AVATAR_BONE_MID_SPINE;
|
||||
_bone[ AVATAR_BONE_NECK ].parent = AVATAR_BONE_CHEST_SPINE;
|
||||
_bone[ AVATAR_BONE_HEAD ].parent = AVATAR_BONE_NECK;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// left chest and arm
|
||||
//----------------------------------------------------------------------------
|
||||
_bone[ AVATAR_BONE_LEFT_CHEST ].parent = AVATAR_BONE_MID_SPINE;
|
||||
_bone[ AVATAR_BONE_LEFT_SHOULDER ].parent = AVATAR_BONE_LEFT_CHEST;
|
||||
_bone[ AVATAR_BONE_LEFT_UPPER_ARM ].parent = AVATAR_BONE_LEFT_SHOULDER;
|
||||
_bone[ AVATAR_BONE_LEFT_FOREARM ].parent = AVATAR_BONE_LEFT_UPPER_ARM;
|
||||
_bone[ AVATAR_BONE_LEFT_HAND ].parent = AVATAR_BONE_LEFT_FOREARM;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// right chest and arm
|
||||
//----------------------------------------------------------------------------
|
||||
_bone[ AVATAR_BONE_RIGHT_CHEST ].parent = AVATAR_BONE_MID_SPINE;
|
||||
_bone[ AVATAR_BONE_RIGHT_SHOULDER ].parent = AVATAR_BONE_RIGHT_CHEST;
|
||||
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].parent = AVATAR_BONE_RIGHT_SHOULDER;
|
||||
_bone[ AVATAR_BONE_RIGHT_FOREARM ].parent = AVATAR_BONE_RIGHT_UPPER_ARM;
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].parent = AVATAR_BONE_RIGHT_FOREARM;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// left pelvis and leg
|
||||
//----------------------------------------------------------------------------
|
||||
_bone[ AVATAR_BONE_LEFT_PELVIS ].parent = AVATAR_BONE_PELVIS_SPINE;
|
||||
_bone[ AVATAR_BONE_LEFT_THIGH ].parent = AVATAR_BONE_LEFT_PELVIS;
|
||||
_bone[ AVATAR_BONE_LEFT_SHIN ].parent = AVATAR_BONE_LEFT_THIGH;
|
||||
_bone[ AVATAR_BONE_LEFT_FOOT ].parent = AVATAR_BONE_LEFT_SHIN;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// right pelvis and leg
|
||||
//----------------------------------------------------------------------------
|
||||
_bone[ AVATAR_BONE_RIGHT_PELVIS ].parent = AVATAR_BONE_PELVIS_SPINE;
|
||||
_bone[ AVATAR_BONE_RIGHT_THIGH ].parent = AVATAR_BONE_RIGHT_PELVIS;
|
||||
_bone[ AVATAR_BONE_RIGHT_SHIN ].parent = AVATAR_BONE_RIGHT_THIGH;
|
||||
|
@ -947,29 +919,54 @@ void Head::initializeSkeleton() {
|
|||
//----------------------------------------------------------
|
||||
// specify the default pose position
|
||||
//----------------------------------------------------------
|
||||
_bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.3, 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.1, 0.0 );
|
||||
_bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||
_bone[ AVATAR_BONE_HEAD ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.06, 0.06, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.03, 0.0, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.12, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.06, 0.06, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_SHOULDER ].defaultPosePosition = glm::vec3( 0.03, 0.0, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.12, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_PELVIS ].defaultPosePosition = glm::vec3( -0.05, 0.0, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_THIGH ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
||||
_bone[ AVATAR_BONE_RIGHT_PELVIS ].defaultPosePosition = glm::vec3( 0.05, 0.0, 0.0 );
|
||||
_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 ].defaultPosePosition = glm::vec3( 0.0, 0.3, 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 );
|
||||
_bone[ AVATAR_BONE_HEAD ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.05, 0.05, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.03, 0.0, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.05, 0.05, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_SHOULDER ].defaultPosePosition = glm::vec3( 0.03, 0.0, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_PELVIS ].defaultPosePosition = glm::vec3( -0.05, 0.0, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_THIGH ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
||||
_bone[ AVATAR_BONE_LEFT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
||||
_bone[ AVATAR_BONE_RIGHT_PELVIS ].defaultPosePosition = glm::vec3( 0.05, 0.0, 0.0 );
|
||||
_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;
|
||||
_bone[ AVATAR_BONE_NECK ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_HEAD ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_LEFT_CHEST ].radius = 0.025;
|
||||
_bone[ AVATAR_BONE_LEFT_SHOULDER ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_LEFT_UPPER_ARM ].radius = 0.015;
|
||||
_bone[ AVATAR_BONE_LEFT_FOREARM ].radius = 0.015;
|
||||
_bone[ AVATAR_BONE_LEFT_HAND ].radius = 0.01;
|
||||
_bone[ AVATAR_BONE_RIGHT_CHEST ].radius = 0.025;
|
||||
_bone[ AVATAR_BONE_RIGHT_SHOULDER ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].radius = 0.015;
|
||||
_bone[ AVATAR_BONE_RIGHT_FOREARM ].radius = 0.015;
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].radius = 0.01;
|
||||
_bone[ AVATAR_BONE_LEFT_PELVIS ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_LEFT_THIGH ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_LEFT_SHIN ].radius = 0.015;
|
||||
_bone[ AVATAR_BONE_LEFT_FOOT ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_RIGHT_PELVIS ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_RIGHT_THIGH ].radius = 0.02;
|
||||
_bone[ AVATAR_BONE_RIGHT_SHIN ].radius = 0.015;
|
||||
_bone[ AVATAR_BONE_RIGHT_FOOT ].radius = 0.02;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// calculate bone length
|
||||
|
@ -1111,16 +1108,16 @@ glm::vec3 Head::getHeadLookatDirectionRight() {
|
|||
}
|
||||
|
||||
glm::vec3 Head::getHeadPosition() {
|
||||
return glm::vec3
|
||||
(
|
||||
_bone[ AVATAR_BONE_HEAD ].position.x,
|
||||
_bone[ AVATAR_BONE_HEAD ].position.y,
|
||||
_bone[ AVATAR_BONE_HEAD ].position.z
|
||||
);
|
||||
|
||||
if ( _usingBodySprings ) {
|
||||
return _bone[ AVATAR_BONE_HEAD ].springyPosition;
|
||||
}
|
||||
|
||||
return _bone[ AVATAR_BONE_HEAD ].position;
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 Head::getBonePosition( AvatarBones b ) {
|
||||
glm::vec3 Head::getBonePosition( AvatarBoneID b ) {
|
||||
return _bone[b].position;
|
||||
}
|
||||
|
||||
|
@ -1140,16 +1137,12 @@ void Head::updateHandMovement() {
|
|||
if ( _usingBodySprings ) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
if ( _mousePressed ) {
|
||||
|
||||
|
||||
glm::vec3 handToHandVector( _otherAvatarHandPosition[ _closestOtherAvatar ]);
|
||||
handToHandVector -= _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||
|
||||
/*
|
||||
glm::vec3 handShakePull( DEBUG_otherAvatarListPosition[ closestOtherAvatar ]);
|
||||
handShakePull -= _bone[ AVATAR_BONE_RIGHT_HAND ].position;
|
||||
|
||||
handShakePull *= 1.0;
|
||||
|
||||
transformedHandMovement += handShakePull;
|
||||
*/
|
||||
|
||||
//_bone[ AVATAR_BONE_RIGHT_HAND ].springyVelocity -= handPull;
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _otherAvatarHandPosition[ _closestOtherAvatar ];
|
||||
}
|
||||
}
|
||||
|
@ -1230,30 +1223,23 @@ void Head::renderBody() {
|
|||
// Render bone positions as spheres
|
||||
//-----------------------------------------
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
|
||||
/*
|
||||
if ( _isMine )
|
||||
{
|
||||
printf( "my avatar: %d\n", _usingBodySprings );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "other avatar: %d\n", _usingBodySprings );
|
||||
}
|
||||
*/
|
||||
|
||||
//renderBoneAsBlock( (AvatarBoneID)b);
|
||||
|
||||
//render bone orientation
|
||||
renderOrientationDirections( _bone[b].springyPosition, _bone[b].orientation, _bone[b].radius * 2.0 );
|
||||
|
||||
if ( _usingBodySprings ) {
|
||||
glColor3fv( lightBlue );
|
||||
glColor3fv( skinColor );
|
||||
glPushMatrix();
|
||||
glTranslatef( _bone[b].springyPosition.x, _bone[b].springyPosition.y, _bone[b].springyPosition.z );
|
||||
glutSolidSphere( _bone[b].radius, 10.0f, 5.0f );
|
||||
glutSolidSphere( _bone[b].radius, 20.0f, 20.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
else {
|
||||
glColor3fv( skinColor );
|
||||
glPushMatrix();
|
||||
glTranslatef( _bone[b].position.x, _bone[b].position.y, _bone[b].position.z );
|
||||
glutSolidSphere( _bone[b].radius, 10.0f, 5.0f );
|
||||
glutSolidSphere( _bone[b].radius, 20.0f, 20.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -1288,7 +1274,6 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (( _usingBodySprings ) && ( _mousePressed )) {
|
||||
glColor4f( 1.0, 1.0, 0.5, 0.5 );
|
||||
glPushMatrix();
|
||||
|
@ -1301,9 +1286,25 @@ else
|
|||
glutSolidSphere( 0.03f, 10.0f, 5.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Head::renderBoneAsBlock( AvatarBoneID b ) {
|
||||
glColor3fv( skinColor );
|
||||
glPushMatrix();
|
||||
glTranslatef( _bone[b].springyPosition.x, _bone[b].springyPosition.y, _bone[b].springyPosition.z );
|
||||
glScalef( _bone[b].radius, _bone[b].length, _bone[b].radius );
|
||||
glRotatef(_bone[b].yaw, 0, 1, 0 );
|
||||
glRotatef(_bone[b].pitch, 1, 0, 0 );
|
||||
glRotatef(_bone[b].roll, 0, 0, 1 );
|
||||
glutSolidCube(1.0);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Head::SetNewHeadTarget(float pitch, float yaw) {
|
||||
_head.pitchTarget = pitch;
|
||||
_head.yawTarget = yaw;
|
||||
|
|
|
@ -22,6 +22,13 @@
|
|||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp> //looks like we might not need this
|
||||
|
||||
const bool AVATAR_GRAVITY = true;
|
||||
const float DECAY = 0.1;
|
||||
const float THRUST_MAG = 10.0;
|
||||
const float YAW_MAG = 300.0;
|
||||
const float TEST_YAW_DECAY = 5.0;
|
||||
const float LIN_VEL_DECAY = 5.0;
|
||||
|
||||
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
||||
|
||||
#define FWD 0
|
||||
|
@ -44,7 +51,7 @@ enum AvatarMode
|
|||
NUM_AVATAR_MODES
|
||||
};
|
||||
|
||||
enum AvatarBones
|
||||
enum AvatarBoneID
|
||||
{
|
||||
AVATAR_BONE_NULL = -1,
|
||||
AVATAR_BONE_PELVIS_SPINE, // connects pelvis joint with torso joint (not supposed to be rotated)
|
||||
|
@ -76,19 +83,19 @@ enum AvatarBones
|
|||
|
||||
struct AvatarBone
|
||||
{
|
||||
AvatarBones parent; // which bone is this bone connected to?
|
||||
glm::vec3 position; // the position at the "end" of the bone
|
||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
|
||||
glm::dvec3 springyVelocity; // used for special effects ( the velocity of the springy position)
|
||||
float springBodyTightness; // how tightly the springy position tries to stay on the position
|
||||
glm::quat rotation; // this will eventually replace yaw, pitch and roll (and maybe orientation)
|
||||
float yaw; // the yaw Euler angle of the bone rotation off the parent
|
||||
float pitch; // the pitch Euler angle of the bone rotation off the parent
|
||||
float roll; // the roll Euler angle of the bone rotation off the parent
|
||||
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||
float length; // the length of the bone
|
||||
float radius; // used for detecting collisions for certain physical effects
|
||||
AvatarBoneID parent; // which bone is this bone connected to?
|
||||
glm::vec3 position; // the position at the "end" of the bone
|
||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position)
|
||||
glm::dvec3 springyVelocity; // used for special effects ( the velocity of the springy position)
|
||||
float springBodyTightness; // how tightly the springy position tries to stay on the position
|
||||
glm::quat rotation; // this will eventually replace yaw, pitch and roll (and maybe orientation)
|
||||
float yaw; // the yaw Euler angle of the bone rotation off the parent
|
||||
float pitch; // the pitch Euler angle of the bone rotation off the parent
|
||||
float roll; // the roll Euler angle of the bone rotation off the parent
|
||||
Orientation orientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||
float length; // the length of the bone
|
||||
float radius; // used for detecting collisions for certain physical effects
|
||||
};
|
||||
|
||||
struct AvatarHead
|
||||
|
@ -168,19 +175,15 @@ class Head : public AvatarData {
|
|||
glm::vec3 getHeadLookatDirectionUp();
|
||||
glm::vec3 getHeadLookatDirectionRight();
|
||||
glm::vec3 getHeadPosition();
|
||||
glm::vec3 getBonePosition( AvatarBones b );
|
||||
glm::vec3 getBonePosition( AvatarBoneID b );
|
||||
|
||||
AvatarMode getMode();
|
||||
|
||||
void setMousePressed( bool pressed );
|
||||
|
||||
void render(int faceToFace);
|
||||
|
||||
void renderBody();
|
||||
void renderHead( int faceToFace);
|
||||
|
||||
void simulate(float);
|
||||
|
||||
void startHandMovement();
|
||||
void stopHandMovement();
|
||||
void setHandMovementValues( glm::vec3 movement );
|
||||
|
@ -217,7 +220,6 @@ class Head : public AvatarData {
|
|||
glm::vec3 _otherAvatarHandPosition[ MAX_OTHER_AVATARS ];
|
||||
bool _mousePressed;
|
||||
float _bodyYawDelta;
|
||||
//float _closeEnoughToInteract;
|
||||
int _closestOtherAvatar;
|
||||
bool _usingBodySprings;
|
||||
glm::vec3 _movedHandOffset;
|
||||
|
@ -231,13 +233,11 @@ class Head : public AvatarData {
|
|||
float _maxArmLength;
|
||||
Orientation _orientation;
|
||||
int _numOtherAvatarsInView;
|
||||
|
||||
int _driveKeys[MAX_DRIVE_KEYS];
|
||||
GLUquadric* _sphere;
|
||||
float _renderYaw;
|
||||
float _renderPitch; // Pitch from view frustum when this is own head.
|
||||
|
||||
|
||||
//
|
||||
// Related to getting transmitter UDP data used to animate the avatar hand
|
||||
//
|
||||
|
@ -255,6 +255,8 @@ class Head : public AvatarData {
|
|||
void calculateBoneLengths();
|
||||
void updateBigSphereCollisionTest( float deltaTime );
|
||||
void readSensors();
|
||||
void renderBoneAsBlock( AvatarBoneID b );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -465,7 +465,7 @@ bool VoxelSystem::falseColorizeInViewOperation(VoxelNode* node, bool down, void*
|
|||
voxelBox.getSize().x);
|
||||
|
||||
// If the voxel is outside of the view frustum, then false color it red
|
||||
if (ViewFrustum::OUTSIDE == viewFrustum->pointInFrustum(voxelBox.getCorner())) {
|
||||
if (ViewFrustum::OUTSIDE == viewFrustum->boxInFrustum(voxelBox)) {
|
||||
// Out of view voxels are colored RED
|
||||
unsigned char newR = 255;
|
||||
unsigned char newG = 0;
|
||||
|
|
|
@ -819,18 +819,16 @@ void display(void)
|
|||
//--------------------------------------------------------
|
||||
// camera settings
|
||||
//--------------------------------------------------------
|
||||
myCamera.setTargetPosition( myAvatar.getBodyPosition() );
|
||||
|
||||
if ( displayHead ) {
|
||||
//-----------------------------------------------
|
||||
// set the camera to looking at my own face
|
||||
//-----------------------------------------------
|
||||
myCamera.setTargetPosition ( myAvatar.getBodyPosition() ); // XXXBHG - Shouldn't we use Head position here?
|
||||
myCamera.setTargetPosition ( myAvatar.getHeadPosition() );
|
||||
myCamera.setYaw ( - myAvatar.getBodyYaw() );
|
||||
myCamera.setPitch ( 0.0 );
|
||||
myCamera.setRoll ( 0.0 );
|
||||
myCamera.setUp ( 0.6 );
|
||||
myCamera.setDistance ( 0.3 );
|
||||
myCamera.setPitch ( 0.0 );
|
||||
myCamera.setRoll ( 0.0 );
|
||||
myCamera.setUp ( 0.0 );
|
||||
myCamera.setDistance ( 0.2 );
|
||||
myCamera.setTightness ( 100.0f );
|
||||
myCamera.update ( 1.f/FPS );
|
||||
} else {
|
||||
|
@ -839,12 +837,12 @@ void display(void)
|
|||
//----------------------------------------------------
|
||||
myCamera.setTargetPosition ( myAvatar.getBodyPosition() );
|
||||
myCamera.setYaw ( 180.0 - myAvatar.getBodyYaw() );
|
||||
myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju
|
||||
myCamera.setRoll ( 0.0 );
|
||||
myCamera.setUp ( 0.45);
|
||||
myCamera.setDistance ( 1.0 );
|
||||
myCamera.setTightness ( 10.0f );
|
||||
myCamera.update ( 1.f/FPS );
|
||||
myCamera.setPitch ( 0.0 ); // temporarily, this must be 0.0 or else bad juju
|
||||
myCamera.setRoll ( 0.0 );
|
||||
myCamera.setUp ( 0.45 );
|
||||
myCamera.setDistance ( 1.0 );
|
||||
myCamera.setTightness ( 8.0f );
|
||||
myCamera.update ( 1.f/FPS);
|
||||
}
|
||||
|
||||
// Note: whichCamera is used to pick between the normal camera myCamera for our
|
||||
|
@ -907,14 +905,12 @@ void display(void)
|
|||
float sphereRadius = 0.25f;
|
||||
glColor3f(1,0,0);
|
||||
glPushMatrix();
|
||||
//glTranslatef( 0.0f, sphereRadius, 0.0f );
|
||||
glutSolidSphere( sphereRadius, 15, 15 );
|
||||
glPopMatrix();
|
||||
|
||||
//draw a grid gound plane....
|
||||
drawGroundPlaneGrid( 5.0f, 9 );
|
||||
|
||||
|
||||
// Draw cloud of dots
|
||||
if (!displayHead) cloud.render();
|
||||
|
||||
|
@ -934,12 +930,7 @@ void display(void)
|
|||
agent++) {
|
||||
if (agent->getLinkedData() != NULL && agent->getType() == AGENT_TYPE_AVATAR) {
|
||||
Head *avatar = (Head *)agent->getLinkedData();
|
||||
//glPushMatrix();
|
||||
|
||||
//printf( "rendering remote avatar\n" );
|
||||
|
||||
avatar->render(0);
|
||||
//glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1509,7 +1500,7 @@ void idle(void) {
|
|||
//
|
||||
// Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents
|
||||
//
|
||||
updateAvatar( 1.f/FPS );
|
||||
updateAvatar(deltaTime);
|
||||
|
||||
//loop through all the other avatars and simulate them.
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
|
@ -1518,14 +1509,9 @@ void idle(void) {
|
|||
if (agent->getLinkedData() != NULL)
|
||||
{
|
||||
Head *avatar = (Head *)agent->getLinkedData();
|
||||
|
||||
//printf( "simulating remote avatar\n" );
|
||||
|
||||
avatar->simulate(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
//updateAvatarHand(1.f/FPS);
|
||||
|
||||
field.simulate (deltaTime);
|
||||
myAvatar.simulate(deltaTime);
|
||||
|
|
|
@ -192,16 +192,16 @@ int ViewFrustum::sphereInFrustum(const glm::vec3& center, float radius) const {
|
|||
|
||||
int ViewFrustum::boxInFrustum(const AABox& box) const {
|
||||
|
||||
printf("ViewFrustum::boxInFrustum() box.corner=%f,%f,%f x=%f\n",
|
||||
box.getCorner().x,box.getCorner().y,box.getCorner().z,box.getSize().x);
|
||||
//printf("ViewFrustum::boxInFrustum() box.corner=%f,%f,%f x=%f\n",
|
||||
// box.getCorner().x,box.getCorner().y,box.getCorner().z,box.getSize().x);
|
||||
int result = INSIDE;
|
||||
for(int i=0; i < 6; i++) {
|
||||
|
||||
printf("plane[%d] -- point(%f,%f,%f) normal(%f,%f,%f) d=%f \n",i,
|
||||
_planes[i].getPoint().x, _planes[i].getPoint().y, _planes[i].getPoint().z,
|
||||
_planes[i].getNormal().x, _planes[i].getNormal().y, _planes[i].getNormal().z,
|
||||
_planes[i].getDCoefficient()
|
||||
);
|
||||
//printf("plane[%d] -- point(%f,%f,%f) normal(%f,%f,%f) d=%f \n",i,
|
||||
// _planes[i].getPoint().x, _planes[i].getPoint().y, _planes[i].getPoint().z,
|
||||
// _planes[i].getNormal().x, _planes[i].getNormal().y, _planes[i].getNormal().z,
|
||||
// _planes[i].getDCoefficient()
|
||||
//);
|
||||
|
||||
glm::vec3 normal = _planes[i].getNormal();
|
||||
glm::vec3 boxVertexP = box.getVertexP(normal);
|
||||
|
@ -210,13 +210,11 @@ int ViewFrustum::boxInFrustum(const AABox& box) const {
|
|||
glm::vec3 boxVertexN = box.getVertexN(normal);
|
||||
float planeToBoxVertexNDistance = _planes[i].distance(boxVertexN);
|
||||
|
||||
|
||||
|
||||
printf("plane[%d] normal=(%f,%f,%f) bVertexP=(%f,%f,%f) planeToBoxVertexPDistance=%f boxVertexN=(%f,%f,%f) planeToBoxVertexNDistance=%f\n",i,
|
||||
normal.x,normal.y,normal.z,
|
||||
boxVertexP.x,boxVertexP.y,boxVertexP.z,planeToBoxVertexPDistance,
|
||||
boxVertexN.x,boxVertexN.y,boxVertexN.z,planeToBoxVertexNDistance
|
||||
);
|
||||
//printf("plane[%d] normal=(%f,%f,%f) bVertexP=(%f,%f,%f) planeToBoxVertexPDistance=%f boxVertexN=(%f,%f,%f) planeToBoxVertexNDistance=%f\n",i,
|
||||
// normal.x,normal.y,normal.z,
|
||||
// boxVertexP.x,boxVertexP.y,boxVertexP.z,planeToBoxVertexPDistance,
|
||||
// boxVertexN.x,boxVertexN.y,boxVertexN.z,planeToBoxVertexNDistance
|
||||
// );
|
||||
|
||||
if (planeToBoxVertexPDistance < 0) {
|
||||
return OUTSIDE;
|
||||
|
|
|
@ -392,7 +392,7 @@ unsigned char * VoxelTree::loadBitstreamBuffer(unsigned char *& bitstreamBuffer,
|
|||
|
||||
bool childIsClose = true; // for now, assume we're close enough
|
||||
bool childInView = !viewFrustumCulling ||
|
||||
(ViewFrustum::OUTSIDE != viewFrustum.pointInFrustum(childBox.getCorner()));
|
||||
(ViewFrustum::OUTSIDE != viewFrustum.boxInFrustum(childBox));
|
||||
|
||||
/// XXXBHG - debug code, switch this to true, and we'll send everything but include false coloring
|
||||
// on voxels based on whether or not they match these rules.
|
||||
|
|
|
@ -49,7 +49,7 @@ VoxelTree randomTree;
|
|||
|
||||
bool wantColorRandomizer = false;
|
||||
bool debugViewFrustum = false;
|
||||
bool viewFrustumCulling = false; // for now
|
||||
bool viewFrustumCulling = true; // for now
|
||||
|
||||
void addSphere(VoxelTree * tree,bool random, bool wantColorRandomizer) {
|
||||
float r = random ? randFloatInRange(0.05,0.1) : 0.25;
|
||||
|
@ -276,8 +276,8 @@ int main(int argc, const char * argv[])
|
|||
::debugViewFrustum = cmdOptionExists(argc, argv, DEBUG_VIEW_FRUSTUM);
|
||||
printf("debugViewFrustum=%s\n", (::debugViewFrustum ? "yes" : "no"));
|
||||
|
||||
const char* VIEW_FRUSTUM_CULLING = "--ViewFrustumCulling";
|
||||
::viewFrustumCulling = cmdOptionExists(argc, argv, VIEW_FRUSTUM_CULLING);
|
||||
const char* NO_VIEW_FRUSTUM_CULLING = "--NoViewFrustumCulling";
|
||||
::viewFrustumCulling = !cmdOptionExists(argc, argv, NO_VIEW_FRUSTUM_CULLING);
|
||||
printf("viewFrustumCulling=%s\n", (::viewFrustumCulling ? "yes" : "no"));
|
||||
|
||||
const char* WANT_COLOR_RANDOMIZER = "--WantColorRandomizer";
|
||||
|
|
Loading…
Reference in a new issue