Line data Source code
1 0 : /* 2 : 3 : PlanetEntity.h 4 : 5 : Entity subclass representing a planet or an atmosphere. 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 : #import "OOStellarBody.h" 28 : 29 : #if !NEW_PLANETS 30 : 31 : #import "Entity.h" 32 : #import "legacy_random.h" 33 : #import "OOColor.h" 34 : 35 : @class OOTexture; 36 : 37 : 38 0 : #define MAX_TRI_INDICES 3*(20+80+320+1280+5120+20480) 39 0 : #define MAX_PLANET_VERTICES 10400 40 : 41 : 42 0 : typedef struct 43 : { 44 0 : Vector vertex_array[MAX_PLANET_VERTICES + 2]; 45 0 : GLfloat color_array[4*MAX_PLANET_VERTICES]; 46 0 : GLfloat uv_array[2*MAX_PLANET_VERTICES]; 47 0 : Vector normal_array[MAX_PLANET_VERTICES]; 48 0 : GLuint index_array[MAX_TRI_INDICES]; 49 : } VertexData; 50 : 51 : 52 0 : #define PlanetEntity OOPlanetEntity 53 : 54 : 55 0 : @interface PlanetEntity: Entity <OOStellarBody> 56 : { 57 : @private 58 : OOStellarBodyType planet_type; 59 0 : 60 : uint8_t lastSubdivideLevel; 61 0 : BOOL useTexturedModel; 62 0 : BOOL isTextureImage; // is the texture explicitly specified (as opposed to synthesized)? 63 0 : NSString *_textureFileName; 64 0 : OOTexture *_texture; 65 0 : 66 : int planet_seed; 67 0 : double polar_color_factor; 68 0 : 69 : double rotational_velocity; 70 0 : 71 : GLfloat amb_land[4]; 72 0 : GLfloat amb_polar_land[4]; 73 0 : GLfloat amb_sea[4]; 74 0 : GLfloat amb_polar_sea[4]; 75 0 : 76 : PlanetEntity *atmosphere; // secondary sphere used to show atmospheric details 77 0 : PlanetEntity *root_planet; // link back to owning planet (not retained) 78 0 : 79 : int shuttles_on_ground; // starting number of shuttles 80 0 : double last_launch_time; // space launches out by about 15 minutes 81 0 : double shuttle_launch_interval; // space launches out by about 15 minutes 82 0 : 83 : double sqrt_zero_distance; 84 0 : 85 : GLuint displayListNames[MAX_SUBDIVIDE]; 86 0 : GLuint vertexCount; 87 0 : VertexData vertexdata; 88 0 : 89 : Vector rotationAxis; 90 0 : } 91 : 92 : - (id) initFromDictionary:(NSDictionary*)dict withAtmosphere:(BOOL)atmo andSeed:(Random_Seed)p_seed; 93 0 : - (void) miniaturize; 94 0 : 95 : - (BOOL) setUpPlanetFromTexture:(NSString *)fileName; 96 0 : 97 : - (int) planet_seed; 98 0 : - (BOOL) isTextured; 99 0 : - (BOOL) isExplicitlyTextured; // Specified texture, not synthesized. 100 0 : - (OOTexture *) texture; 101 0 : - (NSString *) textureFileName; 102 0 : 103 : - (double) polar_color_factor; 104 0 : - (GLfloat *) amb_land; 105 0 : - (GLfloat *) amb_polar_land; 106 0 : - (GLfloat *) amb_sea; 107 0 : - (GLfloat *) amb_polar_sea; 108 0 : 109 : - (OOStellarBodyType) planetType; 110 0 : - (void) setPlanetType:(OOStellarBodyType) pt; 111 0 : 112 : 113 : - (double) radius; // metres 114 0 : - (void) setRadius:(GLfloat) rad; 115 0 : - (double) rotationalVelocity; 116 0 : - (void) setRotationalVelocity:(double) v; 117 0 : 118 : - (BOOL) hasAtmosphere; 119 0 : 120 : - (void) launchShuttle; 121 0 : 122 : - (void) welcomeShuttle:(ShipEntity *) shuttle; 123 0 : 124 : - (void) drawUnconditionally; 125 0 : 126 : #ifndef NDEBUG 127 : - (PlanetEntity *) atmosphere; 128 0 : #endif 129 : 130 : @end 131 : 132 : 133 : #endif // !NEW_PLANETS