353 clusterFactor:(float)nebulaClusterFactor
354 nebulaHueFix:(BOOL)nebulaHueFix
355 alpha:(float)nebulaAlpha
356 scale:(float)nebulaScale
357{
359 unsigned i, actualCount = 0, clusters = 0;
361 Quaternion q;
362 Vector vi, vj, vk;
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 {
376
377
378 q = OORandomQuaternion();
379
380
381 while ((i < _nebulaCount) && (
randf() < nebulaClusterFactor))
382 {
383
386
387
389
390
391#if DEBUG_COLORS
392 currQuad->color = DebugColor(vk);
393#else
395#endif
396 currQuad->texture = [sNebulaTextures selectTexture];
397
399 offset = vector_multiply_scalar(vector_add(vi, vj), 0.5f *
size);
400
401
406
407
408 vj = vector_multiply_scalar(vj,
size);
409 vi = vector_multiply_scalar(vi,
size);
410
411
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
423 quaternion_normalize(&q);
424
425 ++i;
426 ++currQuad;
427 ++actualCount;
428 }
429 ++clusters;
430 }
431
432
433
434
435
436
437 _nebulaCount = actualCount;
438
439 [self addQuads:quads count:_nebulaCount];
440 free(quads);
441}
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)
OOColor * colorWithBrightnessFactor:(float factor)