《基于MFC的OpenGL编程》Part 4.pdf
上传人:qw****27 上传时间:2024-09-12 格式:PDF 页数:5 大小:158KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

《基于MFC的OpenGL编程》Part 4.pdf

《基于MFC的OpenGL编程》Part4.pdf

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

《基于MFC的OpenGL编程》Part4DrawingSimple3Dobjects5D开心SEO博客http://blog.5dkx.com收集整理视见体ViewingVolumeisnothingbuttheregionof3DCartesianspaceinthatwilloccupythewindow.Itisnothingbuttheminimumandmaximumx,yandzvaluesthatareinsidethewindow.Soifavertexisoutsidethisrangeofx,yandzvaluesthentheyareclippedbyOpenGLbeforerenderingcanoccur.ZBufferThenewtermwehavetodealwithinadditiontowidthandheightofanobjectin3Dgraphicsisdepth.Thedepthofanobjectisitsdistancefromtheviewpoint.Theviewpointisthelocationfromwhichwearelookingatthatpoint.ThisdepthvaluegoesintothedepthorZ-buffer.Ifwearedrawing2objectsthathavesomepixelsthatoverlap,thefirstobjectwillafteritisrenderedhaveitsdepthvalueinthedepthbuffer.Whenthenextobjectisrendered,OpenGLwillchecktoseewhetherthepixelit’sabouttodrawisinfrontof(withrespecttotheviewpoint)anypixelfromthefirstobjectthat’salreadydrawn.ItdoesthisbycheckingtheZvalueofthecurrentpixelwiththevaluethatisalreadyinthebuffer.Ifthenewpixelisclosertotheviewpoint,OpenGLplacesitsdepthvalueinthedepthbuffer.ThisishowtheZ-bufferworks.正交投影和透视投影Onetermweneedtounderstandverywelltolearn3DGraphicswellisprojection.Well,computergraphicsatitssimplestisallaboutsettingacolortoapixelonscreen.Andapixelonascreencanhaveonlytwodimensions.So3Dgraphicsismerelyanillusion.The3Dcoordinatesthatwespecifywillhavetobeprojectedontoa2Dsurfacetocreatethisillusionforus.Andwehavetospecifyhowthisprojectionworks.Byspecifyingaprojectionwespecifytheclippingorviewingvolume.基本3D图形绘制1,在CCY457OpenGLView.h中加入下列变量BOOLm_bPoint;//StatusofPointBOOLm_bLine;//StatusofLineBOOLm_bPolygon;//StatusofPolygonBOOLm_bTriangle;//StatusofTriangle并且在构造函数中初始化CCY457OpenGLView::CCY457OpenGLView(){m_bPoint=FALSE;m_bLine=FALSE;m_bPolygon=FALSE;m_bTriangle=FALSE;m_bCube=FALSE;m_bTorus=FALSE;m_bTeapot=FALSE;m_bIcosahedron=FALSE;m_bSimpleCube=FALSE;}2,加入五个菜单项及其对应的事件处理程序。voidCCY457OpenGLView::OnObjectsTeapot(){//画茶壶m_bCube=FALSE;m_bTorus=FALSE;m_bTeapot=TRUE;m_bIcosahedron=FALSE;m_bSimpleCub