mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 18:58:20 +02:00
Use the head position from the loaded skeleton, if available.
This commit is contained in:
parent
349f7b363a
commit
b5f2dcfa55
6 changed files with 39 additions and 12 deletions
|
@ -413,7 +413,11 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
||||||
_head.setPosition(_bodyBall[ BODY_BALL_HEAD_BASE ].position);
|
glm::vec3 headPosition;
|
||||||
|
if (!_skeletonModel.getHeadPosition(headPosition)) {
|
||||||
|
headPosition = _bodyBall[BODY_BALL_HEAD_BASE].position;
|
||||||
|
}
|
||||||
|
_head.setPosition(headPosition);
|
||||||
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
||||||
_head.simulate(deltaTime, false);
|
_head.simulate(deltaTime, false);
|
||||||
_skeletonModel.simulate(deltaTime);
|
_skeletonModel.simulate(deltaTime);
|
||||||
|
|
|
@ -318,7 +318,11 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
_head.setBodyRotation(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll));
|
||||||
_head.setPosition(_bodyBall[ BODY_BALL_HEAD_BASE ].position);
|
glm::vec3 headPosition;
|
||||||
|
if (!_skeletonModel.getHeadPosition(headPosition)) {
|
||||||
|
headPosition = _bodyBall[BODY_BALL_HEAD_BASE].position;
|
||||||
|
}
|
||||||
|
_head.setPosition(headPosition);
|
||||||
_head.setScale(_scale);
|
_head.setScale(_scale);
|
||||||
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
_head.setSkinColor(glm::vec3(SKIN_COLOR[0], SKIN_COLOR[1], SKIN_COLOR[2]));
|
||||||
_head.simulate(deltaTime, true);
|
_head.simulate(deltaTime, true);
|
||||||
|
|
|
@ -662,11 +662,13 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
QByteArray jointNeckName = joints.value("jointNeck", "jointNeck").toByteArray();
|
QByteArray jointNeckName = joints.value("jointNeck", "jointNeck").toByteArray();
|
||||||
QByteArray jointRootName = joints.value("jointRoot", "jointRoot").toByteArray();
|
QByteArray jointRootName = joints.value("jointRoot", "jointRoot").toByteArray();
|
||||||
QByteArray jointLeanName = joints.value("jointLean", "jointLean").toByteArray();
|
QByteArray jointLeanName = joints.value("jointLean", "jointLean").toByteArray();
|
||||||
|
QByteArray jointHeadName = joints.value("jointHead", "jointHead").toByteArray();
|
||||||
QString jointEyeLeftID;
|
QString jointEyeLeftID;
|
||||||
QString jointEyeRightID;
|
QString jointEyeRightID;
|
||||||
QString jointNeckID;
|
QString jointNeckID;
|
||||||
QString jointRootID;
|
QString jointRootID;
|
||||||
QString jointLeanID;
|
QString jointLeanID;
|
||||||
|
QString jointHeadID;
|
||||||
|
|
||||||
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
||||||
QHash<QByteArray, QPair<int, float> > blendshapeIndices;
|
QHash<QByteArray, QPair<int, float> > blendshapeIndices;
|
||||||
|
@ -737,6 +739,9 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
|
|
||||||
} else if (name == jointLeanName) {
|
} else if (name == jointLeanName) {
|
||||||
jointLeanID = object.properties.at(0).toString();
|
jointLeanID = object.properties.at(0).toString();
|
||||||
|
|
||||||
|
} else if (name == jointHeadName) {
|
||||||
|
jointHeadID = object.properties.at(0).toString();
|
||||||
}
|
}
|
||||||
glm::vec3 translation;
|
glm::vec3 translation;
|
||||||
glm::vec3 rotationOffset;
|
glm::vec3 rotationOffset;
|
||||||
|
@ -965,6 +970,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
geometry.neckJointIndex = modelIDs.indexOf(jointNeckID);
|
geometry.neckJointIndex = modelIDs.indexOf(jointNeckID);
|
||||||
geometry.rootJointIndex = modelIDs.indexOf(jointRootID);
|
geometry.rootJointIndex = modelIDs.indexOf(jointRootID);
|
||||||
geometry.leanJointIndex = modelIDs.indexOf(jointLeanID);
|
geometry.leanJointIndex = modelIDs.indexOf(jointLeanID);
|
||||||
|
geometry.headJointIndex = modelIDs.indexOf(jointHeadID);
|
||||||
|
|
||||||
// extract the translation component of the neck transform
|
// extract the translation component of the neck transform
|
||||||
if (geometry.neckJointIndex != -1) {
|
if (geometry.neckJointIndex != -1) {
|
||||||
|
|
|
@ -111,6 +111,7 @@ public:
|
||||||
int neckJointIndex;
|
int neckJointIndex;
|
||||||
int rootJointIndex;
|
int rootJointIndex;
|
||||||
int leanJointIndex;
|
int leanJointIndex;
|
||||||
|
int headJointIndex;
|
||||||
|
|
||||||
glm::vec3 neckPivot;
|
glm::vec3 neckPivot;
|
||||||
};
|
};
|
||||||
|
|
|
@ -347,20 +347,17 @@ bool Model::render(float alpha) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::getHeadPosition(glm::vec3& headPosition) const {
|
||||||
|
return isActive() && getJointPosition(_geometry->getFBXGeometry().headJointIndex, headPosition);
|
||||||
|
}
|
||||||
|
|
||||||
bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const {
|
bool Model::getEyePositions(glm::vec3& firstEyePosition, glm::vec3& secondEyePosition) const {
|
||||||
if (!isActive() || _jointStates.isEmpty()) {
|
if (!isActive()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
if (geometry.leftEyeJointIndex != -1) {
|
return getJointPosition(geometry.leftEyeJointIndex, firstEyePosition) &&
|
||||||
const glm::mat4& transform = _jointStates[geometry.leftEyeJointIndex].transform;
|
getJointPosition(geometry.rightEyeJointIndex, secondEyePosition);
|
||||||
firstEyePosition = glm::vec3(transform[3][0], transform[3][1], transform[3][2]);
|
|
||||||
}
|
|
||||||
if (geometry.rightEyeJointIndex != -1) {
|
|
||||||
const glm::mat4& transform = _jointStates[geometry.rightEyeJointIndex].transform;
|
|
||||||
secondEyePosition = glm::vec3(transform[3][0], transform[3][1], transform[3][2]);
|
|
||||||
}
|
|
||||||
return geometry.leftEyeJointIndex != -1 && geometry.rightEyeJointIndex != -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::setURL(const QUrl& url) {
|
void Model::setURL(const QUrl& url) {
|
||||||
|
@ -398,6 +395,15 @@ void Model::updateJointState(int index) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Model::getJointPosition(int jointIndex, glm::vec3& position) const {
|
||||||
|
if (jointIndex == -1 || _jointStates.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const glm::mat4& transform = _jointStates[jointIndex].transform;
|
||||||
|
position = glm::vec3(transform[3][0], transform[3][1], transform[3][2]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Model::deleteGeometry() {
|
void Model::deleteGeometry() {
|
||||||
foreach (GLuint id, _blendedVertexBufferIDs) {
|
foreach (GLuint id, _blendedVertexBufferIDs) {
|
||||||
glDeleteBuffers(1, &id);
|
glDeleteBuffers(1, &id);
|
||||||
|
|
|
@ -54,6 +54,10 @@ public:
|
||||||
Q_INVOKABLE void setURL(const QUrl& url);
|
Q_INVOKABLE void setURL(const QUrl& url);
|
||||||
const QUrl& getURL() const { return _url; }
|
const QUrl& getURL() const { return _url; }
|
||||||
|
|
||||||
|
/// Returns the position of the head joint.
|
||||||
|
/// \return whether or not the head was found
|
||||||
|
bool getHeadPosition(glm::vec3& headPosition) 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;
|
||||||
|
@ -83,6 +87,8 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool getJointPosition(int jointIndex, glm::vec3& position) const;
|
||||||
|
|
||||||
void deleteGeometry();
|
void deleteGeometry();
|
||||||
|
|
||||||
float _pupilDilation;
|
float _pupilDilation;
|
||||||
|
|
Loading…
Reference in a new issue