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

#include <OOSunEntity.h>

Inheritance diagram for OOSunEntity:
Collaboration diagram for OOSunEntity:

Instance Methods

(id) - initSunWithColor:andDictionary:
(BOOL) - setSunColor:
(BOOL) - changeSunProperty:withDictionary:
(OOStellarBodyType) - planetType
(void) - getDiffuseComponents:
(void) - getSpecularComponents:
(void) - setRadius:andCorona:
(BOOL) - willGoNova
(BOOL) - goneNova
(void) - setGoingNova:inTime:
(void) - drawStarGlare
(void) - drawDirectVisionSunGlare
(void) - resetNova
(id) - init [implementation]
(void) - dealloc [implementation]
(NSString *) - descriptionComponents [implementation]
(BOOL) - canCollide [implementation]
(void) - update: [implementation]
(void) - drawImmediate:translucent: [implementation]
(void) - updateCameraRelativePosition [implementation]
(void) - drawOpaqueParts [implementation]
(void) - drawTranslucentParts [implementation]
(void) - calculateGLArrays:width:zDistance: [implementation]
(double) - radius [implementation]
(void) - setPosition: [implementation]
(BOOL) - isSun [implementation]
(BOOL) - isVisible [implementation]
(NSString *) - name [implementation]
(void) - setName: [implementation]
(BOOL) - isVisibleToScripts [implementation]
(void) - getJSClass:andPrototype: [implementation]
(NSString *) - oo_jsClassName [implementation]
(JSClassID) - oo_jsClassID [implementation]
Instance Methods inherited from Entity
(NSUInteger) - sessionID
(BOOL) - isShip
(BOOL) - isDock
(BOOL) - isStation
(BOOL) - isSubEntity
(BOOL) - isPlayer
(BOOL) - isPlanet
(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) - setPositionX:y:z:
(HPVector) - position
(Vector) - cameraRelativePosition
(GLfloat) - cameraRangeFront
(GLfloat) - cameraRangeBack
(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
(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:
(double) - findCollisionRadius
(BOOL) - isInSpace
(BOOL) - isImmuneToBreakPatternHide
(GLfloat) - universalTime
(GLfloat) - spawnTime
(GLfloat) - timeElapsedSinceSpawn
(void) - setAtmosphereFogging:
(OOColor *) - fogUniform
(BOOL) - checkLinkedLists [implementation]
(id< OOWeakReferenceSupport >) - superShaderBindingTarget [implementation]
(Vector) - relativePosition [implementation]
(void) - subEntityReallyDied: [implementation]
(BOOL) - isBreakPattern
(BOOL) - isECMBlast
(BOOL) - isExhaust
(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:
(void) - drawSubEntityImmediate:translucent: [implementation]
Instance Methods inherited from OOWeakRefObject
(id) - weakSelf
(id) - weakRetain [implementation]
(void) - weakRefDied: [implementation]
Instance Methods inherited from <OOWeakReferenceSupport>
(id) - OO_RETURNS_RETAINED

Private Attributes

GLfloat sun_diffuse [4]
GLfloat sun_specular [4]
GLfloat discColor [4]
GLfloat outerCoronaColor [4]
GLfloat cor16k
GLfloat lim16k
double corona_speed_factor
double corona_stage
GLfloat rvalue [SUN_CORONA_SAMPLES]
float corona_blending
GLuint sunTriangles [3240 *3]
GLfloat sunVertices [1801 *3]
GLfloat sunColors [1801 *4]
OOTimeDelta _novaCountdown
OOTimeDelta _novaExpansionTimer
float _novaExpansionRate
float _sunBrightnessFactor
float _sunCoronaAlphaFactor
NSString * _name

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 50 of file OOSunEntity.h.

Method Documentation

◆ calculateGLArrays:width:zDistance:

- (void) calculateGLArrays: (GLfloat) inner_radius
width: (GLfloat) width
zDistance: (GLfloat) z_distance 
implementation

Provided by category OOSunEntity(Private).

Definition at line 438 of file OOSunEntity.m.

438 :(GLfloat)inner_radius width:(GLfloat)width zDistance:(GLfloat)z_distance
439{
440 // if (EXPECT_NOT(inner_radius >= z_distance)) return; // inside the sphere
441
442 GLfloat activity[8] = { 0.84, 0.74, 0.64, 0.54,
443 0.3, 0.4, 0.7, 0.8 };
444
445 GLfloat si, ci;
446 GLfloat rv0, rv1, rv2, c0, c1, c2;
447 GLfloat pt0, pt1;
448
449 unsigned short i, j, k;
450 GLfloat theta = 0.0f, delta;
451 delta = M_PI / 180.0f; // Convert step from degrees to radians
452 pt0 = (1.0 - corona_stage) * corona_blending;
454
455 sunVertices[0] = 0.0;
456 sunVertices[1] = 0.0;
457 sunVertices[2] = 0.0;
458 k = 3;
459 for (j = 0; j <= 4; j++) {
460 GLfloat r = inner_radius;
461 switch (j) {
462 case 4:
463 r += width;
464 break;
465 case 3:
466 r += width / 1.5f;
467 break;
468 case 2:
469 r += width / 3.0f;
470 break;
471 case 1:
472 r += width / 15.0f;
473 break;
474 }
475 theta = 0.0;
476 for (i = 0; i < 360; i++) {
477 GLfloat rm = 1.0;
478 if (j >= 1 && j < 4) {
479 rm = 1.0 + ((0.04 / j) * (pt0 * (rvalue[i] + rvalue[i + 1] + rvalue[i + 2]) + pt1 * (rvalue[i + 360] + rvalue[i + 361] + rvalue[i + 362]))) / 3;
480 }
481 GLfloat z = r * r * rm * rm / z_distance;
482 si = sinf(theta);
483 ci = cosf(theta);
484 theta += delta;
485 sunVertices[k++] = si * r * rm;
486 sunVertices[k++] = ci * r * rm;
487 sunVertices[k++] = -z;
488 }
489 }
490
491 GLfloat blackColor[4] = { 0.0, 0.0, 0.0, 0.0 };
492 GLfloat* color = blackColor;
493 GLfloat alpha = 0.0;
494
495 k = 0;
496 sunColors[k++] = discColor[0];
497 sunColors[k++] = discColor[1];
498 sunColors[k++] = discColor[2];
500
501 for (j = 0; j <= 4; j++) {
502 switch (j) {
503 case 4:
504 color = blackColor;
505 alpha = 0.0;
506 break;
507 case 3:
508 color = outerCoronaColor;
509 alpha = 0.1;
510 break;
511 case 2:
512 color = outerCoronaColor;
513 alpha = 0.6;
514 break;
515 case 1:
516 color = discColor;
517 alpha = 0.95;
518 break;
519 case 0:
520 color = discColor;
521 alpha = 1.0;
522 break;
523 }
524 for (i = 0; i < 360; i++) {
525 if (j == 0) {
526 sunColors[k++] = color[0];
527 sunColors[k++] = color[1];
528 sunColors[k++] = color[2];
529 sunColors[k++] = alpha * _sunCoronaAlphaFactor;
530 } else {
531 rv0 = pt0 * rvalue[i] + pt1 * rvalue[i + 360];
532 rv1 = pt0 * rvalue[i + 1] + pt1 * rvalue[i + 361];
533 rv2 = pt0 * rvalue[i + 2] + pt1 * rvalue[i + 362];
534 c0 = color[0] * (activity[j - 1] + rv0 * activity[j + 3]);
535 c1 = color[1] * (activity[j - 1] + rv1 * activity[j + 3]);
536 c2 = color[2] * (activity[j - 1] + rv2 * activity[j + 3]);
537 if (c1 > c2 && c1 > c0) {
538 c1 = fmaxf(c0, c2);
539 }
540
541 sunColors[k++] = c0;
542 sunColors[k++] = c1;
543 sunColors[k++] = c2;
544 sunColors[k++] = alpha * _sunCoronaAlphaFactor;
545 }
546 }
547 }
548}
#define M_PI
Definition OOMaths.h:54
float _sunCoronaAlphaFactor
Definition OOSunEntity.h:74
GLfloat outerCoronaColor[4]
Definition OOSunEntity.h:56
GLfloat rvalue[SUN_CORONA_SAMPLES]
Definition OOSunEntity.h:62
float corona_blending
Definition OOSunEntity.h:63
double corona_stage
Definition OOSunEntity.h:61
GLfloat sunColors[1801 *4]
Definition OOSunEntity.h:67
GLfloat discColor[4]
Definition OOSunEntity.h:55
GLfloat sunVertices[1801 *3]
Definition OOSunEntity.h:66

References M_PI.

Referenced by OOSunEntity(Private)::drawOpaqueParts.

Here is the caller graph for this function:

◆ canCollide

- (BOOL) canCollide
implementation

Reimplemented from Entity.

Definition at line 221 of file OOSunEntity.m.

222{
223 return YES;
224}

References canCollide.

Referenced by canCollide.

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

◆ changeSunProperty:withDictionary:

- (BOOL) changeSunProperty: (NSString*) key
withDictionary: (NSDictionary*) dict 

Definition at line 616 of file OOSunEntity.m.

616 :(NSString*)key withDictionary:(NSDictionary*)dict
617{
618 id object = [dict objectForKey:key];
619 static GLfloat oldRadius = 0.0;
620 if ([key isEqualToString:@"sun_radius"]) {
621 oldRadius = [object doubleValue]; // clamp corona_flare in case planetinfo.plist / savegame contains the wrong value
622 [self setRadius:oldRadius andCorona:[dict oo_floatForKey:@"corona_flare" defaultValue:0.0f]];
623 } else if ([key isEqualToString:KEY_SUNNAME]) {
624 [self setName:[dict oo_stringForKey:KEY_SUNNAME]];
625 } else if ([key isEqualToString:@"corona_flare"]) {
626 [self setRadius:collision_radius andCorona:[object floatValue]];
627 } else if ([key isEqualToString:@"corona_shimmer"]) {
628 corona_speed_factor = OOClamp_0_1_f([object floatValue]) * 2.0 + randf() * randf();
629 } else if ([key isEqualToString:@"corona_hues"]) {
630 corona_blending = OOClamp_0_1_f([object floatValue]);
631 } else if ([key isEqualToString:@"sun_gone_nova"]) {
632
633 if ([dict oo_boolForKey:key]) {
634 [self setGoingNova:YES inTime:0];
635 } else {
636 [self setGoingNova:NO inTime:0];
637 // oldRadius is always the radius we had before going nova...
638 [self setRadius:oldRadius andCorona:[dict oo_floatForKey:@"corona_flare" defaultValue:0.0f]];
639 }
640 } else {
641 OOLogWARN(@"script.warning", @"Change to property '%@' not applied, will apply only after leaving this system.", key);
642 return NO;
643 }
644 return YES;
645}
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
#define OOLogWARN(class, format,...)
Definition OOLogging.h:126
#define KEY_SUNNAME
Definition Universe.h:122
double corona_speed_factor
Definition OOSunEntity.h:60
float randf(void)

References corona_blending, corona_speed_factor, KEY_SUNNAME, OOClamp_0_1_f(), OOLogWARN, randf(), setGoingNova:inTime:, setName:, and setRadius:andCorona:.

Referenced by initSunWithColor:andDictionary:, and Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:.

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

◆ dealloc

- (void) dealloc
implementation

Reimplemented from Entity.

Definition at line 203 of file OOSunEntity.m.

204{
205 DESTROY(_name);
206 [super dealloc];
207}
#define DESTROY(x)
NSString * _name
Definition OOSunEntity.h:76

References _name, Entity::dealloc, dealloc, and DESTROY.

Referenced by dealloc.

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

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Reimplemented from Entity.

Definition at line 209 of file OOSunEntity.m.

210{
211 NSString* result = [NSString stringWithFormat:@"ID: %u position: %@ radius: %.3fkm", [self universalID], HPVectorDescription([self position]), 0.001 * [self radius]];
212 if ([self goneNova]) {
213 result = [result stringByAppendingString:@" (gone nova)"];
214 } else if ([self willGoNova]) {
215 result = [result stringByAppendingString:@" (will go nova)"];
216 }
217
218 return result;
219}
BOOL willGoNova()

References descriptionComponents, goneNova, Entity::position, radius, Entity::universalID, and willGoNova.

Referenced by descriptionComponents.

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

◆ drawDirectVisionSunGlare

- (void) drawDirectVisionSunGlare

Definition at line 550 of file OOSunEntity.m.

551{
552#if SUN_DIRECT_VISION_GLARE
554
556
557 GLfloat sunGlareAngularSize = atan([self radius] / HPdistance([PLAYER viewpointPosition], [self position])) * SUN_GLARE_MULT_FACTOR + (SUN_GLARE_ADD_FACTOR);
558
559 GLfloat directVisionSunGlare = [PLAYER lookingAtSunWithThresholdAngleCos:cosf(sunGlareAngularSize)];
560 if (directVisionSunGlare) {
561 NSSize siz = [[UNIVERSE gui] size];
562 MyOpenGLView* gameView = [UNIVERSE gameView];
563 GLfloat aspectRatio = ([gameView viewSize].width / [gameView viewSize].height);
564 GLfloat z = [gameView display_z] / (aspectRatio > 4.0f / 3.0f ? aspectRatio : 1.0f / aspectRatio);
565 GLfloat atmosphericReductionFactor = 1.0f - [PLAYER insideAtmosphereFraction];
566 // 182: square of ratio of radius to sun-witchpoint distance
567 // in default Lave
568 GLfloat distanceReductionFactor = OOClamp_0_1_f(([self radius] * [self radius] * 182.0) / HPdistance2([PLAYER position], [self position]));
569 GLfloat sunGlareFilterMultiplierLocal = [PLAYER sunGlareFilter];
570 GLfloat directVisionSunGlareColor[4] = { discColor[0], discColor[1], discColor[2], directVisionSunGlare * atmosphericReductionFactor * distanceReductionFactor * (1.0f - sunGlareFilterMultiplierLocal) * 0.0085f };
571
572 OOGL(glColor4fv(directVisionSunGlareColor));
573
574 OOGLBEGIN(GL_QUADS);
575 glVertex3f(siz.width, siz.height, z);
576 glVertex3f(siz.width, -siz.height, z);
577 glVertex3f(-siz.width, -siz.height, z);
578 glVertex3f(-siz.width, siz.height, z);
579 OOGLEND();
580 }
581#endif
582}
OOINLINE OOHPScalar HPdistance2(HPVector v1, HPVector v2) INLINE_CONST_FUNC
Definition OOHPVector.h:293
OOINLINE OOHPScalar HPdistance(HPVector v1, HPVector v2) INLINE_CONST_FUNC
Definition OOHPVector.h:298
#define OO_ENTER_OPENGL()
#define OOGLBEGIN
Definition OOOpenGL.h:269
@ OPENGL_STATE_OVERLAY
Definition OOOpenGL.h:124
#define OOSetOpenGLState(STATE)
Definition OOOpenGL.h:132
#define OOGL(statement)
Definition OOOpenGL.h:262
#define OOGLEND
Definition OOOpenGL.h:270
#define PLAYER
HPVector position
Definition Entity.m:576
GLfloat display_z
double radius()

References discColor, MyOpenGLView::display_z, drawDirectVisionSunGlare, HPdistance(), HPdistance2(), OO_ENTER_OPENGL, OOClamp_0_1_f(), OOGL, OOGLBEGIN, OOGLEND, OOSetOpenGLState, OPENGL_STATE_OVERLAY, PLAYER, Entity::position, radius, and MyOpenGLView::viewSize.

Referenced by drawDirectVisionSunGlare, and Universe::drawUniverse.

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

◆ drawImmediate:translucent:

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

Reimplemented from Entity.

Definition at line 307 of file OOSunEntity.m.

307 :(bool)immediate translucent:(bool)translucent
308{
309 if (![UNIVERSE breakPatternHide]) {
310 if (translucent) {
311 // nothing...
312 } else {
313 [self drawOpaqueParts];
314 /* Despite the side effects, we have to draw the translucent
315 * parts on the opaque pass. Planets, at long range, aren't
316 * depth-buffered. So if the translucent parts are drawn on the
317 * translucent pass, they appear in front of planets they are
318 * actually behind. Telabe in G3 is a good one to test with if
319 * you have any clever ideas.
320 *
321 * - CIM 8/7/2013 */
322 [self drawTranslucentParts];
323 }
324 }
325}
#define UNIVERSE
Definition Universe.h:827

References drawOpaqueParts, drawTranslucentParts, and UNIVERSE.

Here is the call graph for this function:

◆ drawOpaqueParts

- (void) drawOpaqueParts
implementation

Provided by category OOSunEntity(Private).

Definition at line 339 of file OOSunEntity.m.

340{
341 float sqrt_zero_distance = sqrt(cam_zero_distance);
342 float effective_radius = collision_radius;
343 float effective_cor16k = cor16k;
344
345 /* At very long ranges the floating point inaccuracies make a
346 * complete mess of the calculations, so if the sun is more than
347 * 1E9 away, draw it closer but smaller. Painter's algorithm
348 * should stop oddities with planets transiting it */
349 float large_distance_compensator = sqrt_zero_distance / 1000000000.0f; // 1E9
350 if (large_distance_compensator > 1.0f) {
351 sqrt_zero_distance /= large_distance_compensator;
352 effective_radius /= large_distance_compensator;
353 effective_cor16k /= large_distance_compensator;
354 }
355
357
359
360 if ([UNIVERSE reducedDetail]) {
361 int subdivideLevel = 2; // 4 is probably the maximum!
362 float drawFactor = [[UNIVERSE gameView] viewSize].width / 100.0;
363 float drawRatio2 = drawFactor * effective_radius / sqrt_zero_distance; // equivalent to size on screen in pixels
364
365 if (cam_zero_distance > 0.0f) {
366 subdivideLevel = 2 + floorf(drawRatio2);
367 if (subdivideLevel > 4)
368 subdivideLevel = 4;
369 }
370
371 /*
372
373 The depth test gets disabled in parts of this and instead
374 we rely on the painters algorithm instead.
375
376 The depth buffer isn't granular enough to cope with huge objects at vast
377 distances.
378
379 */
380 BOOL ignoreDepthBuffer = cam_zero_distance > effective_radius * effective_radius * 25;
381
382 int steps = 2 * (MAX_SUBDIVIDE - subdivideLevel);
383
384 // Close enough not to draw flat?
385 if (ignoreDepthBuffer)
386 OOGL(glDisable(GL_DEPTH_TEST));
387
388 OOGL(glColor3fv(discColor));
389 // FIXME: use vertex arrays
390 OOGL(glDisable(GL_BLEND));
391 OOGLBEGIN(GL_TRIANGLE_FAN);
392 GLDrawBallBillboard(effective_radius, steps, sqrt_zero_distance);
393 OOGLEND();
394 OOGL(glEnable(GL_BLEND));
395
396 if (ignoreDepthBuffer)
397 OOGL(glEnable(GL_DEPTH_TEST));
398
399 } else {
400 [self calculateGLArrays:effective_radius
401 width:effective_cor16k
402 zDistance:sqrt_zero_distance];
403 OOGL(glDisable(GL_BLEND));
404 OOGL(glVertexPointer(3, GL_FLOAT, 0, sunVertices));
405
406 OOGL(glEnableClientState(GL_COLOR_ARRAY));
407 OOGL(glColorPointer(4, GL_FLOAT, 0, sunColors));
408
409 OOGL(glDrawElements(GL_TRIANGLES, 3 * 360, GL_UNSIGNED_INT, sunTriangles));
410
411 OOGL(glDisableClientState(GL_COLOR_ARRAY));
412 OOGL(glEnable(GL_BLEND));
413 }
414
416 OOCheckOpenGLErrors(@"SunEntity after drawing %@", self);
417}
@ OPENGL_STATE_ADDITIVE_BLENDING
Definition OOOpenGL.h:123
#define OOVerifyOpenGLState()
Definition OOOpenGL.h:133
BOOL OOCheckOpenGLErrors(NSString *format,...)
Definition OOOpenGL.m:38
void GLDrawBallBillboard(GLfloat radius, GLfloat step, GLfloat z_distance)
Definition OOOpenGL.m:107
#define MAX_SUBDIVIDE
GLfloat collision_radius
Definition Entity.h:107
GLfloat cam_zero_distance
Definition Entity.h:105
GLuint sunTriangles[3240 *3]
Definition OOSunEntity.h:65
GLfloat cor16k
Definition OOSunEntity.h:58

References calculateGLArrays:width:zDistance:, OOSunEntity(Private)::drawOpaqueParts, GLDrawBallBillboard(), MAX_SUBDIVIDE, OO_ENTER_OPENGL, OOCheckOpenGLErrors(), OOGL, OOGLBEGIN, OOGLEND, OOSetOpenGLState, OOVerifyOpenGLState, OPENGL_STATE_ADDITIVE_BLENDING, and UNIVERSE.

Referenced by drawImmediate:translucent:, and OOSunEntity(Private)::drawOpaqueParts.

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

◆ drawStarGlare

- (void) drawStarGlare

Definition at line 584 of file OOSunEntity.m.

585{
587
589
590 float sqrt_zero_distance = sqrtf(cam_zero_distance);
591 float alt = sqrt_zero_distance - collision_radius;
592 if (EXPECT_NOT(alt < 0)) {
593 return;
594 }
595 float corona = cor16k / SUN_GLARE_CORONA_FACTOR;
596 if (corona > alt) {
597 float alpha = (1 - (alt / corona));
598 float alphaMult = _sunCoronaAlphaFactor * alpha;
599 alpha *= alphaMult;
600 GLfloat glareColor[4] = { discColor[0], discColor[1], discColor[2], alpha };
601 NSSize siz = [[UNIVERSE gui] size];
602 MyOpenGLView* gameView = [UNIVERSE gameView];
603 GLfloat aspectRatio = ([gameView viewSize].width / [gameView viewSize].height);
604 GLfloat z = [gameView display_z] / (aspectRatio > 4.0f / 3.0f ? aspectRatio : 1.0f / aspectRatio);
605 OOGL(glColor4fv(glareColor));
606
607 OOGLBEGIN(GL_QUADS);
608 glVertex3f(siz.width, siz.height, z);
609 glVertex3f(siz.width, -siz.height, z);
610 glVertex3f(-siz.width, -siz.height, z);
611 glVertex3f(-siz.width, siz.height, z);
612 OOGLEND();
613 }
614}
#define EXPECT_NOT(x)
#define SUN_GLARE_CORONA_FACTOR
Definition OOSunEntity.h:45

References _sunCoronaAlphaFactor, Entity::cam_zero_distance, Entity::collision_radius, cor16k, discColor, MyOpenGLView::display_z, drawStarGlare, EXPECT_NOT, OO_ENTER_OPENGL, OOGL, OOGLBEGIN, OOGLEND, OOSetOpenGLState, OPENGL_STATE_OVERLAY, SUN_GLARE_CORONA_FACTOR, and MyOpenGLView::viewSize.

Referenced by drawStarGlare, and Universe::drawUniverse.

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

◆ drawTranslucentParts

- (void) drawTranslucentParts
implementation

Provided by category OOSunEntity(Private).

Definition at line 419 of file OOSunEntity.m.

420{
421 if ([UNIVERSE reducedDetail]) {
422 return;
423 }
424
426
428
429 OOGL(glVertexPointer(3, GL_FLOAT, 0, sunVertices));
430
431 OOGL(glEnableClientState(GL_COLOR_ARRAY));
432 OOGL(glColorPointer(4, GL_FLOAT, 0, sunColors));
433 OOGL(glDrawElements(GL_TRIANGLES, 24 * 360, GL_UNSIGNED_INT, sunTriangles + (3 * 360)));
434
435 OOGL(glDisableClientState(GL_COLOR_ARRAY));
436}

References OOSunEntity(Private)::drawTranslucentParts, OO_ENTER_OPENGL, OOGL, OOSetOpenGLState, OPENGL_STATE_ADDITIVE_BLENDING, and UNIVERSE.

Referenced by drawImmediate:translucent:, and OOSunEntity(Private)::drawTranslucentParts.

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

◆ getDiffuseComponents:

- (void) getDiffuseComponents: (GLfloat[4]) components

Definition at line 652 of file OOSunEntity.m.

652 :(GLfloat[4])components
653{
654 NSParameterAssert(components != NULL);
655 memcpy(components, sun_diffuse, sizeof sun_diffuse);
656}
GLfloat sun_diffuse[4]
Definition OOSunEntity.h:52

References sun_diffuse.

Referenced by Universe::setLighting, and Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:.

Here is the caller graph for this function:

◆ getJSClass:andPrototype:

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

Reimplemented from Entity.

Provided by category OOSunEntity(OOJavaScriptExtensions).

Definition at line 93 of file OOJSSun.m.

93 :(JSClass**)outClass andPrototype:(JSObject**)outPrototype
94{
95 *outClass = &sSunClass;
96 *outPrototype = sSunPrototype;
97}
static JSClass sSunClass
Definition OOJSSun.m:38
static JSObject * sSunPrototype
Definition OOJSSun.m:32

◆ getSpecularComponents:

- (void) getSpecularComponents: (GLfloat[4]) components

Definition at line 658 of file OOSunEntity.m.

658 :(GLfloat[4])components
659{
660 NSParameterAssert(components != NULL);
661 memcpy(components, sun_specular, sizeof sun_specular);
662}
GLfloat sun_specular[4]
Definition OOSunEntity.h:53

References sun_specular.

Referenced by Universe::setLighting, and Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:.

Here is the caller graph for this function:

◆ goneNova

- (BOOL) goneNova

Definition at line 693 of file OOSunEntity.m.

694{
695 return throw_sparks && _novaCountdown <= 0;
696}
unsigned throw_sparks
Definition Entity.h:97
OOTimeDelta _novaCountdown
Definition OOSunEntity.h:69

References _novaCountdown, goneNova, and Entity::throw_sparks.

Referenced by HeadUpDisplay(Private)::checkPlayerInSystemFlight, descriptionComponents, and goneNova.

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

◆ init

- (id) init
implementation

Reimplemented from Entity.

Definition at line 52 of file OOSunEntity.m.

53{
54 assert(0);
55 return nil;
56}
return nil

References init, and nil.

Referenced by init.

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

◆ initSunWithColor:andDictionary:

- (id) initSunWithColor: (OOColor*) sun_color
andDictionary: (NSDictionary*) dict 

Definition at line 123 of file OOSunEntity.m.

123 :(OOColor*)sun_color andDictionary:(NSDictionary*)dict
124{
125 int i;
126
127 self = [super init];
128
129 collision_radius = 100000.0; // 100km across
130
131 scanClass = CLASS_NO_DRAW;
132
133 _sunBrightnessFactor = [[NSUserDefaults standardUserDefaults] oo_floatForKey:@"sbf" defaultValue:80.0f];
134 _sunCoronaAlphaFactor = [[NSUserDefaults standardUserDefaults] oo_floatForKey:@"scaf" defaultValue:0.005f];
135
136 [self setSunColor:sun_color];
137
138 [self setName:OOExpand([dict oo_stringForKey:KEY_SUNNAME defaultValue:@"[oolite-default-star-name]"])];
139
140 corona_blending = OOClamp_0_1_f([dict oo_floatForKey:@"corona_hues" defaultValue:1.0f]);
141 corona_speed_factor = [dict oo_floatForKey:@"corona_shimmer" defaultValue:-1.0];
142 if (corona_speed_factor < 0) {
143 // from .22222 to 2
144 corona_speed_factor = 1.0 / (0.5 + 2.0 * (randf() + randf()));
145 } else {
146 // on average: 0 = .25 , 1 = 2.25 - the same sun should give the same random component
148 }
149#ifdef OO_DUMP_PLANETINFO
150 OOLog(@"planetinfo.record", @"corona_shimmer = %f", corona_speed_factor);
151#endif
152
153 corona_stage = 0.0;
154 for (i = 0; i < SUN_CORONA_SAMPLES; i++)
155 rvalue[i] = randf();
156
157 // set up the radius properties
158 [self changeSunProperty:@"sun_radius" withDictionary:dict];
159
160 unsigned k = 0;
161 for (unsigned i = 0; i < 360; i++) {
162 unsigned j = (i + 1) % 360;
163 // disc
164 sunTriangles[k++] = 0;
165 sunTriangles[k++] = 1 + i;
166 sunTriangles[k++] = 1 + j;
167 }
168 for (unsigned i = 0; i < 360; i++) {
169 unsigned j = (i + 1) % 360;
170 // ring 1
171 sunTriangles[k++] = 1 + i;
172 sunTriangles[k++] = 1 + j;
173 sunTriangles[k++] = 361 + i;
174 sunTriangles[k++] = 1 + j;
175 sunTriangles[k++] = 361 + i;
176 sunTriangles[k++] = 361 + j;
177 // ring 2
178 sunTriangles[k++] = 361 + i;
179 sunTriangles[k++] = 361 + j;
180 sunTriangles[k++] = 721 + i;
181 sunTriangles[k++] = 361 + j;
182 sunTriangles[k++] = 721 + i;
183 sunTriangles[k++] = 721 + j;
184 // ring 3
185 sunTriangles[k++] = 721 + i;
186 sunTriangles[k++] = 721 + j;
187 sunTriangles[k++] = 1081 + i;
188 sunTriangles[k++] = 721 + j;
189 sunTriangles[k++] = 1081 + i;
190 sunTriangles[k++] = 1081 + j;
191 // ring 4
192 sunTriangles[k++] = 1081 + i;
193 sunTriangles[k++] = 1081 + j;
194 sunTriangles[k++] = 1441 + i;
195 sunTriangles[k++] = 1081 + j;
196 sunTriangles[k++] = 1441 + i;
197 sunTriangles[k++] = 1441 + j;
198 }
199
200 return self;
201}
#define OOLog(class, format,...)
Definition OOLogging.h:84
#define SUN_CORONA_SAMPLES
Definition OOSunEntity.h:33
OOScanClass scanClass
Definition Entity.m:743
float _sunBrightnessFactor
Definition OOSunEntity.h:73

References _sunBrightnessFactor, _sunCoronaAlphaFactor, changeSunProperty:withDictionary:, Entity::collision_radius, corona_blending, corona_speed_factor, corona_stage, Entity::init, OOClamp_0_1_f(), OOLog, randf(), rvalue, Entity::scanClass, setName:, setSunColor:, SUN_CORONA_SAMPLES, and sunTriangles.

Here is the call graph for this function:

◆ isSun

- (BOOL) isSun
implementation

Reimplemented from Entity.

Definition at line 717 of file OOSunEntity.m.

718{
719 return YES;
720}

References isSun.

Referenced by isSun.

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

◆ isVisible

- (BOOL) isVisible
implementation

Reimplemented from Entity.

Definition at line 722 of file OOSunEntity.m.

723{
724 return YES;
725}

References isVisible.

Referenced by isVisible.

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

◆ isVisibleToScripts

- (BOOL) isVisibleToScripts
implementation

Reimplemented from Entity.

Provided by category OOSunEntity(OOJavaScriptExtensions).

Definition at line 88 of file OOJSSun.m.

89{
90 return YES;
91}

◆ name

- (NSString *) name
implementation

Reimplemented from <OOStellarBody>.

Definition at line 727 of file OOSunEntity.m.

728{
729 return _name;
730}

References _name, and name.

Referenced by name.

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

◆ oo_jsClassID

- (JSClassID) oo_jsClassID
implementation

Reimplemented from Entity.

Provided by category OOSunEntity(OOJavaScriptExtensions).

Definition at line 93 of file OOJSSun.m.

94{
95 return sSunClassID;
96}
static JSClassID sSunClassID
Definition OOJSSun.m:32

◆ oo_jsClassName

- (NSString *) oo_jsClassName
implementation

Reimplemented from Entity.

Provided by category OOSunEntity(OOJavaScriptExtensions).

Definition at line 99 of file OOJSSun.m.

100{
101 return @"Sun";
102}

◆ planetType

- (OOStellarBodyType) planetType

Reimplemented from <OOStellarBody>.

Definition at line 647 of file OOSunEntity.m.

648{
649 return STELLAR_TYPE_SUN;
650}
@ STELLAR_TYPE_SUN

References planetType, and STELLAR_TYPE_SUN.

Referenced by planetType.

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

◆ radius

- (double) radius
implementation

Reimplemented from <OOStellarBody>.

Definition at line 664 of file OOSunEntity.m.

665{
666 return collision_radius;
667}

References Entity::collision_radius, and radius.

Referenced by Universe::coordinatesForPosition:withCoordinateSystem:returningScalar:, descriptionComponents, drawDirectVisionSunGlare, Universe::legacyPositionFrom:asCoordinateSystem:, and radius.

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

◆ resetNova

- (void) resetNova

Definition at line 710 of file OOSunEntity.m.

711{
713 _novaExpansionRate = 0.0f;
714 _novaCountdown = 0.0;
715}
float _novaExpansionRate
Definition OOSunEntity.h:71
OOTimeDelta _novaExpansionTimer
Definition OOSunEntity.h:70

References _novaCountdown, _novaExpansionRate, _novaExpansionTimer, and resetNova.

Referenced by resetNova, update:, and PlayerEntity(OOPrivate)::witchJumpTo:misjump:.

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

◆ setGoingNova:inTime:

- (void) setGoingNova: (BOOL) yesno
inTime: (double) interval 

Definition at line 698 of file OOSunEntity.m.

698 :(BOOL)yesno inTime:(double)interval
699{
700 throw_sparks = yesno;
701 if (throw_sparks) {
702 _novaCountdown = fmax(interval, 0.0);
703 OOLog(@"script.debug.setSunNovaIn", @"NOVA activated! time until Nova : %.1f s", _novaCountdown);
704 }
705
707 _novaExpansionRate = 10000;
708}

References _novaCountdown, _novaExpansionRate, _novaExpansionTimer, OOLog, and Entity::throw_sparks.

Referenced by changeSunProperty:withDictionary:, SunCancelNova(), SunCancelNova(), SunGoNova(), and SunGoNova().

Here is the caller graph for this function:

◆ setName:

- (void) setName: (NSString*) name
implementation

Reimplemented from <OOStellarBody>.

Definition at line 732 of file OOSunEntity.m.

732 :(NSString*)name
733{
734 [_name release];
735 _name = [name retain];
736}
NSString * name()

References _name.

Referenced by changeSunProperty:withDictionary:, and initSunWithColor:andDictionary:.

Here is the caller graph for this function:

◆ setPosition:

- (void) setPosition: (HPVector) posn
implementation

Reimplemented from Entity.

Definition at line 682 of file OOSunEntity.m.

682 :(HPVector)posn
683{
684 [super setPosition:posn];
685 [UNIVERSE setMainLightPosition:HPVectorToVector(posn)];
686}
struct HPVector HPVector

References Entity::setPosition:.

Referenced by Universe::populateNormalSpace, and Universe::setUpSpace.

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

◆ setRadius:andCorona:

- (void) setRadius: (GLfloat) rad
andCorona: (GLfloat) corona 

Definition at line 669 of file OOSunEntity.m.

669 :(GLfloat)rad andCorona:(GLfloat)corona
670{
671 collision_radius = rad;
672 if (corona < 0.01f) {
673 corona = 0.01f;
674 }
675 cor16k = rad * 8 * corona;
676
677 GLfloat corouter = rad * (1 + (8 * corona));
678
680}
#define NO_DRAW_DISTANCE_FACTOR
Definition Entity.h:49
GLfloat lim16k
Definition OOSunEntity.h:58

References Entity::collision_radius, cor16k, lim16k, and NO_DRAW_DISTANCE_FACTOR.

Referenced by changeSunProperty:withDictionary:, and Universe::setUpSpace.

Here is the caller graph for this function:

◆ setSunColor:

- (BOOL) setSunColor: (OOColor*) sun_color

Definition at line 59 of file OOSunEntity.m.

59 :(OOColor*)sun_color
60{
61 if (sun_color == nil)
62 return NO;
63
65
66 float hue, sat, bri, alf;
67 OOColor* color = nil;
68
69 // blend some white into the sun color to brighten it up
70 sun_color = [sun_color blendedColorWithFraction:0.3 ofColor:[OOColor whiteColor]];
71
72 [sun_color getHue:&hue saturation:&sat brightness:&bri alpha:&alf];
73 hue /= 360;
74
75 /*
76 // FIXME: do away with hue_drift altogether?
77 // The following two lines are functionally identical to 1.73:
78 randf();randf(); // avoid ranrot dirft!
79 float hue_drift = 0.0f;
80 */
81
82 // anything more than a minimal hue drift will wipe out the original colour.
83 float hue_drift = 0.0038f * fabsf(randf() - randf());
84
85 // set the lighting color for the sun
86 GLfloat r, g, b, a;
87 [sun_color getRed:&r green:&g blue:&b alpha:&a];
88
89 GLfloat sun_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; // real ambient light inside gl_LightModel.ambient
90 sun_diffuse[0] = 0.5f * (1.0f + r); // paler
91 sun_diffuse[1] = 0.5f * (1.0f + g); // paler
92 sun_diffuse[2] = 0.5f * (1.0f + b); // paler
93 sun_diffuse[3] = 1.0;
94 sun_specular[0] = r;
95 sun_specular[1] = g;
96 sun_specular[2] = b;
97 sun_specular[3] = 1.0;
98
99 OOGL(glLightfv(GL_LIGHT1, GL_AMBIENT, sun_ambient));
100 OOGL(glLightfv(GL_LIGHT1, GL_DIFFUSE, sun_diffuse));
101 OOGL(glLightfv(GL_LIGHT1, GL_SPECULAR, sun_specular));
102
103 // main disc less saturation (partially taken care of by the ACES tonemapper) more brightness
104 color = [OOColor colorWithHue:hue saturation:sat * 0.75f brightness:1.0f alpha:1.0f];
105 // our OpenGL color values are unclamped, so we can multiply the color components by
106 // any value we want, in order to make the sun a truly bright object in the sky
107 color = [OOColor colorWithRed:[color redComponent] * _sunBrightnessFactor green:[color greenComponent] * _sunBrightnessFactor blue:[color blueComponent] * _sunBrightnessFactor alpha:[color alphaComponent]];
108 [color getRed:&discColor[0] green:&discColor[1] blue:&discColor[2] alpha:&discColor[3]];
109
110 /* Two inner corona layers with low alpha and saturation are additively
111 blended with main corona. This produces something vaguely like a bloom
112 effect.
113 */
114 hue += hue_drift * 3;
115 // saturation = 1 would shift white to red
116 color = [OOColor colorWithHue:hue saturation:OOClamp_0_1_f(sat * 1.0f) brightness:bri * 0.75f alpha:0.45f];
117 color = [OOColor colorWithRed:[color redComponent] * _sunBrightnessFactor green:[color greenComponent] * _sunBrightnessFactor blue:[color blueComponent] * _sunBrightnessFactor alpha:[color alphaComponent]];
118 [color getRed:&outerCoronaColor[0] green:&outerCoronaColor[1] blue:&outerCoronaColor[2] alpha:&outerCoronaColor[3]];
119
120 return YES;
121}
void getHue:saturation:brightness:alpha:(float *hue,[saturation] float *saturation,[brightness] float *brightness,[alpha] float *alpha)
Definition OOColor.m:403
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:107
float alphaComponent()
Definition OOColor.m:442
float blueComponent()
Definition OOColor.m:339
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
Definition OOColor.m:344
OOColor * whiteColor()
Definition OOColor.m:249
OOColor * colorWithHue:saturation:brightness:alpha:(float hue,[saturation] float saturation,[brightness] float brightness,[alpha] float alpha)
Definition OOColor.m:100
float redComponent()
Definition OOColor.m:329
OOColor * blendedColorWithFraction:ofColor:(float fraction,[ofColor] OOColor *color)
Definition OOColor.m:309
float greenComponent()
Definition OOColor.m:334

References OOColor::alphaComponent, OOColor::blendedColorWithFraction:ofColor:, OOColor::blueComponent, OOColor::colorWithHue:saturation:brightness:alpha:, OOColor::colorWithRed:green:blue:alpha:, OOColor::getHue:saturation:brightness:alpha:, OOColor::getRed:green:blue:alpha:, OOColor::greenComponent, nil, OO_ENTER_OPENGL, OOGL, randf(), OOColor::redComponent, sun_diffuse, sun_specular, and OOColor::whiteColor.

Referenced by initSunWithColor:andDictionary:, and Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:.

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 237 of file OOSunEntity.m.

237 :(OOTimeDelta)delta_t
238{
239 [super update:delta_t];
240
241 PlayerEntity* player = PLAYER;
242 assert(player != nil);
243 rotMatrix = OOMatrixForBillboard(position, [player viewpointPosition]);
244
245 if (throw_sparks && _novaExpansionRate > 0.0f) // going NOVA!
246 {
247 if (_novaCountdown >= 0.0) // countdown
248 {
249 _novaCountdown -= delta_t;
250 if (corona_speed_factor < 5.0) {
251 corona_speed_factor += 0.75 * delta_t;
252 }
253 } else {
254 if (_novaExpansionTimer <= 60.0) // expand for a minute
255 {
256 double sky_bri = 1.0 - 1.5 * _novaExpansionTimer;
257 if (sky_bri < 0) {
258 [UNIVERSE setSkyColorRed:0.0f // back to black
259 green:0.0f
260 blue:0.0f
261 alpha:0.0f];
262 } else {
263 [UNIVERSE setSkyColorRed:sky_bri // whiteout
264 green:sky_bri
265 blue:sky_bri
266 alpha:1.0f];
267 }
268 if (sky_bri == 1.0) {
269 // This sun has now gone nova!
270 [UNIVERSE setSystemDataKey:@"sun_gone_nova" value:[NSNumber numberWithBool:YES] fromManifest:@"org.oolite.oolite"];
271 [UNIVERSE setSystemDataKey:@"corona_flare" value:[NSNumber numberWithFloat:0.3] fromManifest:@"org.oolite.oolite"];
272 [UNIVERSE setSystemDataKey:@"corona_hues" value:[NSNumber numberWithFloat:0.05] fromManifest:@"org.oolite.oolite"];
273 // Novas are stored under the core manifest if the
274 // player was there at the time. Default layer 2
275 // is fine.
276 OOLog(@"sun.nova.start", @"DEBUG: NOVA original radius %.1f", collision_radius);
277 }
281 _novaExpansionTimer += delta_t;
282 [UNIVERSE setSystemDataKey:@"sun_radius" value:[NSNumber numberWithFloat:collision_radius + delta_t * _novaExpansionRate] fromManifest:@"org.oolite.oolite"];
283 } else {
284 OOLog(@"sun.nova.end", @"DEBUG: NOVA final radius %.1f", collision_radius);
285
286 // reset at the new size
287 [self resetNova];
288 throw_sparks = YES; // keep throw_sparks at YES to indicate the higher temperature
289 }
290 }
291 }
292
293 // update corona
294 if (![UNIVERSE reducedDetail]) {
296 while (corona_stage > 1.0) {
297 int i;
298 corona_stage -= 1.0;
299 for (i = 0; i < 360; i++) {
300 rvalue[i] = rvalue[360 + i];
301 rvalue[360 + i] = randf();
302 }
303 }
304 }
305}
OOMatrix OOMatrixForBillboard(HPVector bbPos, HPVector eyePos) CONST_FUNC
Definition OOMatrix.m:186
double OOTimeDelta
Definition OOTypes.h:193
OOMatrix rotMatrix
Definition Entity.h:134

References _novaCountdown, _novaExpansionRate, _novaExpansionTimer, _sunBrightnessFactor, Entity::collision_radius, corona_speed_factor, corona_stage, discColor, nil, OOLog, OOMatrixForBillboard(), PLAYER, Entity::position, randf(), resetNova, Entity::rotMatrix, rvalue, Entity::throw_sparks, UNIVERSE, and Entity::update:.

Here is the call graph for this function:

◆ updateCameraRelativePosition

- (void) updateCameraRelativePosition
implementation

Reimplemented from Entity.

Definition at line 327 of file OOSunEntity.m.

328{
329 HPVector cr_temp = HPvector_subtract([self absolutePositionForSubentity], [PLAYER viewpointPosition]);
330 /* Special calculation as suns viewed over ~1E9 - and the bigger
331 * ones are still just about visible at this range - get floating
332 * point errors messing up the display */
333 if (EXPECT_NOT(HPmagnitude2(cr_temp) > 1E18)) {
334 cr_temp = HPvector_multiply_scalar(cr_temp, 1E9 / HPmagnitude(cr_temp));
335 }
337}
OOINLINE HPVector HPvector_subtract(HPVector a, HPVector b) INLINE_CONST_FUNC
Definition OOHPVector.h:236
OOINLINE HPVector HPvector_multiply_scalar(HPVector v, OOHPScalar s) INLINE_CONST_FUNC
Definition OOHPVector.h:198
OOINLINE OOHPScalar HPmagnitude(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:260
OOINLINE Vector HPVectorToVector(HPVector v) INLINE_CONST_FUNC
Definition OOHPVector.h:175
OOINLINE OOHPScalar HPmagnitude2(HPVector vec) INLINE_CONST_FUNC
Definition OOHPVector.h:255
HPVector absolutePositionForSubentity()
Definition Entity.m:627
Vector cameraRelativePosition
Definition Entity.m:581

References Entity::absolutePositionForSubentity, Entity::cameraRelativePosition, EXPECT_NOT, HPmagnitude(), HPmagnitude2(), HPvector_multiply_scalar(), HPvector_subtract(), HPVectorToVector(), PLAYER, and updateCameraRelativePosition.

Referenced by updateCameraRelativePosition.

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

◆ willGoNova

- (BOOL) willGoNova

Definition at line 688 of file OOSunEntity.m.

689{
690 return throw_sparks;
691}

References Entity::throw_sparks, and willGoNova.

Referenced by descriptionComponents, and willGoNova.

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

Member Data Documentation

◆ _name

- (NSString*) _name
private

Definition at line 76 of file OOSunEntity.h.

Referenced by dealloc, name, and setName:.

◆ _novaCountdown

- (OOTimeDelta) _novaCountdown
private

Definition at line 69 of file OOSunEntity.h.

Referenced by goneNova, resetNova, setGoingNova:inTime:, and update:.

◆ _novaExpansionRate

- (float) _novaExpansionRate
private

Definition at line 71 of file OOSunEntity.h.

Referenced by resetNova, setGoingNova:inTime:, and update:.

◆ _novaExpansionTimer

- (OOTimeDelta) _novaExpansionTimer
private

Definition at line 70 of file OOSunEntity.h.

Referenced by resetNova, setGoingNova:inTime:, and update:.

◆ _sunBrightnessFactor

- (float) _sunBrightnessFactor
private

Definition at line 73 of file OOSunEntity.h.

Referenced by initSunWithColor:andDictionary:, and update:.

◆ _sunCoronaAlphaFactor

- (float) _sunCoronaAlphaFactor
private

Definition at line 74 of file OOSunEntity.h.

Referenced by drawStarGlare, and initSunWithColor:andDictionary:.

◆ cor16k

- (GLfloat) cor16k
private

Definition at line 58 of file OOSunEntity.h.

Referenced by drawStarGlare, and setRadius:andCorona:.

◆ corona_blending

- (float) corona_blending
private

Definition at line 63 of file OOSunEntity.h.

Referenced by changeSunProperty:withDictionary:, and initSunWithColor:andDictionary:.

◆ corona_speed_factor

- (double) corona_speed_factor
private

◆ corona_stage

- (double) corona_stage
private

Definition at line 61 of file OOSunEntity.h.

Referenced by initSunWithColor:andDictionary:, and update:.

◆ discColor

- (GLfloat discColor[4])
private

Definition at line 55 of file OOSunEntity.h.

Referenced by drawDirectVisionSunGlare, drawStarGlare, and update:.

◆ lim16k

- (GLfloat) lim16k
private

Definition at line 58 of file OOSunEntity.h.

Referenced by setRadius:andCorona:.

◆ outerCoronaColor

- (GLfloat outerCoronaColor[4])
private

Definition at line 56 of file OOSunEntity.h.

◆ rvalue

- (GLfloat rvalue[SUN_CORONA_SAMPLES])
private

Definition at line 62 of file OOSunEntity.h.

Referenced by initSunWithColor:andDictionary:, and update:.

◆ sun_diffuse

- (GLfloat sun_diffuse[4])
private

Definition at line 52 of file OOSunEntity.h.

Referenced by getDiffuseComponents:, and setSunColor:.

◆ sun_specular

- (GLfloat sun_specular[4])
private

Definition at line 53 of file OOSunEntity.h.

Referenced by getSpecularComponents:, and setSunColor:.

◆ sunColors

- (GLfloat sunColors[1801 *4])
private

Definition at line 67 of file OOSunEntity.h.

◆ sunTriangles

- (GLuint sunTriangles[3240 *3])
private

Definition at line 65 of file OOSunEntity.h.

Referenced by initSunWithColor:andDictionary:.

◆ sunVertices

- (GLfloat sunVertices[1801 *3])
private

Definition at line 66 of file OOSunEntity.h.


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