Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOSkyDrawable(OOPrivate) Category Reference
+ Inheritance diagram for OOSkyDrawable(OOPrivate):
+ Collaboration diagram for OOSkyDrawable(OOPrivate):

Instance Methods

(void) - setUpStarsWithColor1:color2:
 
(void) - setUpNebulaeWithColor1:color2:clusterFactor:nebulaHueFix:alpha:scale:
 
(void) - loadStarTextures
 
(void) - loadNebulaTextures
 
(void) - addQuads:count:
 
(void) - ensureTexturesLoaded
 
(void) - resetGraphicsState [implementation]
 

Detailed Description

Definition at line 110 of file OOSkyDrawable.m.

Method Documentation

◆ addQuads:count:

- (void) addQuads: (OOSkyQuadDesc *) quads
count: (unsigned) count 

Extends class OOSkyDrawable.

Definition at line 83 of file OOSkyDrawable.m.

444 :(OOSkyQuadDesc *)quads count:(unsigned)count
445{
446 if (_quadSets == nil) _quadSets = [[NSMutableArray alloc] init];
447
448 [OOSkyQuadSet addQuads:quads count:count toArray:_quadSets];
449}
unsigned count
return nil
void addQuads:count:toArray:(OOSkyQuadDesc *quads,[count] unsigned count,[toArray] NSMutableArray *ioArray)

◆ ensureTexturesLoaded

- (void) ensureTexturesLoaded

Extends class OOSkyDrawable.

Definition at line 83 of file OOSkyDrawable.m.

493{
494 [sStarTextures ensureTexturesLoaded];
495 [sNebulaTextures ensureTexturesLoaded];
496}

◆ loadNebulaTextures

- (void) loadNebulaTextures

Extends class OOSkyDrawable.

Definition at line 83 of file OOSkyDrawable.m.

473{
474 if (sNebulaTextures == nil)
475 {
477 initWithPListName:@"nebulatextures.plist"
478 options:kOOTextureDefaultOptions | kOOTextureAlphaMask
479 anisotropy:0.0f
480 lodBias:0.0f];
481 if (sNebulaTextures == nil)
482 {
483 [NSException raise:OOLITE_EXCEPTION_DATA_NOT_FOUND format:@"No nebula textures could be loaded."];
484 }
485 }
486
487 [sNebulaTextures setSeed:RANROTGetFullSeed()];
488
489}
static OOProbabilisticTextureManager * sNebulaTextures

◆ loadStarTextures

- (void) loadStarTextures

Extends class OOSkyDrawable.

Definition at line 83 of file OOSkyDrawable.m.

453{
454 if (sStarTextures == nil)
455 {
457 initWithPListName:@"startextures.plist"
458 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask
459 anisotropy:0.0f
460 lodBias:-0.0f];
461 if (sStarTextures == nil)
462 {
463 [NSException raise:OOLITE_EXCEPTION_DATA_NOT_FOUND format:@"No star textures could be loaded."];
464 }
465 }
466
467 [sStarTextures setSeed:RANROTGetFullSeed()];
468
469}
static OOProbabilisticTextureManager * sStarTextures

◆ resetGraphicsState

- (void) resetGraphicsState
implementation

Extends class OOSkyDrawable.

Definition at line 83 of file OOSkyDrawable.m.

500{
502
503 if (_displayListName != 0)
504 {
505 glDeleteLists(_displayListName, 1);
506 _displayListName = 0;
507 }
508}
#define OO_ENTER_OPENGL()

◆ setUpNebulaeWithColor1:color2:clusterFactor:nebulaHueFix:alpha:scale:

- (void) setUpNebulaeWithColor1: (OOColor *) color1
color2: (OOColor *) color2
clusterFactor: (float) nebulaClusterFactor
nebulaHueFix: (BOOL) nebulaHueFix
alpha: (float) nebulaAlpha
scale: (float) nebulaScale 

Extends class OOSkyDrawable.

Definition at line 83 of file OOSkyDrawable.m.

