added more cleanup and preparation for switching over to quaternions

This commit is contained in:
Jeffrey Ventrella 2013-04-17 15:32:16 -07:00
parent a44ff94f85
commit 0306b63af4
3 changed files with 36 additions and 27 deletions

View file

@ -18,6 +18,9 @@
#include <AgentList.h> #include <AgentList.h>
#include <AgentTypes.h> #include <AgentTypes.h>
#include <PacketHeaders.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; using namespace std;
@ -529,8 +532,6 @@ void Head::simulate(float deltaTime) {
void Head::render(int faceToFace, int isMine) { void Head::render(int faceToFace, int isMine) {
//--------------------------------------------------- //---------------------------------------------------
@ -944,18 +945,19 @@ void Head::updateSkeleton() {
_avatar.orientation.setToIdentity(); _avatar.orientation.setToIdentity();
_avatar.orientation.yaw( _bodyYaw ); _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: // calculate positions of all bones by traversing the skeleton tree:
//------------------------------------------------------------------------ //------------------------------------------------------------------------
for (int b=0; b<NUM_AVATAR_BONES; b++) { for (int b=0; b<NUM_AVATAR_BONES; b++) {
if ( _bone[b].parent == AVATAR_BONE_NULL ) { if ( _bone[b].parent == AVATAR_BONE_NULL ) {
_bone[b].orientation.set( _avatar.orientation ); _bone[b].orientation.set( _avatar.orientation );
//printf( "bodyPosition = %f, %f, %f\n", bodyPosition.x, bodyPosition.y, bodyPosition.z ); _bone[b].position = _bodyPosition;
glm::vec3 ppp = _bodyPosition;
// ppp.y += 0.2;
_bone[b].position = ppp;// + glm::vec3( 0.0f, 1.0f, 0.0f ) * 1.0f;
} }
else { else {
_bone[b].orientation.set( _bone[ _bone[b].parent ].orientation ); _bone[b].orientation.set( _bone[ _bone[b].parent ].orientation );
@ -967,6 +969,10 @@ void Head::updateSkeleton() {
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 ); glm::vec3 rotatedBoneVector( xx, yy, zz );
//glm::vec3 myEuler ( 0.0f, 0.0f, 0.0f );
//glm::quat myQuat ( myEuler );
_bone[b].position += rotatedBoneVector; _bone[b].position += rotatedBoneVector;
} }
} }
@ -1057,6 +1063,8 @@ glm::vec3 Head::getHeadPosition() {
); );
} }
void Head::updateHandMovement() { void Head::updateHandMovement() {
glm::vec3 transformedHandMovement; glm::vec3 transformedHandMovement;

View file

@ -22,8 +22,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/quaternion.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}; enum eyeContactTargets {LEFT_EYE, RIGHT_EYE, MOUTH};
@ -85,7 +84,7 @@ struct AvatarBone
glm::vec3 springyPosition; // used for special effects (a 'flexible' variant of position) 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) 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 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 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 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 float roll; // the roll Euler angle of the bone rotation off the parent

View file

@ -58,6 +58,8 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll); destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
//printf( "_bodyYaw = %f\n", _bodyYaw );
return destinationBuffer - bufferStart; return destinationBuffer - bufferStart;
} }