mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 16:52:10 +02:00
Apply the neck position.
This commit is contained in:
parent
b5f2dcfa55
commit
9d89baa506
3 changed files with 38 additions and 7 deletions
|
@ -22,9 +22,18 @@ void FaceModel::simulate(float deltaTime) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Skeleton& skeleton = static_cast<Avatar*>(_owningHead->_owningAvatar)->getSkeleton();
|
Avatar* owningAvatar = static_cast<Avatar*>(_owningHead->_owningAvatar);
|
||||||
setTranslation(skeleton.joint[AVATAR_JOINT_NECK_BASE].position);
|
const Skeleton& skeleton = owningAvatar->getSkeleton();
|
||||||
setRotation(skeleton.joint[AVATAR_JOINT_NECK_BASE].absoluteRotation);
|
glm::vec3 neckPosition;
|
||||||
|
if (!owningAvatar->getSkeletonModel().getNeckPosition(neckPosition)) {
|
||||||
|
neckPosition = owningAvatar->getSkeleton().joint[AVATAR_JOINT_NECK_BASE].position;
|
||||||
|
}
|
||||||
|
setTranslation(neckPosition);
|
||||||
|
glm::quat neckRotation;
|
||||||
|
if (true || !owningAvatar->getSkeletonModel().getNeckRotation(neckRotation)) {
|
||||||
|
neckRotation = owningAvatar->getSkeleton().joint[AVATAR_JOINT_NECK_BASE].absoluteRotation;
|
||||||
|
}
|
||||||
|
setRotation(neckRotation);
|
||||||
const float MODEL_SCALE = 0.0006f;
|
const float MODEL_SCALE = 0.0006f;
|
||||||
setScale(glm::vec3(-1.0f, 1.0f, -1.0f) * _owningHead->getScale() * MODEL_SCALE);
|
setScale(glm::vec3(-1.0f, 1.0f, -1.0f) * _owningHead->getScale() * MODEL_SCALE);
|
||||||
const glm::vec3 MODEL_TRANSLATION(0.0f, -60.0f, 40.0f); // temporary fudge factor
|
const glm::vec3 MODEL_TRANSLATION(0.0f, -60.0f, 40.0f); // temporary fudge factor
|
||||||
|
|
|
@ -85,10 +85,6 @@ void Model::simulate(float deltaTime) {
|
||||||
_resetStates = true;
|
_resetStates = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create our root transform
|
|
||||||
glm::mat4 baseTransform = glm::translate(_translation) * glm::mat4_cast(_rotation) *
|
|
||||||
glm::scale(_scale) * glm::translate(_offset);
|
|
||||||
|
|
||||||
// update the world space transforms for all joints
|
// update the world space transforms for all joints
|
||||||
for (int i = 0; i < _jointStates.size(); i++) {
|
for (int i = 0; i < _jointStates.size(); i++) {
|
||||||
updateJointState(i);
|
updateJointState(i);
|
||||||
|
@ -351,6 +347,14 @@ bool Model::getHeadPosition(glm::vec3& headPosition) const {
|
||||||
return isActive() && getJointPosition(_geometry->getFBXGeometry().headJointIndex, headPosition);
|
return isActive() && getJointPosition(_geometry->getFBXGeometry().headJointIndex, headPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::getNeckPosition(glm::vec3& neckPosition) const {
|
||||||
|
return isActive() && getJointPosition(_geometry->getFBXGeometry().neckJointIndex, neckPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Model::getNeckRotation(glm::quat& neckRotation) const {
|
||||||
|
return isActive() && getJointRotation(_geometry->getFBXGeometry().neckJointIndex, neckRotation);
|
||||||
|
}
|
||||||
|
|
||||||
bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const {
|
bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const {
|
||||||
if (!isActive()) {
|
if (!isActive()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -404,6 +408,15 @@ bool Model::getJointPosition(int jointIndex, glm::vec3& position) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::getJointRotation(int jointIndex, glm::quat& rotation) const {
|
||||||
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const glm::mat4& transform = _jointStates[jointIndex].transform;
|
||||||
|
rotation = glm::normalize(glm::quat_cast(transform));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Model::deleteGeometry() {
|
void Model::deleteGeometry() {
|
||||||
foreach (GLuint id, _blendedVertexBufferIDs) {
|
foreach (GLuint id, _blendedVertexBufferIDs) {
|
||||||
glDeleteBuffers(1, &id);
|
glDeleteBuffers(1, &id);
|
||||||
|
|
|
@ -58,6 +58,14 @@ public:
|
||||||
/// \return whether or not the head was found
|
/// \return whether or not the head was found
|
||||||
bool getHeadPosition(glm::vec3& headPosition) const;
|
bool getHeadPosition(glm::vec3& headPosition) const;
|
||||||
|
|
||||||
|
/// Returns the position of the neck joint.
|
||||||
|
/// \return whether or not the neck was found
|
||||||
|
bool getNeckPosition(glm::vec3& neckPosition) const;
|
||||||
|
|
||||||
|
/// Returns the rotation of the neck joint.
|
||||||
|
/// \return whether or not the neck was found
|
||||||
|
bool getNeckRotation(glm::quat& neckRotation) const;
|
||||||
|
|
||||||
/// Retrieve the positions of up to two eye meshes.
|
/// Retrieve the positions of up to two eye meshes.
|
||||||
/// \return whether or not both eye meshes were found
|
/// \return whether or not both eye meshes were found
|
||||||
bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
|
bool getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const;
|
||||||
|
@ -88,6 +96,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool getJointPosition(int jointIndex, glm::vec3& position) const;
|
bool getJointPosition(int jointIndex, glm::vec3& position) const;
|
||||||
|
bool getJointRotation(int jointIndex, glm::quat& rotation) const;
|
||||||
|
|
||||||
void deleteGeometry();
|
void deleteGeometry();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue