Oolite
Loading...
Searching...
No Matches
OOExhaustPlumeEntity Class Reference

#include <OOExhaustPlumeEntity.h>

Inheritance diagram for OOExhaustPlumeEntity:
Collaboration diagram for OOExhaustPlumeEntity:

Instance Methods

(id) - initForShip:withDefinition:andScale:
(void) - resetPlume
(Vector) - scale
(void) - setScale:
(OOTexture *) - texture
(BOOL) - isExhaust [implementation]
(double) - findCollisionRadius [implementation]
(void) - update: [implementation]
(void) - drawSubEntityImmediate:translucent: [implementation]
(void) - saveToLastFrame [implementation]
(Frame) - frameAtTime:fromFrame: [implementation]
(void) - rescaleBy: [implementation]
(void) - rescaleBy:writeToCache: [implementation]
(void) - getJSClass:andPrototype:
(NSString *) - oo_jsClassName
(NSString *) - oo_jsClassName
(BOOL) - isVisibleToScripts
(BOOL) - isVisibleToScripts
(JSClassID) - oo_jsClassID
Instance Methods inherited from Entity
(NSUInteger) - sessionID
(BOOL) - isShip
(BOOL) - isDock
(BOOL) - isStation
(BOOL) - isSubEntity
(BOOL) - isPlayer
(BOOL) - isPlanet
(BOOL) - isSun
(BOOL) - isSunlit
(BOOL) - isStellarObject
(BOOL) - isSky
(BOOL) - isWormhole
(BOOL) - isEffect
(BOOL) - isVisualEffect
(BOOL) - isWaypoint
(BOOL) - validForAddToUniverse
(void) - addToLinkedLists
(void) - removeFromLinkedLists
(void) - updateLinkedLists
(void) - wasAddedToUniverse
(void) - wasRemovedFromUniverse
(void) - warnAboutHostiles
(CollisionRegion *) - collisionRegion
(void) - setCollisionRegion:
(void) - setUniversalID:
(OOUniversalID) - universalID
(BOOL) - throwingSparks
(void) - setThrowSparks:
(void) - throwSparks
(void) - setOwner:
(id) - owner
(ShipEntity *) - parentEntity
(ShipEntity *) - rootShipEntity
(void) - setPosition:
(void) - setPositionX:y:z:
(HPVector) - position
(Vector) - cameraRelativePosition
(GLfloat) - cameraRangeFront
(GLfloat) - cameraRangeBack
(void) - updateCameraRelativePosition
(Vector) - vectorTo:
(HPVector) - absolutePositionForSubentity
(HPVector) - absolutePositionForSubentityOffset:
(double) - zeroDistance
(double) - camZeroDistance
(NSComparisonResult) - compareZeroDistance:
(BoundingBox) - boundingBox
(GLfloat) - mass
(Quaternion) - orientation
(void) - setOrientation:
(Quaternion) - normalOrientation
(void) - setNormalOrientation:
(void) - orientationChanged
(void) - setVelocity:
(Vector) - velocity
(double) - speed
(GLfloat) - distanceTravelled
(void) - setDistanceTravelled:
(void) - setStatus:
(OOEntityStatus) - status
(void) - setScanClass:
(OOScanClass) - scanClass
(void) - setEnergy:
(GLfloat) - energy
(void) - setMaxEnergy:
(GLfloat) - maxEnergy
(void) - applyRoll:andClimb:
(void) - applyRoll:climb:andYaw:
(void) - moveForward:
(OOMatrix) - rotationMatrix
(OOMatrix) - drawRotationMatrix
(OOMatrix) - transformationMatrix
(OOMatrix) - drawTransformationMatrix
(BOOL) - canCollide
(GLfloat) - collisionRadius
(GLfloat) - frustumRadius
(void) - setCollisionRadius:
(NSMutableArray *) - collisionArray
(void) - applyVelocity:
(BOOL) - checkCloseCollisionWith:
(void) - takeEnergyDamage:from:becauseOf:weaponIdentifier:
(void) - dumpState
(void) - dumpSelfState
(NSUInteger) - lastDrawCounter
(void) - setLastDrawCounter:
(void) - drawImmediate:translucent:
(BOOL) - isVisible
(BOOL) - isInSpace
(BOOL) - isImmuneToBreakPatternHide
(GLfloat) - universalTime
(GLfloat) - spawnTime
(GLfloat) - timeElapsedSinceSpawn
(void) - setAtmosphereFogging:
(OOColor *) - fogUniform
(id) - init [implementation]
(void) - dealloc [implementation]
(NSString *) - descriptionComponents [implementation]
(BOOL) - checkLinkedLists [implementation]
(id< OOWeakReferenceSupport >) - superShaderBindingTarget [implementation]
(Vector) - relativePosition [implementation]
(void) - subEntityReallyDied: [implementation]
(BOOL) - isBreakPattern
(BOOL) - isECMBlast
(BOOL) - isFlasher
(void) - deleteJSSelf
(void) - deleteJSSelf
(jsval) - oo_jsValueInContext: [implementation]
(BOOL) - isCascadeWeapon
(BOOL) - isPlayerLikeShip
(GLfloat) - clock [implementation]
(unsigned) - pseudoFixedD100 [implementation]
(unsigned) - pseudoFixedD256 [implementation]
(unsigned) - systemGovernment [implementation]
(unsigned) - systemEconomy [implementation]
(unsigned) - systemTechLevel [implementation]
(unsigned) - systemPopulation [implementation]
(unsigned) - systemProductivity [implementation]
(BOOL) - isShipWithSubEntityShip:
Instance Methods inherited from OOWeakRefObject
(id) - weakSelf
(id) - weakRetain [implementation]
(void) - weakRefDied: [implementation]
Instance Methods inherited from <OOWeakReferenceSupport>
(id) - OO_RETURNS_RETAINED

Class Methods

