Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOExhaustPlumeEntity(Private) Category Reference

Instance Methods

(void) - saveToLastFrame
 
(Frame- frameAtTime:fromFrame:
 

Detailed Description

Definition at line 51 of file OOExhaustPlumeEntity.m.

Method Documentation

◆ frameAtTime:fromFrame:

- (Frame) frameAtTime: (double) t_frame
fromFrame: (Frame) frame_zero 

Extends class OOExhaustPlumeEntity.

Definition at line 380 of file OOExhaustPlumeEntity.m.

540 :(double)t_frame fromFrame:(Frame) frame_zero // t_frame is relative to now ie. -0.5 = half a second ago.
541{
542 if (t_frame >= 0.0) return frame_zero;
543
544 Frame frame_one;
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) // between the last saved frame and now
551 {
552 frame_one = _track[t1]; // last saved moment
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) // more than kExhaustFrameCount frames back
557 {
558 return _track[_nextFrame];
559 }
560 else
561 {
562 while (moment_in_time < _track[t1].timeframe)
563 {
564 t1 = PREV(t1);
565 }
566 int t0 = NEXT(t1);
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 // interpolate
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
587 Frame result;
588 result.position = posn;
589 result.orientation = qrot;
590 result.timeframe = moment_in_time;
591 result.k = vector_forward_from_quaternion(qrot);
592 return result;
593}
#define PREV(n)
#define NEXT(n)
Vector vector_forward_from_quaternion(Quaternion quat)
float y
float x
Quaternion orientation
HPVector position

◆ saveToLastFrame

- (void) saveToLastFrame

Extends class OOExhaustPlumeEntity.

Definition at line 380 of file OOExhaustPlumeEntity.m.

524{
525 ShipEntity *ship = [self owner];
526
527 // Absolute position of self
528 // normally this would use the transformation matrix, but that
529 // introduces inaccuracies
530 // so just use the rotation matrix, then translate using HPVectors
531 HPVector framePos = OOHPVectorMultiplyMatrix([self position], [ship drawRotationMatrix]);
532 framePos = HPvector_add(framePos,[ship position]);
533 Frame frame = { [UNIVERSE getTime], framePos, [ship normalOrientation], [ship upVector] };
534
535 _track[_nextFrame] = frame;
536 _nextFrame = (_nextFrame + 1) % kExhaustFrameCount;
537}
@ kExhaustFrameCount
HPVector OOHPVectorMultiplyMatrix(HPVector v, OOMatrix m)
Definition OOMatrix.m:145
Quaternion normalOrientation()
Definition Entity.m:738
Vector upVector()

The documentation for this category was generated from the following file: