Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Zitat von »"n0_0ne"«
Ich habe es einfach so gemacht, dass ich die Textur einmal rund herum mappe, also einmal von 0.0f bis 1.0f laufe.
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
void Cylinder::renderAllFaces () { float delta = 0.5f / m_vertices; // start drawing a list of triangles glBegin (GL_TRIANGLES); // loop over all triangles for (unsigned int i = 0; i < faceArray.size(); ++i) { // bottom and top circle faces if (i < m_vertices + m_vertices) renderSingleFace(faceArray [i]); else // side faces { // index of the sideface int j = i - m_vertices - m_vertices; // starting with 0 // first get the coordinates of the three corners of the triangle Vec4 p1 = vertexArray [faceArray [i].i1].pos; Vec4 p2 = vertexArray [faceArray [i].i2].pos; Vec4 p3 = vertexArray [faceArray [i].i3].pos; // now calculate the normal vector of the triangle Vec4 n = faceNormal (p1, p2, p3); // now we have collected all the information needed to draw the triangle // set the normal for all three vertices if (j % 2 == 0) // alternate, because one side is made out of two faces { glNormal3d (n[0], n[1], n[2]); // set first vertex glTexCoord2f (j*delta, 0.0f); glVertex3d (p1[0], p1[1], p1[2]); // set second vertex glTexCoord2f ((j+1)*delta, 0.0f); glVertex3d (p2[0], p2[1], p2[2]); // set third vertex glTexCoord2f (j*delta, 1.0f); glVertex3d (p3[0], p3[1], p3[2]); } else { glNormal3d (n[0], n[1], n[2]); // set first vertex glTexCoord2f (j*delta, 0.0f); glVertex3d (p1[0], p1[1], p1[2]); // set second vertex glTexCoord2f ((j-1)*delta, 1.0f); glVertex3d (p2[0], p2[1], p2[2]); // set third vertex glTexCoord2f (j*delta, 1.0f); glVertex3d (p3[0], p3[1], p3[2]); } } } // done, so do the drawing now glEnd(); } |
Zitat
C-/C++-Quelltext
1 float delta = 0.5f / m_vertices;
Werbeanzeige