mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:53:32 +02:00
cleaned up white space
This commit is contained in:
parent
f83edf4b7f
commit
c80ade98ec
6 changed files with 24 additions and 84 deletions
interface
libraries
tools/skeleton-dump/src
|
@ -9,9 +9,9 @@
|
|||
import QtQuick 2.5
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import "../../styles-uit"
|
||||
import stylesUit 1.0
|
||||
import "../../controls"
|
||||
import "../../controls-uit" as HifiControls
|
||||
import controlsUit 1.0 as HifiControls
|
||||
import "."
|
||||
|
||||
|
||||
|
|
|
@ -90,7 +90,6 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
|
|||
|
||||
// Called within Model::simulate call, below.
|
||||
void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||
|
||||
const HFMModel& hfmModel = getHFMModel();
|
||||
|
||||
Head* head = _owningAvatar->getHead();
|
||||
|
@ -230,7 +229,6 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
params.primaryControllerFlags[Rig::PrimaryControllerType_Hips] = (uint8_t)Rig::ControllerFlags::Enabled | (uint8_t)Rig::ControllerFlags::Estimated;
|
||||
|
||||
// set spine2 if we have hand controllers
|
||||
//qCDebug(interfaceapp) << "spine 2 joint offset " << jointOffsetMap[13];
|
||||
if (myAvatar->getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).isValid() &&
|
||||
myAvatar->getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).isValid() &&
|
||||
!(params.primaryControllerFlags[Rig::PrimaryControllerType_Spine2] & (uint8_t)Rig::ControllerFlags::Enabled)) {
|
||||
|
@ -241,7 +239,6 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
bool spine2Exists = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Spine2"), currentSpine2Pose);
|
||||
bool headExists = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Head"), currentHeadPose);
|
||||
bool hipsExists = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Hips"), currentHipsPose);
|
||||
|
||||
if (spine2Exists && headExists && hipsExists) {
|
||||
|
||||
AnimPose rigSpaceYaw(myAvatar->getSpine2RotationRigSpace());
|
||||
|
|
|
@ -101,10 +101,8 @@ void AnimClip::copyFromNetworkAnim() {
|
|||
|
||||
// build a mapping from animation joint indices to skeleton joint indices.
|
||||
// by matching joints with the same name.
|
||||
|
||||
const HFMModel& hfmModel = _networkAnim->getHFMModel();
|
||||
AnimSkeleton animSkeleton(hfmModel);
|
||||
|
||||
const auto animJointCount = animSkeleton.getNumJoints();
|
||||
const auto skeletonJointCount = _skeleton->getNumJoints();
|
||||
std::vector<int> jointMap;
|
||||
|
|
|
@ -15,76 +15,38 @@
|
|||
#include <GLMHelpers.h>
|
||||
|
||||
#include "AnimationLogging.h"
|
||||
static bool notBound = true;
|
||||
|
||||
AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
|
||||
qCDebug(animation) << "in the animSkeleton";
|
||||
// convert to std::vector of joints
|
||||
std::vector<HFMJoint> joints;
|
||||
joints.reserve(hfmModel.joints.size());
|
||||
for (auto& joint : hfmModel.joints) {
|
||||
joints.push_back(joint);
|
||||
}
|
||||
|
||||
glm::quat offset1(0.5f, 0.5f, 0.5f, -0.5f);
|
||||
glm::quat offset2(0.7071f, 0.0f, -0.7071f, 0.0f);
|
||||
|
||||
buildSkeletonFromJoints(joints, hfmModel.jointRotationOffsets);
|
||||
// add offsets for spine2 and the neck
|
||||
static bool once = true;
|
||||
qCDebug(animation) << "the hfm model path is " << hfmModel.originalURL;
|
||||
//if (once && hfmModel.originalURL == "/angus/avatars/engineer_hifinames/engineer_hifinames/engineer_hifinames.fbx") {
|
||||
//if (once && hfmModel.originalURL == "/angus/avatars/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd.fbx") {
|
||||
once = false;
|
||||
for (int i = 0; i < (int)hfmModel.meshes.size(); i++) {
|
||||
const HFMMesh& mesh = hfmModel.meshes.at(i);
|
||||
for (int j = 0; j < mesh.clusters.size(); j++) {
|
||||
|
||||
for (int i = 0; i < (int)hfmModel.meshes.size(); i++) {
|
||||
const HFMMesh& mesh = hfmModel.meshes.at(i);
|
||||
for (int j = 0; j < mesh.clusters.size(); j++) {
|
||||
|
||||
// cast into a non-const reference, so we can mutate the FBXCluster
|
||||
HFMCluster& cluster = const_cast<HFMCluster&>(mesh.clusters.at(j));
|
||||
// cast into a non-const reference, so we can mutate the FBXCluster
|
||||
HFMCluster& cluster = const_cast<HFMCluster&>(mesh.clusters.at(j));
|
||||
|
||||
// AJT: mutate bind pose! this allows us to oreint the skeleton back into the authored orientaiton before
|
||||
// rendering, with no runtime overhead.
|
||||
// this works if clusters match joints one for one.
|
||||
if (hfmModel.jointRotationOffsets.contains(cluster.jointIndex)) {
|
||||
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset2 << " cluster " << cluster.jointIndex;
|
||||
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
|
||||
//AnimPose localOffset(offset2, glm::vec3());
|
||||
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * hfmModel.clusterBindMatrixOriginalValues[i][j];
|
||||
qCDebug(animation) << "the new bind matrix num: " << cluster.jointIndex << cluster.inverseBindMatrix;
|
||||
if ((hfmModel.clusterBindMatrixOriginalValues.size() > i) && (hfmModel.clusterBindMatrixOriginalValues[i].size() > cluster.jointIndex)) {
|
||||
qCDebug(animation) << "the saved orig matrix num: " << cluster.jointIndex << hfmModel.clusterBindMatrixOriginalValues[i][j];
|
||||
}
|
||||
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
||||
// AJT: mutate bind pose! this allows us to oreint the skeleton back into the authored orientaiton before
|
||||
// rendering, with no runtime overhead.
|
||||
if (hfmModel.jointRotationOffsets.contains(cluster.jointIndex)) {
|
||||
qCDebug(animation) << "found a cluster " << cluster.jointIndex;
|
||||
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
|
||||
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * hfmModel.clusterBindMatrixOriginalValues[i][j];
|
||||
qCDebug(animation) << "the new bind matrix num: " << cluster.jointIndex << cluster.inverseBindMatrix;
|
||||
if ((hfmModel.clusterBindMatrixOriginalValues.size() > i) && (hfmModel.clusterBindMatrixOriginalValues[i].size() > cluster.jointIndex)) {
|
||||
qCDebug(animation) << "the saved orig matrix num: " << cluster.jointIndex << hfmModel.clusterBindMatrixOriginalValues[i][j];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
if (cluster.jointIndex == 62) {
|
||||
qCDebug(animation) << "Neck";
|
||||
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset2 << " cluster " << cluster.jointIndex;
|
||||
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
|
||||
//AnimPose localOffset(offset2, glm::vec3());
|
||||
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
|
||||
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
||||
}
|
||||
if (cluster.jointIndex == 13) {
|
||||
qCDebug(animation) << "Spine2";
|
||||
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset1 << " cluster " << cluster.jointIndex;
|
||||
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
|
||||
//AnimPose localOffset(offset1, glm::vec3());
|
||||
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
|
||||
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
||||
}
|
||||
*/
|
||||
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnimSkeleton::AnimSkeleton(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets) {
|
||||
buildSkeletonFromJoints(joints, jointOffsets);
|
||||
|
@ -253,19 +215,15 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
|
|||
qCDebug(animation) << "relative default pose for joint " << i << " " << relDefaultPose.trans() << " " << relDefaultPose.rot();
|
||||
|
||||
int parentIndex = getParentIndex(i);
|
||||
|
||||
AnimPose newAbsPose;
|
||||
if (parentIndex >= 0) {
|
||||
newAbsPose = _absoluteDefaultPoses[parentIndex] * relDefaultPose;
|
||||
|
||||
_absoluteDefaultPoses.push_back(newAbsPose);
|
||||
} else {
|
||||
|
||||
_absoluteDefaultPoses.push_back(relDefaultPose);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (int k = 0; k < _jointsSize; k++) {
|
||||
int parentIndex2 = getParentIndex(k);
|
||||
if (jointOffsets.contains(k)) {
|
||||
|
@ -273,19 +231,15 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
|
|||
_absoluteDefaultPoses[k] = _absoluteDefaultPoses[k] * localOffset;
|
||||
}
|
||||
if (parentIndex2 >= 0) {
|
||||
|
||||
_relativeDefaultPoses.push_back(_absoluteDefaultPoses[parentIndex2].inverse() * _absoluteDefaultPoses[k]);
|
||||
} else {
|
||||
|
||||
_relativeDefaultPoses.push_back(_absoluteDefaultPoses[k]);
|
||||
}
|
||||
}
|
||||
|
||||
// re-compute relative poses
|
||||
// re-compute relative poses
|
||||
//_relativeDefaultPoses = _absoluteDefaultPoses;
|
||||
//convertAbsolutePosesToRelative(_relativeDefaultPoses);
|
||||
|
||||
|
||||
for (int i = 0; i < _jointsSize; i++) {
|
||||
_jointIndicesByName[_joints[i].name] = i;
|
||||
}
|
||||
|
|
|
@ -632,14 +632,10 @@ QMap<QString, glm::quat> getJointRotationOffsets(const QVariantHash& mapping) {
|
|||
if (!isNaN(quatX) && !isNaN(quatY) && !isNaN(quatZ) && !isNaN(quatW)) {
|
||||
glm::quat rotationOffset = glm::quat(quatW, quatX, quatY, quatZ);
|
||||
jointRotationOffsets.insert(jointName, rotationOffset);
|
||||
|
||||
}
|
||||
}
|
||||
qCDebug(modelformat) << "found an offset in fst";
|
||||
}
|
||||
qCDebug(modelformat) << "found an offset in fst 2";
|
||||
}
|
||||
qCDebug(modelformat) << "found an offset in fst 3";
|
||||
return jointRotationOffsets;
|
||||
}
|
||||
|
||||
|
@ -2031,18 +2027,15 @@ HFMModel* FBXReader::extractHFMModel(const QVariantHash& mapping, const QString&
|
|||
}
|
||||
qCDebug(modelformat) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
|
||||
}
|
||||
//hfmModel.jointRotationOffsets.insert(13, glm::quat(0.5f, 0.5f, 0.5f, -0.5f));
|
||||
//hfmModel.jointRotationOffsets.insert(62, glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f));
|
||||
|
||||
|
||||
// create a backup copy of the bindposes,
|
||||
// these are needed when we recompute the bindpose offsets on reset.
|
||||
for (int i = 0; i < (int)hfmModel.meshes.size(); i++) {
|
||||
const HFMMesh& mesh = hfmModel.meshes.at(i);
|
||||
vector<glm::mat4> tempBindMat;
|
||||
for (int j = 0; j < mesh.clusters.size(); j++) {
|
||||
const HFMCluster& cluster = mesh.clusters.at(j);
|
||||
tempBindMat.push_back(cluster.inverseBindMatrix);
|
||||
//if(hfmModel.clusterBindMatrixOriginalValues[i])
|
||||
//hfmModel.clusterBindMatrixOriginalValues[i].insert(cluster.jointIndex,Matrices::IDENTITY);// cluster.inverseBindMatrix;
|
||||
//glm::mat4 testMat = cluster.inverseBindMatrix;
|
||||
}
|
||||
hfmModel.clusterBindMatrixOriginalValues.push_back(tempBindMat);
|
||||
}
|
||||
|
|
|
@ -54,10 +54,8 @@ SkeletonDumpApp::SkeletonDumpApp(int argc, char* argv[]) : QCoreApplication(argc
|
|||
return;
|
||||
}
|
||||
QByteArray blob = file.readAll();
|
||||
|
||||
std::unique_ptr<HFMModel> geometry(readFBX(blob, QVariantHash()));
|
||||
std::unique_ptr<AnimSkeleton> skeleton(new AnimSkeleton(*geometry));
|
||||
|
||||
skeleton->dump(verbose);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue