Merge remote-tracking branch 'origin'

This commit is contained in:
Philip Rosedale 2013-04-10 00:25:20 -07:00
commit 7edd93fd2c
3 changed files with 69 additions and 47 deletions

View file

@ -272,7 +272,7 @@ void Head::setLeanSideways(float dist){
// Simulate the head over time
// Simulate the avatar over time
//---------------------------------------------------
void Head::simulate(float deltaTime)
{
@ -293,64 +293,50 @@ void Head::simulate(float deltaTime)
thrust = glm::vec3(0);
*/
const float THRUST_MAG = 10.0;
const float THRUST_LATERAL_MAG = 10.0;
const float THRUST_VERTICAL_MAG = 10.0;
const float THRUST_MAG = 10.0;
const float YAW_MAG = 300.0;
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
//notice that the z values from avatar.orientation are flipped to accommodate different coordinate system
if (driveKeys[FWD])
{
avatar.thrust.x += avatar.orientation.getFront().getX() * THRUST_MAG;
avatar.thrust.y += avatar.orientation.getFront().getY() * THRUST_MAG;
avatar.thrust.z -= avatar.orientation.getFront().getZ() * THRUST_MAG;
//thrust += THRUST_MAG*forward;
glm::vec3 front( avatar.orientation.getFront().getX(), avatar.orientation.getFront().getY(), -avatar.orientation.getFront().getZ() );
avatar.thrust += front * THRUST_MAG;
}
if (driveKeys[BACK])
{
avatar.thrust.x -= avatar.orientation.getFront().getX() * THRUST_MAG;
avatar.thrust.y -= avatar.orientation.getFront().getY() * THRUST_MAG;
avatar.thrust.z += avatar.orientation.getFront().getZ() * THRUST_MAG;
//thrust += -THRUST_MAG*forward;
glm::vec3 front( avatar.orientation.getFront().getX(), avatar.orientation.getFront().getY(), -avatar.orientation.getFront().getZ() );
avatar.thrust -= front * THRUST_MAG;
}
if (driveKeys[RIGHT])
{
avatar.thrust.x += avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG;
avatar.thrust.y += avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG;
avatar.thrust.z -= avatar.orientation.getRight().getZ() * THRUST_LATERAL_MAG;
//thrust.x += forward.z*-THRUST_LATERAL_MAG;
//thrust.z += forward.x*THRUST_LATERAL_MAG;
glm::vec3 right( avatar.orientation.getRight().getX(), avatar.orientation.getRight().getY(), -avatar.orientation.getRight().getZ() );
avatar.thrust += right * THRUST_MAG;
}
if (driveKeys[LEFT])
{
avatar.thrust.x -= avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG;
avatar.thrust.y -= avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG;
avatar.thrust.z += avatar.orientation.getRight().getZ() * THRUST_LATERAL_MAG;
//thrust.x += forward.z*THRUST_LATERAL_MAG;
//thrust.z += forward.x*-THRUST_LATERAL_MAG;
glm::vec3 right( avatar.orientation.getRight().getX(), avatar.orientation.getRight().getY(), -avatar.orientation.getRight().getZ() );
avatar.thrust -= right * THRUST_MAG;
}
if (driveKeys[UP])
{
avatar.thrust.x -= avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG;
avatar.thrust.y -= avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG;
avatar.thrust.z += avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG;
//thrust.y += -THRUST_VERTICAL_MAG;
glm::vec3 up( avatar.orientation.getUp().getX(), avatar.orientation.getUp().getY(), -avatar.orientation.getUp().getZ() );
avatar.thrust += up * THRUST_MAG;
}
if (driveKeys[DOWN])
{
avatar.thrust.x += avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG;
avatar.thrust.y += avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG;
avatar.thrust.z -= avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG;
//thrust.y += THRUST_VERTICAL_MAG;
glm::vec3 up( avatar.orientation.getUp().getX(), avatar.orientation.getUp().getY(), -avatar.orientation.getUp().getZ() );
avatar.thrust -= up * THRUST_MAG;
}
if (driveKeys[ROT_RIGHT])
{
avatar.yawDelta -= 300.0 * deltaTime;
avatar.yawDelta -= YAW_MAG * deltaTime;
}
if (driveKeys[ROT_LEFT])
{
avatar.yawDelta += 300.0 * deltaTime;
avatar.yawDelta += YAW_MAG * deltaTime;
}
avatar.yaw += avatar.yawDelta * deltaTime;
@ -910,6 +896,18 @@ float Head::getAvatarYaw()
}
//-------------------------------------------
glm::vec3 Head::getAvatarHeadLookatDirection()
{
return glm::vec3
(
avatar.bone[ AVATAR_BONE_HEAD ].worldOrientation.getFront().x,
avatar.bone[ AVATAR_BONE_HEAD ].worldOrientation.getFront().y,
avatar.bone[ AVATAR_BONE_HEAD ].worldOrientation.getFront().z
);
}
//-------------------------------
void Head::updateHandMovement()

View file

@ -103,15 +103,15 @@ enum AvatarBones
struct AvatarBone
{
AvatarBones parent;
glm::vec3 worldPosition;
glm::vec3 defaultPosePosition;
glm::dvec3 velocity;
float yaw;
float pitch;
float roll;
Orientation worldOrientation;
float length;
AvatarBones parent; // which bone is this bone connected to?
glm::vec3 worldPosition; // the position at the "end" of the bone
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
glm::dvec3 velocity; // pertains to spring physics
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 roll; // the roll Euler angle of the bone rotation off the parent
Orientation worldOrientation; // three orthogonal normals determined by yaw, pitch, roll
float length; // the length of the bone
};
struct Avatar
@ -158,6 +158,7 @@ class Head : public AgentData {
float getLastMeasuredYaw() {return YawRate;}
float getAvatarYaw();
glm::vec3 getAvatarHeadLookatDirection();
void render(int faceToFace, int isMine);

View file

@ -108,6 +108,8 @@ int starsTiles = 20;
double starsLod = 1.0;
#endif
bool showingVoxels = false;
glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
ParticleSystem balls(0,
@ -511,6 +513,8 @@ void simulateHead(float frametime)
void display(void)
{
//printf( "avatar head lookat = %f, %f, %f\n", myHead.getAvatarHeadLookatDirection().x, myHead.getAvatarHeadLookatDirection().y, myHead.getAvatarHeadLookatDirection().z );
PerfStat("display");
glEnable(GL_LINE_SMOOTH);
@ -560,7 +564,7 @@ void display(void)
// set the camera to third-person view behind my av
//----------------------------------------------------
myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() );
myCamera.setPitch ( 10.0 );
myCamera.setPitch ( 0.0 );
myCamera.setRoll ( 0.0 );
myCamera.setUp ( 0.2 );
myCamera.setDistance( 1.6 );
@ -584,17 +588,34 @@ void display(void)
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
//---------------------------------------------
// draw a red sphere
//---------------------------------------------
float sphereRadius = 0.25f;
glColor3f(1,0,0);
glutSolidSphere(0.25, 15, 15);
glPushMatrix();
glTranslatef( 0.0f, sphereRadius, 0.0f );
glutSolidSphere( sphereRadius, 15, 15 );
glPopMatrix();
//---------------------------------------------
// draw a grid gound plane....
//---------------------------------------------
drawGroundPlaneGrid( 5.0f, 9 );
// Draw cloud of dots
glDisable( GL_POINT_SPRITE_ARB );
glDisable( GL_TEXTURE_2D );
if (!displayHead) cloud.render();
// Draw voxels
voxels.render();
if ( showingVoxels )
{
voxels.render();
}
// Draw field vectors
if (displayField) field.render();
@ -1062,6 +1083,8 @@ void audioMixerUpdate(in_addr_t newMixerAddress, in_port_t newMixerPort) {
}
#endif
int main(int argc, const char * argv[])
{
const char* domainIP = getCmdOption(argc, argv, "--domain");