[問題] 關於openGL的座標軸平移

看板C_and_CPP (C/C++)作者 (小歐肥不肥)時間13年前 (2012/12/14 12:57), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) VC++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) OpenGL GLUT 問題(Question): 我想做一個長方體 然後依照(0,5,0) ->(1,5,0) 這條線自轉 glRotatef((float)rRotat,Joint6.x,Joint6.y,Joint6.z); DrawCube(Joint1+Joint2+Joint3-Joint4+Joint5, Joint1+Joint2+Joint3-Joint4+Joint5+Joint6); DrawLine(Joint2+Joint1-Joint4+Joint3+Joint5, Joint2+Joint1+Joint3-Joint4+Joint6+Joint5); 但我這樣畫他是以Joint6這個向量(2.2,0,0)為轉軸整個長方體轉 其中Joint系列都是向量物件 我有想過用 glPushMatrix(); // 暫存目前的座標轉換矩陣 glPopMatrix(); // 完成新物件的轉換後,恢復為原先的座標轉換矩陣 來做 但還是蠻沒頭緒的 不小的可不可以稍微提點一下小弟 感謝各位大大 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.16.8

12/14 13:52, , 1F
glRotatef 旋轉軸只能過原點,所以你要自己實作
12/14 13:52, 1F

12/14 13:53, , 2F
general rotation matrix
12/14 13:53, 2F

12/14 14:08, , 3F
translate(0,-5,0) -> rotate(...) -> translate(0,5,0)
12/14 14:08, 3F

12/14 14:32, , 4F
謝謝樓上這位大大!!!!
12/14 14:32, 4F
文章代碼(AID): #1Goh6ov1 (C_and_CPP)
文章代碼(AID): #1Goh6ov1 (C_and_CPP)