483 :(GLfloat)inner_radius width:(GLfloat)width zDistance:(GLfloat)z_distance
484{
485
486
487 GLfloat activity[8] = {0.84, 0.74, 0.64, 0.54,
488 0.3 , 0.4 , 0.7 , 0.8};
489
490 GLfloat si, ci;
491 GLfloat rv0, rv1, rv2, c0, c1, c2;
492 GLfloat pt0, pt1;
493
494 unsigned short i, j, k;
495 GLfloat theta = 0.0f, delta;
496 delta =
M_PI / 180.0f;
497 pt0=(1.0 - corona_stage) * corona_blending;
498 pt1=corona_stage * corona_blending;
499
500 sunVertices[0] = 0.0;
501 sunVertices[1] = 0.0;
502 sunVertices[2] = 0.0;
503 k = 3;
504 for (j = 0 ; j <= 4 ; j++)
505 {
506 GLfloat r = inner_radius;
507 switch (j) {
508 case 4:
509 r += width;
510 break;
511 case 3:
512 r += width/1.5f;
513 break;
514 case 2:
515 r += width/3.0f;
516 break;
517 case 1:
518 r += width/15.0f;
519 break;
520 }
521 theta = 0.0;
522 for (i = 0 ; i < 360 ; i++)
523 {
524 GLfloat rm = 1.0;
525 if (j >= 1 && j < 4)
526 {
527 rm = 1.0 + ((0.04/j)*(pt0 * (rvalue[i]+rvalue[i+1]+rvalue[i+2]) + pt1 * (rvalue[i+360]+rvalue[i+361]+rvalue[i+362])))/3;
528 }
529 GLfloat z = r * r * rm * rm / z_distance;
530 si = sinf(theta);
531 ci = cosf(theta);
532 theta += delta;
533 sunVertices[k++] = si * r * rm;
534 sunVertices[k++] = ci * r * rm;
535 sunVertices[k++] = -z;
536 }
537 }
538
539 GLfloat blackColor[4] = {0.0,0.0,0.0,0.0};
540 GLfloat *color = blackColor;
541 GLfloat alpha = 0.0;
542
543 k=0;
544 sunColors[k++] = discColor[0];
545 sunColors[k++] = discColor[1];
546 sunColors[k++] = discColor[2];
547 sunColors[k++] = discColor[3] * _sunCoronaAlphaFactor;
548
549 for (j = 0 ; j <= 4 ; j++)
550 {
551 switch (j) {
552 case 4:
553 color = blackColor;
554 alpha = 0.0;
555 break;
556 case 3:
557 color = outerCoronaColor;
558 alpha = 0.1;
559 break;
560 case 2:
561 color = outerCoronaColor;
562 alpha = 0.6;
563 break;
564 case 1:
565 color = discColor;
566 alpha = 0.95;
567 break;
568 case 0:
569 color = discColor;
570 alpha = 1.0;
571 break;
572 }
573 for (i = 0 ; i < 360 ; i++)
574 {
575 if (j == 0)
576 {
577 sunColors[k++] = color[0];
578 sunColors[k++] = color[1];
579 sunColors[k++] = color[2];
580 sunColors[k++] = alpha * _sunCoronaAlphaFactor;
581 }
582 else
583 {
584 rv0 = pt0 * rvalue[i] + pt1 * rvalue[i + 360];
585 rv1 = pt0 * rvalue[i + 1] + pt1 * rvalue[i + 361];
586 rv2 = pt0 * rvalue[i + 2] + pt1 * rvalue[i + 362];
587 c0 = color[0] * (activity[j-1] + rv0*activity[j+3]);
588 c1 = color[1] * (activity[j-1] + rv1*activity[j+3]);
589 c2 = color[2] * (activity[j-1] + rv2*activity[j+3]);
590 if (c1 > c2 && c1 > c0)
591 {
592 c1 = fmaxf(c0,c2);
593 }
594
595 sunColors[k++] = c0;
596 sunColors[k++] = c1;
597 sunColors[k++] = c2;
598 sunColors[k++] = alpha * _sunCoronaAlphaFactor;
599 }
600 }
601 }
602}