b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

opengl超级宝典_opengl超级宝典 kindle_opengl红宝书(3)

电脑杂谈  发布时间:2017-01-10 17:59:52  来源:网络整理

thunderBirdGlass.Scale(fScale);

首先,我们声明了两个三角形网格类

CTriangleMesh thunderBirdBody;

CTriangleMesh thunderBirdGalss;

然后我们要告诉包含所有顶点所需要的大小的最大值,在最坏的情况下我们可能有3074个唯一的顶点,但一般情况下,许多顶点是共享的,值是一样的。

thunderBirdBody.BeginMesh(3074*3);

然后遍历集体所有的面,并收集每一个独立的三角形,并作为AddTriangle的参数,AddTriagnle会组织索引数组。opengl超级宝典在AddTriangle函数中把传进来的参数与之前的顶点数据进行比较看是否有重复的。如果是重复的在索引数组中就用同一个索引值。opengl超级宝典其内部处理代码:

for(GLuint iVertex = 0; iVertex < 3; iVertex++)

    {
    GLuint iMatch = 0;
    for(iMatch = 0; iMatch < nNumVerts; iMatch++)
        {
        // If the vertex positions are the same
        if(m3dCloseEnough(pVerts[iMatch][0], verts[iVertex][0], e) &&
           m3dCloseEnough(pVerts[iMatch][1], verts[iVertex][1], e) &&
           m3dCloseEnough(pVerts[iMatch][2], verts[iVertex][2], e) &&

           // AND the Normal is the same...
           m3dCloseEnough(pNorms[iMatch][0], vNorms[iVertex][0], e) &&
           m3dCloseEnough(pNorms[iMatch][1], vNorms[iVertex][1], e) &&
           m3dCloseEnough(pNorms[iMatch][2], vNorms[iVertex][2], e) &&

            // And Texture is the same...
            m3dCloseEnough(pTexCoords[iMatch][0], vTexCoords[iVertex][0], e) &&
            m3dCloseEnough(pTexCoords[iMatch][1], vTexCoords[iVertex][1], e))
            {
            // Then add the index only
            pIndexes[nNumIndexes] = iMatch;
            nNumIndexes++;
            break;
            }
        }

    // No match for this vertex, add to end of list
    if(iMatch == nNumVerts)
        {
        memcpy(pVerts[nNumVerts], verts[iVertex], sizeof(M3DVector3f));
        memcpy(pNorms[nNumVerts], vNorms[iVertex], sizeof(M3DVector3f));
        memcpy(pTexCoords[nNumVerts], &vTexCoords[iVertex], sizeof(M3DVector2f));
        pIndexes[nNumIndexes] = nNumVerts;
        nNumIndexes++; 
        nNumVerts++;
        }   
    }


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-25412-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 沈易熹
      沈易熹

      有些人不打他是认为你好欺负的

    • 章嘉豪
      章嘉豪

      相信通过杨洋不懈的努力和追求

      • 周孜昱
        周孜昱

        呵呵在南海说自由我们有权利自由

    热点图片
    拼命载入中...