540 :(double)t_frame fromFrame:(
Frame) frame_zero
541{
542 if (t_frame >= 0.0) return frame_zero;
543
545
546 int t1 =
PREV(_nextFrame);
547 double moment_in_time = frame_zero.
timeframe + t_frame;
548 double period, f0;
549
550 if (moment_in_time > _trackTime)
551 {
552 frame_one = _track[t1];
553 period = (moment_in_time - t_frame) - _trackTime;
554 f0 = 1.0 + t_frame/period;
555 }
556 else if (moment_in_time < _track[_nextFrame].timeframe)
557 {
558 return _track[_nextFrame];
559 }
560 else
561 {
562 while (moment_in_time < _track[t1].timeframe)
563 {
565 }
567
568 frame_zero = _track[t0];
569 frame_one = _track[t1];
570 period = frame_zero.
timeframe - frame_one.timeframe;
571 f0 = (moment_in_time - _track[t1].timeframe)/period;
572 }
573
574
575 double f1 = 1.0 - f0;
576
577 HPVector posn;
578 posn.x = f0 * frame_zero.
position.x + f1 * frame_one.position.
x;
579 posn.y = f0 * frame_zero.
position.y + f1 * frame_one.position.
y;
580 posn.z = f0 * frame_zero.
position.z + f1 * frame_one.position.z;
581 Quaternion qrot;
582 qrot.w = (float)f0 * frame_zero.
orientation.w + (float)f1 * frame_one.orientation.w;
583 qrot.x = (float)f0 * frame_zero.
orientation.x + (float)f1 * frame_one.orientation.
x;
584 qrot.y = (float)f0 * frame_zero.
orientation.y + (float)f1 * frame_one.orientation.
y;
585 qrot.z = (float)f0 * frame_zero.
orientation.z + (float)f1 * frame_one.orientation.z;
586
592 return result;
593}
Vector vector_forward_from_quaternion(Quaternion quat)