Re: [問題] openGL 3D圖形重疊?

看板C_and_CPP (C/C++)作者 (一個人寂寞 兩個人麻煩)時間15年前 (2010/10/26 23:27), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/2 (看更多)
Hello, pig. After review your code, I believe you r a beginner in this area. There are 3 errors in your code: A) glOrtho() and gluPerspective() are doing almost the same thing. Here, you don't need the glOrtho(), because I guess you want to have a perspective projection effect. I am not sure, but these two matrix may stack on the projection matrix. because the docs said "multiply the current matrix with an orthographic matrix". Please try to remove the glOrtho(). B) The second parameter of the glPerspective(), will be aspect ratio. Google it. C) Why do you use GL_TRIANGLE_FAN in glBegin()? I don't see the ply file describs that. I am sorry. You are right to use GL_TRIANGLE_FAN here. Ply file describes not only trangles. This is my mistake. I think you will get the right image after solve the above problems. ※ 引述《pig00090 (嘿嘿嘿)》之銘言: : 要把ply model讀出來 : 但是在加入光源以後圖形會有類似透明或是重疊的效果? : 執行結果長這樣 : http://picasaweb.google.com.tw/whatsao71/Ply#5532250796857487426 : 有在討論區找到類似問題 : 然後把gluPerspective()的znear參數 : 從0.1改成設定更大的正整數後有修正一點點 : 但是還是圖形也不是正確的結果 : http://picasaweb.google.com.tw/whatsao71/Ply#5532250797431859698 : 有檢查過法向量是否正確 : 不知道是加入光源的流程還是哪裡出問題 : 所以只好來請教比較有經驗的各位了 : 附上code: : http://codepad.org/BzXrIwrr : http://codepad.org/4pYFR9I5 : 打包好的Codehttp://tinyurl.com/32wwkwc : 感謝 : 環境:Dev C++ 4.9.2 on windows7 : 主機的顯卡是用intel主機板的內顯 : ※ 編輯: pig00090 來自: 114.43.69.252 (10/26 16:57) : 推 Bencrie:有沒有直接打包好的source code啊 XD 10/26 20:55 : ※ 編輯: pig00090 來自: 114.43.69.252 (10/26 22:03) : → pig00090:附上source code~XD tnks 10/26 22:04 : 推 VictorTom:NV 8800GT跑出結果看起來相同, 只是小弟我看不太出來錯 10/26 22:57 : → VictorTom:的地方, 正確的說是不太曉得正確的圖應該是什麼樣子. 10/26 22:57 : → VictorTom:既然是有model了, 表示有其他軟體建的, 有正確該有的樣 10/26 22:57 : → VictorTom:子的圖嗎?? 目前小弟我看起來覺得好像裡外全反過來了, 10/26 22:58 : → VictorTom:不曉得是不是glFrontFace()應該反向一下....@_@" 10/26 22:59 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.32.242.172 ※ 編輯: LouisXIV 來自: 114.32.242.172 (10/26 23:30) ※ 編輯: LouisXIV 來自: 114.32.242.172 (10/26 23:43) ※ 編輯: LouisXIV 來自: 114.32.242.172 (10/27 00:10)

10/27 00:19, , 1F
我用GL_TRIANGLES跑起來跟GL_TRIANGLE_FAN一樣耶 XD
10/27 00:19, 1F

10/27 12:50, , 2F
感謝相救 問題解決了 XD
10/27 12:50, 2F
文章代碼(AID): #1CnlDulL (C_and_CPP)
文章代碼(AID): #1CnlDulL (C_and_CPP)