国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

ios - OpenGL如何將模型在打開時使他默認(rèn)在屏幕中央?
伊謝爾倫
伊謝爾倫 2017-04-17 17:25:18
0
1
334

如題,我再ios端實(shí)現(xiàn)了3d模型文件的展示,但是法線一問題。就是模型創(chuàng)造者在設(shè)計(jì)模型的時候并不一定是把模型放在坐標(biāo)原點(diǎn)開始設(shè)計(jì)的,那么就導(dǎo)致我讀出模型后,有的時候模型是在屏幕外邊的,有的時候模型是超級大或者超級小到看不到的。那么請問,我該修改什么屬性,能讓它按照一定大小展示在屏幕中央呢?
下面是我的展示模型的代碼。


 float verxxx[]={這里有一系列三角面片數(shù)據(jù)};

    glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, 0, verxxx);
    glEnableVertexAttribArray(_positionSlot);
    
    
    
    
    
    GLuint buffer;
    glGenBuffers(1, &buffer);
    glBindBuffer(GL_ARRAY_BUFFER, buffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(verxxx), verxxx, GL_STATIC_DRAW);
    
    //    3、將緩沖區(qū)的數(shù)據(jù)復(fù)制進(jìn)通用頂點(diǎn)屬性中
    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 4*8, (char *)NULL + 0);  //讀頂點(diǎn)坐標(biāo)
    
    
    //4、繼續(xù)復(fù)制其他數(shù)據(jù)
    //    在前面預(yù)定義的頂點(diǎn)數(shù)據(jù)數(shù)組中,還包含了法線和紋理坐標(biāo),所以參照上面的方法,將剩余的數(shù)據(jù)分別復(fù)制進(jìn)通用頂點(diǎn)屬性中。
    glEnableVertexAttribArray(GLKVertexAttribNormal);
    glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 4*8, (char *)NULL +12); //讀法線
    
    
    glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
    glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 4*8, (char *)NULL + 24);  //讀紋理
    
    
    
    
    
    glDrawArrays(GL_TRIANGLES, 0, sumFloat.count/7);
    
    glDeleteBuffers(1, &buffer);

指點(diǎn)一下,謝謝

伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。

reply all(1)
伊謝爾倫

Solved, I finally found the maximum and minimum xyz values ??based on all the vertex data in the model file, calculated the center point coordinates of the model based on the xyz values, and then redrawn the model at (0.0.0) according to the scale. The model is displayed in the center of the screen. As for the appropriate size, you need to find the maximum length of the model, and then find a suitable ratio on the screen based on the length of the model. Multiply all xyz values ??by this ratio. . . . Perfect solution. Hope someone can use it!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template