Oolite
Loading...
Searching...
No Matches
PlanetEntity(OOPrivate) Category Reference
Inheritance diagram for PlanetEntity(OOPrivate):
Collaboration diagram for PlanetEntity(OOPrivate):

Instance Methods

(double) - sqrtZeroDistance
(void) - drawModelWithVertexArraysAndSubdivision:
(void) - initialiseBaseVertexArray
(void) - initialiseBaseTerrainArray:
(void) - paintVertex:seed:
(void) - scaleVertices
(id) - initAsAtmosphereForPlanet:dictionary:
(void) - setTextureColorForPlanet:inSystem:
(id) - initMiniatureFromPlanet:withAlpha:
(void) - loadTexture:
(OOTexture *) - planetTextureWithInfo:
(OOTexture *) - cloudTextureWithCloudColor:cloudImpress:cloudBias:
(void) - deleteDisplayLists
(void) - setUseTexturedModel:
Instance Methods inherited from <OOGraphicsResetClient>
(void) - resetGraphicsState

Detailed Description

Definition at line 64 of file PlanetEntity.m.

Method Documentation

◆ cloudTextureWithCloudColor:cloudImpress:cloudBias:

- (OOTexture *) cloudTextureWithCloudColor: (OOColor *) cloudColor
cloudImpress: (GLfloat) cloud_impress
cloudBias: (GLfloat) cloud_bias 

Extends class PlanetEntity.

Definition at line 1452 of file PlanetEntity.m.

