mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:10:37 +02:00
Use a bound texture for the iris, load it with Qt rather than lodepng (we can
probably just remove the lodepng dependency).
This commit is contained in:
parent
11fcd8f72f
commit
466c062bc1
3 changed files with 25 additions and 15 deletions
|
@ -271,6 +271,7 @@ Avatar::~Avatar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Avatar::init() {
|
void Avatar::init() {
|
||||||
|
_head.init();
|
||||||
_voxels.init();
|
_voxels.init();
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||||
|
|
||||||
#include <glm/gtx/quaternion.hpp>
|
#include <glm/gtx/quaternion.hpp>
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Avatar.h"
|
#include "Avatar.h"
|
||||||
#include "Head.h"
|
#include "Head.h"
|
||||||
|
@ -36,9 +39,7 @@ const float IRIS_RADIUS = 0.007;
|
||||||
const float IRIS_PROTRUSION = 0.0145f;
|
const float IRIS_PROTRUSION = 0.0145f;
|
||||||
const char IRIS_TEXTURE_FILENAME[] = "resources/images/iris.png";
|
const char IRIS_TEXTURE_FILENAME[] = "resources/images/iris.png";
|
||||||
|
|
||||||
unsigned int IRIS_TEXTURE_WIDTH = 768;
|
GLuint Head::_irisTextureID = 0;
|
||||||
unsigned int IRIS_TEXTURE_HEIGHT = 498;
|
|
||||||
vector<unsigned char> irisTexture;
|
|
||||||
|
|
||||||
Head::Head(Avatar* owningAvatar) :
|
Head::Head(Avatar* owningAvatar) :
|
||||||
HeadData((AvatarData*)owningAvatar),
|
HeadData((AvatarData*)owningAvatar),
|
||||||
|
@ -74,6 +75,19 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Head::init() {
|
||||||
|
if (_irisTextureID == 0) {
|
||||||
|
switchToResourcesParentIfRequired();
|
||||||
|
QImage image = QImage(IRIS_TEXTURE_FILENAME).convertToFormat(QImage::Format_RGB888);
|
||||||
|
|
||||||
|
glGenTextures(1, &_irisTextureID);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, _irisTextureID);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.constBits());
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Head::reset() {
|
void Head::reset() {
|
||||||
_yaw = _pitch = _roll = 0.0f;
|
_yaw = _pitch = _roll = 0.0f;
|
||||||
_leanForward = _leanSideways = 0.0f;
|
_leanForward = _leanSideways = 0.0f;
|
||||||
|
@ -469,22 +483,12 @@ void Head::renderEyeBrows() {
|
||||||
|
|
||||||
void Head::renderEyeBalls() {
|
void Head::renderEyeBalls() {
|
||||||
|
|
||||||
if (::irisTexture.size() == 0) {
|
|
||||||
switchToResourcesParentIfRequired();
|
|
||||||
unsigned error = lodepng::decode(::irisTexture, IRIS_TEXTURE_WIDTH, IRIS_TEXTURE_HEIGHT, IRIS_TEXTURE_FILENAME);
|
|
||||||
if (error != 0) {
|
|
||||||
printLog("error %u: %s\n", error, lodepng_error_text(error));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// setup the texutre to be used on each iris
|
// setup the texutre to be used on each iris
|
||||||
GLUquadric* irisQuadric = gluNewQuadric();
|
GLUquadric* irisQuadric = gluNewQuadric();
|
||||||
gluQuadricTexture(irisQuadric, GL_TRUE);
|
gluQuadricTexture(irisQuadric, GL_TRUE);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
gluQuadricOrientation(irisQuadric, GLU_OUTSIDE);
|
gluQuadricOrientation(irisQuadric, GLU_OUTSIDE);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, IRIS_TEXTURE_WIDTH, IRIS_TEXTURE_HEIGHT,
|
glBindTexture(GL_TEXTURE_2D, _irisTextureID);
|
||||||
0, GL_RGBA, GL_UNSIGNED_BYTE, &::irisTexture[0]);
|
|
||||||
|
|
||||||
// render white ball of left eyeball
|
// render white ball of left eyeball
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
@ -579,6 +583,8 @@ void Head::renderEyeBalls() {
|
||||||
// delete the iris quadric now that we're done with it
|
// delete the iris quadric now that we're done with it
|
||||||
gluDeleteQuadric(irisQuadric);
|
gluDeleteQuadric(irisQuadric);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) {
|
void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) {
|
||||||
|
|
|
@ -31,6 +31,7 @@ class Head : public HeadData {
|
||||||
public:
|
public:
|
||||||
Head(Avatar* owningAvatar);
|
Head(Avatar* owningAvatar);
|
||||||
|
|
||||||
|
void init();
|
||||||
void reset();
|
void reset();
|
||||||
void simulate(float deltaTime, bool isMine);
|
void simulate(float deltaTime, bool isMine);
|
||||||
void render(bool lookingInMirror, float alpha);
|
void render(bool lookingInMirror, float alpha);
|
||||||
|
@ -104,6 +105,8 @@ private:
|
||||||
glm::vec3* _mohawkTriangleFan;
|
glm::vec3* _mohawkTriangleFan;
|
||||||
glm::vec3* _mohawkColors;
|
glm::vec3* _mohawkColors;
|
||||||
|
|
||||||
|
static GLuint _irisTextureID;
|
||||||
|
|
||||||
// private methods
|
// private methods
|
||||||
void createMohawk();
|
void createMohawk();
|
||||||
void renderHeadSphere();
|
void renderHeadSphere();
|
||||||
|
|
Loading…
Reference in a new issue