mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:17:58 +02:00
Merge remote-tracking branch 'origin'
This commit is contained in:
commit
7edd93fd2c
3 changed files with 69 additions and 47 deletions
|
@ -272,7 +272,7 @@ void Head::setLeanSideways(float dist){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Simulate the head over time
|
// Simulate the avatar over time
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
void Head::simulate(float deltaTime)
|
void Head::simulate(float deltaTime)
|
||||||
{
|
{
|
||||||
|
@ -293,64 +293,50 @@ void Head::simulate(float deltaTime)
|
||||||
thrust = glm::vec3(0);
|
thrust = glm::vec3(0);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const float THRUST_MAG = 10.0;
|
const float THRUST_MAG = 10.0;
|
||||||
const float THRUST_LATERAL_MAG = 10.0;
|
const float YAW_MAG = 300.0;
|
||||||
const float THRUST_VERTICAL_MAG = 10.0;
|
|
||||||
|
|
||||||
avatar.thrust = glm::vec3( 0.0, 0.0, 0.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])
|
if (driveKeys[FWD])
|
||||||
{
|
{
|
||||||
avatar.thrust.x += avatar.orientation.getFront().getX() * THRUST_MAG;
|
glm::vec3 front( avatar.orientation.getFront().getX(), avatar.orientation.getFront().getY(), -avatar.orientation.getFront().getZ() );
|
||||||
avatar.thrust.y += avatar.orientation.getFront().getY() * THRUST_MAG;
|
avatar.thrust += front * THRUST_MAG;
|
||||||
avatar.thrust.z -= avatar.orientation.getFront().getZ() * THRUST_MAG;
|
|
||||||
//thrust += THRUST_MAG*forward;
|
|
||||||
}
|
}
|
||||||
if (driveKeys[BACK])
|
if (driveKeys[BACK])
|
||||||
{
|
{
|
||||||
avatar.thrust.x -= avatar.orientation.getFront().getX() * THRUST_MAG;
|
glm::vec3 front( avatar.orientation.getFront().getX(), avatar.orientation.getFront().getY(), -avatar.orientation.getFront().getZ() );
|
||||||
avatar.thrust.y -= avatar.orientation.getFront().getY() * THRUST_MAG;
|
avatar.thrust -= front * THRUST_MAG;
|
||||||
avatar.thrust.z += avatar.orientation.getFront().getZ() * THRUST_MAG;
|
|
||||||
//thrust += -THRUST_MAG*forward;
|
|
||||||
}
|
}
|
||||||
if (driveKeys[RIGHT])
|
if (driveKeys[RIGHT])
|
||||||
{
|
{
|
||||||
avatar.thrust.x += avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG;
|
glm::vec3 right( avatar.orientation.getRight().getX(), avatar.orientation.getRight().getY(), -avatar.orientation.getRight().getZ() );
|
||||||
avatar.thrust.y += avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG;
|
avatar.thrust += right * THRUST_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;
|
|
||||||
}
|
}
|
||||||
if (driveKeys[LEFT])
|
if (driveKeys[LEFT])
|
||||||
{
|
{
|
||||||
avatar.thrust.x -= avatar.orientation.getRight().getX() * THRUST_LATERAL_MAG;
|
glm::vec3 right( avatar.orientation.getRight().getX(), avatar.orientation.getRight().getY(), -avatar.orientation.getRight().getZ() );
|
||||||
avatar.thrust.y -= avatar.orientation.getRight().getY() * THRUST_LATERAL_MAG;
|
avatar.thrust -= right * THRUST_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;
|
|
||||||
}
|
}
|
||||||
if (driveKeys[UP])
|
if (driveKeys[UP])
|
||||||
{
|
{
|
||||||
avatar.thrust.x -= avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG;
|
glm::vec3 up( avatar.orientation.getUp().getX(), avatar.orientation.getUp().getY(), -avatar.orientation.getUp().getZ() );
|
||||||
avatar.thrust.y -= avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG;
|
avatar.thrust += up * THRUST_MAG;
|
||||||
avatar.thrust.z += avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG;
|
|
||||||
//thrust.y += -THRUST_VERTICAL_MAG;
|
|
||||||
}
|
}
|
||||||
if (driveKeys[DOWN])
|
if (driveKeys[DOWN])
|
||||||
{
|
{
|
||||||
avatar.thrust.x += avatar.orientation.getUp().getX() * THRUST_VERTICAL_MAG;
|
glm::vec3 up( avatar.orientation.getUp().getX(), avatar.orientation.getUp().getY(), -avatar.orientation.getUp().getZ() );
|
||||||
avatar.thrust.y += avatar.orientation.getUp().getY() * THRUST_VERTICAL_MAG;
|
avatar.thrust -= up * THRUST_MAG;
|
||||||
avatar.thrust.z -= avatar.orientation.getUp().getZ() * THRUST_VERTICAL_MAG;
|
|
||||||
//thrust.y += THRUST_VERTICAL_MAG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (driveKeys[ROT_RIGHT])
|
if (driveKeys[ROT_RIGHT])
|
||||||
{
|
{
|
||||||
avatar.yawDelta -= 300.0 * deltaTime;
|
avatar.yawDelta -= YAW_MAG * deltaTime;
|
||||||
}
|
}
|
||||||
if (driveKeys[ROT_LEFT])
|
if (driveKeys[ROT_LEFT])
|
||||||
{
|
{
|
||||||
avatar.yawDelta += 300.0 * deltaTime;
|
avatar.yawDelta += YAW_MAG * deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
avatar.yaw += avatar.yawDelta * 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()
|
void Head::updateHandMovement()
|
||||||
|
|
|
@ -103,15 +103,15 @@ enum AvatarBones
|
||||||
|
|
||||||
struct AvatarBone
|
struct AvatarBone
|
||||||
{
|
{
|
||||||
AvatarBones parent;
|
AvatarBones parent; // which bone is this bone connected to?
|
||||||
glm::vec3 worldPosition;
|
glm::vec3 worldPosition; // the position at the "end" of the bone
|
||||||
glm::vec3 defaultPosePosition;
|
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||||
glm::dvec3 velocity;
|
glm::dvec3 velocity; // pertains to spring physics
|
||||||
float yaw;
|
float yaw; // the yaw Euler angle of the bone rotation off the parent
|
||||||
float pitch;
|
float pitch; // the pitch Euler angle of the bone rotation off the parent
|
||||||
float roll;
|
float roll; // the roll Euler angle of the bone rotation off the parent
|
||||||
Orientation worldOrientation;
|
Orientation worldOrientation; // three orthogonal normals determined by yaw, pitch, roll
|
||||||
float length;
|
float length; // the length of the bone
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Avatar
|
struct Avatar
|
||||||
|
@ -158,6 +158,7 @@ class Head : public AgentData {
|
||||||
float getLastMeasuredYaw() {return YawRate;}
|
float getLastMeasuredYaw() {return YawRate;}
|
||||||
|
|
||||||
float getAvatarYaw();
|
float getAvatarYaw();
|
||||||
|
glm::vec3 getAvatarHeadLookatDirection();
|
||||||
|
|
||||||
void render(int faceToFace, int isMine);
|
void render(int faceToFace, int isMine);
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,8 @@ int starsTiles = 20;
|
||||||
double starsLod = 1.0;
|
double starsLod = 1.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool showingVoxels = false;
|
||||||
|
|
||||||
glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
|
glm::vec3 box(WORLD_SIZE,WORLD_SIZE,WORLD_SIZE);
|
||||||
|
|
||||||
ParticleSystem balls(0,
|
ParticleSystem balls(0,
|
||||||
|
@ -511,6 +513,8 @@ void simulateHead(float frametime)
|
||||||
|
|
||||||
void display(void)
|
void display(void)
|
||||||
{
|
{
|
||||||
|
//printf( "avatar head lookat = %f, %f, %f\n", myHead.getAvatarHeadLookatDirection().x, myHead.getAvatarHeadLookatDirection().y, myHead.getAvatarHeadLookatDirection().z );
|
||||||
|
|
||||||
PerfStat("display");
|
PerfStat("display");
|
||||||
|
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
|
@ -560,7 +564,7 @@ void display(void)
|
||||||
// set the camera to third-person view behind my av
|
// set the camera to third-person view behind my av
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() );
|
myCamera.setYaw ( 180.0 - myHead.getAvatarYaw() );
|
||||||
myCamera.setPitch ( 10.0 );
|
myCamera.setPitch ( 0.0 );
|
||||||
myCamera.setRoll ( 0.0 );
|
myCamera.setRoll ( 0.0 );
|
||||||
myCamera.setUp ( 0.2 );
|
myCamera.setUp ( 0.2 );
|
||||||
myCamera.setDistance( 1.6 );
|
myCamera.setDistance( 1.6 );
|
||||||
|
@ -584,17 +588,34 @@ void display(void)
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------
|
||||||
|
// draw a red sphere
|
||||||
|
//---------------------------------------------
|
||||||
|
float sphereRadius = 0.25f;
|
||||||
glColor3f(1,0,0);
|
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
|
// Draw cloud of dots
|
||||||
glDisable( GL_POINT_SPRITE_ARB );
|
glDisable( GL_POINT_SPRITE_ARB );
|
||||||
glDisable( GL_TEXTURE_2D );
|
glDisable( GL_TEXTURE_2D );
|
||||||
if (!displayHead) cloud.render();
|
if (!displayHead) cloud.render();
|
||||||
|
|
||||||
// Draw voxels
|
// Draw voxels
|
||||||
voxels.render();
|
if ( showingVoxels )
|
||||||
|
{
|
||||||
|
voxels.render();
|
||||||
|
}
|
||||||
|
|
||||||
// Draw field vectors
|
// Draw field vectors
|
||||||
if (displayField) field.render();
|
if (displayField) field.render();
|
||||||
|
|
||||||
|
@ -1062,6 +1083,8 @@ void audioMixerUpdate(in_addr_t newMixerAddress, in_port_t newMixerPort) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, const char * argv[])
|
int main(int argc, const char * argv[])
|
||||||
{
|
{
|
||||||
const char* domainIP = getCmdOption(argc, argv, "--domain");
|
const char* domainIP = getCmdOption(argc, argv, "--domain");
|
||||||
|
|
Loading…
Reference in a new issue