(id) + exhaustForShip:withDefinition:andScale:
(void) + setUpTexture
(OOTexture *) + plumeTexture
(void) + resetGraphicsState

Private Attributes

Vector _exhaustScale
OOHPScalar _vertices [34 *3]
GLfloat _glVertices [34 *3]
GLfloat _exhaustBaseColors [34 *4]
Frame _track [kExhaustFrameCount]
OOTimeAbsolute _trackTime
uint8_t _nextFrame

Additional Inherited Members

Public Attributes inherited from Entity
OOUniversalID universalID
unsigned isShip: 1
unsigned isStation: 1
unsigned isPlayer: 1
unsigned isWormhole: 1
unsigned isSubEntity: 1
unsigned hasMoved: 1
unsigned hasRotated: 1
unsigned hasCollided: 1
unsigned isSunlit: 1
unsigned collisionTestFilter: 2
unsigned throw_sparks: 1
unsigned isImmuneToBreakPatternHide: 1
unsigned isExplicitlyNotMainStation: 1
unsigned isVisualEffect: 1
OOScanClass scanClass
GLfloat zero_distance
GLfloat cam_zero_distance
GLfloat no_draw_distance
GLfloat collision_radius
HPVector position
Vector cameraRelativePosition
Quaternion orientation
OOColor * atmosphereFogging
int zero_index
Entity * x_previous
Entity * x_next
Entity * y_previous
Entity * y_next
Entity * z_previous
Entity * z_next
Entity * collision_chain
OOUniversalID shadingEntityID
Entity * collider
CollisionRegion * collisionRegion
Protected Attributes inherited from Entity
HPVector lastPosition
Quaternion lastOrientation
GLfloat distanceTravelled
OOMatrix rotMatrix
Vector velocity
GLfloat energy
GLfloat maxEnergy
BoundingBox boundingBox
GLfloat mass
NSMutableArray * collidingEntities
OOTimeAbsolute spawnTime
struct JSObject * _jsSelf
NSUInteger lastDrawCounter
Protected Attributes inherited from OOWeakRefObject
OOWeakReference * weakSelf

Detailed Description

Definition at line 41 of file OOExhaustPlumeEntity.h.

Method Documentation

◆ drawSubEntityImmediate:translucent:

- (void) drawSubEntityImmediate: (bool) immediate
translucent: (bool) translucent 
implementation

Reimplemented from Entity.

Definition at line 359 of file OOExhaustPlumeEntity.m.

359 :(bool)immediate translucent:(bool)translucent
360{
361 if (!translucent)
362 return;
363
364 ShipEntity* ship = [self owner];
365 if ([ship speedFactor] <= 0.001f)
366 return; // don't draw if not moving according to 'update' calculation
367
370
373 // GLTranslateOOVector(vector_flip([self cameraRelativePosition]));
374 HPVector cam = [PLAYER viewpointPosition];
375 for (unsigned n = 0; n < 34 * 3; n++) {
376 switch (n % 3) {
377 case 0: // x coordinates
378 _glVertices[n] = (GLfloat)(_vertices[n] - cam.x);
379 break;
380 case 1: // y coordinates
381 _glVertices[n] = (GLfloat)(_vertices[n] - cam.y);
382 break;
383 case 2: // z coordinates
384 _glVertices[n] = (GLfloat)(_vertices[n] - cam.z);
385 break;
386 }
387 }
388
389 OOGL(glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT));
390
391 OOGL(glDisable(GL_LIGHTING));
392 OOGL(glEnable(GL_BLEND));
393 OOGL(glDepthMask(GL_FALSE));
394 OOGL(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
395 OOGL(glEnable(GL_TEXTURE_2D));
396 [[self texture] apply];
397
398 // OOGL(glDisable(GL_CULL_FACE)); // face culling
399 OOGL(glShadeModel(GL_SMOOTH));
400
401 OOGL(glEnableClientState(GL_COLOR_ARRAY));
402 OOGL(glVertexPointer(3, GL_FLOAT, 0, _glVertices));
403 OOGL(glColorPointer(4, GL_FLOAT, 0, _exhaustBaseColors));
404
405 double intpart, dphase = 1.0 - modf((double)[UNIVERSE getTime] * 2.5, &intpart);
406 GLfloat phase = (GLfloat)dphase;
407
408 GLfloat texCoords[68] = {
409 0.5,
410 phase + pA[0],
411
412 0.1,
413 phase + pA[1],
414 0.1,
415 phase + pA[1],
416 0.1,
417 phase + pA[1],
418 0.1,
419 phase + pA[1],
420 0.9,
421 phase + pA[1],
422 0.9,
423 phase + pA[1],
424 0.9,
425 phase + pA[1],
426 0.9,
427 phase + pA[1],
428
429 0.1,
430 phase + pA[2],
431 0.1,
432 phase + pA[2],
433 0.1,
434 phase + pA[2],
435 0.1,
436 phase + pA[2],
437 0.9,
438 phase + pA[2],
439 0.9,
440 phase + pA[2],
441 0.9,
442 phase + pA[2],
443 0.9,
444 phase + pA[2],
445
446 0.1,
447 phase + pA[3],
448 0.1,
449 phase + pA[3],
450 0.1,
451 phase + pA[3],
452 0.1,
453 phase + pA[3],
454 0.9,
455 phase + pA[3],
456 0.9,
457 phase + pA[3],
458 0.9,
459 phase + pA[3],
460 0.9,
461 phase + pA[3],
462
463 0.1,
464 phase + pA[4],
465 0.1,
466 phase + pA[4],
467 0.1,
468 phase + pA[4],
469 0.1,
470 phase + pA[4],
471 0.9,
472 phase + pA[4],
473 0.9,
474 phase + pA[4],
475 0.9,
476 phase + pA[4],
477 0.9,
478 phase + pA[4],
479
480 0.5,
481 phase + pA[5],
482 };
483 OOGL(glTexCoordPointer(2, GL_FLOAT, 0, texCoords));
484
485 // reduced detail for internal view to avoid rendering artefacts
486 if ([[self owner] isPlayer] && [UNIVERSE viewDirection] != VIEW_CUSTOM) {
487 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, afttstr1));
488 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, afttstr2));
489 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, afttstr3));
490 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, afttstr4));
491 } else {
492 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT, tstr1));
493 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT, tstr2));
494 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT, tstr3));
495 OOGL(glDrawElements(GL_TRIANGLE_STRIP, 9, GL_UNSIGNED_INT, tstr4));
496 }
497
498 /* Need a different texture and color array for this segment */
499 GLfloat fanTextures[18] = {
500 0.5f, 0.0f + phase,
501 0.2f, 0.0f + phase,
502 0.2f, 0.1f + phase,
503 0.2f, 0.2f + phase,
504 0.2f, 0.3f + phase,
505 0.2f, 0.4f + phase,
506 0.2f, 0.3f + phase,
507 0.2f, 0.2f + phase,
508 0.2f, 0.1f + phase
509 };
510 OOGL(glTexCoordPointer(2, GL_FLOAT, 0, fanTextures));
511
512 GLfloat fanColors[36];
513 GLfloat fr = _exhaustBaseColors[0], fg = _exhaustBaseColors[1], fb = _exhaustBaseColors[2];
514 unsigned i = 0;
515 fanColors[i++] = fr;
516 fanColors[i++] = fg;
517 fanColors[i++] = fb;
518 fanColors[i++] = 1.0;
519 for (; i < 36;) {
520 fanColors[i++] = fr;
521 fanColors[i++] = fg;
522 fanColors[i++] = fb;
523 fanColors[i++] = 0.5;
524 }
525 OOGL(glColorPointer(4, GL_FLOAT, 0, fanColors));
526
527 OOGL(glDrawElements(GL_TRIANGLE_FAN, 10, GL_UNSIGNED_INT, tfan1));
528
529 OOGL(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
530 OOGL(glDisable(GL_TEXTURE_2D));
531
532 OOGL(glDisableClientState(GL_COLOR_ARRAY));
533
534 OOGL(glPopAttrib());
535
537}
static GLuint afttstr3[4]
static GLfloat pA[6]
static GLuint tstr4[9]
static GLuint tfan1[10]
static GLuint tstr2[9]
static GLuint afttstr2[4]
static GLuint tstr3[9]
static GLuint tstr1[9]
static GLuint afttstr4[4]
static GLuint afttstr1[4]
struct HPVector HPVector
#define OO_ENTER_OPENGL()
void OOGLPushModelView(void)
OOMatrix OOGLPopModelView(void)
@ OPENGL_STATE_ADDITIVE_BLENDING
Definition OOOpenGL.h:123
#define OOVerifyOpenGLState()
Definition OOOpenGL.h:133
#define OOSetOpenGLState(STATE)
Definition OOOpenGL.h:132
#define OOGL(statement)
Definition OOOpenGL.h:262
#define UNIVERSE
Definition Universe.h:827
unsigned isPlayer
Definition Entity.m:145
id owner()
Definition Entity.m:548
GLfloat _exhaustBaseColors[34 *4]
OOHPScalar _vertices[34 *3]
OOHPScalar x
Definition OOHPVector.h:36
OOHPScalar y
Definition OOHPVector.h:37
OOHPScalar z
Definition OOHPVector.h:38

References _exhaustBaseColors, _glVertices, _vertices, afttstr1, afttstr2, afttstr3, afttstr4, OOTexture::apply, Entity::isPlayer, OO_ENTER_OPENGL, OOGL, OOGLPopModelView(), OOGLPushModelView(), OOSetOpenGLState, OOVerifyOpenGLState, OPENGL_STATE_ADDITIVE_BLENDING, Entity::owner, pA, texture, tfan1, tstr1, tstr2, tstr3, tstr4, UNIVERSE, HPVector::x, HPVector::y, and HPVector::z.

Here is the call graph for this function:

◆ exhaustForShip:withDefinition:andScale:

+ (id) exhaustForShip: (ShipEntity*) ship
withDefinition: (NSArray*) definition
andScale: (float) scale 

Definition at line 57 of file OOExhaustPlumeEntity.m.

57 :(ShipEntity*)ship withDefinition:(NSArray*)definition andScale:(float)scale
58{
59 return [[[self alloc] initForShip:ship withDefinition:definition andScale:(float)scale] autorelease];
60}

Referenced by ShipEntity::setUpSubEntities.

Here is the caller graph for this function:

◆ findCollisionRadius

- (double) findCollisionRadius
implementation

Reimplemented from Entity.

Definition at line 99 of file OOExhaustPlumeEntity.m.

100{
101 return collision_radius;
102}
GLfloat collision_radius
Definition Entity.h:107

References Entity::collision_radius, and findCollisionRadius.

Referenced by findCollisionRadius, and ShipEntity::frustumRadius.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ frameAtTime:fromFrame:

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

Provided by category OOExhaustPlumeEntity(Private).

Definition at line 558 of file OOExhaustPlumeEntity.m.

