Last active
April 9, 2024 02:58
-
-
Save serguei-k/108b7326e35db5749b800f314522d3c8 to your computer and use it in GitHub Desktop.
Variable FK 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
const float t = float(i) / float(sampleCount - 1); | |
for (auto j = 0; j < controlCount; ++j) | |
{ | |
const float& param = controlParams[j]; | |
const float& falloff = controlFalloffs[j]; | |
const MVector& scale = controlScales[j]; | |
float weight = 1.0f - std::abs(t - param) / falloff; | |
weight = std::max(std::min(weight, 1.0f), 0.0f); | |
weight = weight * weight * weight * (weight * (weight * 6 - 15) + 10); | |
if (weight <= 0.0f) continue; | |
// weighted rotation matrix | |
MMatrix rotation = slerp(MQuaternion::identity, | |
MEulerRotation(controlRotations[j]).asQuaternion(), | |
weight).asMatrix(); | |
// weighted translation matrix | |
MMatrix txform; | |
const MVector translation(controlTranslations[j] * weight); | |
txform[3][0] = translation.x; | |
txform[3][1] = translation.y; | |
txform[3][2] = translation.z; | |
// weighted scale matrix | |
MMatrix sclxform; | |
sclxform[1][1] = 1.0 + (scale.y - 1.0) * weight; | |
sclxform[2][2] = 1.0 + (scale.z - 1.0) * weight; | |
// compose the full transformation | |
xform = rotation * xform; | |
sampleXform = sclxform * rotation * sampleXform * txform; | |
controlsHandle.next(); | |
} | |
parentXform = xform; | |
sampleFrames.append(sampleXform); | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment