434{
442 GLfloat texLow = 0.0, texHigh = 0.0;
446
448 if (slices < 2 || loops < 1 || outerRadius <= 0.0 || innerRadius < 0.0 ||
449 innerRadius > outerRadius) {
451 return;
452 }
453
454 if (sweepAngle < -360.0) sweepAngle = 360.0;
455 if (sweepAngle > 360.0) sweepAngle = 360.0;
456 if (sweepAngle < 0) {
457 startAngle += sweepAngle;
458 sweepAngle = -sweepAngle;
459 }
460
461 if (sweepAngle == 360.0) {
462 slices2 = slices;
463 } else {
464 slices2 = slices + 1;
465 }
466
467
468 deltaRadius = outerRadius - innerRadius;
469
470
471
472 angleOffset = startAngle / 180.0 *
PI;
473 for (
i = 0;
i <= slices;
i++) {
474 angle = angleOffset + ((
PI * sweepAngle) / 180.0) *
i / slices;
477 }
478
479 if (sweepAngle == 360.0) {
480 sinCache[slices] = sinCache[0];
481 cosCache[slices] = cosCache[0];
482 }
483
484 switch(qobj->normals) {
489 } else {
491 }
492 break;
493 default:
495 break;
496 }
497
498 switch (qobj->drawStyle) {
500 if (innerRadius == 0.0) {
502
504 if (qobj->textureCoords) {
506 }
508 radiusLow = outerRadius -
509 deltaRadius * ((
float) (loops-1) / loops);
510 if (qobj->textureCoords) {
511 texLow = radiusLow / outerRadius / 2;
512 }
513
515 for (
i = slices;
i >= 0;
i--) {
516 if (qobj->textureCoords) {
518 texLow * cosCache[
i] + 0.5);
519 }
521 radiusLow * cosCache[
i], 0.0);
522 }
523 } else {
524 for (
i = 0;
i <= slices;
i++) {
525 if (qobj->textureCoords) {
527 texLow * cosCache[
i] + 0.5);
528 }
530 radiusLow * cosCache[
i], 0.0);
531 }
532 }
534 } else {
536 }
538 radiusLow = outerRadius - deltaRadius * ((
float)
j / loops);
539 radiusHigh = outerRadius - deltaRadius * ((
float) (
j + 1) / loops);
540 if (qobj->textureCoords) {
541 texLow = radiusLow / outerRadius / 2;
542 texHigh = radiusHigh / outerRadius / 2;
543 }
544
546 for (
i = 0;
i <= slices;
i++) {
548 if (qobj->textureCoords) {
550 texLow * cosCache[
i] + 0.5);
551 }
553 radiusLow * cosCache[
i], 0.0);
554
555 if (qobj->textureCoords) {
557 texHigh * cosCache[
i] + 0.5);
558 }
560 radiusHigh * cosCache[
i], 0.0);
561 } else {
562 if (qobj->textureCoords) {
564 texHigh * cosCache[
i] + 0.5);
565 }
567 radiusHigh * cosCache[
i], 0.0);
568
569 if (qobj->textureCoords) {
571 texLow * cosCache[
i] + 0.5);
572 }
574 radiusLow * cosCache[
i], 0.0);
575 }
576 }
578 }
579 break;
582 for (
i = 0;
i < slices2;
i++) {
583 sintemp = sinCache[
i];
584 costemp = cosCache[
i];
585 for (
j = 0;
j <= loops;
j++) {
586 radiusLow = outerRadius - deltaRadius * ((
float)
j / loops);
587
588 if (qobj->textureCoords) {
589 texLow = radiusLow / outerRadius / 2;
590
592 texLow * cosCache[
i] + 0.5);
593 }
594 glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0);
595 }
596 }
598 break;
600 if (innerRadius == outerRadius) {
602
603 for (
i = 0;
i <= slices;
i++) {
604 if (qobj->textureCoords) {
606 cosCache[
i] / 2 + 0.5);
607 }
609 innerRadius * cosCache[
i], 0.0);
610 }
612 break;
613 }
614 for (
j = 0;
j <= loops;
j++) {
615 radiusLow = outerRadius - deltaRadius * ((
float)
j / loops);
616 if (qobj->textureCoords) {
617 texLow = radiusLow / outerRadius / 2;
618 }
619
621 for (
i = 0;
i <= slices;
i++) {
622 if (qobj->textureCoords) {
624 texLow * cosCache[
i] + 0.5);
625 }
627 radiusLow * cosCache[
i], 0.0);
628 }
630 }
631 for (
i=0;
i < slices2;
i++) {
632 sintemp = sinCache[
i];
633 costemp = cosCache[
i];
635 for (
j = 0;
j <= loops;
j++) {
636 radiusLow = outerRadius - deltaRadius * ((
float)
j / loops);
637 if (qobj->textureCoords) {
638 texLow = radiusLow / outerRadius / 2;
639 }
640
641 if (qobj->textureCoords) {
643 texLow * cosCache[
i] + 0.5);
644 }
645 glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0);
646 }
648 }
649 break;
651 if (sweepAngle < 360.0) {
652 for (
i = 0;
i <= slices;
i+= slices) {
653 sintemp = sinCache[
i];
654 costemp = cosCache[
i];
656 for (
j = 0;
j <= loops;
j++) {
657 radiusLow = outerRadius - deltaRadius * ((
float)
j / loops);
658
659 if (qobj->textureCoords) {
660 texLow = radiusLow / outerRadius / 2;
662 texLow * cosCache[
i] + 0.5);
663 }
664 glVertex3f(radiusLow * sintemp, radiusLow * costemp, 0.0);
665 }
667 }
668 }
669 for (
j = 0;
j <= loops;
j += loops) {
670 radiusLow = outerRadius - deltaRadius * ((
float)
j / loops);
671 if (qobj->textureCoords) {
672 texLow = radiusLow / outerRadius / 2;
673 }
674
676 for (
i = 0;
i <= slices;
i++) {
677 if (qobj->textureCoords) {
679 texLow * cosCache[
i] + 0.5);
680 }
682 radiusLow * cosCache[
i], 0.0);
683 }
685 if (innerRadius == outerRadius) break;
686 }
687 break;
688 default:
689 break;
690 }
691}