Re: [問題] openGL 3D圖形重疊?
看板C_and_CPP (C/C++)作者LouisXIV (一個人寂寞 兩個人麻煩)時間15年前 (2010/10/26 23:27)推噓1(1推 0噓 1→)留言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
10/27 00:19, 1F
推
10/27 12:50, , 2F
10/27 12:50, 2F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
4
16
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章