558 :(double)t_frame fromFrame:(Frame)frame_zero // t_frame is relative to now ie. -0.5 = half a second ago.
559{
560 if (t_frame >= 0.0)
561 return frame_zero;
562
563 Frame frame_one;
564
565 int t1 = PREV(_nextFrame);
566 double moment_in_time = frame_zero.timeframe + t_frame;
567 double period, f0;
568
569 if (moment_in_time > _trackTime) // between the last saved frame and now
570 {
571 frame_one = _track[t1]; // last saved moment
572 period = (moment_in_time - t_frame) - _trackTime;
573 f0 = 1.0 + t_frame / period;
574 } else if (moment_in_time < _track[_nextFrame].timeframe) // more than kExhaustFrameCount frames back
575 {
576 return _track[_nextFrame];
577 } else {
578 while (moment_in_time < _track[t1].timeframe) {
579 t1 = PREV(t1);
580 }
581 int t0 = NEXT(t1);
582
583 frame_zero = _track[t0];
584 frame_one = _track[t1];
585 period = frame_zero.timeframe - frame_one.timeframe;
586 f0 = (moment_in_time - _track[t1].timeframe) / period;
587 }
588
589 // interpolate
590 double f1 = 1.0 - f0;
591
592 HPVector posn;
593 posn.x = f0 * frame_zero.position.x + f1 * frame_one.position.x;
594 posn.y = f0 * frame_zero.position.y + f1 * frame_one.position.y;
595 posn.z = f0 * frame_zero.position.z + f1 * frame_one.position.z;
596 Quaternion qrot;
597 qrot.w = (float)f0 * frame_zero.orientation.w + (float)f1 * frame_one.orientation.w;
598 qrot.x = (float)f0 * frame_zero.orientation.x + (float)f1 * frame_one.orientation.x;
599 qrot.y = (float)f0 * frame_zero.orientation.y + (float)f1 * frame_one.orientation.y;
600 qrot.z = (float)f0 * frame_zero.orientation.z + (float)f1 * frame_one.orientation.z;
601
602 Frame result;
603 result.position = posn;
604 result.orientation = qrot;
605 result.timeframe = moment_in_time;
606 result.k = vector_forward_from_quaternion(qrot);
607 return result;
608}
#define PREV(n)
#define NEXT(n)
Vector vector_forward_from_quaternion(Quaternion quat) CONST_FUNC
struct Quaternion Quaternion
float y
float x
Quaternion orientation
Definition Entity.m:682
HPVector position
Definition Entity.m:576
Frame _track[kExhaustFrameCount]
Quaternion orientation
HPVector position
OOScalar w
OOScalar x
OOScalar y
OOScalar z

References Frame::k, NEXT, Frame::orientation, Frame::position, PREV, Frame::timeframe, vector_forward_from_quaternion(), Quaternion::w, HPVector::x, Quaternion::x, HPVector::y, Quaternion::y, HPVector::z, and Quaternion::z.

Referenced by update:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getJSClass:andPrototype:

- (void) getJSClass: (JSClass**) outClass
andPrototype: (JSObject**) outPrototype 

Reimplemented from Entity.

Provided by category OOExhaustPlumeEntity(OOJavaScriptExtensions).

Definition at line 107 of file OOJSExhaustPlume.m.

107 :(JSClass**)outClass andPrototype:(JSObject**)outPrototype
108{
109 *outClass = &sExhaustPlumeClass;
110 *outPrototype = sExhaustPlumePrototype;
111}
static JSClass sExhaustPlumeClass
static JSObject * sExhaustPlumePrototype

◆ initForShip:withDefinition:andScale:

- (id) initForShip: (ShipEntity*) ship
withDefinition: (NSArray*) definition
andScale: (float) scale 

Definition at line 62 of file OOExhaustPlumeEntity.m.

62 :(ShipEntity*)ship withDefinition:(NSArray*)definition andScale:(float)scaleFactor
63{
64 if ([definition count] == 0) {
65 [self release];
66 return nil;
67 }
68
69 if ((self = [super init])) {
70 [self setOwner:ship];
71 HPVector pos = { [definition oo_floatAtIndex:0] * scaleFactor, [definition oo_floatAtIndex:1] * scaleFactor, [definition oo_floatAtIndex:2] * scaleFactor };
72 [self setPosition:pos];
73 // scale.z is special and *not* multiplied by scaleFactor
74 Vector scale = { [definition oo_floatAtIndex:3] * scaleFactor, [definition oo_floatAtIndex:4] * scaleFactor, [definition oo_floatAtIndex:5] };
75 [self setScale:scale];
76 }
77
78 return self;
79}
unsigned count
return nil
struct Vector Vector
id init()
Definition Entity.m:64

References count, Entity::init, nil, scale, Entity::setOwner:, Entity::setPosition:, and setScale:.

Here is the call graph for this function:

◆ isExhaust

- (BOOL) isExhaust
implementation

Reimplemented from Entity.

Definition at line 94 of file OOExhaustPlumeEntity.m.

95{
96 return YES;
97}

References isExhaust.

Referenced by isExhaust.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isVisibleToScripts [1/2]

- (BOOL) isVisibleToScripts

Reimplemented from Entity.

Provided by category OOExhaustPlumeEntity(OOJavaScriptExtensions).

Definition at line 116 of file OOJSExhaustPlume.m.

117{
118 return YES;
119}

◆ isVisibleToScripts [2/2]

- (BOOL) isVisibleToScripts

Reimplemented from Entity.

Provided by category OOExhaustPlumeEntity(OOJavaScriptExtensions).

◆ oo_jsClassID

- (JSClassID) oo_jsClassID

Reimplemented from Entity.

Provided by category OOExhaustPlumeEntity(OOJavaScriptExtensions).

Definition at line 106 of file OOJSExhaustPlume.m.

107{
109}
static JSClassID sExhaustPlumeClassID

◆ oo_jsClassName [1/2]

- (NSString *) oo_jsClassName

Reimplemented from Entity.

Provided by category OOExhaustPlumeEntity(OOJavaScriptExtensions).

Definition at line 111 of file OOJSExhaustPlume.m.

112{
113 return @"ExhaustPlume";
114}

◆ oo_jsClassName [2/2]

- (NSString *) oo_jsClassName

Reimplemented from Entity.

Provided by category OOExhaustPlumeEntity(OOJavaScriptExtensions).

◆ plumeTexture

+ (OOTexture *) plumeTexture

Definition at line 659 of file OOExhaustPlumeEntity.m.

