Line data Source code
1 0 : /* 2 : 3 : OOSunEntity.h 4 : 5 : Entity subclass representing a sun. 6 : 7 : Oolite 8 : Copyright (C) 2004-2013 Giles C Williams and contributors 9 : 10 : This program is free software; you can redistribute it and/or 11 : modify it under the terms of the GNU General Public License 12 : as published by the Free Software Foundation; either version 2 13 : of the License, or (at your option) any later version. 14 : 15 : This program is distributed in the hope that it will be useful, 16 : but WITHOUT ANY WARRANTY; without even the implied warranty of 17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 : GNU General Public License for more details. 19 : 20 : You should have received a copy of the GNU General Public License 21 : along with this program; if not, write to the Free Software 22 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 : MA 02110-1301, USA. 24 : 25 : */ 26 : 27 : 28 : #import "OOPlanetEntity.h" 29 : 30 : #import "Entity.h" 31 : #import "legacy_random.h" 32 : #import "OOColor.h" 33 : 34 : 35 0 : #define SUN_CORONA_SAMPLES 729 // Samples at half-degree intervals, with a bit of overlap. 36 0 : #define MAX_CORONAFLARE 600000.0 // nova flare 37 : 38 : #ifndef SUN_DIRECT_VISION_GLARE 39 : #define SUN_DIRECT_VISION_GLARE 1 40 : #endif 41 : 42 : #if SUN_DIRECT_VISION_GLARE 43 : #define SUN_GLARE_MULT_FACTOR 3.0 44 : #define SUN_GLARE_ADD_FACTOR (M_PI/16.0) 45 : #define SUN_GLARE_CORONA_FACTOR 0.5f 46 : #else 47 0 : #define SUN_GLARE_CORONA_FACTOR 1.5 48 : #endif 49 : 50 : 51 : @class ShipEntity; 52 : 53 : 54 0 : @interface OOSunEntity: Entity <OOStellarBody> 55 : { 56 : @private 57 : GLfloat sun_diffuse[4]; 58 0 : GLfloat sun_specular[4]; 59 0 : 60 : GLfloat discColor[4]; 61 0 : GLfloat outerCoronaColor[4]; 62 0 : 63 : GLfloat cor16k, lim16k; 64 0 : 65 : double corona_speed_factor; // multiply delta_t by this before adding it to corona_stage 66 0 : double corona_stage; // 0.0 -> 1.0 67 0 : GLfloat rvalue[SUN_CORONA_SAMPLES]; // stores random values for adjusting colors in the corona 68 0 : float corona_blending; 69 0 : 70 : GLuint sunTriangles[3240*3]; 71 0 : GLfloat sunVertices[1801*3]; 72 0 : GLfloat sunColors[1801*4]; 73 0 : 74 : OOTimeDelta _novaCountdown; 75 0 : OOTimeDelta _novaExpansionTimer; 76 0 : float _novaExpansionRate; 77 0 : 78 : float _sunBrightnessFactor; 79 0 : float _sunCoronaAlphaFactor; 80 0 : 81 : NSString *_name; 82 0 : } 83 : 84 : - (id) initSunWithColor:(OOColor*)sun_color andDictionary:(NSDictionary*) dict; 85 0 : - (BOOL) setSunColor:(OOColor*)sun_color; 86 0 : - (BOOL) changeSunProperty:(NSString *)key withDictionary:(NSDictionary*) dict; 87 0 : 88 : - (OOStellarBodyType) planetType; 89 0 : 90 : - (void) getDiffuseComponents:(GLfloat[4])components; 91 0 : - (void) getSpecularComponents:(GLfloat[4])components; 92 0 : 93 : - (void) setRadius:(GLfloat) rad andCorona:(GLfloat)corona; 94 0 : 95 : - (BOOL) willGoNova; 96 0 : - (BOOL) goneNova; 97 0 : - (void) setGoingNova:(BOOL) yesno inTime:(double)interval; 98 0 : 99 : - (void) drawStarGlare; 100 0 : - (void) drawDirectVisionSunGlare; 101 0 : - (void) resetNova; 102 0 : 103 : @end