Oolite
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 99 of file OOSkyDrawable.m.

Method Documentation

◆ addQuads:count:

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

Extends class OOSkyDrawable.

Definition at line 412 of file OOSkyDrawable.m.

412 :(OOSkyQuadDesc*)quads count:(unsigned)count
413{
414 if (_quadSets == nil)
415 _quadSets = [[NSMutableArray alloc] init];
416
417 [OOSkyQuadSet addQuads:quads count:count toArray:_quadSets];
418}
unsigned count
return nil
struct OOSkyQuadDesc OOSkyQuadDesc
void addQuads:count:toArray:(OOSkyQuadDesc *quads,[count] unsigned count,[toArray] NSMutableArray *ioArray)

References OOSkyQuadSet::addQuads:count:toArray:, and nil.

Here is the call graph for this function:

◆ ensureTexturesLoaded

- (void) ensureTexturesLoaded

Extends class OOSkyDrawable.

Definition at line 452 of file OOSkyDrawable.m.

References OOProbabilisticTextureManager::ensureTexturesLoaded, and ensureTexturesLoaded.

Referenced by ensureTexturesLoaded.

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

◆ loadNebulaTextures

- (void) loadNebulaTextures

Extends class OOSkyDrawable.

Definition at line 436 of file OOSkyDrawable.m.

437{
438 if (sNebulaTextures == nil) {
440 initWithPListName:@"nebulatextures.plist"
441 options:kOOTextureDefaultOptions | kOOTextureAlphaMask
442 anisotropy:0.0f
443 lodBias:0.0f];
444 if (sNebulaTextures == nil) {
445 [NSException raise:OOLITE_EXCEPTION_DATA_NOT_FOUND format:@"No nebula textures could be loaded."];
446 }
447 }
448
449 [sNebulaTextures setSeed:RANROTGetFullSeed()];
450}
static OOProbabilisticTextureManager * sNebulaTextures

References loadNebulaTextures, nil, OOProbabilisticTextureManager::setSeed:, and sNebulaTextures.

Referenced by loadNebulaTextures.

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

◆ loadStarTextures

- (void) loadStarTextures

Extends class OOSkyDrawable.

Definition at line 420 of file OOSkyDrawable.m.

421{
422 if (sStarTextures == nil) {
424 initWithPListName:@"startextures.plist"
425 options:kOOTextureMinFilterMipMap | kOOTextureMagFilterLinear | kOOTextureAlphaMask
426 anisotropy:0.0f
427 lodBias:-0.0f];
428 if (sStarTextures == nil) {
429 [NSException raise:OOLITE_EXCEPTION_DATA_NOT_FOUND format:@"No star textures could be loaded."];
430 }
431 }
432
433 [sStarTextures setSeed:RANROTGetFullSeed()];
434}
static OOProbabilisticTextureManager * sStarTextures

References loadStarTextures, nil, OOProbabilisticTextureManager::setSeed:, and sStarTextures.

Referenced by loadStarTextures.

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

◆ resetGraphicsState

- (void) resetGraphicsState
implementation

Extends class OOSkyDrawable.

Definition at line 458 of file OOSkyDrawable.m.

459{
461
462 if (_displayListName != 0) {
463 glDeleteLists(_displayListName, 1);
464 _displayListName = 0;
465 }
466}
#define OO_ENTER_OPENGL()

References OO_ENTER_OPENGL, and resetGraphicsState.

Referenced by resetGraphicsState.

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

◆ 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 322 of file OOSkyDrawable.m.