1452 :(OOColor*)cloudColor cloudImpress:(GLfloat)cloud_impress cloudBias:(GLfloat)cloud_bias
1453{
1454 unsigned char* data;
1455 GLuint width, height;
1456
1458 if (![TextureStore getCloudTextureNameFor:
1459 cloudColor:cloud_impress
1460 :cloud_bias
1461 intoData:&data
1462 width:&width
1463 height:&height]) {
1464 return nil;
1465 }
1466
1467 OOPixMap pm = OOMakePixMap(data, width, height, kOOPixMapRGBA, 0, 0);
1468 OOTextureGenerator* loader = [[OOPixMapTextureLoader alloc] initWithPixMap:pm
1469 textureOptions:kOOTextureDefaultOptions | kOOTextureRepeatS
1470 freeWhenDone:YES];
1471 [loader autorelease];
1472
1473 return [OOTexture textureWithGenerator:loader];
1474}
@ kOOPixMapRGBA
Definition OOPixMap.h:40
OOPixMap OOMakePixMap(void *pixels, OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
Definition OOPixMap.m:44
struct OOPixMap OOPixMap
return nil
void fillRanNoiseBuffer()
id textureWithGenerator:(OOTextureGenerator *generator)
Definition OOTexture.m:209

References fillRanNoiseBuffer(), kOOPixMapRGBA, nil, OOMakePixMap(), and OOTexture::textureWithGenerator:.

Referenced by initAsAtmosphereForPlanet:dictionary:.

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

◆ deleteDisplayLists

- (void) deleteDisplayLists

Extends class PlanetEntity.

Definition at line 1382 of file PlanetEntity.m.

1383{
1384 unsigned i;
1385 for (i = 0; i < MAX_SUBDIVIDE; i++) {
1386 if (displayListNames[i] != 0) {
1387 glDeleteLists(displayListNames[i], 1);
1388 displayListNames[i] = 0;
1389 }
1390 }
1391}
#define MAX_SUBDIVIDE

References deleteDisplayLists, and MAX_SUBDIVIDE.

Referenced by PlanetEntity::dealloc, deleteDisplayLists, initMiniatureFromPlanet:withAlpha:, PlanetEntity::resetGraphicsState, and PlanetEntity::setUpPlanetFromTexture:.

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

◆ drawModelWithVertexArraysAndSubdivision:

- (void) drawModelWithVertexArraysAndSubdivision: (int) subdivide

Extends class PlanetEntity.

Definition at line 1077 of file PlanetEntity.m.

1077 :(int)subdivide
1078{
1079 OOGL(glDrawElements(GL_TRIANGLES, 3 * n_triangles[subdivide], GL_UNSIGNED_INT, &vertexdata.index_array[triangle_start[subdivide]]));
1080}
#define OOGL(statement)
Definition OOOpenGL.h:262
static int triangle_start[MAX_SUBDIVIDE]
static int n_triangles[MAX_SUBDIVIDE]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

References n_triangles, OOGL, and triangle_start.

Referenced by PlanetEntity::drawUnconditionally.

Here is the caller graph for this function:

◆ initAsAtmosphereForPlanet:dictionary:

- (id) initAsAtmosphereForPlanet: (PlanetEntity *) planet
dictionary: (NSDictionary *) dict 

Extends class PlanetEntity.

Definition at line 187 of file PlanetEntity.m.

187 :(PlanetEntity*)planet dictionary:(NSDictionary*)dict
188{
189 BOOL procGen = [UNIVERSE doProcedurallyTexturedPlanets];
190
191 if (dict == nil)
192 dict = [NSDictionary dictionary];
193
194 self = [super init];
195
196 int percent_land = 100 - [dict oo_intForKey:@"percent_cloud" defaultValue:100 - (3 + (gen_rnd_number() & 31) + (gen_rnd_number() & 31))];
197
198 polar_color_factor = 1.0;
199
200#define CLEAR_SKY_ALPHA 0.05
201#define CLOUD_ALPHA 0.50
202#define POLAR_CLEAR_SKY_ALPHA 0.34
203#define POLAR_CLOUD_ALPHA 0.75
204
205 amb_land[0] = gen_rnd_number() / 256.0;
206 amb_land[1] = gen_rnd_number() / 256.0;
207 amb_land[2] = gen_rnd_number() / 256.0;
208 amb_land[3] = CLEAR_SKY_ALPHA; // blue sky, zero clouds
209 amb_sea[0] = 0.5 + gen_rnd_number() / 512.0;
210 amb_sea[1] = 0.5 + gen_rnd_number() / 512.0;
211 amb_sea[2] = 0.5 + gen_rnd_number() / 512.0;
212 amb_sea[3] = CLOUD_ALPHA; // 50% opaque clouds
213 amb_polar_land[0] = gen_rnd_number() / 256.0;
214 amb_polar_land[1] = gen_rnd_number() / 256.0;
215 amb_polar_land[2] = gen_rnd_number() / 256.0;
216 amb_polar_land[3] = POLAR_CLEAR_SKY_ALPHA; // 34% gray clouds
217 amb_polar_sea[0] = 0.9 + gen_rnd_number() / 2560.0;
218 amb_polar_sea[1] = 0.9 + gen_rnd_number() / 2560.0;
219 amb_polar_sea[2] = 0.9 + gen_rnd_number() / 2560.0;
220 amb_polar_sea[3] = POLAR_CLOUD_ALPHA; // 75% clouds
221
222 // Colour overrides from dictionary
223 OOColor* clearSkyColor = nil;
224 OOColor* cloudColor = nil;
225 OOColor* polarClearSkyColor = nil;
226 OOColor* polarCloudColor = nil;
227 float cloudAlpha;
228
229 clearSkyColor = [OOColor colorWithDescription:[dict objectForKey:@"atmosphere_color"]];
230 cloudColor = [OOColor colorWithDescription:[dict objectForKey:@"cloud_color"]];
231 polarClearSkyColor = [OOColor colorWithDescription:[dict objectForKey:@"polar_atmosphere_color"]];
232 polarCloudColor = [OOColor colorWithDescription:[dict objectForKey:@"polar_cloud_color"]];
233 cloudAlpha = OOClamp_0_1_f([dict oo_floatForKey:@"cloud_alpha" defaultValue:1.0]);
234
235 if (clearSkyColor != nil) {
236 [clearSkyColor getRed:&amb_land[0] green:&amb_land[1] blue:&amb_land[2] alpha:&amb_land[3]];
237 }
238
239 if (cloudColor != nil) {
240 [cloudColor getRed:&amb_sea[0] green:&amb_sea[1] blue:&amb_sea[2] alpha:&amb_sea[3]];
241 }
242
243 if (polarClearSkyColor != nil) {
244 [polarClearSkyColor getRed:&amb_polar_land[0] green:&amb_polar_land[1] blue:&amb_polar_land[2] alpha:&amb_polar_land[3]];
245 } else if (clearSkyColor != nil) {
246 memmove(amb_polar_land, amb_land, sizeof amb_polar_land);
247 amb_polar_land[3] = OOClamp_0_1_f(amb_polar_land[3] * (POLAR_CLEAR_SKY_ALPHA / CLEAR_SKY_ALPHA));
248 }
249
250 if (polarCloudColor != nil) {
251 [polarCloudColor getRed:&amb_polar_sea[0] green:&amb_polar_sea[1] blue:&amb_polar_sea[2] alpha:&amb_polar_sea[3]];
252 } else if (cloudColor != nil) {
253 memmove(amb_polar_sea, amb_sea, sizeof amb_polar_sea);
254 amb_polar_sea[3] *= (POLAR_CLOUD_ALPHA / CLOUD_ALPHA);
255 }
256
257 // amb_land[3] is already 0.05
258 amb_sea[3] *= cloudAlpha;
259 amb_polar_land[3] *= cloudAlpha;
260 amb_polar_sea[3] *= cloudAlpha;
261
262 amb_sea[3] = OOClamp_0_1_f(amb_sea[3]);
263 amb_polar_sea[3] = OOClamp_0_1_f(amb_polar_sea[3]);
264
265 atmosphere = nil;
266
267 if (procGen) {
268 RANROTSeed ranrotSavedSeed = RANROTGetFullSeed();
269 RNG_Seed saved_seed = currentRandomSeed();
270 cloudColor = [OOColor colorWithRed:amb_sea[0] green:amb_sea[1] blue:amb_sea[2] alpha:amb_sea[3]];
271 float cloud_bias = -0.01 * (float)percent_land;
272 float cloud_impress = 1.0 - cloud_bias;
273
274 _texture = [self cloudTextureWithCloudColor:cloudColor cloudImpress:cloud_impress cloudBias:cloud_bias];
275 [_texture retain];
276 isTextureImage = NO;
277
278 setRandomSeed(saved_seed);
279 RANROTSetFullSeed(ranrotSavedSeed);
280 }
281
282 if (!planet) {
283 OOLogERR(@"planet.atmosphere.init.noPlanet", @"planet entity initAsAtmosphereForPlanet: no planet found.");
284 return self;
285 }
286
287 [self setOwner:planet];
288
289 position = [planet position];
290 orientation = [planet orientation];
291
293 collision_radius = planet->collision_radius + ATMOSPHERE_DEPTH; // atmosphere is 500m deep only
294 if (planet->planet_type == STELLAR_TYPE_MINIATURE)
295 collision_radius = planet->collision_radius + ATMOSPHERE_DEPTH * PLANET_MINIATURE_FACTOR * 2.0; // not to scale: invisible otherwise
296
297 shuttles_on_ground = 0;
298 last_launch_time = 0.0;
299 shuttle_launch_interval = 3600.0;
300
301 scanClass = CLASS_NO_DRAW;
302
303 // orientation.w = M_SQRT1_2; // is already planet->orientation
304 // orientation.x = M_SQRT1_2;
305 // orientation.y = 0.0;
306 // orientation.z = 0.0;
307
308 planet_type = STELLAR_TYPE_ATMOSPHERE;
309
310 planet_seed = ranrot_rand(); // random set-up for vertex colours
311
312 [self setUseTexturedModel:YES];
313 [self initialiseBaseVertexArray];
314 [self initialiseBaseTerrainArray:percent_land];
315 unsigned i;
316 for (i = 0; i < next_free_vertex; i++) {
317 [self paintVertex:i:planet_seed];
318 }
319
320 [self scaleVertices];
321
322 // set speed of rotation
323 rotational_velocity = [dict oo_floatForKey:@"atmosphere_rotational_velocity" defaultValue:[planet rotationalVelocity] * (0.9 + (randf() * 0.2))]; // 90-110% of planet rotation speed
324
325 root_planet = planet;
326
327 rotationAxis = vector_up_from_quaternion(orientation);
328
330
331 return self;
332}
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
#define OOLogERR(class, format,...)
Definition OOLogging.h:125
Vector vector_up_from_quaternion(Quaternion quat) CONST_FUNC
#define PLANET_MINIATURE_FACTOR
#define ATMOSPHERE_DEPTH
@ STELLAR_TYPE_ATMOSPHERE
@ STELLAR_TYPE_MINIATURE
@ STELLAR_TYPE_NORMAL_PLANET
#define PlanetEntity
#define CLOUD_ALPHA
#define POLAR_CLEAR_SKY_ALPHA
#define POLAR_CLOUD_ALPHA
static unsigned next_free_vertex
#define CLEAR_SKY_ALPHA
GLfloat collision_radius
Definition Entity.h:107
Quaternion orientation
Definition Entity.m:682
HPVector position
Definition Entity.m:576
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:107
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
Definition OOColor.m:344
void registerClient:(id< OOGraphicsResetClient > client)
OOGraphicsResetManager * sharedManager()
OOStellarBodyType planet_type
double rotationalVelocity()
RANROTSeed RANROTGetFullSeed(void)
void setRandomSeed(RNG_Seed a_seed)
RNG_Seed currentRandomSeed(void)
void RANROTSetFullSeed(RANROTSeed seed)
int gen_rnd_number(void)
struct RANROTSeed RANROTSeed
struct RNG_Seed RNG_Seed
#define ranrot_rand()

References ATMOSPHERE_DEPTH, CLEAR_SKY_ALPHA, CLOUD_ALPHA, PlanetEntity::cloudTextureWithCloudColor:cloudImpress:cloudBias:, Entity::collision_radius, OOColor::colorWithDescription:, OOColor::colorWithRed:green:blue:alpha:, currentRandomSeed(), gen_rnd_number(), OOColor::getRed:green:blue:alpha:, Entity::init, PlanetEntity::initialiseBaseTerrainArray:, PlanetEntity::initialiseBaseVertexArray, next_free_vertex, nil, OOClamp_0_1_f(), OOLogERR, Entity::orientation, PLANET_MINIATURE_FACTOR, PlanetEntity::planet_type, PlanetEntity, POLAR_CLEAR_SKY_ALPHA, POLAR_CLOUD_ALPHA, Entity::position, ranrot_rand, RANROTGetFullSeed(), RANROTSetFullSeed(), OOGraphicsResetManager::registerClient:, PlanetEntity::rotationalVelocity, PlanetEntity::scaleVertices, Entity::setOwner:, setRandomSeed(), PlanetEntity::setUseTexturedModel:, OOGraphicsResetManager::sharedManager, STELLAR_TYPE_ATMOSPHERE, STELLAR_TYPE_MINIATURE, STELLAR_TYPE_NORMAL_PLANET, and vector_up_from_quaternion().

Here is the call graph for this function:

◆ initialiseBaseTerrainArray:

- (void) initialiseBaseTerrainArray: (int) percent_land

Extends class PlanetEntity.

Definition at line 1255 of file PlanetEntity.m.

1255 :(int)percent_land
1256{
1257 RANROTSeed saved_seed = RANROTGetFullSeed();
1258
1259 // set first 12 or 14 vertices
1260 if (percent_land >= 0) {
1261 GLuint vi;
1262 for (vi = 0; vi < vertexCount; vi++) {
1263 if (gen_rnd_number() < 256 * percent_land / 100)
1264 base_terrain_array[vi] = 0; // land
1265 else
1266 base_terrain_array[vi] = 100; // sea
1267 }
1268 }
1269
1270 // for the next levels of subdivision simply build up from the level below!...
1271 BOOL isTextured = [self isTextured];
1272
1273 int sublevel;
1274 for (sublevel = 0; sublevel < MAX_SUBDIVIDE - 1; sublevel++) {
1275 int tri;
1276 for (tri = 0; tri < n_triangles[sublevel]; tri++) {
1277 // get the six vertices for this group of four triangles
1278 int v0 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 0];
1279 int v1 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 1];
1280 int v2 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 2];
1281 int v01 = baseVertexIndexForEdge(v0, v1, isTextured); // sets it up if required
1282 int v12 = baseVertexIndexForEdge(v1, v2, isTextured); // ..
1283 int v20 = baseVertexIndexForEdge(v2, v0, isTextured); // ..
1284 // v01
1287 else {
1288 uint32_t s1 = 0xffff0000 * base_vertex_array[v01].x;
1289 uint32_t s2 = 0x00ffff00 * base_vertex_array[v01].y;
1290 uint32_t s3 = 0x0000ffff * base_vertex_array[v01].z;
1291 ranrot_srand(s1 + s2 + s3);
1292 base_terrain_array[v01] = (ranrot_rand() & 4) * 25;
1293 }
1294 // v12
1297 else {
1298 uint32_t s1 = 0xffff0000 * base_vertex_array[v12].x;
1299 uint32_t s2 = 0x00ffff00 * base_vertex_array[v12].y;
1300 uint32_t s3 = 0x0000ffff * base_vertex_array[v12].z;
1301 ranrot_srand(s1 + s2 + s3);
1302 base_terrain_array[v12] = (ranrot_rand() & 4) * 25;
1303 }
1304 // v20
1307 else {
1308 uint32_t s1 = 0xffff0000 * base_vertex_array[v20].x;
1309 uint32_t s2 = 0x00ffff00 * base_vertex_array[v20].y;
1310 uint32_t s3 = 0x0000ffff * base_vertex_array[v20].z;
1311 ranrot_srand(s1 + s2 + s3);
1312 base_terrain_array[v20] = (ranrot_rand() & 4) * 25;
1313 }
1314 }
1315 }
1316
1317 RANROTSetFullSeed(saved_seed);
1318}
static GLuint vertex_index_array[3 *(20+80+320+1280+5120+20480)]
static unsigned baseVertexIndexForEdge(GLushort va, GLushort vb, BOOL textured)
static Vector base_vertex_array[MAX_PLANET_VERTICES]
static int base_terrain_array[MAX_PLANET_VERTICES]
void ranrot_srand(uint32_t seed)
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References base_terrain_array, base_vertex_array, baseVertexIndexForEdge(), gen_rnd_number(), PlanetEntity::isTextured, MAX_SUBDIVIDE, n_triangles, ranrot_rand, ranrot_srand(), RANROTGetFullSeed(), RANROTSetFullSeed(), and vertex_index_array.

