mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
added get avatar bone
This commit is contained in:
parent
8b9017a244
commit
84ca2dcb32
3 changed files with 61 additions and 15 deletions
|
@ -95,7 +95,6 @@ Head::Head() {
|
||||||
usingSprings = false;
|
usingSprings = false;
|
||||||
|
|
||||||
springForce = 6.0f;
|
springForce = 6.0f;
|
||||||
springToBodyTightness = 4.0f;
|
|
||||||
springVelocityDecay = 16.0f;
|
springVelocityDecay = 16.0f;
|
||||||
|
|
||||||
hand = new Hand(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
|
hand = new Hand(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
|
||||||
|
@ -782,23 +781,27 @@ void Head::setHandMovement( glm::vec3 movement ) {
|
||||||
|
|
||||||
|
|
||||||
void Head::initializeAvatar() {
|
void Head::initializeAvatar() {
|
||||||
//avatar.position = glm::vec3( 0.0, 0.0, 0.0 );
|
|
||||||
avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
avatar.velocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
avatar.thrust = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
avatar.orientation.setToIdentity();
|
avatar.orientation.setToIdentity();
|
||||||
|
|
||||||
closestOtherAvatar = 0;
|
closestOtherAvatar = 0;
|
||||||
|
|
||||||
bodyYaw = -90.0;
|
bodyYaw = -90.0;
|
||||||
bodyPitch = 0.0;
|
bodyPitch = 0.0;
|
||||||
bodyRoll = 0.0;
|
bodyRoll = 0.0;
|
||||||
|
bodyYawDelta = 0.0;
|
||||||
bodyYawDelta = 0.0;
|
|
||||||
|
|
||||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||||
avatar.bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
|
avatar.bone[b].parent = AVATAR_BONE_NULL;
|
||||||
avatar.bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
avatar.bone[b].position = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
avatar.bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 );
|
avatar.bone[b].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
avatar.bone[b].springyPosition = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
avatar.bone[b].springyVelocity = glm::vec3( 0.0, 0.0, 0.0 );
|
||||||
|
avatar.bone[b].yaw = 0.0f;
|
||||||
|
avatar.bone[b].pitch = 0.0f;
|
||||||
|
avatar.bone[b].roll = 0.0f;
|
||||||
|
avatar.bone[b].length = 0.0f;
|
||||||
avatar.bone[b].orientation.setToIdentity();
|
avatar.bone[b].orientation.setToIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -877,6 +880,41 @@ void Head::initializeAvatar() {
|
||||||
avatar.bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
avatar.bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
||||||
avatar.bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
avatar.bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------------------
|
||||||
|
// set the spring body tightness (determines how tightly the springy positions stay on the bone positions
|
||||||
|
//----------------------------------------------------------------------------------------------------------------
|
||||||
|
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||||
|
avatar.bone[b].springBodyTightness = 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
avatar.bone[ AVATAR_BONE_NULL ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_PELVIS_SPINE ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_MID_SPINE ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_CHEST_SPINE ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_NECK ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_HEAD ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_CHEST ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_SHOULDER ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_UPPER_ARM ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_FOREARM ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_HAND ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_CHEST ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_SHOULDER ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_UPPER_ARM].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_FOREARM ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_HAND ].springBodyTightness = 0.0f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_PELVIS ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_THIGH ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_SHIN ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_LEFT_FOOT ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_PELVIS ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_THIGH ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_SHIN ].springBodyTightness = 0.8f;
|
||||||
|
avatar.bone[ AVATAR_BONE_RIGHT_FOOT ].springBodyTightness = 0.8f;
|
||||||
|
*/
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// calculate bone length
|
// calculate bone length
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -957,14 +995,15 @@ void Head::updateAvatarSprings( float deltaTime ) {
|
||||||
if ( length > 0.0f ) {
|
if ( length > 0.0f ) {
|
||||||
glm::vec3 springDirection = springVector / length;
|
glm::vec3 springDirection = springVector / length;
|
||||||
|
|
||||||
float force = ( length - avatar.bone[b].length ) * springForce * deltaTime;
|
float force = ( length - avatar.bone[b].length ) * springForce * deltaTime;
|
||||||
|
|
||||||
avatar.bone[ b ].springyVelocity -= springDirection * force;
|
avatar.bone[ b ].springyVelocity -= springDirection * force;
|
||||||
avatar.bone[ avatar.bone[b].parent ].springyVelocity += springDirection * force;
|
avatar.bone[ avatar.bone[b].parent ].springyVelocity += springDirection * force;
|
||||||
}
|
}
|
||||||
|
|
||||||
avatar.bone[b].springyVelocity += ( avatar.bone[b].position - avatar.bone[b].springyPosition ) * springToBodyTightness * deltaTime;
|
avatar.bone[b].springyVelocity += ( avatar.bone[b].position - avatar.bone[b].springyPosition ) *
|
||||||
|
avatar.bone[b].springBodyTightness * deltaTime;
|
||||||
|
|
||||||
float decay = 1.0 - springVelocityDecay * deltaTime;
|
float decay = 1.0 - springVelocityDecay * deltaTime;
|
||||||
|
|
||||||
if ( decay > 0.0 ) {
|
if ( decay > 0.0 ) {
|
||||||
|
@ -1000,6 +1039,11 @@ glm::vec3 Head::getHeadLookatDirectionUp() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 Head::getBonePosition( AvatarBones b )
|
||||||
|
{
|
||||||
|
return avatar.bone[b].position;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 Head::getHeadLookatDirectionRight() {
|
glm::vec3 Head::getHeadLookatDirectionRight() {
|
||||||
return glm::vec3
|
return glm::vec3
|
||||||
(
|
(
|
||||||
|
|
|
@ -109,6 +109,7 @@ struct AvatarBone
|
||||||
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
glm::vec3 defaultPosePosition; // the parent relative position when the avatar is in the "T-pose"
|
||||||
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 (0 to 1) the springy position tries to stay on the position
|
||||||
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
|
||||||
|
@ -159,6 +160,7 @@ class Head : public AgentData {
|
||||||
glm::vec3 getHeadLookatDirectionUp();
|
glm::vec3 getHeadLookatDirectionUp();
|
||||||
glm::vec3 getHeadLookatDirectionRight();
|
glm::vec3 getHeadLookatDirectionRight();
|
||||||
glm::vec3 getHeadPosition();
|
glm::vec3 getHeadPosition();
|
||||||
|
glm::vec3 getBonePosition( AvatarBones b );
|
||||||
glm::vec3 getBodyPosition();
|
glm::vec3 getBodyPosition();
|
||||||
|
|
||||||
void render(int faceToFace, int isMine);
|
void render(int faceToFace, int isMine);
|
||||||
|
@ -254,7 +256,7 @@ class Head : public AgentData {
|
||||||
|
|
||||||
float springVelocityDecay;
|
float springVelocityDecay;
|
||||||
float springForce;
|
float springForce;
|
||||||
float springToBodyTightness;
|
//float springToBodyTightness;
|
||||||
|
|
||||||
int eyeContact;
|
int eyeContact;
|
||||||
eyeContactTargets eyeContactTarget;
|
eyeContactTargets eyeContactTarget;
|
||||||
|
|
|
@ -24,7 +24,7 @@ static const double ONE_THIRD = 0.3333333;
|
||||||
static const double PIE = 3.14159265359;
|
static const double PIE = 3.14159265359;
|
||||||
static const double PI_TIMES_TWO = 3.14159265359 * 2.0;
|
static const double PI_TIMES_TWO = 3.14159265359 * 2.0;
|
||||||
static const double PI_OVER_180 = 3.14159265359 / 180.0;
|
static const double PI_OVER_180 = 3.14159265359 / 180.0;
|
||||||
static const double EPSILON = 0.00001; //smallish number - used as margin of error for some values
|
static const double EPSILON = 0.00001; //smallish number - used as margin of error for some computations
|
||||||
static const double SQUARE_ROOT_OF_2 = sqrt(2);
|
static const double SQUARE_ROOT_OF_2 = sqrt(2);
|
||||||
static const double SQUARE_ROOT_OF_3 = sqrt(3);
|
static const double SQUARE_ROOT_OF_3 = sqrt(3);
|
||||||
static const double METER = 1.0;
|
static const double METER = 1.0;
|
||||||
|
|
Loading…
Reference in a new issue