mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-19 00:57:35 +02:00
fixed some glitches in avatar render alpha transition between 3p and 1p
This commit is contained in:
parent
0e329af03e
commit
31ff768363
5 changed files with 28 additions and 20 deletions
|
@ -1114,16 +1114,19 @@ void Avatar::updateArmIKAndConstraints(float deltaTime) {
|
|||
|
||||
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;
|
||||
|
||||
// Render the body as balls and cones
|
||||
for (int b = 0; b < NUM_AVATAR_JOINTS; b++) {
|
||||
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
|
||||
if (b == AVATAR_JOINT_HEAD_BASE) { // the head is rendered as a special case
|
||||
if (lookingInMirror || _owningAgent || distanceToCamera > RENDER_OPAQUE_BEYOND) {
|
||||
_head.render(lookingInMirror, _cameraPosition);
|
||||
if (lookingInMirror || _owningAgent || distanceToCamera > RENDER_OPAQUE_BEYOND * 0.5) {
|
||||
_head.render(lookingInMirror, _cameraPosition, alpha);
|
||||
}
|
||||
} else if (_owningAgent || distanceToCamera > RENDER_TRANSLUCENT_BEYOND
|
||||
|| b == AVATAR_JOINT_RIGHT_ELBOW
|
||||
|
@ -1140,14 +1143,16 @@ void Avatar::renderBody(bool lookingInMirror) {
|
|||
glColor4f(SKIN_COLOR[0] + _joint[b].touchForce * 0.3f,
|
||||
SKIN_COLOR[1] - _joint[b].touchForce * 0.2f,
|
||||
SKIN_COLOR[2] - _joint[b].touchForce * 0.1f,
|
||||
glm::clamp((distanceToCamera - RENDER_TRANSLUCENT_BEYOND)
|
||||
/ (RENDER_OPAQUE_BEYOND - RENDER_TRANSLUCENT_BEYOND), 0.f, 1.f));
|
||||
alpha);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(_joint[b].springyPosition.x, _joint[b].springyPosition.y, _joint[b].springyPosition.z);
|
||||
glutSolidSphere(_joint[b].radius, 20.0f, 20.0f);
|
||||
glPopMatrix();
|
||||
if ((b != AVATAR_JOINT_HEAD_TOP )
|
||||
&& (b != AVATAR_JOINT_HEAD_BASE )) {
|
||||
glPushMatrix();
|
||||
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
|
||||
if (_joint[b].parent != AVATAR_JOINT_NULL) {
|
||||
|
|
|
@ -32,7 +32,7 @@ AvatarTouch::AvatarTouch() {
|
|||
_myOrientation.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);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,6 @@ void AvatarTouch::render(glm::vec3 cameraPosition) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
void AvatarTouch::renderBeamBetweenHands() {
|
||||
|
||||
glm::vec3 v1(_myHandPosition);
|
||||
|
@ -150,9 +149,9 @@ void AvatarTouch::renderBeamBetweenHands() {
|
|||
glEnd();
|
||||
|
||||
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].y += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
||||
_point[p].z += randFloatInRange(-THREAD_RADIUS, THREAD_RADIUS);
|
||||
|
|
|
@ -46,11 +46,11 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
static const int NUM_POINTS = 100;
|
||||
static const int NUM_PARTICLE_POINTS = 100;
|
||||
|
||||
bool _hasInteractingOther;
|
||||
bool _weAreHoldingHands;
|
||||
glm::vec3 _point [NUM_POINTS];
|
||||
glm::vec3 _point [NUM_PARTICLE_POINTS];
|
||||
glm::vec3 _myBodyPosition;
|
||||
glm::vec3 _yourBodyPosition;
|
||||
glm::vec3 _myHandPosition;
|
||||
|
|
|
@ -40,6 +40,7 @@ vector<unsigned char> irisTexture;
|
|||
|
||||
Head::Head(Avatar* owningAvatar) :
|
||||
HeadData((AvatarData*)owningAvatar),
|
||||
_renderAlpha(0.0),
|
||||
yawRate(0.0f),
|
||||
_returnHeadToCenter(false),
|
||||
_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);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -314,7 +317,7 @@ void Head::renderHeadSphere() {
|
|||
glPushMatrix();
|
||||
glTranslatef(_position.x, _position.y, _position.z); //translate to head position
|
||||
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);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
@ -322,13 +325,13 @@ void Head::renderHeadSphere() {
|
|||
void Head::renderEars() {
|
||||
|
||||
glPushMatrix();
|
||||
glColor3f(_skinColor.x, _skinColor.y, _skinColor.z);
|
||||
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
|
||||
glTranslatef(_leftEarPosition.x, _leftEarPosition.y, _leftEarPosition.z);
|
||||
glutSolidSphere(0.02, 30, 30);
|
||||
glPopMatrix();
|
||||
|
||||
glPushMatrix();
|
||||
glColor3f(_skinColor.x, _skinColor.y, _skinColor.z);
|
||||
glColor4f(_skinColor.x, _skinColor.y, _skinColor.z, _renderAlpha);
|
||||
glTranslatef(_rightEarPosition.x, _rightEarPosition.y, _rightEarPosition.z);
|
||||
glutSolidSphere(0.02, 30, 30);
|
||||
glPopMatrix();
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
|
||||
void reset();
|
||||
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 setScale (float scale ) { _scale = scale; }
|
||||
|
@ -71,6 +71,7 @@ private:
|
|||
glm::vec3 endVelocity;
|
||||
};
|
||||
|
||||
float _renderAlpha;
|
||||
bool _returnHeadToCenter;
|
||||
glm::vec3 _skinColor;
|
||||
glm::vec3 _position;
|
||||
|
|
Loading…
Reference in a new issue