文件名称:opengl_qt_draw3D
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:302.22kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
四棱锥由5个面构成一个封闭的立体图,其中4个共顶点的侧面是三角形,底面是个四边形。如果我们要绘制一个3D的四棱锥只需要绘制这5个面即可,绘制的方法和前一篇文章OpenGL_Qt学习笔记之_03(平面图形的着色和旋转)的相同。只不过这里的顶点坐标是3维的,所以图像深度那一维不一定为0。因此我们可以事先计算好四棱锥各个顶点的坐标,这对学过立体几何的人来说应该是小case了。然后绘制每个面就可以。
注意,在opengl中绘制每个面时,所有面给出的顶点的顺序都要按照逆时针或者顺时针(我这里采用的是逆时针),这样才能保证所绘制出来的图像时正确的。
现在我们在paintGL中开始绘制四棱锥,如果按照NeHe的教程,它只是绘制了个金字塔,并没有底面,只有4个侧面,这里,我采用它的方法,代码如下: -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:
注意,在opengl中绘制每个面时,所有面给出的顶点的顺序都要按照逆时针或者顺时针(我这里采用的是逆时针),这样才能保证所绘制出来的图像时正确的。
现在我们在paintGL中开始绘制四棱锥,如果按照NeHe的教程,它只是绘制了个金字塔,并没有底面,只有4个侧面,这里,我采用它的方法,代码如下: -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:
(系统自动生成,下载前可以参看下载内容)
下载文件列表
OpenGL_Qt学习笔记之_04(3D图形的绘制和旋转).pdf
opengl_qt_nehe_04/glwidget.cpp
opengl_qt_nehe_04/glwidget.h
opengl_qt_nehe_04/glwidget.ui
opengl_qt_nehe_04/main.cpp
opengl_qt_nehe_04/opengl_qt_nehe_04.pro
opengl_qt_nehe_04/opengl_qt_nehe_04.pro.user
opengl_qt_nehe_04
opengl_qt_nehe_04/glwidget.cpp
opengl_qt_nehe_04/glwidget.h
opengl_qt_nehe_04/glwidget.ui
opengl_qt_nehe_04/main.cpp
opengl_qt_nehe_04/opengl_qt_nehe_04.pro
opengl_qt_nehe_04/opengl_qt_nehe_04.pro.user
opengl_qt_nehe_04
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.