BOOL bgAnimMax::CheckForAnimation(INode* pNode, BOOL& bPos, BOOL& bRot, BOOL& bScl) { AffineParts ap; Point3 firstPos, firstRotAxis, firstScaleFactor; Point3 rotAxis; float firstRotAngle; float rotAngle; GetDecompAffine(m_Interval.Start(), pNode, &ap, &firstRotAxis, &firstRotAngle); firstPos = ap.t; firstScaleFactor = ap.k; TimeValue start = m_Interval.Start() + GetTicksPerFrame(); TimeValue end = m_Interval.End(); bPos = bRot = bScl = FALSE; for (TimeValue t = start; t <= end; t += m_iDeltaTick) { GetDecompAffine(t, pNode, &ap, &rotAxis, &rotAngle); if (!bPos) { if (!EqualPoint3(ap.t, firstPos)) { bPos = TRUE; } } if (!bRot) { if (fabs(rotAngle - firstRotAngle) > ALMOST_ZERO) { bRot = TRUE; } else if (!EqualPoint3(rotAxis, firstRotAxis)) { bRot = TRUE; } } if (!bScl) { if (!EqualPoint3(ap.k, firstScaleFactor)) { bScl = TRUE; } } if (bPos && bRot && bScl) break; } return bPos || bRot || bScl; }
void AsciiExp::DumpPosSample(INode* node, int indentLevel) { TSTR indent = GetIndent(indentLevel); _ftprintf(pStream, _T("%s\t\t%s {\n"), indent.data(), ID_POS_TRACK); TimeValue start = ip->GetAnimRange().Start(); TimeValue end = ip->GetAnimRange().End(); TimeValue t; int delta = GetTicksPerFrame() * GetKeyFrameStep(); Matrix3 tm; AffineParts ap; Point3 prevPos; for (t=start; t<=end; t+=delta) { tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t)); decomp_affine(tm, &ap); Point3 pos = ap.t; if (t!= start && EqualPoint3(pos, prevPos)) { // Skip identical keys continue; } prevPos = pos; // Output the sample _ftprintf(pStream, _T("%s\t\t\t%s %d\t%s\n"), indent.data(), ID_POS_SAMPLE, t, Format(pos)); } _ftprintf(pStream, _T("%s\t\t}\n"), indent.data()); }
BOOL AsciiExp::CheckForAnimation(INode* node, BOOL& bPos, BOOL& bRot, BOOL& bScale) { TimeValue start = ip->GetAnimRange().Start(); TimeValue end = ip->GetAnimRange().End(); TimeValue t; int delta = GetTicksPerFrame(); Matrix3 tm; AffineParts ap; Point3 firstPos; float rotAngle, firstRotAngle = 0.0f; Point3 rotAxis, firstRotAxis; Point3 firstScaleFactor; bPos = bRot = bScale = FALSE; for (t=start; t<=end; t+=delta) { tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t)); decomp_affine(tm, &ap); AngAxisFromQ(ap.q, &rotAngle, rotAxis); if (t != start) { if (!bPos) { if (!EqualPoint3(ap.t, firstPos)) { bPos = TRUE; } } // MAX 2.x: // We examine the rotation angle to see if the rotation component // has changed. // Although not entierly true, it should work. // It is rare that the rotation axis is animated without // the rotation angle being somewhat affected. // MAX 3.x: // The above did not work, I have a repro scene that doesn't export a rotation track // because of this. I fixed it to also compare the axis. if (!bRot) { if (fabs(rotAngle - firstRotAngle) > ALMOST_ZERO) { bRot = TRUE; } else if (!EqualPoint3(rotAxis, firstRotAxis)) { bRot = TRUE; } } if (!bScale) { if (!EqualPoint3(ap.k, firstScaleFactor)) { bScale = TRUE; } } } else { firstPos = ap.t; firstRotAngle = rotAngle; firstRotAxis = rotAxis; firstScaleFactor = ap.k; } // No need to continue looping if all components are animated if (bPos && bRot && bScale) break; } return bPos || bRot || bScale; }