mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 16:56:42 +02:00
improved rendering of avatar
This commit is contained in:
parent
caead24462
commit
3dc03f44a1
1 changed files with 71 additions and 51 deletions
|
@ -650,11 +650,6 @@ void Head::render(int faceToFace) {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------
|
|
||||||
// show avatar orientation
|
|
||||||
//---------------------------------------------------
|
|
||||||
renderOrientationDirections( _bone[ AVATAR_BONE_HEAD ].position, _bone[ AVATAR_BONE_HEAD ].orientation, 0.2f );
|
|
||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
// render body
|
// render body
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
@ -708,6 +703,11 @@ void Head::renderHead(int faceToFace) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_RESCALE_NORMAL);
|
glEnable(GL_RESCALE_NORMAL);
|
||||||
|
|
||||||
|
//---------------------------------------------------
|
||||||
|
// show head orientation
|
||||||
|
//---------------------------------------------------
|
||||||
|
//renderOrientationDirections( _bone[ AVATAR_BONE_HEAD ].position, _bone[ AVATAR_BONE_HEAD ].orientation, 0.2f );
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
if (_usingBodySprings) {
|
if (_usingBodySprings) {
|
||||||
|
@ -900,7 +900,7 @@ void Head::initializeSkeleton() {
|
||||||
_bone[b].pitch = 0.0;
|
_bone[b].pitch = 0.0;
|
||||||
_bone[b].roll = 0.0;
|
_bone[b].roll = 0.0;
|
||||||
_bone[b].length = 0.0;
|
_bone[b].length = 0.0;
|
||||||
_bone[b].radius = 0.02; //default
|
_bone[b].radius = 0.0;
|
||||||
_bone[b].springBodyTightness = 4.0;
|
_bone[b].springBodyTightness = 4.0;
|
||||||
_bone[b].orientation.setToIdentity();
|
_bone[b].orientation.setToIdentity();
|
||||||
}
|
}
|
||||||
|
@ -957,17 +957,17 @@ void Head::initializeSkeleton() {
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
_bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.3, 0.0 );
|
_bone[ AVATAR_BONE_PELVIS_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.3, 0.0 );
|
||||||
_bone[ AVATAR_BONE_MID_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 );
|
_bone[ AVATAR_BONE_MID_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 );
|
||||||
_bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.1, 0.0 );
|
_bone[ AVATAR_BONE_CHEST_SPINE ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||||
_bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
_bone[ AVATAR_BONE_NECK ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||||
_bone[ AVATAR_BONE_HEAD ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
_bone[ AVATAR_BONE_HEAD ].defaultPosePosition = glm::vec3( 0.0, 0.06, 0.0 );
|
||||||
_bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.06, 0.06, 0.0 );
|
_bone[ AVATAR_BONE_LEFT_CHEST ].defaultPosePosition = glm::vec3( -0.06, 0.06, 0.0 );
|
||||||
_bone[ AVATAR_BONE_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.03, 0.0, 0.0 );
|
_bone[ AVATAR_BONE_LEFT_SHOULDER ].defaultPosePosition = glm::vec3( -0.03, 0.0, 0.0 );
|
||||||
_bone[ AVATAR_BONE_LEFT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.12, 0.0 );
|
_bone[ AVATAR_BONE_LEFT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||||
_bone[ AVATAR_BONE_LEFT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
_bone[ AVATAR_BONE_LEFT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||||
_bone[ AVATAR_BONE_LEFT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
_bone[ AVATAR_BONE_LEFT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
||||||
_bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.06, 0.06, 0.0 );
|
_bone[ AVATAR_BONE_RIGHT_CHEST ].defaultPosePosition = glm::vec3( 0.06, 0.06, 0.0 );
|
||||||
_bone[ AVATAR_BONE_RIGHT_SHOULDER ].defaultPosePosition = glm::vec3( 0.03, 0.0, 0.0 );
|
_bone[ AVATAR_BONE_RIGHT_SHOULDER ].defaultPosePosition = glm::vec3( 0.03, 0.0, 0.0 );
|
||||||
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.12, 0.0 );
|
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||||
_bone[ AVATAR_BONE_RIGHT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
_bone[ AVATAR_BONE_RIGHT_FOREARM ].defaultPosePosition = glm::vec3( 0.0, -0.1, 0.0 );
|
||||||
_bone[ AVATAR_BONE_RIGHT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
_bone[ AVATAR_BONE_RIGHT_HAND ].defaultPosePosition = glm::vec3( 0.0, -0.05, 0.0 );
|
||||||
_bone[ AVATAR_BONE_LEFT_PELVIS ].defaultPosePosition = glm::vec3( -0.05, 0.0, 0.0 );
|
_bone[ AVATAR_BONE_LEFT_PELVIS ].defaultPosePosition = glm::vec3( -0.05, 0.0, 0.0 );
|
||||||
|
@ -979,6 +979,31 @@ void Head::initializeSkeleton() {
|
||||||
_bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
_bone[ AVATAR_BONE_RIGHT_SHIN ].defaultPosePosition = glm::vec3( 0.0, -0.15, 0.0 );
|
||||||
_bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
_bone[ AVATAR_BONE_RIGHT_FOOT ].defaultPosePosition = glm::vec3( 0.0, 0.0, 0.04 );
|
||||||
|
|
||||||
|
|
||||||
|
_bone[ AVATAR_BONE_PELVIS_SPINE ].radius = 0.05;
|
||||||
|
_bone[ AVATAR_BONE_MID_SPINE ].radius = 0.06;
|
||||||
|
_bone[ AVATAR_BONE_CHEST_SPINE ].radius = 0.03;
|
||||||
|
_bone[ AVATAR_BONE_NECK ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_HEAD ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_CHEST ].radius = 0.025;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_SHOULDER ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_UPPER_ARM ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_FOREARM ].radius = 0.015;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_HAND ].radius = 0.01;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_CHEST ].radius = 0.025;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_SHOULDER ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_UPPER_ARM ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_FOREARM ].radius = 0.015;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_HAND ].radius = 0.01;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_PELVIS ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_THIGH ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_SHIN ].radius = 0.015;
|
||||||
|
_bone[ AVATAR_BONE_LEFT_FOOT ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_PELVIS ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_THIGH ].radius = 0.02;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_SHIN ].radius = 0.015;
|
||||||
|
_bone[ AVATAR_BONE_RIGHT_FOOT ].radius = 0.02;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// calculate bone length
|
// calculate bone length
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1125,17 +1150,6 @@ glm::vec3 Head::getHeadPosition() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return _bone[ AVATAR_BONE_HEAD ].position;
|
return _bone[ AVATAR_BONE_HEAD ].position;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
return glm::vec3
|
|
||||||
(
|
|
||||||
_bone[ AVATAR_BONE_HEAD ].position.x,
|
|
||||||
_bone[ AVATAR_BONE_HEAD ].position.y,
|
|
||||||
_bone[ AVATAR_BONE_HEAD ].position.z
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1251,18 +1265,21 @@ void Head::renderBody() {
|
||||||
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
for (int b=0; b<NUM_AVATAR_BONES; b++) {
|
||||||
//renderBoneAsBlock( (AvatarBoneID)b);
|
//renderBoneAsBlock( (AvatarBoneID)b);
|
||||||
|
|
||||||
|
//render bone orientation
|
||||||
|
//renderOrientationDirections( _bone[b].position, _bone[b].orientation, 0.05f );
|
||||||
|
|
||||||
if ( _usingBodySprings ) {
|
if ( _usingBodySprings ) {
|
||||||
glColor3fv( lightBlue );
|
glColor3fv( skinColor );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef( _bone[b].springyPosition.x, _bone[b].springyPosition.y, _bone[b].springyPosition.z );
|
glTranslatef( _bone[b].springyPosition.x, _bone[b].springyPosition.y, _bone[b].springyPosition.z );
|
||||||
glutSolidSphere( _bone[b].radius, 10.0f, 5.0f );
|
glutSolidSphere( _bone[b].radius, 20.0f, 20.0f );
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glColor3fv( skinColor );
|
glColor3fv( skinColor );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef( _bone[b].position.x, _bone[b].position.y, _bone[b].position.z );
|
glTranslatef( _bone[b].position.x, _bone[b].position.y, _bone[b].position.z );
|
||||||
glutSolidSphere( _bone[b].radius, 10.0f, 5.0f );
|
glutSolidSphere( _bone[b].radius, 20.0f, 20.0f );
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1297,7 +1314,6 @@ void Head::renderBody() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (( _usingBodySprings ) && ( _mousePressed )) {
|
if (( _usingBodySprings ) && ( _mousePressed )) {
|
||||||
glColor4f( 1.0, 1.0, 0.5, 0.5 );
|
glColor4f( 1.0, 1.0, 0.5, 0.5 );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -1313,12 +1329,16 @@ void Head::renderBody() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Head::renderBoneAsBlock( AvatarBoneID b ) {
|
|
||||||
|
|
||||||
glColor3fv( lightBlue );
|
void Head::renderBoneAsBlock( AvatarBoneID b ) {
|
||||||
|
glColor3fv( skinColor );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef( _bone[b].springyPosition.x, _bone[b].springyPosition.y, _bone[b].springyPosition.z );
|
glTranslatef( _bone[b].springyPosition.x, _bone[b].springyPosition.y, _bone[b].springyPosition.z );
|
||||||
glutSolidSphere( _bone[b].radius, 10.0f, 5.0f );
|
glScalef( _bone[b].radius, _bone[b].length, _bone[b].radius );
|
||||||
|
glRotatef(_bone[b].yaw, 0, 1, 0 );
|
||||||
|
glRotatef(_bone[b].pitch, 1, 0, 0 );
|
||||||
|
glRotatef(_bone[b].roll, 0, 0, 1 );
|
||||||
|
glutSolidCube(1.0);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue