From 532dc285e71152775d4db551cbbae80443c7a17f Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 18 Apr 2013 01:16:54 -0700 Subject: [PATCH 1/8] Changed render_view_frustum() to handle broken camera yaw - I discovered that the Camera class has a Yaw that is actually 180deg off of true yaw. So when the avatar is facing at a yaw of 0deg, we were setting the camera to 180. This was causing the direction vectors to be rotated from where we expected them to be, and as a result the frustum was wrong - I did not fix the camera and the calls to glRotate() since I don't yet understan how these work. BUT. I did fix the frustum code to fix up this yaw before calculating the vectors --- interface/src/main.cpp | 39 ++++++++++++++++++----------- libraries/avatars/src/Orientation.h | 4 +++ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 87ad2873d1..5bcae2cbeb 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -530,30 +530,39 @@ void render_view_frustum() { glm::vec3 up; glm::vec3 right; float fov, nearClip, farClip; + float yaw, pitch, roll; // Camera or Head? if (::cameraFrustum) { position = ::myCamera.getPosition(); - direction = ::myCamera.getOrientation().getFront() * glm::vec3(1,1,-1); - up = ::myCamera.getOrientation().getUp() * glm::vec3(1,1,1); - right = ::myCamera.getOrientation().getRight() * glm::vec3(1,1,-1); - fov = ::myCamera.getFieldOfView(); - nearClip = ::myCamera.getNearClip(); - farClip = ::myCamera.getFarClip(); } else { position = ::myAvatar.getHeadPosition(); - direction = ::myAvatar.getHeadLookatDirection(); - up = ::myAvatar.getHeadLookatDirectionUp(); - right = ::myAvatar.getHeadLookatDirectionRight() * glm::vec3(-1,1,-1); - - // NOTE: we use the same lens details if we draw from the head - fov = ::myCamera.getFieldOfView(); - nearClip = ::myCamera.getNearClip(); - farClip = ::myCamera.getFarClip(); } + + // This bit of hackery is all because our Camera's report the incorrect yaw. + // For whatever reason, the camera has a yaw set to 180.0-trueYaw, so we basically + // need to get the "yaw" from the body + yaw = -(::myCamera.getOrientation().getYaw()-180); + pitch = ::myCamera.getOrientation().getPitch(); + roll = ::myCamera.getOrientation().getRoll(); + fov = ::myCamera.getFieldOfView(); + nearClip = ::myCamera.getNearClip(); + farClip = ::myCamera.getFarClip(); + + // We can't use the camera's Orientation because of it's broken yaw. so we make a new + // correct orientation to get our vectors + Orientation o; + o.yaw(yaw); + o.pitch(pitch); + o.roll(roll); + + direction = o.getFront(); + up = o.getUp(); + right = o.getRight(); /* printf("position.x=%f, position.y=%f, position.z=%f\n", position.x, position.y, position.z); + printf("yaw=%f, pitch=%f, roll=%f\n", yaw,pitch,roll); printf("direction.x=%f, direction.y=%f, direction.z=%f\n", direction.x, direction.y, direction.z); printf("up.x=%f, up.y=%f, up.z=%f\n", up.x, up.y, up.z); printf("right.x=%f, right.y=%f, right.z=%f\n", right.x, right.y, right.z); @@ -561,7 +570,7 @@ void render_view_frustum() { printf("nearClip=%f\n", nearClip); printf("farClip=%f\n", farClip); */ - + // Set the viewFrustum up with the correct position and orientation of the camera viewFrustum.setPosition(position); viewFrustum.setOrientation(direction,up,right); diff --git a/libraries/avatars/src/Orientation.h b/libraries/avatars/src/Orientation.h index becddbd338..06425cf5dc 100755 --- a/libraries/avatars/src/Orientation.h +++ b/libraries/avatars/src/Orientation.h @@ -34,6 +34,10 @@ public: void pitch ( float ); void roll ( float ); + float getYaw() { return _yaw; }; + float getPitch(){ return _pitch; }; + float getRoll(){ return _roll; }; + void set( Orientation ); void setToIdentity(); From 894715598c270bbd855c68103b0b393452dfdf3a Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 18 Apr 2013 08:49:07 -0700 Subject: [PATCH 2/8] fixed a comment --- interface/src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 5bcae2cbeb..89fd5f9848 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -539,9 +539,9 @@ void render_view_frustum() { position = ::myAvatar.getHeadPosition(); } - // This bit of hackery is all because our Camera's report the incorrect yaw. + // This bit of hackery is all because our Cameras report the incorrect yaw. // For whatever reason, the camera has a yaw set to 180.0-trueYaw, so we basically - // need to get the "yaw" from the body + // need to get the "yaw" from the camera and adjust it to be the trueYaw yaw = -(::myCamera.getOrientation().getYaw()-180); pitch = ::myCamera.getOrientation().getPitch(); roll = ::myCamera.getOrientation().getRoll(); From de6f33efa6e044cd6b598cf820e48307a000965c Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Thu, 18 Apr 2013 13:16:36 -0700 Subject: [PATCH 3/8] added "_" to all of Philip's old private members and tidied up the formatting in Head.h some --- interface/src/Head.cpp | 346 +++++++++++++------------- interface/src/Head.h | 109 ++++---- libraries/avatars/src/Orientation.cpp | 2 + 3 files changed, 227 insertions(+), 230 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index f39c62e1aa..e68a957c2d 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -16,9 +16,6 @@ #include #include #include -//#include -//#include -//#include //looks like we might not need this using namespace std; @@ -68,40 +65,45 @@ Head::Head(bool isMine) { _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; + for (int i = 0; i < MAX_DRIVE_KEYS; i++) _driveKeys[i] = false; - PupilSize = 0.10; - interPupilDistance = 0.6; - interBrowDistance = 0.75; - NominalPupilSize = 0.10; - _headYaw = 0.0; - EyebrowPitch[0] = EyebrowPitch[1] = -30; - EyebrowRoll[0] = 20; - EyebrowRoll[1] = -20; - MouthPitch = 0; - MouthYaw = 0; - MouthWidth = 1.0; - MouthHeight = 0.2; - EyeballPitch[0] = EyeballPitch[1] = 0; - EyeballScaleX = 1.2; EyeballScaleY = 1.5; EyeballScaleZ = 1.0; - EyeballYaw[0] = EyeballYaw[1] = 0; - PitchTarget = YawTarget = 0; - NoiseEnvelope = 1.0; - PupilConverge = 10.0; - leanForward = 0.0; - leanSideways = 0.0; - eyeContact = 1; - eyeContactTarget = LEFT_EYE; - scale = 1.0; - renderYaw = 0.0; - renderPitch = 0.0; - audioAttack = 0.0; - loudness = 0.0; - averageLoudness = 0.0; - lastLoudness = 0.0; - browAudioLift = 0.0; - noise = 0; - + _pupilSize = 0.10; + _interPupilDistance = 0.6; + _interBrowDistance = 0.75; + _nominalPupilSize = 0.10; + _headYaw = 0.0; + _eyebrowPitch[0] = -30; + _eyebrowPitch[1] = -30; + _eyebrowRoll [0] = 20; + _eyebrowRoll [1] = -20; + _mouthPitch = 0; + _mouthYaw = 0; + _mouthWidth = 1.0; + _mouthHeight = 0.2; + _eyeballPitch[0] = 0; + _eyeballPitch[1] = 0; + _eyeballScaleX = 1.2; + _eyeballScaleY = 1.5; + _eyeballScaleZ = 1.0; + _eyeballYaw[0] = 0; + _eyeballYaw[1] = 0; + _pitchTarget = 0; + _yawTarget = 0; + _noiseEnvelope = 1.0; + _pupilConverge = 10.0; + _leanForward = 0.0; + _leanSideways = 0.0; + _eyeContact = 1; + _eyeContactTarget = LEFT_EYE; + _scale = 1.0; + _renderYaw = 0.0; + _renderPitch = 0.0; + _audioAttack = 0.0; + _loudness = 0.0; + _averageLoudness = 0.0; + _lastLoudness = 0.0; + _browAudioLift = 0.0; + _noise = 0; _handBeingMoved = false; _previousHandBeingMoved = false; _movedHandOffset = glm::vec3( 0.0, 0.0, 0.0 ); @@ -109,7 +111,7 @@ Head::Head(bool isMine) { _springForce = 6.0f; _springVelocityDecay = 16.0f; - sphere = NULL; + _sphere = NULL; if (iris_texture.size() == 0) { switchToResourcesParentIfRequired(); @@ -120,18 +122,18 @@ Head::Head(bool isMine) { } for (int o=0; o BROW_LIFT_THRESHOLD) - browAudioLift += sqrt(audioAttack)/1000.0; + if (_audioAttack > BROW_LIFT_THRESHOLD) + _browAudioLift += sqrt(_audioAttack)/1000.0; - browAudioLift *= .90; + _browAudioLift *= .90; glPushMatrix(); - glTranslatef(-interBrowDistance/2.0,0.4,0.45); + 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); + 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); + glTranslatef(_interBrowDistance, 0, 0); } glPopMatrix(); @@ -785,73 +787,73 @@ void Head::renderHead(int faceToFace) { 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); + 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); + 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); + glTranslatef(_interPupilDistance/10.0, 0, 0.05); glRotatef(20, 0, 0, 1); - glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ); + glScalef(_eyeballScaleX, _eyeballScaleY, _eyeballScaleZ); glutSolidSphere(0.25, 30, 30); } glPopMatrix(); // Right Pupil - if (sphere == NULL) { - sphere = gluNewQuadric(); - gluQuadricTexture(sphere, GL_TRUE); + 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); + 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); + 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); + gluSphere(_sphere, _pupilSize, 15, 15); glDisable(GL_TEXTURE_2D); } glPopMatrix(); // Left Eye glColor3fv(eyeColor); - glTranslatef(interPupilDistance, 0, 0); + glTranslatef(_interPupilDistance, 0, 0); glPushMatrix(); { - glTranslatef(-interPupilDistance/10.0, 0, .05); + glTranslatef(-_interPupilDistance/10.0, 0, .05); glRotatef(-20, 0, 0, 1); - glScalef(EyeballScaleX, EyeballScaleY, EyeballScaleZ); + 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); + 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); + gluSphere(_sphere, _pupilSize, 15, 15); glDisable(GL_TEXTURE_2D); } @@ -939,7 +941,6 @@ void Head::initializeSkeleton() { _bone[ AVATAR_BONE_RIGHT_SHIN ].parent = AVATAR_BONE_RIGHT_THIGH; _bone[ AVATAR_BONE_RIGHT_FOOT ].parent = AVATAR_BONE_RIGHT_SHIN; - //---------------------------------------------------------- // specify the default pose position //---------------------------------------------------------- @@ -1143,11 +1144,10 @@ void Head::updateHandMovement() { transformedHandMovement += handShakePull; */ - _bone[ AVATAR_BONE_RIGHT_HAND ].position = DEBUG_otherAvatarListPosition[ _closestOtherAvatar ]; + _bone[ AVATAR_BONE_RIGHT_HAND ].position = _DEBUG_otherAvatarListPosition[ _closestOtherAvatar ]; } } } - //------------------------------------------------------------------------------- // determine the arm vector @@ -1282,8 +1282,8 @@ void Head::renderBody() { } void Head::SetNewHeadTarget(float pitch, float yaw) { - PitchTarget = pitch; - YawTarget = yaw; + _pitchTarget = pitch; + _yawTarget = yaw; } // getting data from Android transmitte app @@ -1301,17 +1301,17 @@ void Head::processTransmitterData(unsigned char* packetData, int numBytes) { &linX, &linY, &linZ, &rot1, &rot2, &rot3, &rot4); - if (transmitterPackets++ == 0) { - gettimeofday(&transmitterTimer, NULL); + if (_transmitterPackets++ == 0) { + gettimeofday(&_transmitterTimer, NULL); } const int TRANSMITTER_COUNT = 100; - if (transmitterPackets % TRANSMITTER_COUNT == 0) { + if (_transmitterPackets % TRANSMITTER_COUNT == 0) { // Every 100 packets, record the observed Hz of the transmitter data timeval now; gettimeofday(&now, NULL); - double msecsElapsed = diffclock(&transmitterTimer, &now); - transmitterHz = static_cast( (double)TRANSMITTER_COUNT/(msecsElapsed/1000.0) ); - transmitterTimer = now; + double msecsElapsed = diffclock(&_transmitterTimer, &now); + _transmitterHz = static_cast( (double)TRANSMITTER_COUNT/(msecsElapsed/1000.0) ); + _transmitterTimer = now; } /* NOTE: PR: Will add back in when ready to animate avatar hand diff --git a/interface/src/Head.h b/interface/src/Head.h index cedc242ea5..c3150f53b9 100644 --- a/interface/src/Head.h +++ b/interface/src/Head.h @@ -108,15 +108,15 @@ 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 setNoise (float mag) { _noise = mag; } 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;} - float getRenderYaw() {return renderYaw;} - float getRenderPitch() {return renderPitch;} + void setScale(float s) {_scale = s; }; + void setRenderYaw(float y) {_renderYaw = y;} + void setRenderPitch(float p) {_renderPitch = p;} + float getRenderYaw() {return _renderYaw;} + float getRenderPitch() {return _renderPitch;} void setLeanForward(float dist); void setLeanSideways(float dist); void addPitch(float p) {_headPitch -= p; } @@ -152,16 +152,16 @@ class Head : public AvatarData { void setHandMovement( glm::vec3 movement ); void updateHandMovement(); - float getLoudness() {return loudness;}; - float getAverageLoudness() {return averageLoudness;}; - void setAverageLoudness(float al) {averageLoudness = al;}; - void setLoudness(float l) {loudness = l;}; + float getLoudness() {return _loudness;}; + float getAverageLoudness() {return _averageLoudness;}; + void setAverageLoudness(float al) {_averageLoudness = al;}; + void setLoudness(float l) {_loudness = l;}; void SetNewHeadTarget(float, float); // Set what driving keys are being pressed to control thrust levels - void setDriveKeys(int key, bool val) { driveKeys[key] = val; }; - bool getDriveKeys(int key) { return driveKeys[key]; }; + void setDriveKeys(int key, bool val) { _driveKeys[key] = val; }; + bool getDriveKeys(int key) { return _driveKeys[key]; }; // Set/Get update the thrust that will move the avatar around void setThrust(glm::vec3 newThrust) { _avatar.thrust = newThrust; }; @@ -173,51 +173,48 @@ class Head : public AvatarData { // void processTransmitterData(unsigned char * packetData, int numBytes); - float getTransmitterHz() { return transmitterHz; }; + float getTransmitterHz() { return _transmitterHz; }; private: - bool _isMine; - float noise; + bool _isMine; + float _noise; float _headPitch; float _headYaw; float _headRoll; float _headPitchRate; float _headYawRate; float _headRollRate; - float EyeballPitch[2]; - float EyeballYaw[2]; - float EyebrowPitch[2]; - float EyebrowRoll[2]; - float EyeballScaleX, EyeballScaleY, EyeballScaleZ; - float interPupilDistance; - float interBrowDistance; - float NominalPupilSize; - float PupilSize; - float MouthPitch; - float MouthYaw; - float MouthWidth; - float MouthHeight; - float leanForward; - float leanSideways; - float PitchTarget; - float YawTarget; - float NoiseEnvelope; - float PupilConverge; - float scale; + float _eyeballPitch[2]; + float _eyeballYaw[2]; + float _eyebrowPitch[2]; + float _eyebrowRoll[2]; + float _eyeballScaleX, _eyeballScaleY, _eyeballScaleZ; + float _interPupilDistance; + float _interBrowDistance; + float _nominalPupilSize; + float _pupilSize; + float _mouthPitch; + float _mouthYaw; + float _mouthWidth; + float _mouthHeight; + float _leanForward; + float _leanSideways; + float _pitchTarget; + float _yawTarget; + float _noiseEnvelope; + float _pupilConverge; + float _scale; // Sound loudness information - float loudness, lastLoudness; - float averageLoudness; - float audioAttack; - float browAudioLift; + float _loudness, _lastLoudness; + float _averageLoudness; + float _audioAttack; + float _browAudioLift; - glm::vec3 _TEST_bigSpherePosition; - float _TEST_bigSphereRadius; - - //temporary - placeholder for real other avs - glm::vec3 DEBUG_otherAvatarListPosition [ NUM_OTHER_AVATARS ]; - float DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ]; - + glm::vec3 _TEST_bigSpherePosition; + float _TEST_bigSphereRadius; + glm::vec3 _DEBUG_otherAvatarListPosition[ NUM_OTHER_AVATARS ]; + float _DEBUG_otherAvatarListTimer [ NUM_OTHER_AVATARS ]; bool _triggeringAction; float _bodyYawDelta; float _closeEnoughToInteract; @@ -232,23 +229,21 @@ class Head : public AvatarData { AvatarBone _bone[ NUM_AVATAR_BONES ]; AvatarMode _mode; Avatar _avatar; + int _driveKeys[MAX_DRIVE_KEYS]; + int _eyeContact; + eyeContactTargets _eyeContactTarget; - int driveKeys[MAX_DRIVE_KEYS]; - - - int eyeContact; - eyeContactTargets eyeContactTarget; - - GLUquadric *sphere; + GLUquadric *_sphere; - float renderYaw, renderPitch; // Pitch from view frustum when this is own head. + 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 // - timeval transmitterTimer; - float transmitterHz; - int transmitterPackets; + timeval _transmitterTimer; + float _transmitterHz; + int _transmitterPackets; //----------------------------- // private methods... diff --git a/libraries/avatars/src/Orientation.cpp b/libraries/avatars/src/Orientation.cpp index 08a4467f35..1cedb7305e 100755 --- a/libraries/avatars/src/Orientation.cpp +++ b/libraries/avatars/src/Orientation.cpp @@ -20,6 +20,8 @@ using avatars_lib::printLog; // // tosh - yep, I noticed... :-) // +// JJV - I noticed too :-) +// static bool testingForNormalizationAndOrthogonality = false; Orientation::Orientation() { From d9099b5f5a2d660539671bd21b4f14486e4ed9a9 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 18 Apr 2013 13:34:37 -0700 Subject: [PATCH 4/8] removed 2 unneeded debug lines --- interface/src/SerialInterface.cpp | 3 +-- libraries/avatars/src/AvatarData.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index abc1e27bbf..9fe57ecaaf 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -169,7 +169,6 @@ void SerialInterface::readData() { int initialSamples = totalSamples; while (read(serialFd, &bufchar, 1) > 0) { - //printLof("%c", bufchar[0]); serialBuffer[serialBufferPos] = bufchar[0]; serialBufferPos++; // Have we reached end of a line of input? @@ -209,7 +208,7 @@ void SerialInterface::readData() { } if (totalSamples == GRAVITY_SAMPLES) { gravity = glm::normalize(gravity); - //printLof("gravity: %f,%f,%f\n", gravity.x, gravity.y, gravity.z); + printLog("gravity: %f,%f,%f\n", gravity.x, gravity.y, gravity.z); } totalSamples++; diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index ef6012ec76..22b395c475 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -67,7 +67,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) { memcpy(destinationBuffer, &_handPosition, sizeof(float) * 3); destinationBuffer += sizeof(float) * 3; - printLog("%f, %f, %f\n", _handPosition.x, _handPosition.y, _handPosition.z); + //printLog("%f, %f, %f\n", _handPosition.x, _handPosition.y, _handPosition.z); return destinationBuffer - bufferStart; } From 5443d80c6f4f5b4cb4b393866811c76d4e234463 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 18 Apr 2013 14:00:48 -0700 Subject: [PATCH 5/8] Removed negation of front vector which was reversing yaw in avatar skeleton. --- interface/src/Head.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index e68a957c2d..a18965a372 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -1026,7 +1026,7 @@ void Head::updateSkeleton() { 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 () ); + float zz = glm::dot( _bone[b].defaultPosePosition, _bone[b].orientation.getFront () ); glm::vec3 rotatedBoneVector( xx, yy, zz ); From 47ee9385302602e697856912039aa98dc385d1ff Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Thu, 18 Apr 2013 14:12:45 -0700 Subject: [PATCH 6/8] reversed x value in hand movement --- interface/src/Head.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index e68a957c2d..91a227a72a 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -866,9 +866,9 @@ void Head::renderHead(int faceToFace) { -void Head::setHandMovement( glm::vec3 movement ) { +void Head::setHandMovement( glm::vec3 handOffset ) { _handBeingMoved = true; - _movedHandOffset = movement; + _movedHandOffset = handOffset; } AvatarMode Head::getMode() { @@ -1024,9 +1024,9 @@ void Head::updateSkeleton() { _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 () ); + 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 ); @@ -1125,9 +1125,9 @@ void Head::updateHandMovement() { glm::vec3 transformedHandMovement; transformedHandMovement - = _avatar.orientation.getRight() * -_movedHandOffset.x - + _avatar.orientation.getUp() * -_movedHandOffset.y * 0.5f - + _avatar.orientation.getFront() * -_movedHandOffset.y; + = _avatar.orientation.getRight() * _movedHandOffset.x + + _avatar.orientation.getUp() * -_movedHandOffset.y * 0.5f + + _avatar.orientation.getFront() * -_movedHandOffset.y; _bone[ AVATAR_BONE_RIGHT_HAND ].position += transformedHandMovement; From 9ce1683c50efe75aa1dcf33ffdba56e74e3d0fd4 Mon Sep 17 00:00:00 2001 From: Jeffrey Ventrella Date: Thu, 18 Apr 2013 14:45:54 -0700 Subject: [PATCH 7/8] reversed strafe left right, and commented-out updateAvatarHand --- interface/src/Head.cpp | 6 +++--- interface/src/main.cpp | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/interface/src/Head.cpp b/interface/src/Head.cpp index 91a227a72a..6f77ee66dc 100644 --- a/interface/src/Head.cpp +++ b/interface/src/Head.cpp @@ -33,7 +33,7 @@ float MouthWidthChoices[3] = {0.5, 0.77, 0.3}; float browWidth = 0.8; float browThickness = 0.16; -bool usingBigSphereCollisionTest = true; +bool usingBigSphereCollisionTest = false; const float DECAY = 0.1; const float THRUST_MAG = 10.0; @@ -381,11 +381,11 @@ void Head::simulate(float deltaTime) { } if (_driveKeys[RIGHT]) { glm::vec3 right( _avatar.orientation.getRight().x, _avatar.orientation.getRight().y, _avatar.orientation.getRight().z ); - _avatar.thrust -= right * THRUST_MAG; + _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; + _avatar.thrust -= right * THRUST_MAG; } if (_driveKeys[UP]) { glm::vec3 up( _avatar.orientation.getUp().x, _avatar.orientation.getUp().y, _avatar.orientation.getUp().z ); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index d81838287e..82bc1d0bbd 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -363,6 +363,7 @@ void reset_sensors() } } +/* void updateAvatarHand(float deltaTime) { // If mouse is being dragged, send current force to the hand controller if (mousePressed == 1) @@ -376,6 +377,7 @@ void updateAvatarHand(float deltaTime) { //myAvatar.hand->addVelocity(vel*deltaTime); } } +*/ // // Using gyro data, update both view frustum and avatar head position @@ -1357,30 +1359,33 @@ void idle(void) { else { myAvatar.setTriggeringAction( false ); } + + float deltaTime = 1.f/FPS; // // Sample hardware, update view frustum if needed, Lsend avatar data to mixer/agents // updateAvatar( 1.f/FPS ); + //loop through all the other avatars and simulate them. AgentList * agentList = AgentList::getInstance(); for(std::vector::iterator agent = agentList->getAgents().begin(); agent != agentList->getAgents().end(); agent++) { if (agent->getLinkedData() != NULL) { - Head *agentHead = (Head *)agent->getLinkedData(); - agentHead->simulate(1.f/FPS); + Head *avatar = (Head *)agent->getLinkedData(); + avatar->simulate(deltaTime); } } + - - updateAvatarHand(1.f/FPS); + //updateAvatarHand(1.f/FPS); - field.simulate(1.f/FPS); - myAvatar.simulate(1.f/FPS); - balls.simulate(1.f/FPS); - cloud.simulate(1.f/FPS); + field.simulate (deltaTime); + myAvatar.simulate(deltaTime); + balls.simulate (deltaTime); + cloud.simulate (deltaTime); glutPostRedisplay(); lastTimeIdle = check; From 54cef39f51bb019850ba498f37c9e73a5b513311 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 18 Apr 2013 14:48:00 -0700 Subject: [PATCH 8/8] Fixed problem with avatars rendering at 2X their location --- interface/src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index d81838287e..0b02b9ecf3 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -830,8 +830,6 @@ void display(void) if (agent->getLinkedData() != NULL) { Head *agentHead = (Head *)agent->getLinkedData(); glPushMatrix(); - glm::vec3 pos = agentHead->getBodyPosition(); - glTranslatef(pos.x, pos.y, pos.z); agentHead->render(0); glPopMatrix(); }