Referenced by initAsAtmosphereForPlanet:dictionary:, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, and PlanetEntity::setUpPlanetFromTexture:.

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

◆ initialiseBaseVertexArray

- (void) initialiseBaseVertexArray

Extends class PlanetEntity.

Definition at line 1120 of file PlanetEntity.m.

1121{
1122 BOOL isTextured = [self isTextured];
1123 static BOOL lastOneWasTextured;
1124
1125 if (lastOneWasTextured != isTextured) {
1126 if (sEdgeToVertex != NULL) {
1127 NSFreeMapTable(sEdgeToVertex);
1128 sEdgeToVertex = NULL;
1129 }
1130 lastOneWasTextured = isTextured;
1131 }
1132
1133 if (sEdgeToVertex == NULL) {
1134 sEdgeToVertex = NSCreateMapTable(NSIntegerMapKeyCallBacks, NSIntegerMapValueCallBacks, 7680); // make a new one
1135 next_free_vertex = 0;
1136
1137 const Vector* vertices = NULL;
1138 const BaseFace(*faces)[3] = NULL;
1139 GLuint faceCount = 0;
1140 if (useTexturedModel) {
1141 vertices = kTexturedVertices;
1142 faces = kTexturedFaces;
1143 faceCount = sizeof kTexturedFaces / sizeof *kTexturedFaces;
1144 } else {
1145 vertices = kUntexturedVertices;
1146 faces = kUntexturedFaces;
1147 faceCount = sizeof kUntexturedFaces / sizeof *kUntexturedFaces;
1148 }
1149
1150 // set first 12 or 14 vertices
1151 GLuint vi;
1152 for (vi = 0; vi < vertexCount; vi++) {
1153 base_vertex_array[next_free_vertex++] = vertices[vi];
1154 }
1155
1156 // set first 20 triangles
1157 triangle_start[0] = 0;
1158 n_triangles[0] = faceCount;
1159 GLuint fi;
1160 for (fi = 0; fi < faceCount; fi++) {
1161 unsigned j;
1162 for (j = 0; j < 3; j++) {
1163 vertex_index_array[fi * 3 + j] = faces[fi][j].v;
1164 texture_uv_array[faces[fi][j].v * 2 + 0] = faces[fi][j].s;
1165 texture_uv_array[faces[fi][j].v * 2 + 1] = faces[fi][j].t;
1166 }
1167 }
1168
1169 // for the next levels of subdivision simply build up from the level below!...
1170 unsigned sublevel;
1171 for (sublevel = 0; sublevel < MAX_SUBDIVIDE - 1; sublevel++) {
1172 int newlevel = sublevel + 1;
1173 triangle_start[newlevel] = triangle_start[sublevel] + n_triangles[sublevel] * 3;
1174 n_triangles[newlevel] = n_triangles[sublevel] * 4;
1175
1176 int tri;
1177 for (tri = 0; tri < n_triangles[sublevel]; tri++) {
1178 // get the six vertices for this group of four triangles
1179 int v0 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 0];
1180 int v1 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 1];
1181 int v2 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 2];
1182 int v01 = baseVertexIndexForEdge(v0, v1, isTextured); // sets it up if required
1183 int v12 = baseVertexIndexForEdge(v1, v2, isTextured); // ..
1184 int v20 = baseVertexIndexForEdge(v2, v0, isTextured); // ..
1185 // v0 v01 v20
1186 vertex_index_array[triangle_start[newlevel] + tri * 12 + 0] = v0;
1187 vertex_index_array[triangle_start[newlevel] + tri * 12 + 1] = v01;
1188 vertex_index_array[triangle_start[newlevel] + tri * 12 + 2] = v20;
1189 // v01 v1 v12
1190 vertex_index_array[triangle_start[newlevel] + tri * 12 + 3] = v01;
1191 vertex_index_array[triangle_start[newlevel] + tri * 12 + 4] = v1;
1192 vertex_index_array[triangle_start[newlevel] + tri * 12 + 5] = v12;
1193 // v20 v12 v2
1194 vertex_index_array[triangle_start[newlevel] + tri * 12 + 6] = v20;
1195 vertex_index_array[triangle_start[newlevel] + tri * 12 + 7] = v12;
1196 vertex_index_array[triangle_start[newlevel] + tri * 12 + 8] = v2;
1197 // v01 v12 v20
1198 vertex_index_array[triangle_start[newlevel] + tri * 12 + 9] = v01;
1199 vertex_index_array[triangle_start[newlevel] + tri * 12 + 10] = v12;
1200 vertex_index_array[triangle_start[newlevel] + tri * 12 + 11] = v20;
1201 }
1202 }
1203 }
1204
1205 // all done - copy the indices to the instance
1206 unsigned i;
1207 for (i = 0; i < MAX_TRI_INDICES; i++) {
1208 vertexdata.index_array[i] = vertex_index_array[i];
1209 }
1210}
struct Vector Vector
#define MAX_TRI_INDICES
static const Vector kUntexturedVertices[]
static const Vector kTexturedVertices[]
static NSMapTable * sEdgeToVertex
static GLfloat texture_uv_array[MAX_PLANET_VERTICES *2]
static const BaseFace kUntexturedFaces[][3]
static const BaseFace kTexturedFaces[][3]

References base_vertex_array, baseVertexIndexForEdge(), initialiseBaseVertexArray, PlanetEntity::isTextured, kTexturedFaces, kTexturedVertices, kUntexturedFaces, kUntexturedVertices, MAX_SUBDIVIDE, MAX_TRI_INDICES, n_triangles, next_free_vertex, sEdgeToVertex, texture_uv_array, triangle_start, and vertex_index_array.

Referenced by initAsAtmosphereForPlanet:dictionary:, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, initialiseBaseVertexArray, and PlanetEntity::setUpPlanetFromTexture:.

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

◆ initMiniatureFromPlanet:withAlpha:

- (id) initMiniatureFromPlanet: (PlanetEntity *) planet
withAlpha: (float) alpha 

Extends class PlanetEntity.

References deleteDisplayLists, and PlanetEntity.

Here is the call graph for this function:

◆ loadTexture:

- (void) loadTexture: (NSDictionary *) configuration

Extends class PlanetEntity.

Definition at line 1408 of file PlanetEntity.m.

1408 :(NSDictionary*)configuration
1409{
1410 [_texture release];
1411 _texture = [OOTexture textureWithConfiguration:configuration extraOptions:kOOTextureAllowCubeMap | kOOTextureRepeatS];
1412 [_texture retain];
1413
1414 [_textureFileName release];
1415 if (_texture != nil) {
1416 _textureFileName = [[configuration oo_stringForKey:@"name"] copy];
1417 isTextureImage = YES;
1418 } else {
1419 _textureFileName = nil;
1420 isTextureImage = NO;
1421 }
1422}
id textureWithConfiguration:extraOptions:(id configuration,[extraOptions] OOTextureFlags extraOptions)
Definition OOTexture.m:191

References nil, and OOTexture::textureWithConfiguration:extraOptions:.

Referenced by PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, and PlanetEntity::setUpPlanetFromTexture:.

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

◆ paintVertex:seed:

- (void) paintVertex: (unsigned) vi
seed: (int) seed 

Extends class PlanetEntity.

Definition at line 1320 of file PlanetEntity.m.

1320 :(unsigned)vi seed:(int)seed
1321{
1322 RANROTSeed saved_seed = RANROTGetFullSeed();
1323 BOOL isTextured = _texture != nil;
1324
1325 GLfloat paint_land[4] = { 0.2, 0.9, 0.0, 1.0 };
1326 GLfloat paint_sea[4] = { 0.0, 0.2, 0.9, 1.0 };
1327 GLfloat paint_color[4];
1328 Vector v = base_vertex_array[vi];
1329 int r = isTextured ? 0 : base_terrain_array[vi]; // use land color (0) for textured planets
1330 int i;
1331 double pole_blend = v.z * v.z * polar_color_factor;
1332 if (pole_blend < 0.0)
1333 pole_blend = 0.0;
1334 if (pole_blend > 1.0)
1335 pole_blend = 1.0;
1336
1337 paint_land[0] = (1.0 - pole_blend) * amb_land[0] + pole_blend * amb_polar_land[0];
1338 paint_land[1] = (1.0 - pole_blend) * amb_land[1] + pole_blend * amb_polar_land[1];
1339 paint_land[2] = (1.0 - pole_blend) * amb_land[2] + pole_blend * amb_polar_land[2];
1340 paint_sea[0] = (1.0 - pole_blend) * amb_sea[0] + pole_blend * amb_polar_sea[0];
1341 paint_sea[1] = (1.0 - pole_blend) * amb_sea[1] + pole_blend * amb_polar_sea[1];
1342 paint_sea[2] = (1.0 - pole_blend) * amb_sea[2] + pole_blend * amb_polar_sea[2];
1343 if (planet_type == STELLAR_TYPE_ATMOSPHERE) // do alphas
1344 {
1345 paint_land[3] = (1.0 - pole_blend) * amb_land[3] + pole_blend * amb_polar_land[3];
1346 paint_sea[3] = (1.0 - pole_blend) * amb_sea[3] + pole_blend * amb_polar_sea[3];
1347 }
1348
1349 ranrot_srand((uint32_t)(seed + v.x * 1000 + v.y * 100 + v.z * 10));
1350
1351 for (i = 0; i < 3; i++) {
1352 double cv = (ranrot_rand() % 100) * 0.01; // 0..1 ***** DON'T CHANGE THIS LINE, '% 100' MAY NOT BE EFFICIENT BUT THE PATTERNING IS GOOD.
1353 paint_land[i] += (cv - 0.5) * 0.1;
1354 paint_sea[i] += (cv - 0.5) * 0.1;
1355 }
1356
1357 for (i = 0; i < 4; i++) {
1358 if (planet_type == STELLAR_TYPE_ATMOSPHERE && isTextured)
1359 paint_color[i] = 1.0;
1360 else
1361 paint_color[i] = (r * paint_sea[i]) * 0.01 + ((100 - r) * paint_land[i]) * 0.01;
1362 // finally initialise the color array entry
1363 vertexdata.color_array[vi * 4 + i] = paint_color[i];
1364 }
1365
1366 RANROTSetFullSeed(saved_seed);
1367}

References base_terrain_array, base_vertex_array, nil, ranrot_rand, ranrot_srand(), RANROTGetFullSeed(), RANROTSetFullSeed(), STELLAR_TYPE_ATMOSPHERE, Vector::x, Vector::y, and Vector::z.

Here is the call graph for this function:

◆ planetTextureWithInfo:

- (OOTexture *) planetTextureWithInfo: (NSDictionary *) info

Extends class PlanetEntity.

Definition at line 1430 of file PlanetEntity.m.

1430 :(NSDictionary*)info
1431{
1432 unsigned char* data;
1433 GLuint width, height;
1434
1436 if (![TextureStore getPlanetTextureNameFor:info
1437 intoData:&data
1438 width:&width
1439 height:&height]) {
1440 return nil;
1441 }
1442
1443 OOPixMap pm = OOMakePixMap(data, width, height, kOOPixMapRGBA, 0, 0);
1444 OOTextureGenerator* loader = [[OOPixMapTextureLoader alloc] initWithPixMap:pm
1445 textureOptions:kOOTextureDefaultOptions | kOOTextureRepeatS
1446 freeWhenDone:YES];
1447 [loader autorelease];
1448
1449 return [OOTexture textureWithGenerator:loader];
1450}

References fillRanNoiseBuffer(), kOOPixMapRGBA, nil, OOMakePixMap(), and OOTexture::textureWithGenerator:.

Referenced by PlanetEntity::initFromDictionary:withAtmosphere:andSeed:.

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

◆ scaleVertices

- (void) scaleVertices

Extends class PlanetEntity.

Definition at line 1369 of file PlanetEntity.m.

1370{
1371 NSUInteger vi;
1372 for (vi = 0; vi < next_free_vertex; vi++) {
1373 Vector v = base_vertex_array[vi];
1374 vertexdata.normal_array[vi] = v;
1375 vertexdata.vertex_array[vi] = make_vector(v.x * collision_radius, v.y * collision_radius, v.z * collision_radius);
1376
1377 vertexdata.uv_array[vi * 2] = texture_uv_array[vi * 2];
1378 vertexdata.uv_array[vi * 2 + 1] = texture_uv_array[vi * 2 + 1];
1379 }
1380}
OOINLINE Vector make_vector(OOScalar vx, OOScalar vy, OOScalar vz) INLINE_CONST_FUNC
Definition OOVector.h:149

References base_vertex_array, make_vector(), next_free_vertex, scaleVertices, texture_uv_array, Vector::x, Vector::y, and Vector::z.

Referenced by initAsAtmosphereForPlanet:dictionary:, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, PlanetEntity::miniaturize, scaleVertices, and PlanetEntity::setUpPlanetFromTexture:.

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

◆ setTextureColorForPlanet:inSystem:

- (void) setTextureColorForPlanet: (BOOL) isMain
inSystem: (BOOL) isLocal 

Extends class PlanetEntity.

Definition at line 942 of file PlanetEntity.m.

942 :(BOOL)isMain inSystem:(BOOL)isLocal
943{
944 Vector land_hsb, land_polar_hsb;
945 land_hsb.x = 0.0;
946 land_hsb.y = 0.0;
947 land_hsb.z = 1.0; // white
948
949 // the colour override should only apply to main planets
950 if (isMain) {
951 if (isLocal)
952 ScanVectorFromString([[UNIVERSE currentSystemData] objectForKey:@"texture_hsb_color"], &land_hsb);
953 else
954 ScanVectorFromString([[UNIVERSE generateSystemData:[PLAYER target_system_seed]] objectForKey:@"texture_hsb_color"], &land_hsb);
955 }
956
957 land_polar_hsb.x = land_hsb.x;
958 land_polar_hsb.y = (land_hsb.y / 5.0);
959 land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
960
961 amb_sea[0] = amb_land[0] = [[OOColor colorWithHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] redComponent];
962 amb_sea[1] = amb_land[1] = [[OOColor colorWithHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] blueComponent];
963 amb_sea[2] = amb_land[2] = [[OOColor colorWithHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] greenComponent];
964 amb_sea[3] = amb_land[3] = 1.0;
965 amb_polar_sea[0] = amb_polar_land[0] = [[OOColor colorWithHue:land_polar_hsb.x saturation:land_polar_hsb.y brightness:land_polar_hsb.z alpha:1.0] redComponent];
966 amb_polar_sea[1] = amb_polar_land[1] = [[OOColor colorWithHue:land_polar_hsb.x saturation:land_polar_hsb.y brightness:land_polar_hsb.z alpha:1.0] blueComponent];
967 amb_polar_sea[2] = amb_polar_land[2] = [[OOColor colorWithHue:land_polar_hsb.x saturation:land_polar_hsb.y brightness:land_polar_hsb.z alpha:1.0] greenComponent];
968 amb_polar_sea[3] = amb_polar_land[3] = 1.0;
969}
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
#define PLAYER
#define UNIVERSE
Definition Universe.h:827
float blueComponent()
Definition OOColor.m:339
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
float greenComponent()
Definition OOColor.m:334

References OOColor::blueComponent, OOColor::colorWithHue:saturation:brightness:alpha:, OOColor::greenComponent, PLAYER, OOColor::redComponent, ScanVectorFromString(), UNIVERSE, Vector::x, Vector::y, and Vector::z.

Referenced by PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, and PlanetEntity::setUpPlanetFromTexture:.

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

◆ setUseTexturedModel:

- (void) setUseTexturedModel: (BOOL) flag

Extends class PlanetEntity.

Definition at line 709 of file PlanetEntity.m.

709 :(BOOL)flag
710{
711 if (flag) {
712 useTexturedModel = YES;
713 vertexCount = sizeof kTexturedVertices / sizeof *kTexturedVertices;
714 } else {
715 useTexturedModel = NO;
716 vertexCount = sizeof kUntexturedVertices / sizeof *kTexturedVertices;
717 }
718}

References kTexturedVertices, and kUntexturedVertices.

Referenced by initAsAtmosphereForPlanet:dictionary:, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, and PlanetEntity::setUpPlanetFromTexture:.

Here is the caller graph for this function:

◆ sqrtZeroDistance

- (double) sqrtZeroDistance

Extends class PlanetEntity.

Definition at line 1067 of file PlanetEntity.m.

1068{
1069 return sqrt_zero_distance;
1070}

References sqrtZeroDistance.

Referenced by sqrtZeroDistance.

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

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