Description: A closed perspective view of four-sided pyramid is constituted by 5 surface, wherein the side of vertex 4 is triangular, the bottom surface is a quadrangle. If we want to draw a 3D pyramid only need to draw the five faces can, the drawn and former article OpenGL_Qt study notes _03 (planar graph coloring and rotation). But here vertex coordinates of a three-dimensional, so the image depth that dimension is not necessarily 0. So we can be calculated in advance the good four-sided pyramid coordinates of each vertex should learn solid geometry, is a small case. Then you can draw each face. Opengl in draw each surface, all surface given vertex order must be in accordance with the counterclockwise or clockwise (I used counterclockwise), so as to ensure the drawn image. Now we start drawing in paintGL four pyramid NeHe tutorial, it just draws a pyramid and the bottom surface of only four sides, here, I adopt its methods, the code is as follows:
To Search:
File list (Check if you may need any files):
OpenGL_Qt学习笔记之_04(3D图形的绘制和旋转).pdf
opengl_qt_nehe_04\glwidget.cpp
.................\glwidget.h
.................\glwidget.ui
.................\main.cpp
.................\opengl_qt_nehe_04.pro
.................\opengl_qt_nehe_04.pro.user
opengl_qt_nehe_04