Skip to content

Commit

Permalink
+ Add correct angle value conversion (for Rotation Z axis)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikich340 committed Aug 24, 2021
1 parent 61152a8 commit f99835b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
10 changes: 3 additions & 7 deletions W3MayaAnimUtil/W3MayaAnimUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,7 @@ bool W3MayaAnimUtil::applyMotionToBone(QJsonValueRef ref) {
QVector<int> framePoints;
framePoints.append(1);
upn(i, 0, deltaTimes.size() - 1) {
int delta = static_cast<uint8_t>(deltaTimes[i]);
if (delta <= 0) {
addLog(QString("!!!!!! NEGATIVE! [%1] = %2, dtimes = %3").arg(i).arg(delta).arg(QString(deltaTimes)) );
}
framePoints.append( framePoints.back() + delta );
framePoints.append( framePoints.back() + static_cast<uint8_t>(deltaTimes[i]) );
}

QVector<double> motionX, motionY, motionZ, motionRotZ;
Expand Down Expand Up @@ -293,7 +289,7 @@ bool W3MayaAnimUtil::applyMotionToBone(QJsonValueRef ref) {
anyFlag = false;
break;
}
motionRotZ.append( framesObj[i].toDouble() );
motionRotZ.append( framesObj[i].toDouble() * 360.0 / mW3AngleKoefficient );
++i;
}
}
Expand Down Expand Up @@ -471,7 +467,7 @@ bool W3MayaAnimUtil::extractMotionFromBone(QJsonValueRef ref) {
motionZ.append( posArray[frame].toObject().value("z").toDouble() );
}
upn(frame, 0, rotFrames - 1) {
motionRotZ.append( rotArray[frame].toObject().value("Z").toDouble() );
motionRotZ.append( rotArray[frame].toObject().value("Z").toDouble() * mW3AngleKoefficient / 360.0 );
}

if (rotFrames == 1) {
Expand Down
1 change: 1 addition & 0 deletions W3MayaAnimUtil/W3MayaAnimUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class W3MayaAnimUtil : public QMainWindow
const double mFps = 30.0;
const int mBoneIndex = 94;
const double mReductionSensitivity = 1e-4; // 10^-4
const double mW3AngleKoefficient = 8.07; // picked up experimentally, real value is in [8.05 - 8.10]
bool animSet;
bool hasChanges = false;
QFile jsonFile;
Expand Down
Binary file modified W3MayaAnimUtil_windows_x64.zip
Binary file not shown.

0 comments on commit f99835b

Please sign in to comment.