mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
cleaned up for merge with luis
This commit is contained in:
parent
244b768b9a
commit
e36ab9efd6
10 changed files with 8 additions and 142 deletions
|
@ -84,8 +84,7 @@ void ScriptableAvatar::update(float deltatime) {
|
|||
// Run animation
|
||||
if (_animation && _animation->isLoaded() && _animation->getFrames().size() > 0 && !_bind.isNull() && _bind->isLoaded()) {
|
||||
if (!_animSkeleton) {
|
||||
QMap<int, glm::quat> jointRotationOffsets;
|
||||
_animSkeleton = std::make_shared<AnimSkeleton>(_bind->getHFMModel(), jointRotationOffsets);
|
||||
_animSkeleton = std::make_shared<AnimSkeleton>(_bind->getHFMModel());
|
||||
}
|
||||
float currentFrame = _animationDetails.currentFrame + deltatime * _animationDetails.fps;
|
||||
if (_animationDetails.loop || currentFrame < _animationDetails.lastFrame) {
|
||||
|
|
|
@ -92,7 +92,6 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
|
|||
void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||
|
||||
const HFMModel& hfmModel = getHFMModel();
|
||||
const QMap<int, glm::quat> jointOffsetMap = _rig.getJointRotationOffsets();
|
||||
|
||||
Head* head = _owningAvatar->getHead();
|
||||
|
||||
|
|
|
@ -103,8 +103,7 @@ void AnimClip::copyFromNetworkAnim() {
|
|||
// by matching joints with the same name.
|
||||
|
||||
const HFMModel& hfmModel = _networkAnim->getHFMModel();
|
||||
QMap<int, glm::quat> jointRotationOffsets;
|
||||
AnimSkeleton animSkeleton(hfmModel, jointRotationOffsets);
|
||||
AnimSkeleton animSkeleton(hfmModel);
|
||||
|
||||
const auto animJointCount = animSkeleton.getNumJoints();
|
||||
const auto skeletonJointCount = _skeleton->getNumJoints();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "AnimationLogging.h"
|
||||
static bool notBound = true;
|
||||
|
||||
AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel, const QMap<int, glm::quat> jointOffsets) {
|
||||
AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
|
||||
qCDebug(animation) << "in the animSkeleton";
|
||||
// convert to std::vector of joints
|
||||
std::vector<HFMJoint> joints;
|
||||
|
@ -26,7 +26,7 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel, const QMap<int, glm::quat>
|
|||
joints.push_back(joint);
|
||||
}
|
||||
|
||||
buildSkeletonFromJoints(joints, jointOffsets);
|
||||
buildSkeletonFromJoints(joints, hfmModel.jointOffsets);
|
||||
// add offsets for spine2 and the neck
|
||||
|
||||
|
||||
|
@ -203,7 +203,7 @@ void AnimSkeleton::mirrorAbsolutePoses(AnimPoseVec& poses) const {
|
|||
}
|
||||
}
|
||||
|
||||
void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets) {
|
||||
void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets) {
|
||||
|
||||
_joints = joints;
|
||||
_jointsSize = (int)joints.size();
|
||||
|
|
|
@ -267,7 +267,7 @@ void Rig::initJointStates(const HFMModel& hfmModel, const glm::mat4& modelOffset
|
|||
_rigToGeometryTransform = glm::inverse(_geometryToRigTransform);
|
||||
setModelOffset(modelOffset);
|
||||
|
||||
_animSkeleton = std::make_shared<AnimSkeleton>(hfmModel, _jointRotationOffsets);
|
||||
_animSkeleton = std::make_shared<AnimSkeleton>(hfmModel);
|
||||
|
||||
_internalPoseSet._relativePoses.clear();
|
||||
_internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses();
|
||||
|
@ -311,7 +311,7 @@ void Rig::reset(const HFMModel& hfmModel) {
|
|||
_geometryOffset = AnimPose(hfmModel.offset);
|
||||
_invGeometryOffset = _geometryOffset.inverse();
|
||||
|
||||
_animSkeleton = std::make_shared<AnimSkeleton>(hfmModel, _jointRotationOffsets);
|
||||
_animSkeleton = std::make_shared<AnimSkeleton>(hfmModel);
|
||||
|
||||
|
||||
_internalPoseSet._relativePoses.clear();
|
||||
|
@ -2064,97 +2064,3 @@ void Rig::computeAvatarBoundingCapsule(
|
|||
glm::vec3 capsuleCenter = transformPoint(_geometryToRigTransform, (0.5f * (totalExtents.maximum + totalExtents.minimum)));
|
||||
localOffsetOut = capsuleCenter - hipsPosition;
|
||||
}
|
||||
|
||||
void Rig::setJointRotationOffsets(const QMap<QString, glm::quat>& offsets) {
|
||||
_jointRotationOffsets.clear();
|
||||
for (auto itr = offsets.begin(); itr != offsets.end(); itr++) {
|
||||
QString jointName = itr.key();
|
||||
glm::quat rotationOffset = itr.value();
|
||||
int jointIndex = indexOfJoint(jointName);
|
||||
if (jointIndex != -1) {
|
||||
_jointRotationOffsets.insert(jointIndex, rotationOffset);
|
||||
}
|
||||
qDebug() << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
|
||||
}
|
||||
int neckId = 62;
|
||||
int spine2Id = 13;
|
||||
if (true){ //neckIndex != -1) {
|
||||
_jointRotationOffsets.insert(neckId, glm::quat(0.0f, 0.7071f, 0.7071f, 0.0f) * glm::quat(0.5f, 0.5f, 0.5f, -0.5f) ); //glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f)
|
||||
qCDebug(animation) << "multiplied quats are " << glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f) * glm::quat(0.5f, 0.5f, 0.5f, -0.5f);
|
||||
}
|
||||
if (true){ //spine2Index != -1) {
|
||||
_jointRotationOffsets.insert(spine2Id, glm::quat(0.5f, 0.5f, 0.5f, -0.5f));
|
||||
}
|
||||
|
||||
std::vector<glm::vec3> eulersFromEngineer;
|
||||
eulersFromEngineer.push_back(glm::vec3(-81.1050620752f, -20.1443891394f, 100.309499473f));
|
||||
eulersFromEngineer.push_back(glm::vec3(260.889773298f, -20.143735467f, 79.7184972987f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-196.885439853f, -15.4618394328f, 107.273377257f));
|
||||
eulersFromEngineer.push_back(glm::vec3(185.169288353f, -14.3865564204f, 73.5514142013f));
|
||||
eulersFromEngineer.push_back(glm::vec3(85.0436206363f, -0.405424354654f, 279.126747746f));
|
||||
eulersFromEngineer.push_back(glm::vec3(265.040827938f, -24.8809133357f, 80.8874530433f));
|
||||
eulersFromEngineer.push_back(glm::vec3(0.0000012746f, -9.5408567955f, 89.9999827841f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-304.676178613f, -1.77806457464f, 94.6267844984f));
|
||||
eulersFromEngineer.push_back(glm::vec3(299.239708621f, -1.75410019523f, 85.3712190608f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-70.5442845855f, 180.00795643f, -73.899282669f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-5.65981473995f, -0.554837824572f, 90.3818083467f));
|
||||
eulersFromEngineer.push_back(glm::vec3(282.516400893f, -2.86457680169f, 106.966109268f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-5.74446362761f, -3.69252247483f, 89.4088276443f));
|
||||
eulersFromEngineer.push_back(glm::vec3(175.098015269f, 11.7273076323f, 282.707060357f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-5.86440719705f, -11.5976507143f, 93.7305032918f));
|
||||
eulersFromEngineer.push_back(glm::vec3(212.162310762f, 11.1889030401f, 90.489887929f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-183.528298852f, 11.1630787238f, 89.5119846423f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-21.5907187136f, -1.16096242449f, 93.4017341288f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-230.174545226f, -1.16165879865f, 86.5984269351f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-71.3250132734f, 179.345867731f, -73.9245897857f));
|
||||
eulersFromEngineer.push_back(glm::vec3(4.4183033408f, 0.0214780500113f, 89.6156394563f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-71.3557521294f, -1.96233777224f, 101.311991763f));
|
||||
eulersFromEngineer.push_back(glm::vec3(4.52300317986f, -3.2744480538f, 93.9297689938f));
|
||||
eulersFromEngineer.push_back(glm::vec3(183.372659045f, 18.4240672177f, 289.089833888f));
|
||||
eulersFromEngineer.push_back(glm::vec3(4.69575782766f, -18.4271517191f, 85.8795582505f));
|
||||
eulersFromEngineer.push_back(glm::vec3(180.000000381f, 184.227605816f, -90.0000102753f));
|
||||
eulersFromEngineer.push_back(glm::vec3(180.000018095f, -4.74360667058f, -89.9994155926f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-6.65059725988f, 179.738939306f, -74.3826161322f));
|
||||
eulersFromEngineer.push_back(glm::vec3(1.39276173327f, 0.376166992987f, 92.9332563713f));
|
||||
eulersFromEngineer.push_back(glm::vec3(290.266370725f, -2.98535083963f, 105.944099833f));
|
||||
eulersFromEngineer.push_back(glm::vec3(1.43200712942f, -2.97286285904f, 93.1492284976f));
|
||||
eulersFromEngineer.push_back(glm::vec3(194.564263389f, 20.3832505773f, 294.645037769f));
|
||||
eulersFromEngineer.push_back(glm::vec3(1.63629620002f, -20.9266621269f, 88.1506158063f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-0.0431167069757f, 179.97446471f, -73.261703364f));
|
||||
eulersFromEngineer.push_back(glm::vec3(7.60338271732f, -0.342204658844f, 91.3116554499f));
|
||||
eulersFromEngineer.push_back(glm::vec3(279.206234833f, -3.4007859075f, 106.246009192f));
|
||||
eulersFromEngineer.push_back(glm::vec3(7.72548545025f, -3.33436960581f, 92.0998444782f));
|
||||
eulersFromEngineer.push_back(glm::vec3(197.45405684f, 22.6995116972f, 295.695981195f));
|
||||
eulersFromEngineer.push_back(glm::vec3(8.21527813645f, -19.794697098f, 86.2545417524f));
|
||||
eulersFromEngineer.push_back(glm::vec3(180.000036925f, 168.400465599f, -90.0003196145f));
|
||||
eulersFromEngineer.push_back(glm::vec3(7.86635710548e-05f, -2.45210839758f, 89.9992192762f));
|
||||
eulersFromEngineer.push_back(glm::vec3(179.999920323f, 4.95709895474f, 269.999215822f));
|
||||
eulersFromEngineer.push_back(glm::vec3(241.077352225f, -184.455008741f, -426.541304554f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-70.6642196779f, 6.88023375774f, 85.5052784744f));
|
||||
eulersFromEngineer.push_back(glm::vec3(51.5850104459f, 4.10357301154f, 96.1370118091f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-70.3665845407f, 5.50499763056f, 102.700969646f));
|
||||
eulersFromEngineer.push_back(glm::vec3(94.1058470618f, -4.50566341059f, -63.663409373f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-70.8795528982f, 7.23642133863f, 82.4215992116f));
|
||||
eulersFromEngineer.push_back(glm::vec3(354.986036508f, -0.167802950666f, -73.0700479208f));
|
||||
eulersFromEngineer.push_back(glm::vec3(174.972844269f, 0.163203627576f, 73.0320316709f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-156.40949683f, -2.25584901219f, 89.478726037f));
|
||||
eulersFromEngineer.push_back(glm::vec3(-147.791270237f, -2.25609369727f, 90.5216948763f));
|
||||
|
||||
qCDebug(animation) << "list of joint quats for engineer";
|
||||
for (glm::vec3 bone : eulersFromEngineer) {
|
||||
glm::quat boneQuat(glm::vec3((bone.x / 180.0f)*PI, (bone.y / 180.0f)*PI, (bone.z / 180.0f)*PI));
|
||||
qCDebug(animation) << boneQuat;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//qCDebug(animation) << "set the neck and spine2 offsets " << spine2Id << " " << neckId;
|
||||
//glm::quat leftShoulder(glm::vec3((-81.1050620752f / 180.0f)*PI, (-20.1443891394f / 180.0f)*PI, (100.309499473f / 180.0f)*PI));
|
||||
//qCDebug(animation) << "jointRotationOffset = LeftShoulder = (" << leftShoulder << ")";
|
||||
//glm::quat testRot2(glm::vec3(PI / 2.0f, 0.0f, PI / 2.0f));
|
||||
//qCDebug(animation) << "test rot2 from euler" << testRot2;
|
||||
}
|
||||
|
||||
const QMap<int, glm::quat>& Rig::getJointRotationOffsets() const {
|
||||
return _jointRotationOffsets;
|
||||
}
|
|
@ -128,7 +128,6 @@ public:
|
|||
int getJointStateCount() const;
|
||||
int indexOfJoint(const QString& jointName) const;
|
||||
QString nameOfJoint(int jointIndex) const;
|
||||
const QMap<int, glm::quat>& getJointRotationOffsets() const;
|
||||
|
||||
void setModelOffset(const glm::mat4& modelOffsetMat);
|
||||
|
||||
|
@ -232,8 +231,6 @@ public:
|
|||
const AnimContext::DebugAlphaMap& getDebugAlphaMap() const { return _lastContext.getDebugAlphaMap(); }
|
||||
const AnimVariantMap& getAnimVars() const { return _lastAnimVars; }
|
||||
const AnimContext::DebugStateMachineMap& getStateMachineMap() const { return _lastContext.getStateMachineMap(); }
|
||||
|
||||
void setJointRotationOffsets(const QMap<QString, glm::quat>& offsets);
|
||||
|
||||
signals:
|
||||
void onLoadComplete();
|
||||
|
@ -303,8 +300,6 @@ protected:
|
|||
int _rightElbowJointIndex { -1 };
|
||||
int _rightShoulderJointIndex { -1 };
|
||||
|
||||
QMap<int, glm::quat> _jointRotationOffsets;
|
||||
|
||||
glm::vec3 _lastForward;
|
||||
glm::vec3 _lastPosition;
|
||||
glm::vec3 _lastVelocity;
|
||||
|
@ -423,7 +418,6 @@ protected:
|
|||
|
||||
SnapshotBlendPoseHelper _hipsBlendHelper;
|
||||
ControllerParameters _previousControllerParameters;
|
||||
bool _alreadyInitialized { false };
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__Rig__) */
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <DebugDraw.h>
|
||||
#include <AnimDebugDraw.h>
|
||||
#include <CharacterController.h>
|
||||
#include <FSTReader.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
#include "Logging.h"
|
||||
|
@ -58,7 +57,6 @@ void SkeletonModel::initJointStates() {
|
|||
const HFMModel& hfmModel = getHFMModel();
|
||||
glm::mat4 modelOffset = glm::scale(_scale) * glm::translate(_offset);
|
||||
|
||||
_rig.setJointRotationOffsets(FSTReader::getJointRotationOffsets(getGeometry()->getMapping()));
|
||||
_rig.initJointStates(hfmModel, modelOffset);
|
||||
|
||||
{
|
||||
|
@ -85,7 +83,6 @@ void SkeletonModel::initJointStates() {
|
|||
|
||||
// Skeleton may have already been scaled so unscale it
|
||||
_defaultEyeModelPosition = _defaultEyeModelPosition / _scale;
|
||||
//_rig.setJointRotationOffsets(FSTReader::getJointRotationOffsets(getGeometry()->getMapping()));
|
||||
computeBoundingShape();
|
||||
|
||||
Extents meshExtents = getMeshExtents();
|
||||
|
|
|
@ -207,30 +207,6 @@ QVector<QString> FSTReader::getScripts(const QUrl& url, const QVariantHash& mapp
|
|||
return scriptPaths;
|
||||
}
|
||||
|
||||
QMap<QString, glm::quat> FSTReader::getJointRotationOffsets(const QVariantHash& mapping) {
|
||||
QMap<QString, glm::quat> jointRotationOffsets;
|
||||
if (!mapping.isEmpty() && mapping.contains(JOINT_ROTATION_OFFSET_FIELD) && mapping[JOINT_ROTATION_OFFSET_FIELD].type() == QVariant::Hash) {
|
||||
auto offsets = mapping[JOINT_ROTATION_OFFSET_FIELD].toHash();
|
||||
for (auto itr = offsets.begin(); itr != offsets.end(); itr++) {
|
||||
QString jointName = itr.key();
|
||||
QString line = itr.value().toString();
|
||||
auto eulerAngles = line.split(',');
|
||||
if (eulerAngles.size() == 3) {
|
||||
float eulerX = eulerAngles[0].mid(1).toFloat();
|
||||
float eulerY = eulerAngles[1].toFloat();
|
||||
float eulerZ = eulerAngles[2].mid(0, eulerAngles[2].size() - 1).toFloat();
|
||||
if (!isNaN(eulerX) && !isNaN(eulerY) && !isNaN(eulerZ)) {
|
||||
glm::quat rotationOffset = (glm::angleAxis(eulerX * RADIANS_PER_DEGREE, Vectors::UNIT_Y) *
|
||||
glm::angleAxis(eulerY * RADIANS_PER_DEGREE, Vectors::UNIT_X) *
|
||||
glm::angleAxis(eulerZ * RADIANS_PER_DEGREE, Vectors::UNIT_Z));
|
||||
jointRotationOffsets.insert(jointName, rotationOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return jointRotationOffsets;
|
||||
}
|
||||
|
||||
QVariantHash FSTReader::downloadMapping(const QString& url) {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <QBuffer>
|
||||
#include <QVariantHash>
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
static const QString NAME_FIELD = "name";
|
||||
static const QString TYPE_FIELD = "type";
|
||||
|
@ -30,7 +29,6 @@ static const QString JOINT_FIELD = "joint";
|
|||
static const QString FREE_JOINT_FIELD = "freeJoint";
|
||||
static const QString BLENDSHAPE_FIELD = "bs";
|
||||
static const QString SCRIPT_FIELD = "script";
|
||||
static const QString JOINT_ROTATION_OFFSET_FIELD = "jointRotationOffset";
|
||||
|
||||
class FSTReader {
|
||||
public:
|
||||
|
@ -53,7 +51,6 @@ public:
|
|||
static ModelType predictModelType(const QVariantHash& mapping);
|
||||
|
||||
static QVector<QString> getScripts(const QUrl& fstUrl, const QVariantHash& mapping = QVariantHash());
|
||||
static QMap<QString, glm::quat> getJointRotationOffsets(const QVariantHash& mapping);
|
||||
|
||||
static QString getNameFromType(ModelType modelType);
|
||||
static FSTReader::ModelType getTypeFromName(const QString& name);
|
||||
|
|
|
@ -56,8 +56,7 @@ SkeletonDumpApp::SkeletonDumpApp(int argc, char* argv[]) : QCoreApplication(argc
|
|||
QByteArray blob = file.readAll();
|
||||
|
||||
std::unique_ptr<HFMModel> geometry(readFBX(blob, QVariantHash()));
|
||||
QMap<int, glm::quat> jointRotationOffsets;
|
||||
std::unique_ptr<AnimSkeleton> skeleton(new AnimSkeleton(*geometry, jointRotationOffsets));
|
||||
std::unique_ptr<AnimSkeleton> skeleton(new AnimSkeleton(*geometry));
|
||||
|
||||
skeleton->dump(verbose);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue