Oolite 1.91.0.7644-241112-7f5034b
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:vi:
 
(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 67 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 1317 of file PlanetEntity.m.

1585 :(OOColor *)cloudColor cloudImpress:(GLfloat)cloud_impress cloudBias:(GLfloat)cloud_bias
1586{
1587 unsigned char *data;
1588 GLuint width, height;
1589
1591 if (![TextureStore getCloudTextureNameFor:cloudColor
1592 :cloud_impress
1593 :cloud_bias
1594 intoData:&data
1595 width:&width
1596 height:&height])
1597 {
1598 return nil;
1599 }
1600
1601 OOPixMap pm = OOMakePixMap(data, width, height, kOOPixMapRGBA, 0, 0);
1602 OOTextureGenerator *loader = [[OOPixMapTextureLoader alloc] initWithPixMap:pm
1603 textureOptions:kOOTextureDefaultOptions | kOOTextureRepeatS
1604 freeWhenDone:YES];
1605 [loader autorelease];
1606
1607 return [OOTexture textureWithGenerator:loader];
1608}
@ kOOPixMapRGBA
Definition OOPixMap.h:43
OOPixMap OOMakePixMap(void *pixels, OOPixMapDimension width, OOPixMapDimension height, OOPixMapFormat format, size_t rowBytes, size_t bufferSize)
Definition OOPixMap.m:53
return nil
void fillRanNoiseBuffer()
id textureWithGenerator:(OOTextureGenerator *generator)
Definition OOTexture.m:217

◆ deleteDisplayLists

- (void) deleteDisplayLists

Extends class PlanetEntity.

Definition at line 1317 of file PlanetEntity.m.

1504{
1505 unsigned i;
1506 for (i = 0; i < MAX_SUBDIVIDE; i++)
1507 {
1508 if (displayListNames[i] != 0)
1509 {
1510 glDeleteLists(displayListNames[i], 1);
1511 displayListNames[i] = 0;
1512 }
1513 }
1514}
#define MAX_SUBDIVIDE

◆ drawModelWithVertexArraysAndSubdivision:

- (void) drawModelWithVertexArraysAndSubdivision: (int) subdivide

Extends class PlanetEntity.

Definition at line 102 of file PlanetEntity.m.

1163 : (int) subdivide
1164{
1165 OOGL(glDrawElements(GL_TRIANGLES, 3 * n_triangles[subdivide], GL_UNSIGNED_INT, &vertexdata.index_array[triangle_start[subdivide]]));
1166}
#define OOGL(statement)
Definition OOOpenGL.h:251
static int triangle_start[MAX_SUBDIVIDE]
static int n_triangles[MAX_SUBDIVIDE]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

◆ initAsAtmosphereForPlanet:dictionary:

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

Extends class PlanetEntity.

Definition at line 102 of file PlanetEntity.m.

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

◆ initialiseBaseTerrainArray:

- (void) initialiseBaseTerrainArray: (int) percent_land

Extends class PlanetEntity.

Definition at line 1317 of file PlanetEntity.m.

1364 :(int) percent_land
1365{
1366 RANROTSeed saved_seed = RANROTGetFullSeed();
1367
1368 // set first 12 or 14 vertices
1369 if (percent_land >= 0)
1370 {
1371 GLuint vi;
1372 for (vi = 0; vi < vertexCount; vi++)
1373 {
1374 if (gen_rnd_number() < 256 * percent_land / 100)
1375 base_terrain_array[vi] = 0; // land
1376 else
1377 base_terrain_array[vi] = 100; // sea
1378
1379 }
1380 }
1381
1382 // for the next levels of subdivision simply build up from the level below!...
1383 BOOL isTextured = [self isTextured];
1384
1385 int sublevel;
1386 for (sublevel = 0; sublevel < MAX_SUBDIVIDE - 1; sublevel++)
1387 {
1388 int tri;
1389 for (tri = 0; tri < n_triangles[sublevel]; tri++)
1390 {
1391 // get the six vertices for this group of four triangles
1392 int v0 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 0];
1393 int v1 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 1];
1394 int v2 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 2];
1395 int v01 = baseVertexIndexForEdge(v0, v1, isTextured); // sets it up if required
1396 int v12 = baseVertexIndexForEdge(v1, v2, isTextured); // ..
1397 int v20 = baseVertexIndexForEdge(v2, v0, isTextured); // ..
1398 // v01
1401 else
1402 {
1403 uint32_t s1 = 0xffff0000 * base_vertex_array[v01].x;
1404 uint32_t s2 = 0x00ffff00 * base_vertex_array[v01].y;
1405 uint32_t s3 = 0x0000ffff * base_vertex_array[v01].z;
1406 ranrot_srand(s1+s2+s3);
1407 base_terrain_array[v01] = (ranrot_rand() & 4) *25;
1408 }
1409 // v12
1412 else
1413 {
1414 uint32_t s1 = 0xffff0000 * base_vertex_array[v12].x;
1415 uint32_t s2 = 0x00ffff00 * base_vertex_array[v12].y;
1416 uint32_t s3 = 0x0000ffff * base_vertex_array[v12].z;
1417 ranrot_srand(s1+s2+s3);
1418 base_terrain_array[v12] = (ranrot_rand() & 4) *25;
1419 }
1420 // v20
1423 else
1424 {
1425 uint32_t s1 = 0xffff0000 * base_vertex_array[v20].x;
1426 uint32_t s2 = 0x00ffff00 * base_vertex_array[v20].y;
1427 uint32_t s3 = 0x0000ffff * base_vertex_array[v20].z;
1428 ranrot_srand(s1+s2+s3);
1429 base_terrain_array[v20] = (ranrot_rand() & 4) *25;
1430 }
1431 }
1432 }
1433
1434 RANROTSetFullSeed(saved_seed);
1435}
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)

◆ initialiseBaseVertexArray

- (void) initialiseBaseVertexArray

Extends class PlanetEntity.

Definition at line 102 of file PlanetEntity.m.

1212{
1213 BOOL isTextured = [self isTextured];
1214 static BOOL lastOneWasTextured;
1215
1216 if (lastOneWasTextured != isTextured)
1217 {
1218 if (sEdgeToVertex != NULL)
1219 {
1220 NSFreeMapTable(sEdgeToVertex);
1221 sEdgeToVertex = NULL;
1222 }
1223 lastOneWasTextured = isTextured;
1224 }
1225
1226 if (sEdgeToVertex == NULL)
1227 {
1228 sEdgeToVertex = NSCreateMapTable(NSIntegerMapKeyCallBacks, NSIntegerMapValueCallBacks, 7680); // make a new one
1229 next_free_vertex = 0;
1230
1231 const Vector *vertices = NULL;
1232 const BaseFace (*faces)[3] = NULL;
1233 GLuint faceCount = 0;
1234 if (useTexturedModel)
1235 {
1236 vertices = kTexturedVertices;
1237 faces = kTexturedFaces;
1238 faceCount = sizeof kTexturedFaces / sizeof *kTexturedFaces;
1239 }
1240 else
1241 {
1242 vertices = kUntexturedVertices;
1243 faces = kUntexturedFaces;
1244 faceCount = sizeof kUntexturedFaces / sizeof *kUntexturedFaces;
1245 }
1246
1247 // set first 12 or 14 vertices
1248 GLuint vi;
1249 for (vi = 0; vi < vertexCount; vi++)
1250 {
1251 base_vertex_array[next_free_vertex++] = vertices[vi];
1252 }
1253
1254 // set first 20 triangles
1255 triangle_start[0] = 0;
1256 n_triangles[0] = faceCount;
1257 GLuint fi;
1258 for (fi = 0; fi < faceCount; fi++)
1259 {
1260 unsigned j;
1261 for (j = 0; j < 3; j++)
1262 {
1263 vertex_index_array[fi * 3 + j] = faces[fi][j].v;
1264 texture_uv_array[faces[fi][j].v * 2 + 0] = faces[fi][j].s;
1265 texture_uv_array[faces[fi][j].v * 2 + 1] = faces[fi][j].t;
1266 }
1267 }
1268
1269 // for the next levels of subdivision simply build up from the level below!...
1270 unsigned sublevel;
1271 for (sublevel = 0; sublevel < MAX_SUBDIVIDE - 1; sublevel++)
1272 {
1273 int newlevel = sublevel + 1;
1274 triangle_start[newlevel] = triangle_start[sublevel] + n_triangles[sublevel] * 3;
1275 n_triangles[newlevel] = n_triangles[sublevel] * 4;
1276
1277 int tri;
1278 for (tri = 0; tri < n_triangles[sublevel]; tri++)
1279 {
1280 // get the six vertices for this group of four triangles
1281 int v0 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 0];
1282 int v1 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 1];
1283 int v2 = vertex_index_array[triangle_start[sublevel] + tri * 3 + 2];
1284 int v01 = baseVertexIndexForEdge(v0, v1, isTextured); // sets it up if required
1285 int v12 = baseVertexIndexForEdge(v1, v2, isTextured); // ..
1286 int v20 = baseVertexIndexForEdge(v2, v0, isTextured); // ..
1287 // v0 v01 v20
1288 vertex_index_array[triangle_start[newlevel] + tri * 12 + 0] = v0;
1289 vertex_index_array[triangle_start[newlevel] + tri * 12 + 1] = v01;
1290 vertex_index_array[triangle_start[newlevel] + tri * 12 + 2] = v20;
1291 // v01 v1 v12
1292 vertex_index_array[triangle_start[newlevel] + tri * 12 + 3] = v01;
1293 vertex_index_array[triangle_start[newlevel] + tri * 12 + 4] = v1;
1294 vertex_index_array[triangle_start[newlevel] + tri * 12 + 5] = v12;
1295 // v20 v12 v2
1296 vertex_index_array[triangle_start[newlevel] + tri * 12 + 6] = v20;
1297 vertex_index_array[triangle_start[newlevel] + tri * 12 + 7] = v12;
1298 vertex_index_array[triangle_start[newlevel] + tri * 12 + 8] = v2;
1299 // v01 v12 v20
1300 vertex_index_array[triangle_start[newlevel] + tri * 12 + 9] = v01;
1301 vertex_index_array[triangle_start[newlevel] + tri * 12 +10] = v12;
1302 vertex_index_array[triangle_start[newlevel] + tri * 12 +11] = v20;
1303
1304 }
1305 }
1306 }
1307
1308 // all done - copy the indices to the instance
1309 unsigned i;
1310 for (i = 0; i < MAX_TRI_INDICES; i++)
1311 {
1312 vertexdata.index_array[i] = vertex_index_array[i];
1313 }
1314}
#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]

◆ initMiniatureFromPlanet:withAlpha:

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

Extends class PlanetEntity.

◆ loadTexture:

- (void) loadTexture: (NSDictionary *) configuration

Extends class PlanetEntity.

Definition at line 1317 of file PlanetEntity.m.

1535 :(NSDictionary *)configuration
1536{
1537 [_texture release];
1538 _texture = [OOTexture textureWithConfiguration:configuration extraOptions:kOOTextureAllowCubeMap | kOOTextureRepeatS];
1539 [_texture retain];
1540
1541 [_textureFileName release];
1542 if (_texture != nil)
1543 {
1544 _textureFileName = [[configuration oo_stringForKey:@"name"] copy];
1545 isTextureImage = YES;
1546 }
1547 else
1548 {
1549 _textureFileName = nil;
1550 isTextureImage = NO;
1551 }
1552}
id textureWithConfiguration:extraOptions:(id configuration,[extraOptions] OOTextureFlags extraOptions)
Definition OOTexture.m:198

◆ paintVertex:vi:

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

Extends class PlanetEntity.

Definition at line 1317 of file PlanetEntity.m.

1438 :(unsigned) vi :(int) seed
1439{
1440 RANROTSeed saved_seed = RANROTGetFullSeed();
1441 BOOL isTextured = _texture != nil;
1442
1443 GLfloat paint_land[4] = { 0.2, 0.9, 0.0, 1.0};
1444 GLfloat paint_sea[4] = { 0.0, 0.2, 0.9, 1.0};
1445 GLfloat paint_color[4];
1446 Vector v = base_vertex_array[vi];
1447 int r = isTextured ? 0 : base_terrain_array[vi]; // use land color (0) for textured planets
1448 int i;
1449 double pole_blend = v.z * v.z * polar_color_factor;
1450 if (pole_blend < 0.0) pole_blend = 0.0;
1451 if (pole_blend > 1.0) pole_blend = 1.0;
1452
1453 paint_land[0] = (1.0 - pole_blend)*amb_land[0] + pole_blend*amb_polar_land[0];
1454 paint_land[1] = (1.0 - pole_blend)*amb_land[1] + pole_blend*amb_polar_land[1];
1455 paint_land[2] = (1.0 - pole_blend)*amb_land[2] + pole_blend*amb_polar_land[2];
1456 paint_sea[0] = (1.0 - pole_blend)*amb_sea[0] + pole_blend*amb_polar_sea[0];
1457 paint_sea[1] = (1.0 - pole_blend)*amb_sea[1] + pole_blend*amb_polar_sea[1];
1458 paint_sea[2] = (1.0 - pole_blend)*amb_sea[2] + pole_blend*amb_polar_sea[2];
1459 if (planet_type == STELLAR_TYPE_ATMOSPHERE) // do alphas
1460 {
1461 paint_land[3] = (1.0 - pole_blend)*amb_land[3] + pole_blend*amb_polar_land[3];
1462 paint_sea[3] = (1.0 - pole_blend)*amb_sea[3] + pole_blend*amb_polar_sea[3];
1463 }
1464
1465 ranrot_srand((uint32_t)(seed+v.x*1000+v.y*100+v.z*10));
1466
1467 for (i = 0; i < 3; i++)
1468 {
1469 double cv = (ranrot_rand() % 100)*0.01; // 0..1 ***** DON'T CHANGE THIS LINE, '% 100' MAY NOT BE EFFICIENT BUT THE PATTERNING IS GOOD.
1470 paint_land[i] += (cv - 0.5)*0.1;
1471 paint_sea[i] += (cv - 0.5)*0.1;
1472 }
1473
1474 for (i = 0; i < 4; i++)
1475 {
1476 if (planet_type == STELLAR_TYPE_ATMOSPHERE && isTextured)
1477 paint_color[i] = 1.0;
1478 else
1479 paint_color[i] = (r * paint_sea[i])*0.01 + ((100 - r) * paint_land[i])*0.01;
1480 // finally initialise the color array entry
1481 vertexdata.color_array[vi*4 + i] = paint_color[i];
1482 }
1483
1484 RANROTSetFullSeed(saved_seed);
1485}

◆ planetTextureWithInfo:

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

Extends class PlanetEntity.

Definition at line 1317 of file PlanetEntity.m.

1561 :(NSDictionary *)info
1562{
1563 unsigned char *data;
1564 GLuint width, height;
1565
1567 if (![TextureStore getPlanetTextureNameFor:info
1568 intoData:&data
1569 width:&width
1570 height:&height])
1571 {
1572 return nil;
1573 }
1574
1575 OOPixMap pm = OOMakePixMap(data, width, height, kOOPixMapRGBA, 0, 0);
1576 OOTextureGenerator *loader = [[OOPixMapTextureLoader alloc] initWithPixMap:pm
1577 textureOptions:kOOTextureDefaultOptions | kOOTextureRepeatS
1578 freeWhenDone:YES];
1579 [loader autorelease];
1580
1581 return [OOTexture textureWithGenerator:loader];
1582}

◆ scaleVertices

- (void) scaleVertices

Extends class PlanetEntity.

Definition at line 1317 of file PlanetEntity.m.

1489{
1490 NSUInteger vi;
1491 for (vi = 0; vi < next_free_vertex; vi++)
1492 {
1493 Vector v = base_vertex_array[vi];
1494 vertexdata.normal_array[vi] = v;
1495 vertexdata.vertex_array[vi] = make_vector(v.x * collision_radius, v.y * collision_radius, v.z * collision_radius);
1496
1497 vertexdata.uv_array[vi * 2] = texture_uv_array[vi * 2];
1498 vertexdata.uv_array[vi * 2 + 1] = texture_uv_array[vi * 2 + 1];
1499 }
1500}

◆ setTextureColorForPlanet:inSystem:

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

Extends class PlanetEntity.

Definition at line 102 of file PlanetEntity.m.

1019 :(BOOL)isMain inSystem:(BOOL)isLocal
1020{
1021 Vector land_hsb, land_polar_hsb;
1022 land_hsb.x = 0.0; land_hsb.y = 0.0; land_hsb.z = 1.0; // white
1023
1024 // the colour override should only apply to main planets
1025 if (isMain)
1026 {
1027 if (isLocal) ScanVectorFromString([[UNIVERSE currentSystemData] objectForKey:@"texture_hsb_color"], &land_hsb);
1028 else ScanVectorFromString([[UNIVERSE generateSystemData:[PLAYER target_system_seed]] objectForKey:@"texture_hsb_color"], &land_hsb);
1029 }
1030
1031 land_polar_hsb.x = land_hsb.x; land_polar_hsb.y = (land_hsb.y / 5.0); land_polar_hsb.z = 1.0 - (land_hsb.z / 10.0);
1032
1033 amb_sea[0] = amb_land[0] = [[OOColor colorWithHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] redComponent];
1034 amb_sea[1] = amb_land[1] = [[OOColor colorWithHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] blueComponent];
1035 amb_sea[2] = amb_land[2] = [[OOColor colorWithHue:land_hsb.x saturation:land_hsb.y brightness:land_hsb.z alpha:1.0] greenComponent];
1036 amb_sea[3] = amb_land[3] = 1.0;
1037 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];
1038 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];
1039 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];
1040 amb_polar_sea[3] =amb_polar_land[3] = 1.0;
1041}
BOOL ScanVectorFromString(NSString *xyzString, Vector *outVector)
#define PLAYER
#define UNIVERSE
Definition Universe.h:833
float blueComponent()
Definition OOColor.m:362
OOColor * colorWithHue:saturation:brightness:alpha:(float hue,[saturation] float saturation,[brightness] float brightness,[alpha] float alpha)
Definition OOColor.m:87
float redComponent()
Definition OOColor.m:350
float greenComponent()
Definition OOColor.m:356

◆ setUseTexturedModel:

- (void) setUseTexturedModel: (BOOL) flag

Extends class PlanetEntity.

Definition at line 102 of file PlanetEntity.m.

747 :(BOOL)flag
748{
749 if (flag)
750 {
751 useTexturedModel = YES;
752 vertexCount = sizeof kTexturedVertices / sizeof *kTexturedVertices;
753 }
754 else
755 {
756 useTexturedModel = NO;
757 vertexCount = sizeof kUntexturedVertices / sizeof *kTexturedVertices;
758 }
759}

◆ sqrtZeroDistance

- (double) sqrtZeroDistance

Extends class PlanetEntity.

Definition at line 102 of file PlanetEntity.m.

1152{
1153 return sqrt_zero_distance;
1154}

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