Bonjour à tous,
Je travaille dans un projet en 3D. Mais je ne suis pas très bien en OpenGL.
Quelqu'un me donne une structure d'un bâtiment, et je dois dessiner en 3D.
Un bâtiment comprend une empreinte (footprint), une hauteur et la latitude. Donc, un bâtiment ressemble à une boîte de 3D, quelques choses comme ça (voir l'image, s'il vous plaît). Un bâtiment peut avoir plus de 4 vertex:
Quelqu'un me donne une classe de bâtiment comme ça (j'ai enlevé un certain nombre de données) et il a dit que je devrais utiliser la fonction glDrawElements. Voici le code de la classe de bâtiment (s'il vous plaît, lire le fichier cpp):
http://video.igala.net/building.cpp.html
J'ai utilisé la fonction glDrawElements comme ceci:
Mais il ne fonctionne pas, il a été cassé quand il commence à dessiner.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 GlEnableClientState (GL_VERTEX_ARRAY); nbVertices int = pbuilding-> getData () -> GetWallVerticesCount (); GLfloat * sommets pbuilding-=> getData () -> GLWallVertices (); GlVertexPointer (3, GL_FLOAT, 0, sommets); Int n = pbuilding-> getData () -> getNbRings (); unsigned int * PN = pbuilding-> getData () -> GetWallIndicesCount (); unsigned int index = ** pbuilding-> getData () -> GLWallIndices (); For (int i = 0; i <n; i) ( If (n == 0) glDrawElements (GL_TRIANGLES, PN [i], GL_UNSIGNED_SHORT, (GLvoid *) les indices [i]); ) GlDisableClientState (GL_VERTEX_ARRAY);
Donc comment je peux tracer ce bâtiment?
Merci beaucoup,






Répondre avec citation



Partager