12 Shapes::~Shapes(
void) {
16 drawCircle( pos.
x, pos.
y, pos.
z, n, r, colorCenter, colorSurface );
19 void Shapes::drawCircle( GLfloat xPos, GLfloat yPos, GLfloat zPos, GLint n, GLfloat r,
const GLfloat *colorCenter,
const GLfloat *colorSurface ) {
21 float alphaPi = ( ( 360.0/n ) / 180.0) * M_PI;
23 printf(
"\nFehler! Mindestens 3 Ecken!.\n\n");
24 glBegin( GL_TRIANGLE_FAN );
25 glColor3fv(colorCenter);
26 glVertex3f( xPos + r/3, yPos + r/3, 0 );
27 glColor3fv(colorSurface);
29 glVertex3f(xPos + cos(i * alphaPi + M_PI_2)*r, yPos + sin(i * alphaPi + M_PI_2)*r, zPos);
39 float alphaPi = ( ( 360.0/n ) / 180.0) * M_PI;
41 printf(
"\nFehler! Mindestens 3 Ecken!.\n\n");
42 glBegin( GL_TRIANGLE_FAN );
43 glTexCoord2f( 0.5, 0.5 );
44 glVertex3f( xPos, yPos, 0 );
45 for(i=0; i <= n; i++) {
47 glTexCoord2f( 0.5 + cos(i * alphaPi + M_PI_2) * 0.5, 0.5 + sin(i * alphaPi + M_PI_2) * 0.5 );
48 glVertex3f( xPos + cos(i * alphaPi + M_PI_2)*r, yPos + sin(i * alphaPi + M_PI_2)*r, zPos );
53 void Shapes::drawCircleTex( GLfloat xPos, GLfloat yPos, GLfloat zPos, GLint n, GLfloat r,
const GLfloat *colorCenter,
const GLfloat *colorSurface ) {
55 float alphaPi = ( ( 360.0/n ) / 180.0) * M_PI;
57 printf(
"\nFehler! Mindestens 3 Ecken!.\n\n");
58 glBegin( GL_TRIANGLE_FAN );
59 glColor3fv( colorCenter );
60 glTexCoord2f( 0.5, 0.5 );
61 glVertex3f( xPos, yPos, 0 );
62 glColor3fv( colorSurface );
63 for(i=0; i <= n; i++) {
65 glTexCoord2f(0.5 + cos( i * alphaPi + M_PI_2 ) * 0.5, 0.5 + sin( i * alphaPi + M_PI_2 ) * 0.5 );
66 glVertex3f( xPos + cos(i * alphaPi + M_PI_2)*r, yPos + sin(i * alphaPi + M_PI_2)*r, zPos );
71 void Shapes::drawCircle( GLfloat xPos, GLfloat yPos, GLfloat zPos, GLint n, GLfloat r,
float segmentStart,
float segmentEnd,
const GLfloat *colorCenter,
const GLfloat *colorSurface ) {
73 float alphaPi = ( 360.0/n ) * ANGLE2DEG;
75 printf(
"\nFehler! Mindestens 3 Ecken!.\n\n");
76 glBegin( GL_TRIANGLE_FAN );
77 glColor3fv(colorCenter);
78 glVertex3f( xPos + r/3, yPos + r/3, 0 );
79 glColor3fv(colorSurface);
81 glVertex3f(xPos + cos(i * alphaPi + M_PI_2)*r, yPos + sin(i * alphaPi + M_PI_2)*r, zPos);
87 float alphaPi = ( 360.0/n ) * ANGLE2DEG;
90 printf(
"\nFehler! Mindestens 3 Ecken!.\n\n");
93 glBegin( GL_LINE_LOOP );
95 glVertex3f(xPos + cos(i * alphaPi + M_PI_2)*r, yPos + sin(i * alphaPi + M_PI_2)*r, zPos);
99 void Shapes::drawCircleShape( GLfloat xPos, GLfloat yPos, GLfloat zPos, GLint n, GLfloat r,
float segmentStart,
float segmentEnd,
const GLfloat * color ) {
101 float segmentStart2 = segmentStart - floor(segmentStart/360.0f)*360.0;
102 float segmentEnd2 = segmentEnd - floor(segmentEnd/360.0f)*360.0;
104 if( segmentEnd2 < segmentStart2 )
105 alphaPi = ((360.0 - segmentStart2 + segmentEnd2 )/n) * ANGLE2DEG;
107 alphaPi = ((segmentEnd2 - segmentStart2)/n) * ANGLE2DEG;
111 printf(
"\nFehler! Mindestens 3 Ecken!.\n\n");
114 glBegin( GL_LINE_STRIP );
115 for(i=0; i <= n; i++)
116 glVertex3f(xPos + cos(i * alphaPi + M_PI_2 + segmentStart2*ANGLE2DEG)*r, yPos + sin(i * alphaPi + M_PI_2 + segmentStart2*ANGLE2DEG)*r, zPos);
121 drawCircleShape( (GLfloat)pos.
x, (GLfloat)pos.
y, (GLfloat)pos.
z, n, r, segmentStart, segmentEnd, color );
127 float alphaPi = ( 360.0/n ) * ANGLE2DEG;
130 printf(
"\nFehler! Mindestens 3 Ecken!.\n\n");
134 for(i=0; i <= n; i+=2)
135 glVertex3f(xPos + cos(i * alphaPi + M_PI_2)*r, yPos + sin(i * alphaPi + M_PI_2)*r, zPos);
139 void Shapes::drawRect( GLfloat xCenterPos, GLfloat yCenterPos, GLfloat zPos, GLfloat width, GLfloat height ) {
141 glVertex3f( xCenterPos - width*0.5, yCenterPos + height*0.5, zPos );
142 glVertex3f( xCenterPos - width*0.5, yCenterPos - height*0.5, zPos );
143 glVertex3f( xCenterPos + width*0.5, yCenterPos - height*0.5, zPos );
144 glVertex3f( xCenterPos + width*0.5, yCenterPos + height*0.5, zPos );