added test 'other' avatar for proxemixs testing

This commit is contained in:
Jeffrey Ventrella 2013-04-11 15:32:35 -07:00
parent 6f0881f40d
commit 556f11a0c0
3 changed files with 188 additions and 113 deletions

View file

@ -86,9 +86,12 @@ Head::Head()
noise = 0; noise = 0;
handBeingMoved = false; handBeingMoved = false;
previousHandBeingMoved = false;
movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 );
sphere = NULL; sphere = NULL;
usingSprings = false;
springForce = 6.0f; springForce = 6.0f;
springToBodyTightness = 4.0f; springToBodyTightness = 4.0f;
@ -103,6 +106,12 @@ Head::Head()
std::cout << "error " << error << ": " << lodepng_error_text(error) << std::endl; std::cout << "error " << error << ": " << lodepng_error_text(error) << std::endl;
} }
} }
for (int o=0; o<NUM_OTHER_AVATARS; o++)
{
DEBUG_otherAvatarListTimer[o] = 0.0f;
DEBUG_otherAvatarListPosition[o] = glm::vec3( 0.0f, 0.0f, 0.0f );
}
} }
@ -174,18 +183,12 @@ Head::~Head()
} }
} }
//--------------------------------------------------- //---------------------------------------------------
Head* Head::clone() const Head* Head::clone() const
{ {
return new Head(*this); return new Head(*this);
} }
//--------------------------------------------------- //---------------------------------------------------
void Head::reset() void Head::reset()
{ {
@ -194,8 +197,6 @@ void Head::reset()
} }
//this pertains to moving the head with the glasses //this pertains to moving the head with the glasses
//--------------------------------------------------- //---------------------------------------------------
void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity) void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int head_mirror, glm::vec3 * gravity)
@ -241,7 +242,6 @@ void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int hea
} }
} }
//--------------------------------------------------- //---------------------------------------------------
void Head::addLean(float x, float z) { void Head::addLean(float x, float z) {
// Add Body lean as impulse // Add Body lean as impulse
@ -249,37 +249,90 @@ void Head::addLean(float x, float z) {
leanForward += z; leanForward += z;
} }
//------------------------------------
//---------------------------------------------------
void Head::setLeanForward(float dist){ void Head::setLeanForward(float dist){
leanForward = dist; leanForward = dist;
} }
//-------------------------------------
//---------------------------------------------------
void Head::setLeanSideways(float dist){ void Head::setLeanSideways(float dist){
leanSideways = dist; leanSideways = dist;
} }
//----------------------------------
void Head::simulate(float deltaTime) {
//-------------------------------------
// DEBUG - other avatars...
//-------------------------------------
closeEnoughToInteract = 2.0f;
closestOtherAvatar = -1;
float closestDistance = 10000.0f;
for (int o=0; o<NUM_OTHER_AVATARS; o++) {
//-------------------------------------
// move the debug other avatars around...
//-------------------------------------
DEBUG_otherAvatarListTimer[o] += deltaTime;
float x = 6.0f * sin( DEBUG_otherAvatarListTimer[o] * 0.07 + o * 129.0 );
float z = 6.0f * sin( DEBUG_otherAvatarListTimer[o] * 0.10 + o * 12.0 );
float y = 0.0f;
DEBUG_otherAvatarListPosition[o] = glm::vec3( x, y, z );
//-------------------------------------
// test other avs for proximity...
//-------------------------------------
glm::vec3 v( position );
v -= DEBUG_otherAvatarListPosition[o];
float distance = glm::length( v );
if ( distance < closeEnoughToInteract ) {
if ( distance < closestDistance ) {
closestDistance = distance;
closestOtherAvatar = o;
}
}
}
//printf( "closestOtherAvatar = %d \n", closestOtherAvatar );
//------------------------
// update avatar skeleton
// Simulate the avatar over time //------------------------
//---------------------------------------------------
void Head::simulate(float deltaTime)
{
updateAvatarSkeleton(); updateAvatarSkeleton();
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// update springy behavior: // reset hand and elbow position according to hand movement
//------------------------------------------------------------------------ //------------------------------------------------------------------------
updateAvatarSprings( deltaTime ); if ( handBeingMoved ){
if (! previousHandBeingMoved ){
initializeAvatarSprings();
usingSprings = true;
//printf( "just started moving hand\n" );
}
}
else{
if ( previousHandBeingMoved ){
usingSprings = false;
//printf( "just stopped moving hand\n" );
}
}
if ( handBeingMoved )
{
updateHandMovement();
updateAvatarSprings( deltaTime );
}
previousHandBeingMoved = handBeingMoved;
handBeingMoved = false;
const float THRUST_MAG = 10.0; const float THRUST_MAG = 10.0;
const float YAW_MAG = 300.0; const float YAW_MAG = 300.0;
@ -467,16 +520,57 @@ void Head::simulate(float deltaTime)
//--------------------------------------------------- //---------------------------------------------------
void Head::render(int faceToFace, int isMine) void Head::render(int faceToFace, int isMine)
{ {
//---------------------------------------------------
// show avatar position
//---------------------------------------------------
glPushMatrix(); glPushMatrix();
glTranslatef( position.x, position.y, position.z ); glTranslatef( position.x, position.y, position.z );
glScalef( 0.03, 0.03, 0.03 ); glScalef( 0.03, 0.03, 0.03 );
glutSolidSphere( 1, 10, 10 ); glutSolidSphere( 1, 10, 10 );
glPopMatrix(); glPopMatrix();
//---------------------------------------------------
// show avatar orientation
//---------------------------------------------------
renderOrientationDirections(avatar.bone[ AVATAR_BONE_HEAD ].position, avatar.bone[ AVATAR_BONE_HEAD ].orientation, 0.2f ); renderOrientationDirections(avatar.bone[ AVATAR_BONE_HEAD ].position, avatar.bone[ AVATAR_BONE_HEAD ].orientation, 0.2f );
//---------------------------------------------------
// render body
//---------------------------------------------------
renderBody(); renderBody();
//---------------------------------------------------
// render head
//---------------------------------------------------
renderHead( faceToFace, isMine ); renderHead( faceToFace, 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 ) {
glm::vec3 v1( avatar.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();
}
}
} }
@ -697,6 +791,8 @@ void Head::initializeAvatar()
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 ); avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
avatar.orientation.setToIdentity(); avatar.orientation.setToIdentity();
closestOtherAvatar = 0;
avatar.yaw = -90.0; avatar.yaw = -90.0;
avatar.pitch = 0.0; avatar.pitch = 0.0;
avatar.roll = 0.0; avatar.roll = 0.0;
@ -847,19 +943,19 @@ void Head::updateAvatarSkeleton()
glm::vec3 rotatedBoneVector( xx, yy, zz ); glm::vec3 rotatedBoneVector( xx, yy, zz );
avatar.bone[b].position += rotatedBoneVector; avatar.bone[b].position += rotatedBoneVector;
} }
//------------------------------------------------------------------------
// reset hand and elbow position according to hand movement
//------------------------------------------------------------------------
if ( handBeingMoved )
{
updateHandMovement();
handBeingMoved = false;
}
} }
//-----------------------------------------------
void Head::initializeAvatarSprings() {
for (int b=0; b<NUM_AVATAR_BONES; b++) {
avatar.bone[b].springyPosition = avatar.bone[b].position;
avatar.bone[b].springyVelocity = glm::vec3( 0.0f, 0.0f, 0.0f );
}
}
//----------------------------------------------- //-----------------------------------------------
void Head::updateAvatarSprings( float deltaTime ) void Head::updateAvatarSprings( float deltaTime )
@ -1057,87 +1153,57 @@ void Head::renderBody()
//----------------------------------------- //-----------------------------------------
for (int b=0; b<NUM_AVATAR_BONES; b++) for (int b=0; b<NUM_AVATAR_BONES; b++)
{ {
glColor3fv( skinColor ); if ( usingSprings )
//glColor4f( 1.0f, 0.8f, 0.6f, 0.4f ); {
glPushMatrix(); glColor3fv( lightBlue );
glTranslatef( avatar.bone[b].position.x, avatar.bone[b].position.y, avatar.bone[b].position.z ); glPushMatrix();
glutSolidSphere( 0.02f, 10.0f, 5.0f ); glTranslatef( avatar.bone[b].springyPosition.x, avatar.bone[b].springyPosition.y, avatar.bone[b].springyPosition.z );
glPopMatrix(); glutSolidSphere( 0.02f, 10.0f, 5.0f );
glPopMatrix();
glColor4fv( lightBlue ); }
glPushMatrix(); else
glTranslatef( avatar.bone[b].springyPosition.x, avatar.bone[b].springyPosition.y, avatar.bone[b].springyPosition.z ); {
glutSolidSphere( 0.01f, 10.0f, 5.0f ); glColor3fv( skinColor );
glPopMatrix(); glPushMatrix();
glTranslatef( avatar.bone[b].position.x, avatar.bone[b].position.y, avatar.bone[b].position.z );
glutSolidSphere( 0.02f, 10.0f, 5.0f );
glPopMatrix();
}
} }
//----------------------------------------------------- //-----------------------------------------------------
// Render lines connecting the bone positions // Render lines connecting the bone positions
//----------------------------------------------------- //-----------------------------------------------------
//glColor3f(1,1,1); if ( usingSprings )
glColor3fv( skinColor );
//glColor4f( 1.0f, 0.8f, 0.6f, 0.4f );
glLineWidth(3.0);
for (int b=1; b<NUM_AVATAR_BONES; b++)
{ {
glBegin( GL_LINE_STRIP ); glColor3f( 0.2f, 0.3f, 0.4f );
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].position.x ); glLineWidth(3.0);
glVertex3fv( &avatar.bone[ b ].position.x);
glEnd(); for (int b=1; b<NUM_AVATAR_BONES; b++)
{
glBegin( GL_LINE_STRIP );
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].springyPosition.x );
glVertex3fv( &avatar.bone[ b ].springyPosition.x );
glEnd();
}
}
else
{
glColor3fv( skinColor );
glLineWidth(3.0);
for (int b=1; b<NUM_AVATAR_BONES; b++)
{
glBegin( GL_LINE_STRIP );
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].position.x );
glVertex3fv( &avatar.bone[ b ].position.x);
glEnd();
}
} }
//----------------------------------------------------- //-----------------------------------------------------
// Render lines connecting the springy positions // Render lines connecting the springy positions
//----------------------------------------------------- //-----------------------------------------------------
glColor3f( 0.2f, 0.3f, 0.4f );
glLineWidth(3.0);
for (int b=1; b<NUM_AVATAR_BONES; b++)
{
glBegin( GL_LINE_STRIP );
glVertex3fv( &avatar.bone[ avatar.bone[ b ].parent ].springyPosition.x );
glVertex3fv( &avatar.bone[ b ].springyPosition.x );
glEnd();
}
/*
glBegin(GL_LINE_STRIP);
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_NECK].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_SHOULDER].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_UPPER_ARM].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_FOREARM].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_HAND].position.x);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_SHOULDER].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_UPPER_ARM].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_FOREARM].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_HAND].position.x);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3fv(&avatar.bone[AVATAR_BONE_CHEST_SPINE].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_MID_SPINE].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_PELVIS_SPINE].position.x);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3fv(&avatar.bone[AVATAR_BONE_PELVIS_SPINE].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_PELVIS].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_THIGH].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_SHIN].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_LEFT_FOOT].position.x);
glEnd();
glBegin(GL_LINE_STRIP);
glVertex3fv(&avatar.bone[AVATAR_BONE_PELVIS_SPINE].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_PELVIS].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_THIGH].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_SHIN].position.x);
glVertex3fv(&avatar.bone[AVATAR_BONE_RIGHT_FOOT].position.x);
glEnd();
*/
} }
@ -1152,6 +1218,7 @@ int Head::getBroadcastData(char* data)
// Copy data for transmission to the buffer, return length of data // Copy data for transmission to the buffer, return length of data
sprintf(data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f", sprintf(data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
getRenderPitch() + Pitch, -getRenderYaw() + 180 -Yaw, Roll, getRenderPitch() + Pitch, -getRenderYaw() + 180 -Yaw, Roll,
//avatar.yaw, avatar.pitch, avatar.roll,
position.x + leanSideways, position.y, position.z + leanForward, position.x + leanSideways, position.y, position.z + leanForward,
loudness, averageLoudness, loudness, averageLoudness,
//hand->getPos().x, hand->getPos().y, hand->getPos().z); //previous to Ventrella change //hand->getPos().x, hand->getPos().y, hand->getPos().z); //previous to Ventrella change
@ -1170,6 +1237,7 @@ void Head::parseData(void *data, int size)
( (
(char *)data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f", (char *)data, "H%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f",
&Pitch, &Yaw, &Roll, &Pitch, &Yaw, &Roll,
//&avatar.yaw, &avatar.pitch, &avatar.roll,
&position.x, &position.y, &position.z, &position.x, &position.y, &position.z,
&loudness, &averageLoudness, &loudness, &averageLoudness,
&avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x, &avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x,

View file

@ -30,6 +30,8 @@ enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
#define ROT_RIGHT 7 #define ROT_RIGHT 7
#define MAX_DRIVE_KEYS 8 #define MAX_DRIVE_KEYS 8
#define NUM_OTHER_AVATARS 5
/* /*
enum AvatarJoints enum AvatarJoints
{ {
@ -237,7 +239,15 @@ class Head : public AgentData {
//glm::vec3 velocity; //glm::vec3 velocity;
//glm::vec3 thrust; //glm::vec3 thrust;
float closeEnoughToInteract;
int closestOtherAvatar;
glm::vec3 DEBUG_otherAvatarListPosition [ NUM_OTHER_AVATARS ];
float DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ];
bool usingSprings;
bool handBeingMoved; bool handBeingMoved;
bool previousHandBeingMoved;
glm::vec3 movedHandOffset; glm::vec3 movedHandOffset;
//glm::vec3 movedHandPosition; //glm::vec3 movedHandPosition;
@ -255,6 +265,7 @@ class Head : public AgentData {
void initializeAvatar(); void initializeAvatar();
void updateAvatarSkeleton(); void updateAvatarSkeleton();
void initializeAvatarSprings();
void updateAvatarSprings( float deltaTime ); void updateAvatarSprings( float deltaTime );
void calculateBoneLengths(); void calculateBoneLengths();

View file

@ -827,10 +827,8 @@ void display(void)
if (displayField) field.render(); if (displayField) field.render();
// Render avatars of other agents // Render avatars of other agents
for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) for(std::vector<Agent>::iterator agent = agentList.getAgents().begin(); agent != agentList.getAgents().end(); agent++) {
{ if (agent->getLinkedData() != NULL) {
if (agent->getLinkedData() != NULL)
{
Head *agentHead = (Head *)agent->getLinkedData(); Head *agentHead = (Head *)agent->getLinkedData();
glPushMatrix(); glPushMatrix();
glm::vec3 pos = agentHead->getPos(); glm::vec3 pos = agentHead->getPos();
@ -870,8 +868,7 @@ void display(void)
if (audioScope.getState()) audioScope.render(); if (audioScope.getState()) audioScope.render();
#endif #endif
if (displayHeadMouse && !displayHead && statsOn) if (displayHeadMouse && !displayHead && statsOn) {
{
// Display small target box at center or head mouse target that can also be used to measure LOD // Display small target box at center or head mouse target that can also be used to measure LOD
glColor3f(1.0, 1.0, 1.0); glColor3f(1.0, 1.0, 1.0);
glDisable(GL_LINE_SMOOTH); glDisable(GL_LINE_SMOOTH);
@ -1026,8 +1023,7 @@ void shiftPaintingColor()
::paintingVoxel.blue = (::dominantColor==2)?randIntInRange(200,255):randIntInRange(40,100); ::paintingVoxel.blue = (::dominantColor==2)?randIntInRange(200,255):randIntInRange(40,100);
} }
void setupPaintingVoxel() void setupPaintingVoxel() {
{
glm::vec3 avatarPos = myAvatar.getPos(); glm::vec3 avatarPos = myAvatar.getPos();
::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space ::paintingVoxel.x = avatarPos.z/-10.0; // voxel space x is negative z head space