• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Shuffy

            不斷的學(xué)習(xí),不斷的思考,才能不斷的進(jìn)步.Let's do better together!
            posts - 102, comments - 43, trackbacks - 0, articles - 19
            視見(jiàn)體

            Viewing Volume is nothing but the region of 3D Cartesian space in that will occupy the window. It is nothing but the minimum and maximum x, y and z values that are inside the window. So if a vertex is outside this range of x, y and z values then they are clipped by OpenGL before rendering can occur.

            Z Buffer

            The new term we have to deal with in addition to width and height of an object in 3D graphics is depth. The depth of an object is its distance from the viewpoint. The viewpoint is the location from which we are looking at that point. This depth value goes into the depth or Z-buffer. If we are drawing 2 objects that have some pixels that overlap, the first object will after it is rendered have its depth value in the depth buffer. When the next object is rendered, OpenGL will check to see whether the pixel it’s about to draw is in front of (with respect to the viewpoint) any pixel from the first object that’s already drawn. It does this by checking the Z value of the current pixel with the value that is already in the buffer. If the new pixel is closer to the viewpoint, OpenGL places its depth value in the depth buffer. This is how the Z-buffer works.

            正交投影和透視投影

            One term we need to understand very well to learn 3D Graphics well is projection. Well, computer graphics at its simplest is all about setting a color to a pixel on screen. And a pixel on a screen can have only two dimensions. So 3D graphics is merely an illusion. The 3D coordinates that we specify will have to be projected onto a 2D surface to create this illusion for us. And we have to specify how this projection works. By specifying a projection we specify the clipping or viewing volume.

            基本3D圖形繪制

            1,CCY457OpenGLView.h中加入下列變量

            BOOL m_bPoint;        //Status of Point
            BOOL m_bLine;        //Status of Line
            BOOL m_bPolygon;    //Status of Polygon
            BOOL m_bTriangle;    //Status of Triangle

            并且在構(gòu)造函數(shù)中初始化

            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,加入五個(gè)菜單項(xiàng)及其對(duì)應(yīng)的事件處理程序。

             

            void CCY457OpenGLView::OnObjectsTeapot() 
            {
            //畫(huà)茶壺
                m_bCube           = FALSE;        
                m_bTorus       
            = FALSE;        
                m_bTeapot       
            = TRUE;        
                m_bIcosahedron 
            = FALSE;
                m_bSimpleCube  
            = FALSE;        
                InvalidateRect(NULL,FALSE);    
            }
            void CCY457OpenGLView::OnObjectsCube() 
            {
            //畫(huà)立方體
                m_bCube           = TRUE;    
                m_bTorus       
            = FALSE;        
                m_bTeapot       
            = FALSE;        
                m_bIcosahedron 
            = FALSE;
                m_bSimpleCube  
            = FALSE;        
                InvalidateRect(NULL,FALSE);    
            }
            void CCY457OpenGLView::OnObjectsIcosahedron() 
            {
            //畫(huà)二十面體
                m_bCube           = FALSE;        
                m_bTorus       
            = FALSE;        
                m_bTeapot       
            = FALSE;        
                m_bIcosahedron 
            = TRUE;
                m_bSimpleCube  
            = FALSE;    
                InvalidateRect(NULL,FALSE);    
            }
            void CCY457OpenGLView::OnObjectsTorus() 
            {
            //畫(huà)環(huán)面
                m_bCube           = FALSE;        
                m_bTorus       
            = TRUE;        
                m_bTeapot       
            = FALSE;        
                m_bIcosahedron 
            = FALSE;
                m_bSimpleCube  
            = FALSE;            
                InvalidateRect(NULL,FALSE);    
            }

            void CCY457OpenGLView::OnObjectsSimplecube() 
            {
            //畫(huà)簡(jiǎn)單立方體
                m_bCube           = FALSE;        
                m_bTorus       
            = FALSE;        
                m_bTeapot       
            = FALSE;        
                m_bIcosahedron 
            = FALSE;
                m_bSimpleCube  
            = TRUE;        
                InvalidateRect(NULL,FALSE);
            }

            3,由于開(kāi)始繪制3維圖形,因此使用第一篇文章的OnSize()函數(shù)。

            4,RenderScene中加入具體的繪制代碼:

            void CCY457OpenGLView::RenderScene ()
            {
            //繪制函數(shù)
                if(m_bPoint==TRUE)
                {
                    glPointSize(
            3.0f);
                    glBegin(GL_POINTS);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            1.0f,0.0f);
                        glVertex2f(
            0.0f,1.0f);
                    glEnd();
                }
                
            if(m_bLine==TRUE)
                {
                    glBegin(GL_LINES);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            1.0f,0.0f);
                    glEnd();
                }
                
            if(m_bTriangle==TRUE)
                {
                    glBegin(GL_TRIANGLES);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            2.0f,0.0f);
                        glVertex2f(
            0.0f,2.0f);
                    glEnd();
                }
                
            if(m_bPolygon==TRUE)
                {
                    glBegin(GL_POLYGON);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            3.0f,0.0f);
                        glVertex2f(
            4.0f,3.0f);
                        glVertex2f(
            1.5f,6.0f);
                        glVertex2f(
            -1.0f,3.0f);
                    glEnd();
                }
                
            //Replace the current matrix with Identity Matrix
                glLoadIdentity();
                glTranslatef(
            0.0f,0.0f,-5.0f);
                glRotatef(
            -30.0f,1.0f,1.0f,0.0f);
                
            //Draw a Cube
                if(m_bCube)
                {
                    glutWireCube(
            1.0f);
                }
                
            //Draw a Torus
                if(m_bTorus)
                {
                    glutWireTorus(
            0.5f1.0f5050);
                }
                
            //Draw a Teapot
                if(m_bTeapot)
                {
                    glutWireTeapot(
            1.0f);
                }
                
            //Draw a Icosahedron
                if(m_bIcosahedron)
                {
                    glutWireIcosahedron();
                }
                
            //Draw a cube by specifying the vertices individually
                if(m_bSimpleCube)
                {
                    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
                    
                    
            //Front Face
                    glBegin(GL_POLYGON);
                        glVertex3f(
            -1.0f,-1.0f,0.0f);
                        glVertex3f( 
            1.0f,-1.0f,0.0f);
                        glVertex3f( 
            1.0f1.0f,0.0f);
                        glVertex3f(
            -1.0f1.0f,0.0f);
                    glEnd();
                    
            //Back Face
                    glBegin(GL_POLYGON);
                        glVertex3f(
            -1.0f,-1.0f,-1.0f);
                        glVertex3f(
            -1.0f1.0f,-1.0f);
                        glVertex3f( 
            1.0f1.0f,-1.0f);
                        glVertex3f( 
            1.0f,-1.0f,-1.0f);
                    glEnd();
                    
            //Left Face
                    glBegin(GL_POLYGON);
                        glVertex3f(
            -1.0f,-1.0f0.0f);
                        glVertex3f(
            -1.0f1.0f0.0f);
                        glVertex3f(
            -1.0f1.0f,-1.0f);
                        glVertex3f(
            -1.0f,-1.0f,-1.0f);
                    glEnd();
                    
            //Right Face
                    glBegin(GL_POLYGON);
                        glVertex3f(
            1.0f,-1.0f0.0f);
                        glVertex3f(
            1.0f,-1.0f,-1.0f);
                        glVertex3f(
            1.0f1.0f,-1.0f);
                        glVertex3f(
            1.0f1.0f0.0f);
                    glEnd();
                    
            //Top Face
                    glBegin(GL_POLYGON);
                        glVertex3f(
            -1.0f1.0f,  0.0f);
                        glVertex3f( 
            1.0f1.0f,  0.0f);
                        glVertex3f( 
            1.0f1.0f-1.0f);
                        glVertex3f(
            -1.0f1.0f-1.0f);
                    glEnd();
                    
            //Botton Face
                    glBegin(GL_POLYGON);
                        glVertex3f(
            -1.0f-1.0f,  0.0f);
                        glVertex3f(
            -1.0f-1.0f-1.0f);
                        glVertex3f( 
            1.0f-1.0f-1.0f);
                        glVertex3f( 
            1.0f-1.0f,  0.0f);
                    glEnd();
                }
            }

            作者:洞庭散人

            出處:http://phinecos.cnblogs.com/    

            本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁(yè)面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
            原文鏈接:http://www.cnblogs.com/phinecos/archive/2008/11/05/1327385.html
            国产成人精品久久亚洲高清不卡 | 精品国产91久久久久久久a| 日韩人妻无码一区二区三区久久 | 久久99这里只有精品国产| 天天做夜夜做久久做狠狠| 亚洲精品国产字幕久久不卡| 国产精品欧美久久久天天影视 | 无码AV中文字幕久久专区| 伊人久久大香线蕉精品| 久久成人小视频| 99久久综合国产精品二区| 亚洲AV无码久久精品色欲| 九九久久精品国产| 99久久婷婷免费国产综合精品| 久久精品亚洲福利| 精品久久久久久久| 久久久久久精品免费免费自慰| 国产女人aaa级久久久级| 精品久久亚洲中文无码| 久久九九免费高清视频| 国产成人久久激情91 | 国产精品久久久久一区二区三区| 日本强好片久久久久久AAA| 久久久久久国产a免费观看不卡| 狠狠色丁香久久婷婷综合五月| 一本色综合久久| 日韩电影久久久被窝网| 国内精品久久久久影院网站 | 国产午夜精品久久久久免费视 | 久久线看观看精品香蕉国产| 亚洲中文字幕久久精品无码喷水| 看全色黄大色大片免费久久久| 国产成人综合久久精品尤物| 国产精品久久久久久福利69堂| 久久精品a亚洲国产v高清不卡| 亚洲愉拍99热成人精品热久久| 久久精品国产久精国产果冻传媒| 亚洲精品tv久久久久| 午夜精品久久久久久影视riav| 性高湖久久久久久久久AAAAA| 中文字幕无码久久久|