351 :(OOColor *)color1
352 color2:(OOColor *)color2
353 clusterFactor:(float)nebulaClusterFactor
354 nebulaHueFix:(BOOL)nebulaHueFix
355 alpha:(float)nebulaAlpha
356 scale:(float)nebulaScale
357{
358 OOSkyQuadDesc *quads = NULL, *currQuad = NULL;
359 unsigned i, actualCount = 0, clusters = 0;
360 OOColor *color;
361 Quaternion q;
362 Vector vi, vj, vk;
363 double size, r2;
364 Vector middle, offset;
365 int r1;
366
367 [self loadNebulaTextures];
368
369 quads = malloc(sizeof *quads * _nebulaCount);
370 if (quads == NULL) return;
371
372 currQuad = quads;
373 for (i = 0; i < _nebulaCount; ++i)
374 {
375 color = SaturatedColorInRange(color1, color2, nebulaHueFix);
376
377 // Select a direction and rotation.
378 q = OORandomQuaternion();
379
380 // Create a cluster of nebula quads.
381 while ((i < _nebulaCount) && (randf() < nebulaClusterFactor))
382 {
383 // Select size.
384 r1 = 1 + (ranrot_rand() & 15);
385 size = nebulaScale * r1 * SKY_ELEMENT_SCALE_FACTOR;
386
387 // Calculate centre position and offset to first corner.
388 basis_vectors_from_quaternion(q, &vi, &vj, &vk);
389
390 // Select colour and texture. Smaller nebula quads are dimmer.
391#if DEBUG_COLORS
392 currQuad->color = DebugColor(vk);
393#else
394 currQuad->color = [color colorWithBrightnessFactor:nebulaAlpha * (0.5f + (float)r1 / 32.0f)];
395#endif
396 currQuad->texture = [sNebulaTextures selectTexture]; // Not retained, since sStarTextures is never released.
397
398 middle = vector_multiply_scalar(vk, BILLBOARD_DEPTH);
399 offset = vector_multiply_scalar(vector_add(vi, vj), 0.5f * size);
400
401 // Rotate vi and vj by a random angle
402 r2 = randf() * M_PI * 2.0;
406
407 // Scale the "side" vectors.
408 vj = vector_multiply_scalar(vj, size);
409 vi = vector_multiply_scalar(vi, size);
410
411 // Set up corners.
412 currQuad->corners[0] = vector_subtract(middle, offset);
413 currQuad->corners[1] = vector_add(currQuad->corners[0], vj);
414 currQuad->corners[2] = vector_add(currQuad->corners[1], vi);
415 currQuad->corners[3] = vector_add(currQuad->corners[0], vi);
416
417 // Shuffle direction quat around a bit to spread the cluster out.
419 q.x += size * (randf() - 0.5);
420 q.y += size * (randf() - 0.5);
421 q.z += size * (randf() - 0.5);
422 q.w += size * (randf() - 0.5);
423 quaternion_normalize(&q);
424
425 ++i;
426 ++currQuad;
427 ++actualCount;
428 }
429 ++clusters;
430 }
431
432 /* The above code generates less than _nebulaCount quads, because i is
433 incremented once in the outer loop as well as in the inner loop. To
434 keep skies looking the same, we leave the bug in and fill in the
435 actual generated count here.
436 */
437 _nebulaCount = actualCount;
438
439 [self addQuads:quads count:_nebulaCount];
440 free(quads);
441}
#define M_PI
Definition OOMaths.h:73
Vector vector_up_from_quaternion(Quaternion quat)
Vector vector_right_from_quaternion(Quaternion quat)
void basis_vectors_from_quaternion(Quaternion quat, Vector *outRight, Vector *outUp, Vector *outForward)
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle)
#define SKY_ELEMENT_SCALE_FACTOR
#define NEBULA_SHUFFLE_FACTOR
static OOColor * SaturatedColorInRange(OOColor *color1, OOColor *color2, BOOL hueFix)
#define BILLBOARD_DEPTH
Definition Universe.h:162
OOColor * colorWithBrightnessFactor:(float factor)
Definition OOColor.m:502
voidpf void uLong size
Definition ioapi.h:134
voidpf uLong offset
Definition ioapi.h:140
float randf(void)
#define ranrot_rand()

◆ setUpStarsWithColor1:color2:

- (void) setUpStarsWithColor1: (OOColor *) color1
color2: (OOColor *) color2 

Extends class OOSkyDrawable.

Definition at line 83 of file OOSkyDrawable.m.

299 :(OOColor *)color1 color2:(OOColor *)color2
300{
301 OOSkyQuadDesc *quads = NULL, *currQuad = NULL;
302 unsigned i;
303 Quaternion q;
304 Vector vi, vj, vk;
305 float size;
306 Vector middle, offset;
307
308 [self loadStarTextures];
309
310 quads = malloc(sizeof *quads * _starCount);
311 if (quads == NULL) return;
312
313 currQuad = quads;
314 for (i = 0; i != _starCount; ++i)
315 {
316 // Select a direction and rotation.
317 q = OORandomQuaternion();
318 basis_vectors_from_quaternion(q, &vi, &vj, &vk);
319
320 // Select colour and texture.
321#if DEBUG_COLORS
322 currQuad->color = DebugColor(vk);
323#else
324 currQuad->color = [color1 blendedColorWithFraction:randf() ofColor:color2];
325#endif
326 currQuad->texture = [sStarTextures selectTexture]; // Not retained, since sStarTextures is never released.
327
328 // Select scale; calculate centre position and offset to first corner.
329 size = (1 + (ranrot_rand() % 6)) * SKY_ELEMENT_SCALE_FACTOR;
330 middle = vector_multiply_scalar(vk, BILLBOARD_DEPTH);
331 offset = vector_multiply_scalar(vector_add(vi, vj), 0.5f * size);
332
333 // Scale the "side" vectors.
334 Vector vj2 = vector_multiply_scalar(vj, size);
335 Vector vi2 = vector_multiply_scalar(vi, size);
336
337 // Set up corners.
338 currQuad->corners[0] = vector_subtract(middle, offset);
339 currQuad->corners[1] = vector_add(currQuad->corners[0], vj2);
340 currQuad->corners[2] = vector_add(currQuad->corners[1], vi2);
341 currQuad->corners[3] = vector_add(currQuad->corners[0], vi2);
342
343 ++currQuad;
344 }
345
346 [self addQuads:quads count:_starCount];
347 free(quads);
348}
OOColor * blendedColorWithFraction:ofColor:(float fraction,[ofColor] OOColor *color)
Definition OOColor.m:328

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