본문 바로가기

유물/MDX/MDL

StealthFox - Extrarius 의 글에 StealthFox 의 리플


원문: http://wc3campaigns.com/showthread.php?t=79038
함부로 긁어왔습니다.

내가 가지고 있는 뼈대 회전, SLerp, Hermite 보간, 그리고 MDL 파일안의 InTan, OutTan 에 대한 지식을 추가하겠다.

당신이 알아낸것 처럼, 워크래프트3 모델은 뼈대 회전에 hermite을 가지고 뼈대 회전 보간에 SLerp(Spherical Linear Interpolation)을 사용한다...내가 생각하기에. 여기 공식이 있다  http://number-none.com/product/Under...%20Using%20It/

Written in C++

Quaternion slerp(Quaternion const &v0, Quaternion const &v1, double t) { --v0 is the initial bone position and v1 is next bone position and t is a scalar value
// v0 and v1 should be unit length or else
// something broken will happen.

// Compute the cosine of the angle between the two vectors.
double dot = dot_product(v0, v1);
--This pertains to omega which represents cos theta = v0 (dot product) v1 and is found in wikipedia's formula for SLerp

const double DOT_THRESHOLD = 0.9995;
if (dot > DOT_THRESHOLD) {
// If the inputs are too close for comfort, linearly interpolate
// and normalize the result.

Quaternion result = v0 + t*(v1 – v0);
result.normalize();
return result;
}

Clamp(dot, -1, 1); // Robustness: Stay within domain of acos()
double theta_0 = acos(dot); // theta_0 = angle between input vectors
double theta = theta_0*t; // theta = angle between v0 and result

Quaternion v2 = v1 – v0*dot;
v2.normalize(); // { v0, v2 } is now an orthonormal basis

return v0*cos(theta) + v2*sin(theta);
}

SLerp 이 어떻게 처리되고 회전의 부드러움을 어떻게 증진할까:

"그림 1: 우리는 v0 에서 부터 각 θ 의 벡터 r을 찾기 원한다."

"그림 2: v1을 사용해, 우리는 쉽게 r 을 계산할수 있게 하는 수직노멀 basis { v0, v2 } 을 만든다."

일차 보간은 쉬운 회전을 위해 좋다, 하지만 대부분의 회전에 고르지 못하다.

이 hermite splines 을 위한것과 아닌 것:

내 hermite 에 관한 여러 조사에서, hermite 스플라인은 키프레임에서 키프레임까지 부드러운 이동을 만들기 위해 키프레이밍에서 사용된다. 난 3dsMax 가 그들의 보간에서 TCB(tension, bias, continuity) 스플라인을 사용한다고 믿는다.

TCB splines

tension

As a side note, tension pertains to the speed at which a position is interpolated to another position (smooth bellcurve at tension = -1 and sharp pointy curve at tension = 1), bias pertains to the skewedness of the spline (curve slopes up fast on the left at bias = -1 and slopes down slowly and the curve initially slopes slowly but then drops quickly on the right when bias = 1), and continuity pertains to the continuity of the derivative of the curve or, in the common tongue, the smoothness of the curve as it approaches the next position and the smoothness as it leaves that position (continuity of -1 is a smooth curve throught the next position and a continuity of 1 curves sharply into the next position and sharply curves out of it).

Hermite splines

Finally, hermite splines use 4 formulas to interpolate keyframes. The formulas are the function for the initial position, the function for the derviative (tangent) of the initial position, the function for the next position, and the function for the derivative (tangent) of the next position. There are also formulas for calculating hermite spline interpolation, but they are complex and are everywhere on the internet. Google "hermite spline""interpolation."

Now if we could only figure out a way to export this "knowledge" from MilkShape3d.......that would help me LOTS.
Attached Images
File Type: jpg slerpvisual1.jpg (13.8 KB, 12 views)
File Type: jpg slerpvisual2.jpg (15.4 KB, 7 views)