660{
661 if (sPlumeTexture == nil)
662 [self setUpTexture];
663 return sPlumeTexture;
664}
static OOTexture * sPlumeTexture

References nil, plumeTexture, setUpTexture, and sPlumeTexture.

Referenced by plumeTexture, and texture.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rescaleBy:

- (void) rescaleBy: (GLfloat) factor
implementation

Reimplemented from <OOSubEntity>.

Definition at line 631 of file OOExhaustPlumeEntity.m.

631 :(GLfloat)factor
632{
634}
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
Definition OOVector.h:180

References _exhaustScale, and vector_multiply_scalar().

Here is the call graph for this function:

◆ rescaleBy:writeToCache:

- (void) rescaleBy: (GLfloat) factor
writeToCache: (BOOL) writeToCache 
implementation

Reimplemented from <OOSubEntity>.

Definition at line 636 of file OOExhaustPlumeEntity.m.

636 :(GLfloat)factor writeToCache:(BOOL)writeToCache
637{
638 /* Do nothing; this is only needed because of OOEntityWithDrawable
639 implementation requirements */
640}

◆ resetGraphicsState

+ (void) resetGraphicsState

Definition at line 666 of file OOExhaustPlumeEntity.m.

667{
668 [sPlumeTexture release];
670}

References nil, resetGraphicsState, and sPlumeTexture.

Referenced by resetGraphicsState.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetPlume

- (void) resetPlume

Definition at line 610 of file OOExhaustPlumeEntity.m.

611{
612 /*ShipEntity *ship = [self owner];
613
614 // Absolute position of self
615 Vector framePos = OOVectorMultiplyMatrix([self position], [ship drawTransformationMatrix]);
616 Frame frame = { [UNIVERSE getTime], framePos, [ship normalOrientation], [ship upVector] };
617
618 _track[_nextFrame] = frame;
619 _nextFrame = (_nextFrame + 1) % kExhaustFrameCount;*/
620 _nextFrame = 0;
622 uint8_t i;
623 for (i = 0; i < kExhaustFrameCount; i++) {
624 _track[i].timeframe = 0.0;
625 _track[i].position = framePos;
626 _track[i].orientation = kIdentityQuaternion;
627 _track[i].k = kZeroVector;
628 }
629}
@ kExhaustFrameCount
HPVector OOHPVectorMultiplyMatrix(HPVector v, OOMatrix m) CONST_FUNC
Definition OOMatrix.m:137
const Quaternion kIdentityQuaternion
const Vector kZeroVector
Definition OOVector.m:27
OOMatrix drawTransformationMatrix()
Definition Entity.m:819

References _nextFrame, _track, Entity::drawTransformationMatrix, kExhaustFrameCount, kIdentityQuaternion, kZeroVector, OOHPVectorMultiplyMatrix(), Entity::owner, Entity::position, and resetPlume.

Referenced by ShipEntity::resetExhaustPlumes, and resetPlume.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToLastFrame

- (void) saveToLastFrame
implementation

Provided by category OOExhaustPlumeEntity(Private).

Definition at line 542 of file OOExhaustPlumeEntity.m.

