2014-02-09 144 views
2

我最近從使用已棄用的gl_*Matrix切換到自己處理矩陣。一切似乎都工作得很好,除了旋轉大約是它的80倍。我可以切換到使用opengl的矩陣而不更改任何其他代碼,並且旋轉很好。完整的數據來源於Github。最相關的功能在這裏:OpenGL旋轉太敏感

calculateMatricesFromPlayer :: GameObject a -> WorldMatrices 
calculateMatricesFromPlayer [email protected](Player{}) = 
    let Vec3 px py pz = playerPosition p 
     Vec3 rx ry _ = playerRotation p 

     -- Create projection matrix 
     projMat = gperspectiveMatrix 45 (800/600) 0.1 100 

     -- Create view matrix 
     rotatedMatX = grotationMatrix rx [-1, 0, 0] 
     rotatedMatXY = rotatedMatX * grotationMatrix ry [0, -1, 0] 
     translatedMat = gtranslationMatrix [-px, -py, -pz] 
     viewMat = rotatedMatXY * translatedMat 

     -- Model matrix is identity by default 
     modelMat = gidentityMatrix 
    in WorldMatrices modelMat viewMat projMat 

有沒有什麼明顯的我做錯了?

+3

這可能是弧度問題 –

回答

8

由於有360度,並以環繞2*pi弧度,與pi爲約3,似乎很可能是因爲您使用度作爲輸入到sincostan功能,這是由大約80的因數被淘汰是以弧度爲單位輸入,因爲360/(2*pi)約爲80.