More work on face points.

This commit is contained in:
Andrzej Kapolka 2013-07-15 16:09:49 -07:00
parent 6c587af6ac
commit fdeb63c121
4 changed files with 20 additions and 11 deletions

View file

@ -23,9 +23,10 @@ uniform sampler2D depthTexture;
void main(void) {
gl_TexCoord[0] = vec4(texCoordCorner + gl_Vertex.x * texCoordRight + gl_Vertex.y * texCoordUp, 0.0, 1.0);
float depth = texture2D(depthTexture, gl_TexCoord[0].st).r;
const float MIN_VISIBLE_DEPTH = 1.0 / 255.0;
const float MAX_VISIBLE_DEPTH = 254.0 / 255.0;
gl_FrontColor = vec4(1.0, 1.0, 1.0, step(MIN_VISIBLE_DEPTH, depth) * (1.0 - step(MAX_VISIBLE_DEPTH, depth)));
gl_Position = gl_ModelViewProjectionMatrix * vec4(0.5 - gl_Vertex.x,
gl_Vertex.y * length(texCoordUp) / length(texCoordRight), depth * -2.0 + 1.0, 1.0);
(gl_Vertex.y - 0.5) * length(texCoordUp) / length(texCoordRight), depth * 2.0 - 2.0, 1.0);
}

View file

@ -1574,6 +1574,7 @@ void Application::initMenu() {
(_renderAvatarBalls = renderMenu->addAction("Avatar as Balls"))->setCheckable(true);
_renderAvatarBalls->setChecked(false);
renderMenu->addAction("Cycle Voxel Mode", _myAvatar.getVoxels(), SLOT(cycleMode()));
renderMenu->addAction("Cycle Face Mode", &_myAvatar.getHead().getFace(), SLOT(cycleRenderMode()));
(_renderFrameTimerOn = renderMenu->addAction("Show Timer"))->setCheckable(true);
_renderFrameTimerOn->setChecked(false);
(_renderLookatOn = renderMenu->addAction("Lookat Vectors"))->setCheckable(true);

View file

@ -8,6 +8,7 @@
#include <glm/gtx/quaternion.hpp>
#include "Avatar.h"
#include "Head.h"
#include "Face.h"
#include "renderer/ProgramObject.h"
@ -33,8 +34,9 @@ bool Face::render(float alpha) {
glTranslatef(_owningHead->getPosition().x, _owningHead->getPosition().y, _owningHead->getPosition().z);
glm::quat orientation = _owningHead->getOrientation();
glm::vec3 axis = glm::axis(orientation);
//glRotatef(glm::angle(orientation), axis.x, axis.y, axis.z);
glScalef(_owningHead->getScale(), _owningHead->getScale(), _owningHead->getScale());
glRotatef(glm::angle(orientation), axis.x, axis.y, axis.z);
float scale = BODY_BALL_RADIUS_HEAD_BASE * _owningHead->getScale();
glScalef(scale, scale, scale);
glColor4f(1.0f, 1.0f, 1.0f, alpha);
@ -121,6 +123,9 @@ bool Face::render(float alpha) {
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, 0);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_EQUAL, 1.0f);
if (_renderMode == POINTS) {
glPointSize(3.0f);
glDrawArrays(GL_POINTS, 0, VERTEX_COUNT);
@ -131,6 +136,8 @@ bool Face::render(float alpha) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
glDisable(GL_ALPHA_TEST);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
_program->release();
@ -144,13 +151,13 @@ bool Face::render(float alpha) {
glBegin(GL_QUADS);
glTexCoord2f(points[0].x / _textureSize.width, points[0].y / _textureSize.height);
glVertex3f(0.5f, 0, 0);
glVertex3f(0.5f, -aspect * 0.5f, -0.5f);
glTexCoord2f(points[1].x / _textureSize.width, points[1].y / _textureSize.height);
glVertex3f(0.5f, aspect, 0);
glVertex3f(0.5f, aspect * 0.5f, -0.5f);
glTexCoord2f(points[2].x / _textureSize.width, points[2].y / _textureSize.height);
glVertex3f(-0.5f, aspect, 0);
glVertex3f(-0.5f, aspect * 0.5f, -0.5f);
glTexCoord2f(points[3].x / _textureSize.width, points[3].y / _textureSize.height);
glVertex3f(-0.5f, 0, 0);
glVertex3f(-0.5f, -aspect * 0.5f, -0.5f);
glEnd();
glDisable(GL_TEXTURE_2D);

View file

@ -593,7 +593,7 @@ void Head::renderEyeBalls() {
glm::quat rotation = rotationBetween(front, targetLookatVector) * orientation;
glm::vec3 rotationAxis = glm::axis(rotation);
glRotatef(glm::angle(rotation), rotationAxis.x, rotationAxis.y, rotationAxis.z);
glTranslatef(0.0f, 0.0f, -IRIS_PROTRUSION);
glTranslatef(0.0f, 0.0f, -_scale * IRIS_PROTRUSION);
glScalef(_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS); // flatten the iris
@ -602,7 +602,7 @@ void Head::renderEyeBalls() {
_irisProgram->setUniform(_eyePositionLocation, (glm::inverse(rotation) *
(Application::getInstance()->getCamera()->getPosition() - _leftEyePosition) +
glm::vec3(0.0f, 0.0f, _scale * IRIS_PROTRUSION)) * glm::vec3(1.0f / (_scale * IRIS_RADIUS * 2.0f),
1.0f / (_scale * IRIS_RADIUS * 2.0f), 1.0f / _scale * IRIS_RADIUS));
1.0f / (_scale * IRIS_RADIUS * 2.0f), 1.0f / (_scale * IRIS_RADIUS)));
glutSolidSphere(0.5f, 15, 15);
}
@ -617,7 +617,7 @@ void Head::renderEyeBalls() {
glm::quat rotation = rotationBetween(front, targetLookatVector) * orientation;
glm::vec3 rotationAxis = glm::axis(rotation);
glRotatef(glm::angle(rotation), rotationAxis.x, rotationAxis.y, rotationAxis.z);
glTranslatef(0.0f, 0.0f, -IRIS_PROTRUSION);
glTranslatef(0.0f, 0.0f, -_scale * IRIS_PROTRUSION);
glScalef(_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS * 2.0f,
_scale * IRIS_RADIUS); // flatten the iris
@ -626,7 +626,7 @@ void Head::renderEyeBalls() {
_irisProgram->setUniform(_eyePositionLocation, (glm::inverse(rotation) *
(Application::getInstance()->getCamera()->getPosition() - _rightEyePosition) +
glm::vec3(0.0f, 0.0f, _scale * IRIS_PROTRUSION)) * glm::vec3(1.0f / (_scale * IRIS_RADIUS * 2.0f),
1.0f / (_scale * IRIS_RADIUS * 2.0f), 1.0f / _scale * IRIS_RADIUS));
1.0f / (_scale * IRIS_RADIUS * 2.0f), 1.0f / (_scale * IRIS_RADIUS)));
glutSolidSphere(0.5f, 15, 15);
}