543{
544 ShipEntity* ship = [self owner];
545
546 // Absolute position of self
547 // normally this would use the transformation matrix, but that
548 // introduces inaccuracies
549 // so just use the rotation matrix, then translate using HPVectors
551 framePos = HPvector_add(framePos, [ship position]);
552 Frame frame = { [UNIVERSE getTime], framePos, [ship normalOrientation], [ship upVector] };
553
554 _track[_nextFrame] = frame;
556}
OOINLINE HPVector HPvector_add(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:213
Quaternion normalOrientation()
Definition Entity.m:687
OOMatrix drawRotationMatrix()
Definition Entity.m:808
Vector upVector()

References HPvector_add(), kExhaustFrameCount, Entity::normalOrientation, OOHPVectorMultiplyMatrix(), Entity::owner, OOExhaustPlumeEntity(Private)::saveToLastFrame, and ShipEntity::upVector.

Referenced by OOExhaustPlumeEntity(Private)::saveToLastFrame, and update:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scale

- (Vector) scale

Definition at line 81 of file OOExhaustPlumeEntity.m.

82{
83 return _exhaustScale;
84}

References _exhaustScale, and scale.

Referenced by initForShip:withDefinition:andScale:, scale, and setScale:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setScale:

- (void) setScale: (Vector) scale

Definition at line 86 of file OOExhaustPlumeEntity.m.

87{
89 if (scale.z < 0.5 || scale.z > 2.0) {
90 _exhaustScale.z = 1.0;
91 }
92}

References _exhaustScale, and scale.

Referenced by ExhaustPlumeSetProperty(), ExhaustPlumeSetProperty(), and initForShip:withDefinition:andScale:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUpTexture

+ (void) setUpTexture

Definition at line 647 of file OOExhaustPlumeEntity.m.

648{
649 if (sPlumeTexture == nil) {
650 sPlumeTexture = [[OOTexture textureWithName:@"oolite-exhaust-blur.png"
651 inFolder:@"Textures"
652 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask | kOOTextureRepeatT | kOOTextureRepeatS
653 anisotropy:kOOTextureDefaultAnisotropy / 2.0
654 lodBias:0.0] retain];
655 [[OOGraphicsResetManager sharedManager] registerClient:(id<OOGraphicsResetClient>)[OOExhaustPlumeEntity class]];
656 }
657}
void registerClient:(id< OOGraphicsResetClient > client)
OOGraphicsResetManager * sharedManager()
id textureWithName:inFolder:options:anisotropy:lodBias:(NSString *name,[inFolder] NSString *directory,[options] OOTextureFlags options,[anisotropy] GLfloat anisotropy,[lodBias] GLfloat lodBias)
Definition OOTexture.m:132

References nil, OOGraphicsResetManager::registerClient:, setUpTexture, OOGraphicsResetManager::sharedManager, sPlumeTexture, and OOTexture::textureWithName:inFolder:options:anisotropy:lodBias:.

Referenced by plumeTexture, and setUpTexture.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ texture

- (OOTexture *) texture

Definition at line 642 of file OOExhaustPlumeEntity.m.

643{
645}

References plumeTexture, and texture.

Referenced by drawSubEntityImmediate:translucent:, and texture.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update:

- (void) update: (OOTimeDelta) delta_t
implementation

Reimplemented from Entity.

Definition at line 104 of file OOExhaustPlumeEntity.m.

104 :(OOTimeDelta)delta_t
105{
106 // Profiling: this function and subfunctions are expensive - CIM
107
108 // don't draw if there's no ship, or if we're just jumping out of witchspace/docked at a station!
109 ShipEntity* ship = [self owner];
110 // also don't draw if the ship isn't visible
111 if (EXPECT_NOT(ship == nil || ![ship isVisible] || ([ship isPlayer] && [ship suppressFlightNotifications])))
112 return;
113
114 OOTimeAbsolute now = [UNIVERSE getTime];
115 if ([UNIVERSE getTime] > _trackTime + kTimeStep) {
116 [self saveToLastFrame];
117 _trackTime = now;
118 }
119
120 // GLfloat ex_emissive[4] = {0.7f, 0.9, 1.0f, 0.9f * kOverallAlpha}; // pale blue - old definition
122 GLfloat length;
123 HPVector vertex;
124 GLfloat ex_emissive[4];
125 [[ship exhaustEmissiveColor] getRed:&ex_emissive[0] green:&ex_emissive[1] blue:&ex_emissive[2] alpha:&ex_emissive[3]];
126 const GLfloat s1[8] = { 0.0, M_SQRT1_2, 1.0, M_SQRT1_2, 0.0, -M_SQRT1_2, -1.0, -M_SQRT1_2 };
127 const GLfloat c1[8] = { 1.0, M_SQRT1_2, 0.0, -M_SQRT1_2, -1.0, -M_SQRT1_2, 0.0, M_SQRT1_2 };
128
129 Quaternion shipQrotation = [ship normalOrientation];
130
131 Frame zero = {
132 .timeframe = [UNIVERSE getTime],
133 .orientation = shipQrotation,
134 .k = [ship forwardVector]
135 };
136 int dam = [ship damage];
137
138 GLfloat speed = [ship speedFactor];
139 // don't draw if not moving.
140 if (EXPECT_NOT(speed <= 0.001f))
141 return;
142
143 GLfloat hyper_fade = 8.0f / (8.0f + speed * speed * speed);
144
145 GLfloat flare_factor = fmaxf(speed, 1.0) * ex_emissive[3] * hyper_fade;
146 GLfloat red_factor = speed * ex_emissive[0] * (ranrot_rand() % 11) * 0.1f; // random fluctuations
147 GLfloat green_factor = speed * ex_emissive[1] * hyper_fade;
148
149 if (speed > 1.0f) // afterburner!
150 {
151 red_factor = 1.5;
152 }
153
154 if ((int)(ranrot_rand() % 50) < dam - 50) // flicker the damaged engines
155 red_factor = 0.0;
156 if ((int)(ranrot_rand() % 40) < dam - 60)
157 green_factor = 0.0;
158 if ((int)(ranrot_rand() % 25) < dam - 75)
159 flare_factor = 0.0;
160
161 HPVector currentPos = ship->position;
162 Vector vfwd = [ship forwardVector];
163 GLfloat spd = 0.5f * [ship flightSpeed];
164 vfwd = vector_multiply_scalar(vfwd, spd);
165 Vector master_i = [ship rightVector];
166 Vector vi, vj, vk;
167 vi = master_i;
168 vj = [ship upVector];
169 vk = [ship forwardVector];
170 zero.position = make_HPvector(currentPos.x + vi.x * position.x + vj.x * position.y + vk.x * position.z,
171 currentPos.y + vi.y * position.x + vj.y * position.y + vk.y * position.z,
172 currentPos.z + vi.z * position.x + vj.z * position.y + vk.z * position.z);
173
174 GLfloat speedScale = fminf(1.0f, speed * 5.0f);
175
176 GLfloat exhaust_factor = _exhaustScale.z;
177 GLfloat i01 = -0.00f * hyper_fade;
178 GLfloat i03 = -0.12f * exhaust_factor;
179 GLfloat i06 = -0.25f * exhaust_factor;
180 GLfloat i08 = -0.32f * exhaust_factor;
181 GLfloat i10 = -0.40f * exhaust_factor;
182 GLfloat q01 = i01 / i10; // factor for trail
183 GLfloat q03 = i03 / i10;
184 GLfloat q06 = i06 / i10;
185 GLfloat q08 = i08 / i10;
186 GLfloat r01 = 1.0f - q01; // factor for jet
187 GLfloat r03 = 1.0f - q03;
188 GLfloat r06 = 1.0f - q06;
189 GLfloat r08 = 1.0f - q08;
190 Frame f01 = [self frameAtTime:i01 fromFrame:zero];
191 Vector b01 = make_vector(r01 * i01 * vfwd.x, r01 * i01 * vfwd.y, r01 * i01 * vfwd.z);
192 Frame f03 = [self frameAtTime:i03 fromFrame:zero];
193 Vector b03 = make_vector(r03 * i03 * vfwd.x, r03 * i03 * vfwd.y, r03 * i03 * vfwd.z);
194 Frame f06 = [self frameAtTime:i06 fromFrame:zero];
195 Vector b06 = make_vector(r06 * i06 * vfwd.x, r06 * i06 * vfwd.y, r06 * i06 * vfwd.z);
196 Frame f08 = [self frameAtTime:i08 fromFrame:zero];
197 Vector b08 = make_vector(r08 * i08 * vfwd.x, r08 * i08 * vfwd.y, r08 * i08 * vfwd.z);
198 Frame f10 = [self frameAtTime:i10 fromFrame:zero];
199
200 int ci = 0;
201 int iv = 0;
202 int i;
203 float r1;
204
205 // f01.position = vector_subtract(zero.position, vk); // 1m out from zero
206 f01.position = zero.position;
207
208 ex_emissive[3] = flare_factor * kOverallAlpha; // fade alpha towards rear of exhaust
209 ex_emissive[1] = green_factor; // diminish green part towards rear of exhaust
210 ex_emissive[0] = red_factor; // diminish red part towards rear of exhaust
211 vertex = HPvector_add(f01.position, vectorToHPVector(b01));
212 collision_radius = HPmagnitude(HPvector_subtract(vertex, currentPos));
213 _vertices[iv++] = vertex.x; // + zero.k.x * flare_factor * 4.0;
214 _vertices[iv++] = vertex.y; // + zero.k.y * flare_factor * 4.0;
215 _vertices[iv++] = vertex.z; // + zero.k.z * flare_factor * 4.0;
216 _exhaustBaseColors[ci++] = ex_emissive[0];
217 _exhaustBaseColors[ci++] = ex_emissive[1];
218 _exhaustBaseColors[ci++] = ex_emissive[2];
219 _exhaustBaseColors[ci++] = ex_emissive[3];
220
221 Vector k1 = f01.k;
222 Vector j1 = cross_product(master_i, k1);
223 Vector i1 = vector_multiply_scalar(cross_product(j1, k1), _exhaustScale.x * speedScale);
224 j1 = vector_multiply_scalar(j1, _exhaustScale.y * speedScale);
225
226 for (i = 0; i < 8; i++) {
227 vertex = HPvector_add(f01.position,
230 vector_multiply_scalar(j1, c1[i])))));
231 length = HPmagnitude(HPvector_subtract(vertex, currentPos));
232 if (length > collision_radius) {
233 collision_radius = length;
234 }
235 _vertices[iv++] = vertex.x;
236 _vertices[iv++] = vertex.y;
237 _vertices[iv++] = vertex.z;
238 _exhaustBaseColors[ci++] = ex_emissive[0];
239 _exhaustBaseColors[ci++] = ex_emissive[1];
240 _exhaustBaseColors[ci++] = ex_emissive[2];
241 _exhaustBaseColors[ci++] = ex_emissive[3];
242 }
243
244 ex_emissive[3] = kFadeLevel1 * flare_factor * kOverallAlpha; // fade alpha towards rear of exhaust
245 ex_emissive[1] = kFadeLevel1 * green_factor; // diminish green part towards rear of exhaust
246 ex_emissive[0] = kFadeLevel1 * red_factor; // diminish red part towards rear of exhaust
247
248 k1 = f03.k;
249 i1 = vector_multiply_scalar(cross_product(j1, k1), _exhaustScale.x * kScaleLevel1 * speedScale);
250 j1 = vector_multiply_scalar(cross_product(master_i, k1), _exhaustScale.y * kScaleLevel1 * speedScale);
251 for (i = 0; i < 8; i++) {
252 r1 = randf();
253 vertex = HPvector_add(f03.position,
257 vector_multiply_scalar(k1, r1))))));
258 length = HPmagnitude(HPvector_subtract(vertex, currentPos));
259 if (length > collision_radius) {
260 collision_radius = length;
261 }
262 _vertices[iv++] = vertex.x;
263 _vertices[iv++] = vertex.y;
264 _vertices[iv++] = vertex.z;
265 _exhaustBaseColors[ci++] = ex_emissive[0];
266 _exhaustBaseColors[ci++] = ex_emissive[1];
267 _exhaustBaseColors[ci++] = ex_emissive[2];
268 _exhaustBaseColors[ci++] = ex_emissive[3];
269 }
270
271 ex_emissive[3] = kFadeLevel2 * flare_factor * kOverallAlpha; // fade alpha towards rear of exhaust
272 ex_emissive[1] = kFadeLevel2 * green_factor; // diminish green part towards rear of exhaust
273 ex_emissive[0] = kFadeLevel2 * red_factor; // diminish red part towards rear of exhaust
274
275 k1 = f06.k;
276 i1 = vector_multiply_scalar(cross_product(j1, k1), 0.8f * _exhaustScale.x * kScaleLevel2 * speedScale);
277 j1 = vector_multiply_scalar(cross_product(master_i, k1), 0.8f * _exhaustScale.y * kScaleLevel2 * speedScale);
278 for (i = 0; i < 8; i++) {
279 r1 = randf();
280 vertex = HPvector_add(f06.position,
284 vector_multiply_scalar(k1, r1))))));
285 length = HPmagnitude(HPvector_subtract(vertex, currentPos));
286 if (length > collision_radius) {
287 collision_radius = length;
288 }
289 _vertices[iv++] = vertex.x;
290 _vertices[iv++] = vertex.y;
291 _vertices[iv++] = vertex.z;
292 _exhaustBaseColors[ci++] = ex_emissive[0];
293 _exhaustBaseColors[ci++] = ex_emissive[1];
294 _exhaustBaseColors[ci++] = ex_emissive[2];
295 _exhaustBaseColors[ci++] = ex_emissive[3];
296 }
297
298 ex_emissive[3] = kFadeLevel3 * flare_factor * kOverallAlpha; // fade alpha towards rear of exhaust
299 ex_emissive[1] = kFadeLevel3 * green_factor; // diminish green part towards rear of exhaust
300 ex_emissive[0] = kFadeLevel3 * red_factor; // diminish red part towards rear of exhaust
301 k1 = f08.k;
302 i1 = vector_multiply_scalar(cross_product(j1, k1), 0.5f * _exhaustScale.x * kScaleLevel3 * speedScale);
303 j1 = vector_multiply_scalar(cross_product(master_i, k1), 0.5f * _exhaustScale.y * kScaleLevel3 * speedScale);
304 for (i = 0; i < 8; i++) {
305 r1 = randf();
306 vertex = HPvector_add(f08.position,
310 vector_multiply_scalar(k1, r1))))));
311 length = HPmagnitude(HPvector_subtract(vertex, currentPos));
312 if (length > collision_radius) {
313 collision_radius = length;
314 }
315 _vertices[iv++] = vertex.x;
316 _vertices[iv++] = vertex.y;
317 _vertices[iv++] = vertex.z;
318 _exhaustBaseColors[ci++] = ex_emissive[0];
319 _exhaustBaseColors[ci++] = ex_emissive[1];
320 _exhaustBaseColors[ci++] = ex_emissive[2];
321 _exhaustBaseColors[ci++] = ex_emissive[3];
322 }
323
324 ex_emissive[3] = 0.0; // fade alpha towards rear of exhaust
325 ex_emissive[1] = 0.0; // diminish green part towards rear of exhaust
326 ex_emissive[0] = 0.0; // diminish red part towards rear of exhaust
327 length = HPmagnitude(HPvector_subtract(vertex, currentPos));
328 if (length > collision_radius) {
329 collision_radius = length;
330 }
331 _vertices[iv++] = f10.position.x;
332 _vertices[iv++] = f10.position.y;
333 _vertices[iv++] = f10.position.z;
334 _exhaustBaseColors[ci++] = ex_emissive[0];
335 _exhaustBaseColors[ci++] = ex_emissive[1];
336 _exhaustBaseColors[ci++] = ex_emissive[2];
337 _exhaustBaseColors[ci++] = ex_emissive[3];
338
339 (void)iv;
340 (void)ci; // Suppress Clang static analyzer warnings.
341}
#define kFadeLevel1
#define kScaleLevel2
#define kScaleLevel3
#define kTimeStep
#define kFadeLevel2
#define kFadeLevel3
#define kOverallAlpha
#define kScaleLevel1
#define EXPECT_NOT(x)
OOINLINE HPVector vectorToHPVector(Vector v) INLINE_CONST_FUNC
Definition OOHPVector.h:166
OOINLINE HPVector HPvector_subtract(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:236
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:260
OOINLINE HPVector make_HPvector(OOHPScalar vx, OOHPScalar vy, OOHPScalar vz) INLINE_CONST_FUNC
Definition OOHPVector.h:149
#define M_SQRT1_2
Definition OOMaths.h:75
double OOTimeDelta
Definition OOTypes.h:193
double OOTimeAbsolute
Definition OOTypes.h:192
OOINLINE Vector vector_add(Vector a, Vector b) INLINE_CONST_FUNC
Definition OOVector.h:195
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
Definition OOVector.h:149
OOINLINE Vector cross_product(Vector first, Vector second) INLINE_CONST_FUNC
Definition OOVector.h:294
BOOL isVisible()
Definition Entity.m:1028
double speed()
Definition Entity.m:713
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
Definition OOColor.m:344
Vector forwardVector()
GLfloat flightSpeed
GLfloat speedFactor()
OOColor * exhaustEmissiveColor()
Vector rightVector()
float randf(void)
#define ranrot_rand()
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References _exhaustBaseColors, _exhaustScale, _trackTime, _vertices, Entity::collision_radius, cross_product(), ShipEntity::damage, ShipEntity::exhaustEmissiveColor, EXPECT_NOT, ShipEntity::flightSpeed, ShipEntity::forwardVector, frameAtTime:fromFrame:, OOColor::getRed:green:blue:alpha:, HPmagnitude(), HPvector_add(), HPvector_subtract(), Entity::isPlayer, Entity::isVisible, Frame::k, kFadeLevel1, kFadeLevel2, kFadeLevel3, kOverallAlpha, kScaleLevel1, kScaleLevel2, kScaleLevel3, kTimeStep, M_SQRT1_2, make_HPvector(), make_vector(), nil, Entity::normalOrientation, Entity::owner, Entity::position, Frame::position, randf(), ranrot_rand, ShipEntity::rightVector, saveToLastFrame, Entity::speed, ShipEntity::speedFactor, UNIVERSE, ShipEntity::upVector, vector_add(), vector_multiply_scalar(), vectorToHPVector(), HPVector::x, Vector::x, HPVector::y, Vector::y, HPVector::z, and Vector::z.

Here is the call graph for this function:

Member Data Documentation

◆ _exhaustBaseColors

- (GLfloat _exhaustBaseColors[34 *4])
private

Definition at line 46 of file OOExhaustPlumeEntity.h.

Referenced by drawSubEntityImmediate:translucent:, and update:.

◆ _exhaustScale

- (Vector) _exhaustScale
private

Definition at line 43 of file OOExhaustPlumeEntity.h.

Referenced by rescaleBy:, scale, setScale:, and update:.

◆ _glVertices

- (GLfloat _glVertices[34 *3])
private

Definition at line 45 of file OOExhaustPlumeEntity.h.

Referenced by drawSubEntityImmediate:translucent:.

◆ _nextFrame

- (uint8_t) _nextFrame
private

Definition at line 49 of file OOExhaustPlumeEntity.h.

Referenced by resetPlume.

◆ _track

- (Frame _track[kExhaustFrameCount])
private

Definition at line 47 of file OOExhaustPlumeEntity.h.

Referenced by resetPlume.

◆ _trackTime

- (OOTimeAbsolute) _trackTime
private

Definition at line 48 of file OOExhaustPlumeEntity.h.

Referenced by update:.

◆ _vertices

- (OOHPScalar _vertices[34 *3])
private

Definition at line 44 of file OOExhaustPlumeEntity.h.

Referenced by drawSubEntityImmediate:translucent:, and update:.


The documentation for this class was generated from the following files: