mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 10:59:37 +02:00
Merge pull request #74 from Ventrella/master
removed initilalizeAvatar() (deprecated)
This commit is contained in:
commit
f4acdda922
5 changed files with 440 additions and 372 deletions
|
@ -18,6 +18,9 @@
|
|||
#include <AgentList.h>
|
||||
#include <AgentTypes.h>
|
||||
#include <PacketHeaders.h>
|
||||
//#include <glm/glm.hpp>
|
||||
//#include <glm/gtc/quaternion.hpp>
|
||||
//#include <glm/gtx/quaternion.hpp> //looks like we might not need this
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -35,6 +38,8 @@ float MouthWidthChoices[3] = {0.5, 0.77, 0.3};
|
|||
float browWidth = 0.8;
|
||||
float browThickness = 0.16;
|
||||
|
||||
bool usingBigSphereCollisionTest = false;
|
||||
|
||||
const float DECAY = 0.1;
|
||||
const float THRUST_MAG = 10.0;
|
||||
const float YAW_MAG = 300.0;
|
||||
|
@ -46,7 +51,6 @@ unsigned int iris_texture_width = 512;
|
|||
unsigned int iris_texture_height = 256;
|
||||
|
||||
Head::Head(bool isMine) {
|
||||
initializeAvatar();
|
||||
|
||||
_avatar.orientation.setToIdentity();
|
||||
_avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
|
@ -63,13 +67,16 @@ Head::Head(bool isMine) {
|
|||
|
||||
initializeSkeleton();
|
||||
|
||||
_TEST_bigSphereRadius = 0.3f;
|
||||
_TEST_bigSpherePosition = glm::vec3( 0.0f, _TEST_bigSphereRadius, 2.0f );
|
||||
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = false;
|
||||
|
||||
PupilSize = 0.10;
|
||||
interPupilDistance = 0.6;
|
||||
interBrowDistance = 0.75;
|
||||
NominalPupilSize = 0.10;
|
||||
Yaw = 0.0;
|
||||
_headYaw = 0.0;
|
||||
EyebrowPitch[0] = EyebrowPitch[1] = -30;
|
||||
EyebrowRoll[0] = 20;
|
||||
EyebrowRoll[1] = -20;
|
||||
|
@ -129,9 +136,7 @@ Head::Head(bool isMine) {
|
|||
DEBUG_otherAvatarListPosition[ 4 ] = glm::vec3( -2.0, 0.3, -2.0 );
|
||||
}
|
||||
|
||||
|
||||
Head::Head(const Head &otherHead) {
|
||||
initializeAvatar();
|
||||
|
||||
_avatar.orientation.set( otherHead._avatar.orientation );
|
||||
_avatar.velocity = otherHead._avatar.velocity;
|
||||
|
@ -153,7 +158,7 @@ Head::Head(const Head &otherHead) {
|
|||
interPupilDistance = otherHead.interPupilDistance;
|
||||
interBrowDistance = otherHead.interBrowDistance;
|
||||
NominalPupilSize = otherHead.NominalPupilSize;
|
||||
Yaw = otherHead.Yaw;
|
||||
_headYaw = otherHead._headYaw;
|
||||
EyebrowPitch[0] = otherHead.EyebrowPitch[0];
|
||||
EyebrowPitch[1] = otherHead.EyebrowPitch[1];
|
||||
EyebrowRoll[0] = otherHead.EyebrowRoll[0];
|
||||
|
@ -202,7 +207,7 @@ Head* Head::clone() const {
|
|||
}
|
||||
|
||||
void Head::reset() {
|
||||
Pitch = Yaw = Roll = 0;
|
||||
_headPitch = _headYaw = _headRoll = 0;
|
||||
leanForward = leanSideways = 0;
|
||||
}
|
||||
|
||||
|
@ -214,13 +219,13 @@ void Head::UpdateGyros(float frametime, SerialInterface * serialInterface, int h
|
|||
{
|
||||
const float PITCH_ACCEL_COUPLING = 0.5;
|
||||
const float ROLL_ACCEL_COUPLING = -1.0;
|
||||
float measured_pitch_rate = serialInterface->getRelativeValue(PITCH_RATE);
|
||||
YawRate = serialInterface->getRelativeValue(YAW_RATE);
|
||||
float measured_pitch_rate = serialInterface->getRelativeValue(HEAD_PITCH_RATE);
|
||||
_headYawRate = serialInterface->getRelativeValue(HEAD_YAW_RATE);
|
||||
float measured_lateral_accel = serialInterface->getRelativeValue(ACCEL_X) -
|
||||
ROLL_ACCEL_COUPLING*serialInterface->getRelativeValue(ROLL_RATE);
|
||||
ROLL_ACCEL_COUPLING*serialInterface->getRelativeValue(HEAD_ROLL_RATE);
|
||||
float measured_fwd_accel = serialInterface->getRelativeValue(ACCEL_Z) -
|
||||
PITCH_ACCEL_COUPLING*serialInterface->getRelativeValue(PITCH_RATE);
|
||||
float measured_roll_rate = serialInterface->getRelativeValue(ROLL_RATE);
|
||||
PITCH_ACCEL_COUPLING*serialInterface->getRelativeValue(HEAD_PITCH_RATE);
|
||||
float measured_roll_rate = serialInterface->getRelativeValue(HEAD_ROLL_RATE);
|
||||
|
||||
//std::cout << "Pitch Rate: " << serialInterface->getRelativeValue(PITCH_RATE) <<
|
||||
// " fwd_accel: " << serialInterface->getRelativeValue(ACCEL_Z) << "\n";
|
||||
|
@ -237,18 +242,18 @@ void Head::UpdateGyros(float frametime, SerialInterface * serialInterface, int h
|
|||
const float MAX_YAW = 85;
|
||||
const float MIN_YAW = -85;
|
||||
|
||||
if ((Pitch < MAX_PITCH) && (Pitch > MIN_PITCH))
|
||||
if ((_headPitch < MAX_PITCH) && (_headPitch > MIN_PITCH))
|
||||
addPitch(measured_pitch_rate * -HEAD_ROTATION_SCALE * frametime);
|
||||
|
||||
addRoll(-measured_roll_rate * HEAD_ROLL_SCALE * frametime);
|
||||
|
||||
if (head_mirror) {
|
||||
if ((Yaw < MAX_YAW) && (Yaw > MIN_YAW))
|
||||
addYaw(-YawRate * HEAD_ROTATION_SCALE * frametime);
|
||||
if ((_headYaw < MAX_YAW) && (_headYaw > MIN_YAW))
|
||||
addYaw(-_headYawRate * HEAD_ROTATION_SCALE * frametime);
|
||||
addLean(-measured_lateral_accel * frametime * HEAD_LEAN_SCALE, -measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
||||
} else {
|
||||
if ((Yaw < MAX_YAW) && (Yaw > MIN_YAW))
|
||||
addYaw(YawRate * -HEAD_ROTATION_SCALE * frametime);
|
||||
if ((_headYaw < MAX_YAW) && (_headYaw > MIN_YAW))
|
||||
addYaw(_headYawRate * -HEAD_ROTATION_SCALE * frametime);
|
||||
addLean(measured_lateral_accel * frametime * -HEAD_LEAN_SCALE, measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +261,7 @@ void Head::UpdateGyros(float frametime, SerialInterface * serialInterface, int h
|
|||
void Head::addLean(float x, float z) {
|
||||
// Add Body lean as impulse
|
||||
leanSideways += x;
|
||||
leanForward += z;
|
||||
leanForward += z;
|
||||
}
|
||||
|
||||
|
||||
|
@ -276,49 +281,59 @@ void Head::setTriggeringAction( bool d ) {
|
|||
|
||||
void Head::simulate(float deltaTime) {
|
||||
|
||||
//-------------------------------------
|
||||
// DEBUG - other avatars...
|
||||
//-------------------------------------
|
||||
//closeEnoughToInteract = 0.3f;
|
||||
_closestOtherAvatar = -1;
|
||||
float closestDistance = 10000.0f;
|
||||
//-------------------------------------------------------------
|
||||
// if the avatar being simulated is mine, then loop through
|
||||
// all the other avatars to get information about them...
|
||||
//-------------------------------------------------------------
|
||||
if ( _isMine )
|
||||
{
|
||||
//-------------------------------------
|
||||
// DEBUG - other avatars...
|
||||
//-------------------------------------
|
||||
_closestOtherAvatar = -1;
|
||||
float closestDistance = 10000.0f;
|
||||
|
||||
|
||||
/*
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
/*
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
|
||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin();
|
||||
agent != agentList->getAgents().end();
|
||||
agent++) {
|
||||
if (( agent->getLinkedData() != NULL && ( agent->getType() == AGENT_TYPE_INTERFACE ) )) {
|
||||
Head *agentHead = (Head *)agent->getLinkedData();
|
||||
|
||||
// when this is working, I will grab the position here...
|
||||
//glm::vec3 pos = agentHead->getPos();
|
||||
Head *otherAvatar = (Head *)agent->getLinkedData();
|
||||
|
||||
// when this is working, I will grab the position here...
|
||||
//glm::vec3 otherAvatarPosition = otherAvatar->getBodyPosition();
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
|
||||
//-------------------------------------
|
||||
// test other avs for proximity...
|
||||
//-------------------------------------
|
||||
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
||||
v -= DEBUG_otherAvatarListPosition[o];
|
||||
///for testing only (prior to having real avs working)
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
|
||||
//-------------------------------------
|
||||
// test other avs for proximity...
|
||||
//-------------------------------------
|
||||
glm::vec3 v( _bone[ AVATAR_BONE_RIGHT_SHOULDER ].position );
|
||||
v -= DEBUG_otherAvatarListPosition[o];
|
||||
|
||||
float distance = glm::length( v );
|
||||
|
||||
if ( distance < _avatar.maxArmLength ) {
|
||||
if ( distance < closestDistance ) {
|
||||
closestDistance = distance;
|
||||
_closestOtherAvatar = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
float distance = glm::length( v );
|
||||
|
||||
if ( distance < _avatar.maxArmLength ) {
|
||||
if ( distance < closestDistance ) {
|
||||
closestDistance = distance;
|
||||
_closestOtherAvatar = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( usingBigSphereCollisionTest ) {
|
||||
//--------------------------------------------------------------
|
||||
// test for avatar collision response (using a big sphere :)
|
||||
//--------------------------------------------------------------
|
||||
updateBigSphereCollisionTest(deltaTime);
|
||||
}
|
||||
|
||||
}//if ( _isMine )
|
||||
|
||||
//------------------------
|
||||
// update avatar skeleton
|
||||
|
@ -350,41 +365,44 @@ void Head::simulate(float deltaTime) {
|
|||
_previousHandBeingMoved = _handBeingMoved;
|
||||
_handBeingMoved = false;
|
||||
|
||||
//-------------------------------------------------
|
||||
// this handles the avatar being driven around...
|
||||
//-------------------------------------------------
|
||||
_avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
if ( _isMine ) { // driving the avatar around should only apply is this is my avatar (as opposed to an avatar being driven remotely)
|
||||
//-------------------------------------------------
|
||||
// this handles the avatar being driven around...
|
||||
//-------------------------------------------------
|
||||
_avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
|
||||
if (driveKeys[FWD]) {
|
||||
glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z );
|
||||
_avatar.thrust += front * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[BACK]) {
|
||||
glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z );
|
||||
_avatar.thrust -= front * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[RIGHT]) {
|
||||
glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z );
|
||||
_avatar.thrust -= right * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[LEFT]) {
|
||||
glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z );
|
||||
_avatar.thrust += right * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[UP]) {
|
||||
glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z );
|
||||
_avatar.thrust += up * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[DOWN]) {
|
||||
glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z );
|
||||
_avatar.thrust -= up * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[ROT_RIGHT]) {
|
||||
_bodyYawDelta -= YAW_MAG * deltaTime;
|
||||
}
|
||||
if (driveKeys[ROT_LEFT]) {
|
||||
_bodyYawDelta += YAW_MAG * deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
if (driveKeys[FWD]) {
|
||||
glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z );
|
||||
_avatar.thrust += front * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[BACK]) {
|
||||
glm::vec3 front( _avatar.orientation.getFront().x, _avatar.orientation.getFront().y, _avatar.orientation.getFront().z );
|
||||
_avatar.thrust -= front * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[RIGHT]) {
|
||||
glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z );
|
||||
_avatar.thrust -= right * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[LEFT]) {
|
||||
glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z );
|
||||
_avatar.thrust += right * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[UP]) {
|
||||
glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z );
|
||||
_avatar.thrust += up * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[DOWN]) {
|
||||
glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z );
|
||||
_avatar.thrust -= up * THRUST_MAG;
|
||||
}
|
||||
if (driveKeys[ROT_RIGHT]) {
|
||||
_bodyYawDelta -= YAW_MAG * deltaTime;
|
||||
}
|
||||
if (driveKeys[ROT_LEFT]) {
|
||||
_bodyYawDelta += YAW_MAG * deltaTime;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
float translationalSpeed = glm::length( _avatar.velocity );
|
||||
|
@ -401,28 +419,30 @@ void Head::simulate(float deltaTime) {
|
|||
//----------------------------------------------------------
|
||||
// update body yaw by body yaw delta
|
||||
//----------------------------------------------------------
|
||||
_bodyYaw += _bodyYawDelta * deltaTime;
|
||||
if (_isMine) {
|
||||
_bodyYaw += _bodyYawDelta * deltaTime;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
// (for now) set head yaw to body yaw
|
||||
//----------------------------------------------------------
|
||||
Yaw = _bodyYaw;
|
||||
// we will be eventually getting head rotation from elsewhere. For now, just setting it to body rotation
|
||||
_headYaw = _bodyYaw;
|
||||
_headPitch = _bodyPitch;
|
||||
_headRoll = _bodyRoll;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// decay body yaw delta
|
||||
//----------------------------------------------------------
|
||||
const float TEST_YAW_DECAY = 5.0;
|
||||
_bodyYawDelta *= ( 1.0 - TEST_YAW_DECAY * deltaTime );
|
||||
_bodyYawDelta *= (1.0 - TEST_YAW_DECAY * deltaTime);
|
||||
|
||||
//----------------------------------------------------------
|
||||
// add thrust to velocity
|
||||
//----------------------------------------------------------
|
||||
_avatar.velocity += glm::dvec3( _avatar.thrust * deltaTime );
|
||||
_avatar.velocity += glm::dvec3(_avatar.thrust * deltaTime);
|
||||
|
||||
//----------------------------------------------------------
|
||||
// update position by velocity
|
||||
//----------------------------------------------------------
|
||||
_bodyPosition += (glm::vec3)_avatar.velocity * deltaTime;
|
||||
//----------------------------------------------------------
|
||||
// update position by velocity
|
||||
//----------------------------------------------------------
|
||||
_bodyPosition += (glm::vec3)_avatar.velocity * deltaTime;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// decay velocity
|
||||
|
@ -430,26 +450,22 @@ void Head::simulate(float deltaTime) {
|
|||
const float LIN_VEL_DECAY = 5.0;
|
||||
_avatar.velocity *= ( 1.0 - LIN_VEL_DECAY * deltaTime );
|
||||
|
||||
|
||||
|
||||
if (!noise) {
|
||||
// Decay back toward center
|
||||
Pitch *= (1.f - DECAY*2*deltaTime);
|
||||
Yaw *= (1.f - DECAY*2*deltaTime);
|
||||
Roll *= (1.f - DECAY*2*deltaTime);
|
||||
_headPitch *= (1.0f - DECAY*2*deltaTime);
|
||||
_headYaw *= (1.0f - DECAY*2*deltaTime);
|
||||
_headRoll *= (1.0f - DECAY*2*deltaTime);
|
||||
}
|
||||
else {
|
||||
// Move toward new target
|
||||
Pitch += (PitchTarget - Pitch)*10*deltaTime; // (1.f - DECAY*deltaTime)*Pitch + ;
|
||||
Yaw += (YawTarget - Yaw)*10*deltaTime; // (1.f - DECAY*deltaTime);
|
||||
Roll *= (1.f - DECAY*deltaTime);
|
||||
_headPitch += (PitchTarget - _headPitch)*10*deltaTime; // (1.f - DECAY*deltaTime)*Pitch + ;
|
||||
_headYaw += (YawTarget - _headYaw)*10*deltaTime; // (1.f - DECAY*deltaTime);
|
||||
_headRoll *= (1.f - DECAY*deltaTime);
|
||||
}
|
||||
|
||||
leanForward *= (1.f - DECAY*30.f*deltaTime);
|
||||
leanSideways *= (1.f - DECAY*30.f*deltaTime);
|
||||
|
||||
|
||||
|
||||
// Update where the avatar's eyes are
|
||||
//
|
||||
// First, decide if we are making eye contact or not
|
||||
|
@ -486,15 +502,15 @@ void Head::simulate(float deltaTime) {
|
|||
if (eyeContactTarget == RIGHT_EYE) eye_target_yaw_adjust = -DEGREES_BETWEEN_VIEWER_EYES;
|
||||
if (eyeContactTarget == MOUTH) eye_target_pitch_adjust = DEGREES_TO_VIEWER_MOUTH;
|
||||
|
||||
EyeballPitch[0] = EyeballPitch[1] = -Pitch + eye_target_pitch_adjust;
|
||||
EyeballYaw[0] = EyeballYaw[1] = -Yaw + eye_target_yaw_adjust;
|
||||
EyeballPitch[0] = EyeballPitch[1] = -_headPitch + eye_target_pitch_adjust;
|
||||
EyeballYaw[0] = EyeballYaw[1] = -_headYaw + eye_target_yaw_adjust;
|
||||
}
|
||||
|
||||
|
||||
if (noise)
|
||||
{
|
||||
Pitch += (randFloat() - 0.5)*0.2*NoiseEnvelope;
|
||||
Yaw += (randFloat() - 0.5)*0.3*NoiseEnvelope;
|
||||
_headPitch += (randFloat() - 0.5)*0.2*NoiseEnvelope;
|
||||
_headYaw += (randFloat() - 0.5)*0.3*NoiseEnvelope;
|
||||
//PupilSize += (randFloat() - 0.5)*0.001*NoiseEnvelope;
|
||||
|
||||
if (randFloat() < 0.005) MouthWidth = MouthWidthChoices[rand()%3];
|
||||
|
@ -504,7 +520,7 @@ void Head::simulate(float deltaTime) {
|
|||
if (randFloat() < 0.01) EyeballYaw[0] = EyeballYaw[1] = (randFloat()- 0.5)*10;
|
||||
}
|
||||
|
||||
if ((randFloat() < 0.005) && (fabs(PitchTarget - Pitch) < 1.0) && (fabs(YawTarget - Yaw) < 1.0)) {
|
||||
if ((randFloat() < 0.005) && (fabs(PitchTarget - _headPitch) < 1.0) && (fabs(YawTarget - _headYaw) < 1.0)) {
|
||||
SetNewHeadTarget((randFloat()-0.5)*20.0, (randFloat()-0.5)*45.0);
|
||||
}
|
||||
|
||||
|
@ -520,27 +536,89 @@ void Head::simulate(float deltaTime) {
|
|||
EyebrowRoll[0] = EyebrowRoll[1] = BrowRollAngle[rand()%5];
|
||||
EyebrowRoll[1]*=-1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//hand->simulate(deltaTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// This is a workspace for testing avatar body collision detection and response
|
||||
//--------------------------------------------------------------------------------
|
||||
void Head::updateBigSphereCollisionTest( float deltaTime ) {
|
||||
|
||||
float myBodyApproximateBoundingRadius = 1.0f;
|
||||
glm::vec3 vectorFromMyBodyToBigSphere(_bodyPosition - _TEST_bigSpherePosition);
|
||||
bool jointCollision = false;
|
||||
|
||||
float distanceToBigSphere = glm::length(vectorFromMyBodyToBigSphere);
|
||||
if ( distanceToBigSphere < myBodyApproximateBoundingRadius + _TEST_bigSphereRadius)
|
||||
{
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++)
|
||||
{
|
||||
glm::vec3 vectorFromJointToBigSphere(_bone[b].position - _TEST_bigSpherePosition);
|
||||
float distanceToBigSphereCenter = glm::length(vectorFromJointToBigSphere);
|
||||
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;
|
||||
_avatar.velocity += collisionForce * 18.0f * deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( jointCollision ) {
|
||||
//----------------------------------------------------------
|
||||
// add gravity to velocity
|
||||
//----------------------------------------------------------
|
||||
_avatar.velocity += glm::dvec3( 0.0, -1.0, 0.0 ) * 0.05;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// ground collisions
|
||||
//----------------------------------------------------------
|
||||
if ( _bodyPosition.y < 0.0 ) {
|
||||
_bodyPosition.y = 0.0;
|
||||
if ( _avatar.velocity.y < 0.0 ) {
|
||||
_avatar.velocity.y *= -0.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Head::render(int faceToFace) {
|
||||
|
||||
//---------------------------------------------------
|
||||
// show avatar position
|
||||
//---------------------------------------------------
|
||||
glColor4f( 0.5f, 0.5f, 0.5f, 0.6 );
|
||||
glPushMatrix();
|
||||
glTranslatef(_bodyPosition.x, _bodyPosition.y, _bodyPosition.z);
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
if ( usingBigSphereCollisionTest ) {
|
||||
//---------------------------------------------------
|
||||
// show TEST big sphere
|
||||
//---------------------------------------------------
|
||||
glColor4f( 0.5f, 0.6f, 0.8f, 0.7 );
|
||||
glPushMatrix();
|
||||
glTranslatef(_TEST_bigSpherePosition.x, _TEST_bigSpherePosition.y, _TEST_bigSpherePosition.z);
|
||||
glScalef( _TEST_bigSphereRadius, _TEST_bigSphereRadius, _TEST_bigSphereRadius );
|
||||
glutSolidSphere( 1, 20, 20 );
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
// show avatar orientation
|
||||
//---------------------------------------------------
|
||||
|
@ -556,31 +634,37 @@ void Head::render(int faceToFace) {
|
|||
//---------------------------------------------------
|
||||
renderHead(faceToFace);
|
||||
|
||||
//---------------------------------------------------
|
||||
// render other avatars (DEBUG TEST)
|
||||
//---------------------------------------------------
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
|
||||
glPushMatrix();
|
||||
glTranslatef( DEBUG_otherAvatarListPosition[o].x, DEBUG_otherAvatarListPosition[o].y, DEBUG_otherAvatarListPosition[o].z );
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
// if this is my avatar, then render my interactions with the other avatars
|
||||
//---------------------------------------------------------------------------
|
||||
if ( _isMine )
|
||||
{
|
||||
//---------------------------------------------------
|
||||
// render other avatars (DEBUG TEST)
|
||||
//---------------------------------------------------
|
||||
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
|
||||
glPushMatrix();
|
||||
glTranslatef( DEBUG_otherAvatarListPosition[o].x, DEBUG_otherAvatarListPosition[o].y, DEBUG_otherAvatarListPosition[o].z );
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
glutSolidSphere( 1, 10, 10 );
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if ( _usingSprings ) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
if ( _usingSprings ) {
|
||||
if ( _closestOtherAvatar != -1 ) {
|
||||
|
||||
glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
glm::vec3 v2( DEBUG_otherAvatarListPosition[ _closestOtherAvatar ] );
|
||||
glm::vec3 v1( _bone[ AVATAR_BONE_RIGHT_HAND ].position );
|
||||
glm::vec3 v2( DEBUG_otherAvatarListPosition[ _closestOtherAvatar ] );
|
||||
|
||||
glLineWidth( 5.0 );
|
||||
glColor4f( 0.9f, 0.5f, 0.2f, 0.6 );
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3f( v1.x, v1.y, v1.z );
|
||||
glVertex3f( v2.x, v2.y, v2.z );
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
glLineWidth( 5.0 );
|
||||
glColor4f( 0.9f, 0.5f, 0.2f, 0.6 );
|
||||
glBegin( GL_LINE_STRIP );
|
||||
glVertex3f( v1.x, v1.y, v1.z );
|
||||
glVertex3f( v2.x, v2.y, v2.z );
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -614,7 +698,7 @@ void Head::renderOrientationDirections( glm::vec3 position, Orientation orientat
|
|||
|
||||
|
||||
|
||||
void Head::renderHead( int faceToFace) {
|
||||
void Head::renderHead(int faceToFace) {
|
||||
int side = 0;
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -622,8 +706,7 @@ void Head::renderHead( int faceToFace) {
|
|||
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
if ( _usingSprings ) {
|
||||
if (_usingSprings) {
|
||||
glTranslatef
|
||||
(
|
||||
_bone[ AVATAR_BONE_HEAD ].springyPosition.x,
|
||||
|
@ -643,142 +726,140 @@ void Head::renderHead( int faceToFace) {
|
|||
|
||||
glScalef( 0.03, 0.03, 0.03 );
|
||||
|
||||
glRotatef(_bodyYaw, 0, 1, 0);
|
||||
glRotatef(_headYaw, 0, 1, 0);
|
||||
glRotatef(_headPitch, 1, 0, 0);
|
||||
glRotatef(_headRoll, 0, 0, 1);
|
||||
|
||||
// Overall scale of head
|
||||
if (faceToFace) glScalef(2.0, 2.0, 2.0);
|
||||
else glScalef(0.75, 1.0, 1.0);
|
||||
|
||||
|
||||
// Don't render a head if it is really close to your location, because that is your own head!
|
||||
//if (!isMine || faceToFace)
|
||||
{
|
||||
|
||||
glRotatef(Pitch, 1, 0, 0);
|
||||
glRotatef(Roll, 0, 0, 1);
|
||||
|
||||
// Overall scale of head
|
||||
if (faceToFace) glScalef(2.0, 2.0, 2.0);
|
||||
else glScalef(0.75, 1.0, 1.0);
|
||||
|
||||
// Head
|
||||
if (_isMine) {
|
||||
glColor3fv(skinColor);
|
||||
|
||||
// Head
|
||||
if (!_isMine) glColor3f(0,0,1); // Temp: Other people are BLUE
|
||||
glutSolidSphere(1, 30, 30);
|
||||
|
||||
// Ears
|
||||
glPushMatrix();
|
||||
glTranslatef(1.0, 0, 0);
|
||||
for(side = 0; side < 2; side++) {
|
||||
glPushMatrix();
|
||||
glScalef(0.3, 0.65, .65);
|
||||
glutSolidSphere(0.5, 30, 30);
|
||||
glPopMatrix();
|
||||
glTranslatef(-2.0, 0, 0);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
// Eyebrows
|
||||
audioAttack = 0.9*audioAttack + 0.1*fabs(loudness - lastLoudness);
|
||||
lastLoudness = loudness;
|
||||
|
||||
const float BROW_LIFT_THRESHOLD = 100;
|
||||
if (audioAttack > BROW_LIFT_THRESHOLD)
|
||||
browAudioLift += sqrt(audioAttack)/1000.0;
|
||||
|
||||
browAudioLift *= .90;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-interBrowDistance/2.0,0.4,0.45);
|
||||
for(side = 0; side < 2; side++) {
|
||||
glColor3fv(browColor);
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0.35 + browAudioLift, 0);
|
||||
glRotatef(EyebrowPitch[side]/2.0, 1, 0, 0);
|
||||
glRotatef(EyebrowRoll[side]/2.0, 0, 0, 1);
|
||||
glScalef(browWidth, browThickness, 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
glTranslatef(interBrowDistance, 0, 0);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
// Mouth
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0,-0.35,0.75);
|
||||
glColor3f(0,0,0);
|
||||
glRotatef(MouthPitch, 1, 0, 0);
|
||||
glRotatef(MouthYaw, 0, 0, 1);
|
||||
glScalef(MouthWidth*(.7 + sqrt(averageLoudness)/60.0), MouthHeight*(1.0 + sqrt(averageLoudness)/30.0), 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
|
||||
glTranslatef(0, 1.0, 0);
|
||||
|
||||
glTranslatef(-interPupilDistance/2.0,-0.68,0.7);
|
||||
// Right Eye
|
||||
glRotatef(-10, 1, 0, 0);
|
||||
glColor3fv(eyeColor);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(interPupilDistance/10.0, 0, 0.05);
|
||||
glRotatef(20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
// Right Pupil
|
||||
if (sphere == NULL) {
|
||||
sphere = gluNewQuadric();
|
||||
gluQuadricTexture(sphere, GL_TRUE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gluQuadricOrientation(sphere, GLU_OUTSIDE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iris_texture_width, iris_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &iris_texture[0]);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
{
|
||||
glRotatef(EyeballPitch[1], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[1] + PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0,0,.35);
|
||||
glRotatef(-75,1,0,0);
|
||||
glScalef(1.0, 0.4, 1.0);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(sphere, PupilSize, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
// Left Eye
|
||||
glColor3fv(eyeColor);
|
||||
glTranslatef(interPupilDistance, 0, 0);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(-interPupilDistance/10.0, 0, .05);
|
||||
glRotatef(-20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
// Left Pupil
|
||||
glPushMatrix();
|
||||
{
|
||||
glRotatef(EyeballPitch[0], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[0] - PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0, 0, .35);
|
||||
glRotatef(-75, 1, 0, 0);
|
||||
glScalef(1.0, 0.4, 1.0);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(sphere, PupilSize, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
else {
|
||||
glColor3f(0,0,1); // Temp: Other people are BLUE
|
||||
}
|
||||
glutSolidSphere(1, 30, 30);
|
||||
|
||||
// Ears
|
||||
glPushMatrix();
|
||||
glTranslatef(1.0, 0, 0);
|
||||
for(side = 0; side < 2; side++) {
|
||||
glPushMatrix();
|
||||
glScalef(0.3, 0.65, .65);
|
||||
glutSolidSphere(0.5, 30, 30);
|
||||
glPopMatrix();
|
||||
glTranslatef(-2.0, 0, 0);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
// Eyebrows
|
||||
audioAttack = 0.9*audioAttack + 0.1*fabs(loudness - lastLoudness);
|
||||
lastLoudness = loudness;
|
||||
|
||||
const float BROW_LIFT_THRESHOLD = 100;
|
||||
if (audioAttack > BROW_LIFT_THRESHOLD)
|
||||
browAudioLift += sqrt(audioAttack)/1000.0;
|
||||
|
||||
browAudioLift *= .90;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(-interBrowDistance/2.0,0.4,0.45);
|
||||
for(side = 0; side < 2; side++) {
|
||||
glColor3fv(browColor);
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0.35 + browAudioLift, 0);
|
||||
glRotatef(EyebrowPitch[side]/2.0, 1, 0, 0);
|
||||
glRotatef(EyebrowRoll[side]/2.0, 0, 0, 1);
|
||||
glScalef(browWidth, browThickness, 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
glTranslatef(interBrowDistance, 0, 0);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
// Mouth
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0,-0.35,0.75);
|
||||
glColor3f(0,0,0);
|
||||
glRotatef(MouthPitch, 1, 0, 0);
|
||||
glRotatef(MouthYaw, 0, 0, 1);
|
||||
glScalef(MouthWidth*(.7 + sqrt(averageLoudness)/60.0), MouthHeight*(1.0 + sqrt(averageLoudness)/30.0), 1);
|
||||
glutSolidCube(0.5);
|
||||
glPopMatrix();
|
||||
|
||||
glTranslatef(0, 1.0, 0);
|
||||
|
||||
glTranslatef(-interPupilDistance/2.0,-0.68,0.7);
|
||||
// Right Eye
|
||||
glRotatef(-10, 1, 0, 0);
|
||||
glColor3fv(eyeColor);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(interPupilDistance/10.0, 0, 0.05);
|
||||
glRotatef(20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
|
||||
// Right Pupil
|
||||
if (sphere == NULL) {
|
||||
sphere = gluNewQuadric();
|
||||
gluQuadricTexture(sphere, GL_TRUE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
gluQuadricOrientation(sphere, GLU_OUTSIDE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iris_texture_width, iris_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &iris_texture[0]);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
{
|
||||
glRotatef(EyeballPitch[1], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[1] + PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0,0,.35);
|
||||
glRotatef(-75,1,0,0);
|
||||
glScalef(1.0, 0.4, 1.0);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(sphere, PupilSize, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
// Left Eye
|
||||
glColor3fv(eyeColor);
|
||||
glTranslatef(interPupilDistance, 0, 0);
|
||||
glPushMatrix();
|
||||
{
|
||||
glTranslatef(-interPupilDistance/10.0, 0, .05);
|
||||
glRotatef(-20, 0, 0, 1);
|
||||
glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ);
|
||||
glutSolidSphere(0.25, 30, 30);
|
||||
}
|
||||
glPopMatrix();
|
||||
// Left Pupil
|
||||
glPushMatrix();
|
||||
{
|
||||
glRotatef(EyeballPitch[0], 1, 0, 0);
|
||||
glRotatef(EyeballYaw[0] - PupilConverge, 0, 1, 0);
|
||||
glTranslatef(0, 0, .35);
|
||||
glRotatef(-75, 1, 0, 0);
|
||||
glScalef(1.0, 0.4, 1.0);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
gluSphere(sphere, PupilSize, 15, 15);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
@ -795,44 +876,22 @@ AvatarMode Head::getMode() {
|
|||
}
|
||||
|
||||
|
||||
void Head::initializeAvatar() {
|
||||
/*
|
||||
avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
avatar.orientation.setToIdentity();
|
||||
|
||||
closestOtherAvatar = 0;
|
||||
|
||||
_bodyYaw = -90.0;
|
||||
_bodyPitch = 0.0;
|
||||
_bodyRoll = 0.0;
|
||||
|
||||
bodyYawDelta = 0.0;
|
||||
|
||||
triggeringAction = false;
|
||||
|
||||
mode = AVATAR_MODE_STANDING;
|
||||
|
||||
initializeSkeleton();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void Head::initializeSkeleton() {
|
||||
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
_bone[b].parent = AVATAR_BONE_NULL;
|
||||
_bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||
_bone[b].rotation = glm::quat( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
_bone[b].yaw = 0.0;
|
||||
_bone[b].pitch = 0.0;
|
||||
_bone[b].roll = 0.0;
|
||||
_bone[b].length = 0.0;
|
||||
_bone[b].springBodyTightness = 4.0;
|
||||
_bone[b].orientation.setToIdentity();
|
||||
_bone[b].yaw = 0.0;
|
||||
_bone[b].pitch = 0.0;
|
||||
_bone[b].roll = 0.0;
|
||||
_bone[b].length = 0.0;
|
||||
_bone[b].radius = 0.02; //default
|
||||
_bone[b].springBodyTightness = 4.0;
|
||||
_bone[b].orientation.setToIdentity();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -871,8 +930,8 @@ void Head::initializeSkeleton() {
|
|||
//----------------------------------------------------------------------------
|
||||
_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;
|
||||
_bone[ AVATAR_BONE_LEFT_SHIN ].parent = AVATAR_BONE_LEFT_THIGH;
|
||||
_bone[ AVATAR_BONE_LEFT_FOOT ].parent = AVATAR_BONE_LEFT_SHIN;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// right pelvis and leg
|
||||
|
@ -930,13 +989,11 @@ void Head::calculateBoneLengths() {
|
|||
}
|
||||
|
||||
_avatar.maxArmLength
|
||||
= _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].length
|
||||
+ _bone[ AVATAR_BONE_RIGHT_FOREARM ].length
|
||||
+ _bone[ AVATAR_BONE_RIGHT_HAND ].length;
|
||||
= _bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].length
|
||||
+ _bone[ AVATAR_BONE_RIGHT_FOREARM ].length
|
||||
+ _bone[ AVATAR_BONE_RIGHT_HAND ].length;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Head::updateSkeleton() {
|
||||
//----------------------------------
|
||||
// rotate body...
|
||||
|
@ -944,29 +1001,39 @@ void Head::updateSkeleton() {
|
|||
_avatar.orientation.setToIdentity();
|
||||
_avatar.orientation.yaw( _bodyYaw );
|
||||
|
||||
//test! - make sure this does what expected: st rotation to be identity PLUS _bodyYaw
|
||||
//_rotation = glm::angleAxis( _bodyYaw, _avatar.orientation.up );
|
||||
|
||||
//glm::quat yaw_rotation = glm::angleAxis( _bodyYaw, _avatar.orientation.up );
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// calculate positions of all bones by traversing the skeleton tree:
|
||||
//------------------------------------------------------------------------
|
||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||
if ( _bone[b].parent == AVATAR_BONE_NULL ) {
|
||||
_bone[b].orientation.set( _avatar.orientation );
|
||||
//printf( "bodyPosition = %f, %f, %f\n", bodyPosition.x, bodyPosition.y, bodyPosition.z );
|
||||
glm::vec3 ppp = _bodyPosition;
|
||||
|
||||
// ppp.y += 0.2;
|
||||
|
||||
_bone[b].position = ppp;// + glm::vec3( 0.0f, 1.0f, 0.0f ) * 1.0f;
|
||||
_bone[b].position = _bodyPosition;
|
||||
}
|
||||
else {
|
||||
_bone[b].orientation.set( _bone[ _bone[b].parent ].orientation );
|
||||
_bone[b].position = _bone[ _bone[b].parent ].position;
|
||||
}
|
||||
|
||||
///TEST! - get this working and then add a comment; JJV
|
||||
if ( ! _isMine ) {
|
||||
_bone[ AVATAR_BONE_RIGHT_HAND ].position = _handPosition;
|
||||
}
|
||||
|
||||
float xx = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getRight () );
|
||||
float yy = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getUp () );
|
||||
float zz = -glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getFront () );
|
||||
|
||||
glm::vec3 rotatedBoneVector( xx, yy, zz );
|
||||
|
||||
//glm::vec3 myEuler ( 0.0f, 0.0f, 0.0f );
|
||||
//glm::quat myQuat ( myEuler );
|
||||
|
||||
_bone[b].position += rotatedBoneVector;
|
||||
}
|
||||
}
|
||||
|
@ -1053,6 +1120,8 @@ glm::vec3 Head::getHeadPosition() {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Head::updateHandMovement() {
|
||||
glm::vec3 transformedHandMovement;
|
||||
|
||||
|
@ -1082,7 +1151,6 @@ void Head::updateHandMovement() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// determine the arm vector
|
||||
//-------------------------------------------------------------------------------
|
||||
|
@ -1161,14 +1229,14 @@ void Head::renderBody() {
|
|||
glColor3fv( lightBlue );
|
||||
glPushMatrix();
|
||||
glTranslatef( _bone[b].springyPosition.x, _bone[b].springyPosition.y, _bone[b].springyPosition.z );
|
||||
glutSolidSphere( 0.02f, 10.0f, 5.0f );
|
||||
glutSolidSphere( _bone[b].radius, 10.0f, 5.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
else {
|
||||
glColor3fv( skinColor );
|
||||
glPushMatrix();
|
||||
glTranslatef( _bone[b].position.x, _bone[b].position.y, _bone[b].position.z );
|
||||
glutSolidSphere( 0.02f, 10.0f, 5.0f );
|
||||
glutSolidSphere( _bone[b].radius, 10.0f, 5.0f );
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
@ -1220,6 +1288,7 @@ void Head::SetNewHeadTarget(float pitch, float yaw) {
|
|||
YawTarget = yaw;
|
||||
}
|
||||
|
||||
// getting data from Android transmitte app
|
||||
void Head::processTransmitterData(unsigned char* packetData, int numBytes) {
|
||||
// Read a packet from a transmitter app, process the data
|
||||
float accX, accY, accZ,
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
#include <glm/gtx/quaternion.hpp> //looks like we might not need this
|
||||
|
||||
enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
|
||||
|
||||
|
@ -85,12 +84,13 @@ struct AvatarBone
|
|||
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 orienttion)
|
||||
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 Avatar
|
||||
|
@ -111,9 +111,9 @@ class Head : public AvatarData {
|
|||
void reset();
|
||||
void UpdateGyros(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity);
|
||||
void setNoise (float mag) { noise = mag; }
|
||||
void setPitch(float p) {Pitch = p; }
|
||||
void setYaw(float y) {Yaw = y; }
|
||||
void setRoll(float r) {Roll = r; };
|
||||
void setPitch(float p) {_headPitch = p; }
|
||||
void setYaw(float y) {_headYaw = y; }
|
||||
void setRoll(float r) {_headRoll = r; };
|
||||
void setScale(float s) {scale = s; };
|
||||
void setRenderYaw(float y) {renderYaw = y;}
|
||||
void setRenderPitch(float p) {renderPitch = p;}
|
||||
|
@ -121,14 +121,14 @@ class Head : public AvatarData {
|
|||
float getRenderPitch() {return renderPitch;}
|
||||
void setLeanForward(float dist);
|
||||
void setLeanSideways(float dist);
|
||||
void addPitch(float p) {Pitch -= p; }
|
||||
void addYaw(float y){Yaw -= y; }
|
||||
void addRoll(float r){Roll += r; }
|
||||
void addPitch(float p) {_headPitch -= p; }
|
||||
void addYaw(float y){_headYaw -= y; }
|
||||
void addRoll(float r){_headRoll += r; }
|
||||
void addLean(float x, float z);
|
||||
float getPitch() {return Pitch;}
|
||||
float getRoll() {return Roll;}
|
||||
float getYaw() {return Yaw;}
|
||||
float getLastMeasuredYaw() {return YawRate;}
|
||||
float getPitch() {return _headPitch;}
|
||||
float getRoll() {return _headRoll;}
|
||||
float getYaw() {return _headYaw;}
|
||||
float getLastMeasuredYaw() {return _headYawRate;}
|
||||
|
||||
float getBodyYaw() {return _bodyYaw;};
|
||||
void addBodyYaw(float y) {_bodyYaw += y;};
|
||||
|
@ -180,12 +180,12 @@ class Head : public AvatarData {
|
|||
private:
|
||||
bool _isMine;
|
||||
float noise;
|
||||
float Pitch;
|
||||
float Yaw;
|
||||
float Roll;
|
||||
float PitchRate;
|
||||
float YawRate;
|
||||
float RollRate;
|
||||
float _headPitch;
|
||||
float _headYaw;
|
||||
float _headRoll;
|
||||
float _headPitchRate;
|
||||
float _headYawRate;
|
||||
float _headRollRate;
|
||||
float EyeballPitch[2];
|
||||
float EyeballYaw[2];
|
||||
float EyebrowPitch[2];
|
||||
|
@ -213,6 +213,8 @@ class Head : public AvatarData {
|
|||
float audioAttack;
|
||||
float browAudioLift;
|
||||
|
||||
glm::vec3 _TEST_bigSpherePosition;
|
||||
float _TEST_bigSphereRadius;
|
||||
|
||||
//temporary - placeholder for real other avs
|
||||
glm::vec3 DEBUG_otherAvatarListPosition [ NUM_OTHER_AVATARS ];
|
||||
|
@ -253,12 +255,12 @@ class Head : public AvatarData {
|
|||
//-----------------------------
|
||||
// private methods...
|
||||
//-----------------------------
|
||||
void initializeAvatar();
|
||||
void initializeSkeleton();
|
||||
void updateSkeleton();
|
||||
void initializeBodySprings();
|
||||
void updateBodySprings( float deltaTime );
|
||||
void calculateBoneLengths();
|
||||
void updateBigSphereCollisionTest( float deltaTime );
|
||||
void readSensors();
|
||||
};
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
#define ACCEL_Z 5
|
||||
|
||||
// Gyro sensors, in coodinate system of head/airplane
|
||||
#define PITCH_RATE 1
|
||||
#define YAW_RATE 0
|
||||
#define ROLL_RATE 2
|
||||
#define HEAD_PITCH_RATE 1
|
||||
#define HEAD_YAW_RATE 0
|
||||
#define HEAD_ROLL_RATE 2
|
||||
|
||||
class SerialInterface {
|
||||
public:
|
||||
|
|
|
@ -167,8 +167,8 @@ int headMouseX, headMouseY;
|
|||
int mouseX, mouseY; // Where is the mouse
|
||||
|
||||
// Mouse location at start of last down click
|
||||
int mouseStartX;// = WIDTH / 2;
|
||||
int mouseStartY;// = HEIGHT / 2;
|
||||
int mouseStartX = WIDTH / 2;
|
||||
int mouseStartY = HEIGHT / 2;
|
||||
int mousePressed = 0; // true if mouse has been pressed (clear when finished)
|
||||
|
||||
Menu menu; // main menu
|
||||
|
@ -379,8 +379,8 @@ void updateAvatarHand(float deltaTime) {
|
|||
//
|
||||
void updateAvatar(float frametime)
|
||||
{
|
||||
float gyroPitchRate = serialPort.getRelativeValue(PITCH_RATE);
|
||||
float gyroYawRate = serialPort.getRelativeValue(YAW_RATE);
|
||||
float gyroPitchRate = serialPort.getRelativeValue(HEAD_PITCH_RATE);
|
||||
float gyroYawRate = serialPort.getRelativeValue(HEAD_YAW_RATE );
|
||||
|
||||
myAvatar.UpdateGyros(frametime, &serialPort, headMirror, &gravity);
|
||||
|
||||
|
@ -833,7 +833,6 @@ void display(void)
|
|||
// brad's frustum for debugging
|
||||
if (::frustumOn) render_view_frustum();
|
||||
|
||||
|
||||
//Render my own avatar
|
||||
myAvatar.render(true);
|
||||
}
|
||||
|
@ -1319,22 +1318,21 @@ void idle(void) {
|
|||
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time
|
||||
|
||||
if (diffclock(&lastTimeIdle, &check) > IDLE_SIMULATE_MSECS) {
|
||||
// If mouse is being dragged, update hand movement in the avatar
|
||||
//if ( mousePressed == 1 )
|
||||
|
||||
if ( myAvatar.getMode() == AVATAR_MODE_COMMUNICATING ) {
|
||||
//if ( myAvatar.getMode() == AVATAR_MODE_COMMUNICATING ) {
|
||||
float leftRight = ( mouseX - mouseStartX ) / (float)WIDTH;
|
||||
float downUp = ( mouseY - mouseStartY ) / (float)HEIGHT;
|
||||
float backFront = 0.0;
|
||||
glm::vec3 handMovement( leftRight, downUp, backFront );
|
||||
myAvatar.setHandMovement( handMovement );
|
||||
}
|
||||
/*}
|
||||
else {
|
||||
mouseStartX = mouseX;
|
||||
mouseStartY = mouseY;
|
||||
//mouseStartX = (float)WIDTH / 2.0f;
|
||||
//mouseStartY = (float)HEIGHT / 2.0f;
|
||||
}
|
||||
*/
|
||||
|
||||
//--------------------------------------------------------
|
||||
// when the mouse is being pressed, an 'action' is being
|
||||
|
@ -1348,14 +1346,13 @@ void idle(void) {
|
|||
}
|
||||
|
||||
//
|
||||
// Sample hardware, update view frustum if needed, send avatar data to mixer/agents
|
||||
// Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents
|
||||
//
|
||||
updateAvatar( 1.f/FPS );
|
||||
|
||||
|
||||
//test
|
||||
/*
|
||||
for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++)
|
||||
//loop through all the other avatars and simulate them.
|
||||
AgentList * agentList = AgentList::getInstance();
|
||||
for(std::vector<Agent>::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); agent++)
|
||||
{
|
||||
if (agent->getLinkedData() != NULL)
|
||||
{
|
||||
|
@ -1363,7 +1360,7 @@ void idle(void) {
|
|||
agentHead->simulate(1.f/FPS);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
updateAvatarHand(1.f/FPS);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
memcpy(destinationBuffer, &_handPosition, sizeof(float) * 3);
|
||||
destinationBuffer += sizeof(float) * 3;
|
||||
|
||||
//std::cout << _bodyPosition.x << ", " << _bodyPosition.y << ", " << _bodyPosition.z << "\n";
|
||||
std::cout << _handPosition.x << ", " << _handPosition.y << ", " << _handPosition.z << "\n";
|
||||
|
||||
return destinationBuffer - bufferStart;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue