mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 16:50:43 +02:00
Merge pull request #446 from Ventrella/master
fixed some glitches in avatar render alpha transition between 3p and 1p
This commit is contained in:
commit
01b0efbb66
5 changed files with 28 additions and 20 deletions
|
@ -1114,16 +1114,19 @@ void Avatar::updateArmIKAndConstraints(float deltaTime) {
|
||||||
|
|
||||||
void Avatar::renderBody(bool lookingInMirror) {
|
void Avatar::renderBody(bool lookingInMirror) {
|
||||||
|
|
||||||
const float RENDER_OPAQUE_BEYOND = 1.2f; // Meters beyond which body is shown opaque
|
const float RENDER_OPAQUE_BEYOND = 1.0f; // Meters beyond which body is shown opaque
|
||||||
const float RENDER_TRANSLUCENT_BEYOND = 0.5f;
|
const float RENDER_TRANSLUCENT_BEYOND = 0.5f;
|
||||||
|
|
||||||
// Render the body as balls and cones
|
// Render the body as balls and cones
|
||||||
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
||||||
float distanceToCamera = glm::length(_cameraPosition - _joint[b].position);
|
float distanceToCamera = glm::length(_cameraPosition - _joint[b].position);
|
||||||
|
|
||||||
|
float alpha = glm::clamp((distanceToCamera - RENDER_TRANSLUCENT_BEYOND) / (RENDER_OPAQUE_BEYOND - RENDER_TRANSLUCENT_BEYOND), 0.f, 1.f);
|
||||||
|
|
||||||
// Always render other people, and render myself when beyond threshold distance
|
// Always render other people, and render myself when beyond threshold distance
|
||||||
if (b == AVATAR_JOINT_HEAD_BASE) { // the head is rendered as a special case
|
if (b == AVATAR_JOINT_HEAD_BASE) { // the head is rendered as a special case
|
||||||
if (lookingInMirror || _owningAgent || distanceToCamera > RENDER_OPAQUE_BEYOND) {
|
if (lookingInMirror || _owningAgent || distanceToCamera > RENDER_OPAQUE_BEYOND * 0.5) {
|
||||||
_head.render(lookingInMirror, _cameraPosition);
|
_head.render(lookingInMirror, _cameraPosition, alpha);
|
||||||
}
|
}
|
||||||
} else if (_owningAgent || distanceToCamera > RENDER_TRANSLUCENT_BEYOND
|
} else if (_owningAgent || distanceToCamera > RENDER_TRANSLUCENT_BEYOND
|
||||||
|| b == AVATAR_JOINT_RIGHT_ELBOW
|
|| b == AVATAR_JOINT_RIGHT_ELBOW
|
||||||
|
@ -1140,14 +1143,16 @@ void Avatar::renderBody(bool lookingInMirror) {
|
||||||
glColor4f(SKIN_COLOR[0] + _joint[b].touchForce * 0.3f,
|
glColor4f(SKIN_COLOR[0] + _joint[b].touchForce * 0.3f,
|
||||||
SKIN_COLOR[1] - _joint[b].touchForce * 0.2f,
|
SKIN_COLOR[1] - _joint[b].touchForce * 0.2f,
|
||||||
SKIN_COLOR[2] - _joint[b].touchForce * 0.1f,
|
SKIN_COLOR[2] - _joint[b].touchForce * 0.1f,
|
||||||
glm::clamp((distanceToCamera - RENDER_TRANSLUCENT_BEYOND)
|
alpha);
|
||||||
/ (RENDER_OPAQUE_BEYOND - RENDER_TRANSLUCENT_BEYOND), 0.f, 1.f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glPushMatrix();
|
if ((b != AVATAR_JOINT_HEAD_TOP )
|
||||||
glTranslatef(_joint[b].springyPosition.x, _joint[b].springyPosition.y, _joint[b].springyPosition.z);
|
&& (b != AVATAR_JOINT_HEAD_BASE )) {
|
||||||
glutSolidSphere(_joint[b].radius, 20.0f, 20.0f);
|
glPushMatrix();
|
||||||
glPopMatrix();
|
glTranslatef(_joint[b].springyPosition.x, _joint[b].springyPosition.y, _joint[b].springyPosition.z);
|
||||||
|
glutSolidSphere(_joint[b].radius, 20.0f, 20.0f);
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
// Render the cone connecting this joint to its parent
|
// Render the cone connecting this joint to its parent
|
||||||
if (_joint[b].parent != AVATAR_JOINT_NULL) {
|
if (_joint[b].parent != AVATAR_JOINT_NULL) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ AvatarTouch::AvatarTouch() {
|
||||||
_myOrientation.setToIdentity();
|
_myOrientation.setToIdentity();
|
||||||
_yourOrientation.setToIdentity();
|
_yourOrientation.setToIdentity();
|
||||||
|
|
||||||
for (int p=0; p<NUM_POINTS; p++) {
|
for (int p=0; p<NUM_PARTICLE_POINTS; p++) {
|
||||||
_point[p] = glm::vec3(0.0, 0.0, 0.0);
|
_point[p] = glm::vec3(0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,6 @@ void AvatarTouch::render(glm::vec3 cameraPosition) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AvatarTouch::renderBeamBetweenHands() {
|
void AvatarTouch::renderBeamBetweenHands() {
|
||||||
|
|
||||||
glm::vec3 v1(_myHandPosition);
|
glm::vec3 v1(_myHandPosition);
|
||||||
|
@ -150,9 +149,9 @@ void AvatarTouch::renderBeamBetweenHands() {
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glColor3f(0.5f, 0.3f, 0.0f);
|
glColor3f(0.5f, 0.3f, 0.0f);
|
||||||
for (int p=0; p<NUM_POINTS; p++) {
|
for (int p=0; p<NUM_PARTICLE_POINTS; p++) {
|
||||||
|
|
||||||
_point[p] = _myHandPosition + _vectorBetweenHands * ((float)p / (float)NUM_POINTS);
|
_point[p] = _myHandPosition + _vectorBetweenHands * ((float)p / (float)NUM_PARTICLE_POINTS);
|
||||||
_point[p].x += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
_point[p].x += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
||||||
_point[p].y += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
_point[p].y += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
||||||
_point[p].z += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
_point[p].z += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
||||||
|
|
|
@ -46,11 +46,11 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static const int NUM_POINTS = 100;
|
static const int NUM_PARTICLE_POINTS = 100;
|
||||||
|
|
||||||
bool _hasInteractingOther;
|
bool _hasInteractingOther;
|
||||||
bool _weAreHoldingHands;
|
bool _weAreHoldingHands;
|
||||||
glm::vec3 _point [NUM_POINTS];
|
glm::vec3 _point [NUM_PARTICLE_POINTS];
|
||||||
glm::vec3 _myBodyPosition;
|
glm::vec3 _myBodyPosition;
|
||||||
glm::vec3 _yourBodyPosition;
|
glm::vec3 _yourBodyPosition;
|
||||||
glm::vec3 _myHandPosition;
|
glm::vec3 _myHandPosition;
|
||||||
|
|
|
@ -40,6 +40,7 @@ vector<unsigned char> irisTexture;
|
||||||
|
|
||||||
Head::Head(Avatar* owningAvatar) :
|
Head::Head(Avatar* owningAvatar) :
|
||||||
HeadData((AvatarData*)owningAvatar),
|
HeadData((AvatarData*)owningAvatar),
|
||||||
|
_renderAlpha(0.0),
|
||||||
yawRate(0.0f),
|
yawRate(0.0f),
|
||||||
_returnHeadToCenter(false),
|
_returnHeadToCenter(false),
|
||||||
_skinColor(0.0f, 0.0f, 0.0f),
|
_skinColor(0.0f, 0.0f, 0.0f),
|
||||||
|
@ -205,8 +206,10 @@ void Head::calculateGeometry(bool lookingInMirror) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Head::render(bool lookingInMirror, glm::vec3 cameraPosition) {
|
void Head::render(bool lookingInMirror, glm::vec3 cameraPosition, float alpha) {
|
||||||
|
|
||||||
|
_renderAlpha = alpha;
|
||||||
|
|
||||||
calculateGeometry(lookingInMirror);
|
calculateGeometry(lookingInMirror);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
@ -314,7 +317,7 @@ void Head::renderHeadSphere() {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(_position.x, _position.y, _position.z); //translate to head position
|
glTranslatef(_position.x, _position.y, _position.z); //translate to head position
|
||||||
glScalef(_scale, _scale, _scale); //scale to head size
|
glScalef(_scale, _scale, _scale); //scale to head size
|
||||||
glColor3f(_skinColor.x, _skinColor.y, _skinColor.z);
|
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
|
||||||
glutSolidSphere(1, 30, 30);
|
glutSolidSphere(1, 30, 30);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -322,13 +325,13 @@ void Head::renderHeadSphere() {
|
||||||
void Head::renderEars() {
|
void Head::renderEars() {
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor3f(_skinColor.x, _skinColor.y, _skinColor.z);
|
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
|
||||||
glTranslatef(_leftEarPosition.x, _leftEarPosition.y, _leftEarPosition.z);
|
glTranslatef(_leftEarPosition.x, _leftEarPosition.y, _leftEarPosition.z);
|
||||||
glutSolidSphere(0.02, 30, 30);
|
glutSolidSphere(0.02, 30, 30);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glColor3f(_skinColor.x, _skinColor.y, _skinColor.z);
|
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
|
||||||
glTranslatef(_rightEarPosition.x, _rightEarPosition.y, _rightEarPosition.z);
|
glTranslatef(_rightEarPosition.x, _rightEarPosition.y, _rightEarPosition.z);
|
||||||
glutSolidSphere(0.02, 30, 30);
|
glutSolidSphere(0.02, 30, 30);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void simulate(float deltaTime, bool isMine);
|
void simulate(float deltaTime, bool isMine);
|
||||||
void render(bool lookingInMirror, glm::vec3 cameraPosition);
|
void render(bool lookingInMirror, glm::vec3 cameraPosition, float alpha);
|
||||||
void renderMohawk(bool lookingInMirror, glm::vec3 cameraPosition);
|
void renderMohawk(bool lookingInMirror, glm::vec3 cameraPosition);
|
||||||
|
|
||||||
void setScale (float scale ) { _scale = scale; }
|
void setScale (float scale ) { _scale = scale; }
|
||||||
|
@ -71,6 +71,7 @@ private:
|
||||||
glm::vec3 endVelocity;
|
glm::vec3 endVelocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float _renderAlpha;
|
||||||
bool _returnHeadToCenter;
|
bool _returnHeadToCenter;
|
||||||
glm::vec3 _skinColor;
|
glm::vec3 _skinColor;
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
|
|
Loading…
Reference in a new issue