Skip to content

Instantly share code, notes, and snippets.

@serguei-k
Created December 31, 2018 07:44
Show Gist options
  • Save serguei-k/cfddc60febca7bfd7a5dc4465866330b to your computer and use it in GitHub Desktop.
Save serguei-k/cfddc60febca7bfd7a5dc4465866330b to your computer and use it in GitHub Desktop.
Variable FK 4
// ...
const int prev_sample = int(std::floor(controlParams[j] * (sampleCount - 1)));
const int next_sample = int(std::ceil(controlParams[j] * (sampleCount - 1)));
const float alpha = controlParams[j] - sampleParams[prev_sample];
const MVector tangent = curveFn.tangent(param);
const MVector up1(sampleFrames[prev_sample][1][0],
sampleFrames[prev_sample][1][1],
sampleFrames[prev_sample][1][2]);
const MVector up2(sampleFrames[next_sample][1][0],
sampleFrames[next_sample][1][1],
sampleFrames[next_sample][1][2]);
MVector normal = lerp(up1, up2, alpha);
const MVector binormal = tangent ^ normal;
normal = binormal ^ tangent;
MMatrix xform;
xform[0][0] = tangent.x;
xform[0][1] = tangent.y;
xform[0][2] = tangent.z;
xform[1][0] = normal.x;
xform[1][1] = normal.y;
xform[1][2] = normal.z;
xform[2][0] = binormal.x;
xform[2][1] = binormal.y;
xform[2][2] = binormal.z;
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment