Game Development Reference
InDepth Information
Now we simply need to know what 1.5 is as a proportion of 3.57. When
the time is 6.3 this method will give
t
as 0 and when the time is 9.87,
t
will
be 1.0. But at time 7.8,
t
is given by
t
= 1.5/3.57 = 0.42
The Hermite coefficients are defined as:
h
0
=2
t
3
 3
t
2
+ 1
h
1
=2
t
3
+ 3
t
2
h
2
=
t
3
 2
t
2
+
t
h
3
=
t
3

t
2
Finally, we are able to calculate the actual value at time
t
:
Q
(
t
)=
h
0
*
K
1.value +
h
1
*
K
2.value +
h
2
*
T
1 +
h
3
*
T
2
Notice that when
t
= 0,
h
0
= 1,
h
1
= 0,
h
2
= 0 and
h
3
= 0, and at
t
= 1,
h
0
= 0,
h
1
= 1,
h
2
= 0 and
h
3
= 0. Hence at
t
= 0 the value for the curve is
Q
(0)=1
*
K
1.value + 0
*
K
2.value + 0
*
T
1 + 0
*
T
2=
K
1.value
And at
t
= 1 the value for the curve is
Q
(1)=0
*
K
1.value + 1
*
K
2.value + 0
*
T
1 + 0
*
T
2=
K
2.value
So the curve goes through the key positions just as we planned.
Having calculated the tangents at each end of a curve segment we can
interpolate the curve.
Now that we know the theory, let's look at how to implement this. In the
source code for Toon3D Creator, you will see that all the key positions for
an object are stored as arrays in member variables of the CToon3DObject
class. We also use an array that stores the total number of keys in each
channel.
KEYCHANNEL *anim[9];
int keytotal[9];
void CToon3DObject::SetTime(double time, int channel)
{
//Test for parameters out of range
if (channel<0  channel>8  !anim[channel) return;
Search Nedrilad ::
Custom Search