mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Use the blend face eye locations for the eye vectors, when possible.
This commit is contained in:
parent
9a16d44a47
commit
402f65fc00
3 changed files with 34 additions and 6 deletions
|
@ -35,6 +35,9 @@ void BlendFace::init() {
|
|||
}
|
||||
}
|
||||
|
||||
const glm::vec3 MODEL_TRANSLATION(0.0f, -0.025f, -0.025f); // temporary fudge factor
|
||||
const float MODEL_SCALE = 0.0006f;
|
||||
|
||||
bool BlendFace::render(float alpha) {
|
||||
if (_meshIDs.isEmpty()) {
|
||||
return false;
|
||||
|
@ -44,11 +47,9 @@ bool BlendFace::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);
|
||||
const glm::vec3 MODEL_TRANSLATION(0.0f, -0.025f, -0.025f); // temporary fudge factor
|
||||
glRotatef(glm::angle(orientation), axis.x, axis.y, axis.z);
|
||||
glTranslatef(MODEL_TRANSLATION.x, MODEL_TRANSLATION.y, MODEL_TRANSLATION.z);
|
||||
const float MODEL_SCALE = 0.0006f;
|
||||
glm::vec3 scale(_owningHead->getScale() * MODEL_SCALE, _owningHead->getScale() * MODEL_SCALE,
|
||||
glm::vec3 scale(-_owningHead->getScale() * MODEL_SCALE, _owningHead->getScale() * MODEL_SCALE,
|
||||
-_owningHead->getScale() * MODEL_SCALE);
|
||||
glScalef(scale.x, scale.y, scale.z);
|
||||
|
||||
|
@ -75,7 +76,7 @@ bool BlendFace::render(float alpha) {
|
|||
glm::quat rotation = glm::inverse(orientation) * _owningHead->getEyeRotation(orientation *
|
||||
(mesh.pivot * scale + MODEL_TRANSLATION) + _owningHead->getPosition());
|
||||
glm::vec3 rotationAxis = glm::axis(rotation);
|
||||
glRotatef(glm::angle(-rotation), rotationAxis.x, rotationAxis.y, rotationAxis.z);
|
||||
glRotatef(glm::angle(rotation), -rotationAxis.x, rotationAxis.y, -rotationAxis.z);
|
||||
glTranslatef(-mesh.pivot.x, -mesh.pivot.y, -mesh.pivot.z);
|
||||
|
||||
// use texture coordinates only for the eye, for now
|
||||
|
@ -149,6 +150,25 @@ bool BlendFace::render(float alpha) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void BlendFace::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const {
|
||||
glm::quat orientation = _owningHead->getOrientation();
|
||||
glm::vec3 scale(-_owningHead->getScale() * MODEL_SCALE, _owningHead->getScale() * MODEL_SCALE,
|
||||
-_owningHead->getScale() * MODEL_SCALE);
|
||||
bool foundFirst = false;
|
||||
|
||||
foreach (const FBXMesh& mesh, _geometry.meshes) {
|
||||
if (mesh.isEye) {
|
||||
glm::vec3 position = orientation * (mesh.pivot * scale + MODEL_TRANSLATION) + _owningHead->getPosition();
|
||||
if (foundFirst) {
|
||||
secondEyePosition = position;
|
||||
return;
|
||||
}
|
||||
firstEyePosition = position;
|
||||
foundFirst = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlendFace::setModelURL(const QUrl& url) {
|
||||
// don't restart the download if it's the same URL
|
||||
if (_modelURL == url) {
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
Q_INVOKABLE void setModelURL(const QUrl& url);
|
||||
const QUrl& getModelURL() const { return _modelURL; }
|
||||
|
||||
void getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
|
||||
|
||||
private slots:
|
||||
|
||||
void handleModelDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||
|
|
|
@ -343,7 +343,13 @@ void Head::render(float alpha, bool isMine) {
|
|||
}
|
||||
|
||||
if (_renderLookatVectors) {
|
||||
renderLookatVectors(_leftEyePosition, _rightEyePosition, _lookAtPosition);
|
||||
glm::vec3 firstEyePosition = _leftEyePosition;
|
||||
glm::vec3 secondEyePosition = _rightEyePosition;
|
||||
if (_blendFace.isActive()) {
|
||||
// the blend face may have custom eye meshes
|
||||
_blendFace.getEyePositions(firstEyePosition, secondEyePosition);
|
||||
}
|
||||
renderLookatVectors(firstEyePosition, secondEyePosition, _lookAtPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue