预览加载中,请您耐心等待几秒...
1/5
2/5
3/5
4/5
5/5

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

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

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

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

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

《基于MFC的OpenGL编程》Part4DrawingSimple3D objects 5D开心SEO博客http://blog.5dkx.com收集整理 视见体ViewingVolumeisnothingbuttheregionof3DCartesianspacein thatwilloccupythewindow.Itisnothingbuttheminimumandmaximumx,y andzvaluesthatareinsidethewindow.Soifavertexisoutsidethisrangeofx, yandzvaluesthentheyareclippedbyOpenGLbeforerenderingcanoccur. ZBuffer Thenewtermwehavetodealwithinadditiontowidthandheightofan objectin3Dgraphicsisdepth.Thedepthofanobjectisitsdistancefromthe viewpoint.Theviewpointisthelocationfromwhichwearelookingatthatpoint. ThisdepthvaluegoesintothedepthorZ-buffer.Ifwearedrawing2objectsthat havesomepixelsthatoverlap,thefirstobjectwillafteritisrenderedhaveits depthvalueinthedepthbuffer.Whenthenextobjectisrendered,OpenGLwill checktoseewhetherthepixelit’sabouttodrawisinfrontof(withrespectto theviewpoint)anypixelfromthefirstobjectthat’salreadydrawn.Itdoesthis bycheckingtheZvalueofthecurrentpixelwiththevaluethatisalreadyinthe buffer.Ifthenewpixelisclosertotheviewpoint,OpenGLplacesitsdepthvalue inthedepthbuffer.ThisishowtheZ-bufferworks. 正交投影和透视投影 Onetermweneedtounderstandverywelltolearn3DGraphicswellis projection.Well,computergraphicsatitssimplestisallaboutsettingacolorto apixelonscreen.Andapixelonascreencanhaveonlytwodimensions.So3D graphicsismerelyanillusion.The3Dcoordinatesthatwespecifywillhavetobe projectedontoa2Dsurfacetocreatethisillusionforus.Andwehavetospecify howthisprojectionworks.Byspecifyingaprojectionwespecifytheclippingor viewingvolume. 基本3D图形绘制 1,在CCY457OpenGLView.h中加入下列变量 BOOLm_bPoint;//StatusofPoint BOOLm_bLine;//StatusofLine BOOLm_bPolygon;//StatusofPolygon BOOLm_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