From ecb5047e7cbeacc3c805a15d42d33901f841db45 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Wed, 17 Apr 2013 16:58:04 -0700 Subject: [PATCH] removed initializeAvatar() method in Head class (deprecated). and also un-negated the pos in the rendering of other avatars (same fix as Philip just made) --- interface/src/Head.cpp | 118 +++++++++++---------------- interface/src/Head.h | 1 - interface/src/main.cpp | 5 +- libraries/avatars/src/AvatarData.cpp | 4 + 4 files changed, 55 insertions(+), 73 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 3bb78aa5bb..d691bc2e1b 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -49,7 +49,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 ); @@ -133,7 +132,6 @@ Head::Head(bool isMine) { } Head::Head(const Head &otherHead) { - initializeAvatar(); _avatar.orientation.set( otherHead._avatar.orientation ); _avatar.velocity = otherHead._avatar.velocity; @@ -352,42 +350,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 (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 ( _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; + } + } + //---------------------------------------------------------- float translationalSpeed = glm::length( _avatar.velocity ); float rotationalSpeed = fabs( _bodyYawDelta ); @@ -403,7 +403,7 @@ void Head::simulate(float deltaTime) { //---------------------------------------------------------- // update body yaw by body yaw delta //---------------------------------------------------------- - _bodyYaw += _bodyYawDelta * deltaTime; + _bodyYaw += _bodyYawDelta * deltaTime; //---------------------------------------------------------- // (for now) set head yaw to body yaw @@ -650,7 +650,7 @@ void Head::renderHead( int faceToFace) { // 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); @@ -780,7 +780,7 @@ void Head::renderHead( int faceToFace) { glPopMatrix(); - } + //} glPopMatrix(); } @@ -797,29 +797,6 @@ 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; bgetLinkedData(); glPushMatrix(); glm::vec3 pos = agentHead->getBodyPosition(); - glTranslatef(-pos.x, -pos.y, -pos.z); + glTranslatef(pos.x, pos.y, pos.z); agentHead->render(0); glPopMatrix(); } @@ -839,7 +839,6 @@ void display(void) // brad's frustum for debugging if (::frustumOn) render_view_frustum(); - //Render my own avatar myAvatar.render(true); } @@ -1361,7 +1360,7 @@ 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 ); diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 02c97e3446..fe36b44817 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -57,6 +57,8 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) { destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll); + //printf( "_bodyYaw = %f\n", _bodyYaw ); + memcpy(destinationBuffer, &_handPosition, sizeof(float) * 3); destinationBuffer += sizeof(float) * 3; @@ -78,6 +80,8 @@ void AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) { sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t *)sourceBuffer, &_bodyPitch); sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t *)sourceBuffer, &_bodyRoll); + printf( "_bodyYaw = %f\n", _bodyYaw ); + memcpy(&_handPosition, sourceBuffer, sizeof(float) * 3); sourceBuffer += sizeof(float) * 3;