reversed left-right strafe

This commit is contained in:
Jeffrey Ventrella 2013-04-11 13:06:47 -07:00
parent b08c0b7159
commit 6f0881f40d
2 changed files with 31 additions and 39 deletions

View file

@ -49,7 +49,7 @@ Head::Head()
//position = glm::vec3(0,0,0);
//velocity = glm::vec3(0,0,0);
thrust = glm::vec3(0,0,0);
//thrust = glm::vec3(0,0,0);
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = false;
@ -92,7 +92,7 @@ Head::Head()
springForce = 6.0f;
springToBodyTightness = 4.0f;
springVelocityDecay = 2.0f;
springVelocityDecay = 16.0f;
hand = new Hand(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
@ -115,7 +115,7 @@ Head::Head(const Head &otherHead)
position = otherHead.position;
//velocity = otherHead.velocity;
thrust = otherHead.thrust;
//thrust = otherHead.thrust;
for (int i = 0; i < MAX_DRIVE_KEYS; i++) driveKeys[i] = otherHead.driveKeys[i];
PupilSize = otherHead.PupilSize;
@ -299,12 +299,12 @@ 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])
{
@ -840,28 +840,9 @@ void Head::updateAvatarSkeleton()
avatar.bone[b].position = avatar.bone[ avatar.bone[b].parent ].position;
}
/*
float xx = glm::dot( avatar.bone[b].defaultPosePosition.x, (float)avatar.bone[b].orientation.getRight ().x )
+ glm::dot( avatar.bone[b].defaultPosePosition.y, (float)avatar.bone[b].orientation.getRight ().y )
+ glm::dot( avatar.bone[b].defaultPosePosition.z, (float)avatar.bone[b].orientation.getRight ().z );
float yy = glm::dot( avatar.bone[b].defaultPosePosition.x, (float)avatar.bone[b].orientation.getUp ().x )
+ glm::dot( avatar.bone[b].defaultPosePosition.y, (float)avatar.bone[b].orientation.getUp ().y )
+ glm::dot( avatar.bone[b].defaultPosePosition.z, (float)avatar.bone[b].orientation.getUp ().z );
float zz = glm::dot( avatar.bone[b].defaultPosePosition.x, (float)avatar.bone[b].orientation.getFront ().x )
+ glm::dot( avatar.bone[b].defaultPosePosition.y, (float)avatar.bone[b].orientation.getFront ().y )
+ glm::dot( avatar.bone[b].defaultPosePosition.z, (float)avatar.bone[b].orientation.getFront ().z );
*/
float xx = glm::dot( avatar.bone[b].defaultPosePosition, avatar.bone[b].orientation.getRight () );
float yy = glm::dot( avatar.bone[b].defaultPosePosition, avatar.bone[b].orientation.getUp () );
float zz = -glm::dot( avatar.bone[b].defaultPosePosition, avatar.bone[b].orientation.getFront () );
//float xx = avatar.bone[b].defaultPosePosition.x;
//float yy = avatar.bone[b].defaultPosePosition.y;
//float zz = avatar.bone[b].defaultPosePosition.z;
float xx = glm::dot( avatar.bone[b].defaultPosePosition, avatar.bone[b].orientation.getRight() );
float yy = glm::dot( avatar.bone[b].defaultPosePosition, avatar.bone[b].orientation.getUp () );
float zz = -glm::dot( avatar.bone[b].defaultPosePosition, avatar.bone[b].orientation.getFront() );
glm::vec3 rotatedBoneVector( xx, yy, zz );
avatar.bone[b].position += rotatedBoneVector;
@ -913,10 +894,20 @@ void Head::updateAvatarSprings( float deltaTime )
}
avatar.bone[b].springyVelocity += ( avatar.bone[b].position - avatar.bone[b].springyPosition ) * springToBodyTightness * deltaTime;
avatar.bone[b].springyVelocity *= 0.8;
avatar.bone[b].springyVelocity *= ( 1.0 - springVelocityDecay * deltaTime );
float decay = 1.0 - springVelocityDecay * deltaTime;
if ( decay > 0.0 )
{
avatar.bone[b].springyVelocity *= decay;
}
else
{
avatar.bone[b].springyVelocity = glm::vec3( 0.0f, 0.0f, 0.0f );
}
avatar.bone[b].springyPosition += avatar.bone[b].springyVelocity;
}
}
@ -1067,12 +1058,13 @@ void Head::renderBody()
for (int b=0; b<NUM_AVATAR_BONES; b++)
{
glColor3fv( skinColor );
//glColor4f( 1.0f, 0.8f, 0.6f, 0.4f );
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();
glColor3fv( lightBlue );
glColor4fv( lightBlue );
glPushMatrix();
glTranslatef( avatar.bone[b].springyPosition.x, avatar.bone[b].springyPosition.y, avatar.bone[b].springyPosition.z );
glutSolidSphere( 0.01f, 10.0f, 5.0f );
@ -1082,7 +1074,9 @@ void Head::renderBody()
//-----------------------------------------------------
// Render lines connecting the bone positions
//-----------------------------------------------------
glColor3f(1,1,1);
//glColor3f(1,1,1);
glColor3fv( skinColor );
//glColor4f( 1.0f, 0.8f, 0.6f, 0.4f );
glLineWidth(3.0);
for (int b=1; b<NUM_AVATAR_BONES; b++)
@ -1163,7 +1157,7 @@ int Head::getBroadcastData(char* data)
//hand->getPos().x, hand->getPos().y, hand->getPos().z); //previous to Ventrella change
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.x,
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.y,
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.z ); // Ventrella change
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].position.z );
return strlen(data);
}

View file

@ -116,7 +116,6 @@ struct AvatarBone
struct Avatar
{
//glm::vec3 position;
glm::dvec3 velocity;
glm::vec3 thrust;
float yaw;
@ -166,7 +165,6 @@ class Head : public AgentData {
void render(int faceToFace, int isMine);
//void setAvatarPosition( float, float, float );
void renderBody();
void renderHead( int faceToFace, int isMine );
void renderOrientationDirections( glm::vec3 position, Orientation orientation, float size );
@ -194,9 +192,9 @@ class Head : public AgentData {
bool getDriveKeys(int key) { return driveKeys[key]; };
// Set/Get update the thrust that will move the avatar around
void setThrust(glm::vec3 newThrust) { thrust = newThrust; };
void addThrust(glm::vec3 newThrust) { thrust += newThrust; };
glm::vec3 getThrust() { return thrust; };
void setThrust(glm::vec3 newThrust) { avatar.thrust = newThrust; };
void addThrust(glm::vec3 newThrust) { avatar.thrust += newThrust; };
glm::vec3 getThrust() { return avatar.thrust; };
Hand * hand;
@ -237,7 +235,7 @@ class Head : public AgentData {
glm::vec3 position;
//glm::vec3 velocity;
glm::vec3 thrust;
//glm::vec3 thrust;
bool handBeingMoved;
glm::vec3 movedHandOffset;