322 :(OOColor*)color1
323 color2:(OOColor*)color2
324 clusterFactor:(float)nebulaClusterFactor
325 nebulaHueFix:(BOOL)nebulaHueFix
326 alpha:(float)nebulaAlpha
327 scale:(float)nebulaScale
328{
329 OOSkyQuadDesc *quads = NULL, *currQuad = NULL;
330 unsigned i, actualCount = 0;
331 OOColor* color;
332 Quaternion q;
333 Vector vi, vj, vk;
334 double size, r2;
335 Vector middle, offset;
336 int r1;
337
338 [self loadNebulaTextures];
339
340 quads = malloc(sizeof *quads * _nebulaCount);
341 if (quads == NULL)
342 return;
343
344 currQuad = quads;
345 for (i = 0; i < _nebulaCount; ++i) {
346 color = SaturatedColorInRange(color1, color2, nebulaHueFix);
347
348 // Select a direction and rotation.
349 q = OORandomQuaternion();
350
351 // Create a cluster of nebula quads.
352 while ((i < _nebulaCount) && (randf() < nebulaClusterFactor)) {
353 // Select size.
354 r1 = 1 + (ranrot_rand() & 15);
355 size = nebulaScale * r1 * SKY_ELEMENT_SCALE_FACTOR;
356
357 // Calculate centre position and offset to first corner.
358 basis_vectors_from_quaternion(q, &vi, &vj, &vk);
359
360 // Select colour and texture. Smaller nebula quads are dimmer.
361#if DEBUG_COLORS
362 currQuad->color = DebugColor(vk);
363#else
364 currQuad->color = [color colorWithBrightnessFactor:nebulaAlpha * (0.5f + (float)r1 / 32.0f)];
365#endif
366 currQuad->texture = [sNebulaTextures selectTexture]; // Not retained, since sStarTextures is never released.
367
369 offset = vector_multiply_scalar(vector_add(vi, vj), 0.5f * size);
370
371 // Rotate vi and vj by a random angle
372 r2 = randf() * M_PI * 2.0;
376
377 // Scale the "side" vectors.
380
381 // Set up corners.
382 currQuad->corners[0] = vector_subtract(middle, offset);
383 currQuad->corners[1] = vector_add(currQuad->corners[0], vj);
384 currQuad->corners[2] = vector_add(currQuad->corners[1], vi);
385 currQuad->corners[3] = vector_add(currQuad->corners[0], vi);
386
387 // Shuffle direction quat around a bit to spread the cluster out.
389 q.x += size * (randf() - 0.5);
390 q.y += size * (randf() - 0.5);
391 q.z += size * (randf() - 0.5);
392 q.w += size * (randf() - 0.5);
394
395 ++i;
396 ++currQuad;
397 ++actualCount;
398 }
399 }
400
401 /* The above code generates less than _nebulaCount quads, because i is
402 incremented once in the outer loop as well as in the inner loop. To
403 keep skies looking the same, we leave the bug in and fill in the
404 actual generated count here.
405 */
406 _nebulaCount = actualCount;
407
408 [self addQuads:quads count:_nebulaCount];
409 free(quads);
410}
#define M_PI
Definition OOMaths.h:54
void basis_vectors_from_quaternion(Quaternion quat, Vector *outRight, Vector *outUp, Vector *outForward)
struct Quaternion Quaternion
void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, OOScalar angle) NONNULL_FUNC
OOINLINE void quaternion_normalize(Quaternion *quat) NONNULL_FUNC ALWAYS_INLINE_FUNC
Vector vector_up_from_quaternion(Quaternion quat) CONST_FUNC
OOINLINE Quaternion OORandomQuaternion(void) ALWAYS_INLINE_FUNC
Vector vector_right_from_quaternion(Quaternion quat) CONST_FUNC
#define SKY_ELEMENT_SCALE_FACTOR
#define NEBULA_SHUFFLE_FACTOR
static OOColor * SaturatedColorInRange(OOColor *color1, OOColor *color2, BOOL hueFix)
OOINLINE Vector vector_add(Vector a, Vector b) INLINE_CONST_FUNC
Definition OOVector.h:195
OOINLINE Vector vector_subtract(Vector a, Vector b) INLINE_CONST_FUNC
Definition OOVector.h:218
struct Vector Vector
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
Definition OOVector.h:180
#define BILLBOARD_DEPTH
Definition Universe.h:154
OOColor * colorWithBrightnessFactor:(float factor)
Definition OOColor.m:457
voidpf void uLong size
Definition ioapi.h:126
voidpf uLong offset
Definition ioapi.h:132
float randf(void)
#define ranrot_rand()
OOScalar w
OOScalar x
OOScalar y
OOScalar z

References OOSkyDrawable::addQuads:count:, basis_vectors_from_quaternion(), BILLBOARD_DEPTH, OOColor::colorWithBrightnessFactor:, OOSkyDrawable::loadNebulaTextures, M_PI, NEBULA_SHUFFLE_FACTOR, OORandomQuaternion(), quaternion_normalize(), quaternion_rotate_about_axis(), randf(), ranrot_rand, SaturatedColorInRange(), OOProbabilisticTextureManager::selectTexture, SKY_ELEMENT_SCALE_FACTOR, vector_add(), vector_multiply_scalar(), vector_right_from_quaternion(), vector_subtract(), vector_up_from_quaternion(), Quaternion::w, Quaternion::x, Quaternion::y, and Quaternion::z.

Here is the call graph for this function:

◆ setUpStarsWithColor1:color2:

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

Extends class OOSkyDrawable.

Definition at line 271 of file OOSkyDrawable.m.

271 :(OOColor*)color1 color2:(OOColor*)color2
272{
273 OOSkyQuadDesc *quads = NULL, *currQuad = NULL;
274 unsigned i;
275 Quaternion q;
276 Vector vi, vj, vk;
277 float size;
278 Vector middle, offset;
279
280 [self loadStarTextures];
281
282 quads = malloc(sizeof *quads * _starCount);
283 if (quads == NULL)
284 return;
285
286 currQuad = quads;
287 for (i = 0; i != _starCount; ++i) {
288 // Select a direction and rotation.
289 q = OORandomQuaternion();
290 basis_vectors_from_quaternion(q, &vi, &vj, &vk);
291
292 // Select colour and texture.
293#if DEBUG_COLORS
294 currQuad->color = DebugColor(vk);
295#else
296 currQuad->color = [color1 blendedColorWithFraction:randf() ofColor:color2];
297#endif
298 currQuad->texture = [sStarTextures selectTexture]; // Not retained, since sStarTextures is never released.
299
300 // Select scale; calculate centre position and offset to first corner.
301 size = (1 + (ranrot_rand() % 6)) * SKY_ELEMENT_SCALE_FACTOR;
303 offset = vector_multiply_scalar(vector_add(vi, vj), 0.5f * size);
304
305 // Scale the "side" vectors.
308
309 // Set up corners.
310 currQuad->corners[0] = vector_subtract(middle, offset);
311 currQuad->corners[1] = vector_add(currQuad->corners[0], vj2);
312 currQuad->corners[2] = vector_add(currQuad->corners[1], vi2);
313 currQuad->corners[3] = vector_add(currQuad->corners[0], vi2);
314
315 ++currQuad;
316 }
317
318 [self addQuads:quads count:_starCount];
319 free(quads);
320}
OOColor * blendedColorWithFraction:ofColor:(float fraction,[ofColor] OOColor *color)
Definition OOColor.m:309

References OOSkyDrawable::addQuads:count:, basis_vectors_from_quaternion(), BILLBOARD_DEPTH, OOColor::blendedColorWithFraction:ofColor:, OOSkyDrawable::loadStarTextures, OORandomQuaternion(), ranrot_rand, OOProbabilisticTextureManager::selectTexture, SKY_ELEMENT_SCALE_FACTOR, vector_add(), vector_multiply_scalar(), and vector_subtract().

Here is the call graph for this function:

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