mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 01:23:57 +02:00
Merge pull request #424 from PhilipRosedale/master
Mohawk same for everyone, rotates with head
This commit is contained in:
commit
b866bfd879
3 changed files with 26 additions and 12 deletions
|
@ -1139,9 +1139,14 @@ void Avatar::renderBody(bool lookingInMirror) {
|
|||
if (lookingInMirror || _owningAgent || distanceToCamera > RENDER_OPAQUE_BEYOND) {
|
||||
_head.render(lookingInMirror);
|
||||
}
|
||||
} else if (_owningAgent || distanceToCamera > RENDER_TRANSLUCENT_BEYOND) {
|
||||
} else if (_owningAgent || distanceToCamera > RENDER_TRANSLUCENT_BEYOND
|
||||
|| b == AVATAR_JOINT_RIGHT_ELBOW
|
||||
|| b == AVATAR_JOINT_RIGHT_WRIST
|
||||
|| b == AVATAR_JOINT_RIGHT_FINGERTIPS ) {
|
||||
// Render the sphere at the joint
|
||||
if (_owningAgent) {
|
||||
if (_owningAgent || b == AVATAR_JOINT_RIGHT_ELBOW
|
||||
|| b == AVATAR_JOINT_RIGHT_WRIST
|
||||
|| b == AVATAR_JOINT_RIGHT_FINGERTIPS ) {
|
||||
glColor3f(skinColor[0] + _joint[b].touchForce * 0.3f,
|
||||
skinColor[1] - _joint[b].touchForce * 0.2f,
|
||||
skinColor[2] - _joint[b].touchForce * 0.1f);
|
||||
|
|
|
@ -55,7 +55,6 @@ Head::Head(Avatar* owningAvatar) :
|
|||
_audioAttack(0.0f),
|
||||
_returnSpringScale(1.0f),
|
||||
_bodyRotation(0.0f, 0.0f, 0.0f),
|
||||
_headRotation(0.0f, 0.0f, 0.0f),
|
||||
_renderLookatVectors(false),
|
||||
_mohawkTriangleFan(NULL),
|
||||
_mohawkColors(NULL)
|
||||
|
@ -180,7 +179,7 @@ void Head::render(bool lookingInMirror) {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
||||
renderMohawk();
|
||||
renderMohawk(lookingInMirror);
|
||||
renderHeadSphere();
|
||||
renderEyeBalls();
|
||||
renderEars();
|
||||
|
@ -193,9 +192,18 @@ void Head::render(bool lookingInMirror) {
|
|||
}
|
||||
|
||||
void Head::createMohawk() {
|
||||
// int agentId = AgentList::getInstance()
|
||||
float height = 0.05f + randFloat() * 0.10f;
|
||||
float variance = 0.05 + randFloat() * 0.05f;
|
||||
uint16_t agentId = 0;
|
||||
if (_owningAvatar->getOwningAgent()) {
|
||||
agentId = _owningAvatar->getOwningAgent()->getAgentID();
|
||||
} else {
|
||||
agentId = AgentList::getInstance()->getOwnerID();
|
||||
if (agentId == UNKNOWN_AGENT_ID) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
srand(agentId);
|
||||
float height = 0.08f + randFloat() * 0.05f;
|
||||
float variance = 0.03 + randFloat() * 0.03f;
|
||||
const float RAD_PER_TRIANGLE = (2.3f + randFloat() * 0.2f) / (float)MOHAWK_TRIANGLES;
|
||||
_mohawkTriangleFan = new glm::vec3[MOHAWK_TRIANGLES];
|
||||
_mohawkColors = new glm::vec3[MOHAWK_TRIANGLES];
|
||||
|
@ -213,13 +221,16 @@ void Head::createMohawk() {
|
|||
}
|
||||
}
|
||||
|
||||
void Head::renderMohawk() {
|
||||
void Head::renderMohawk(bool lookingInMirror) {
|
||||
if (!_mohawkTriangleFan) {
|
||||
createMohawk();
|
||||
} else {
|
||||
glPushMatrix();
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
glRotatef(_bodyRotation.y, 0, 1, 0);
|
||||
glRotatef((lookingInMirror ? (_bodyRotation.y - _yaw) : (_bodyRotation.y + _yaw)), 0, 1, 0);
|
||||
glRotatef(lookingInMirror ? _roll: -_roll, 0, 0, 1);
|
||||
glRotatef(-_pitch, 1, 0, 0);
|
||||
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
for (int i = 0; i < MOHAWK_TRIANGLES; i++) {
|
||||
glColor3f(_mohawkColors[i].x, _mohawkColors[i].y, _mohawkColors[i].z);
|
||||
|
|
|
@ -33,12 +33,11 @@ public:
|
|||
void reset();
|
||||
void simulate(float deltaTime, bool isMine);
|
||||
void render(bool lookingInMirror);
|
||||
void renderMohawk();
|
||||
void renderMohawk(bool lookingInMirror);
|
||||
|
||||
void setScale (float scale ) { _scale = scale; }
|
||||
void setPosition (glm::vec3 position ) { _position = position; }
|
||||
void setBodyRotation (glm::vec3 bodyRotation ) { _bodyRotation = bodyRotation; }
|
||||
void setRotationOffBody(glm::vec3 headRotation ) { _headRotation = headRotation; }
|
||||
void setGravity (glm::vec3 gravity ) { _gravity = gravity; }
|
||||
void setSkinColor (glm::vec3 skinColor ) { _skinColor = skinColor; }
|
||||
void setSpringScale (float returnSpringScale ) { _returnSpringScale = returnSpringScale; }
|
||||
|
@ -81,7 +80,6 @@ private:
|
|||
float _returnSpringScale; //strength of return springs
|
||||
Orientation _orientation;
|
||||
glm::vec3 _bodyRotation;
|
||||
glm::vec3 _headRotation;
|
||||
bool _renderLookatVectors;
|
||||
glm::vec3* _mohawkTriangleFan;
|
||||
glm::vec3* _mohawkColors;
|
||||
|
|
Loading…
Reference in a new issue