OpenGL旋转太敏感
我最近从使用不推荐的OpenGL旋转太敏感,opengl,haskell,matrix,linear-algebra,Opengl,Haskell,Matrix,Linear Algebra,我最近从使用不推荐的gl_*Matrix改为自己处理矩阵。一切似乎都很好,除了旋转大约是它应该的80倍。我可以在不更改任何其他代码的情况下切换到使用opengl的矩阵,并且可以进行旋转。完整的源代码已打开。最相关的功能如下: calculateMatricesFromPlayer :: GameObject a -> WorldMatrices calculateMatricesFromPlayer p@(Player{}) = let Vec3 px py pz = player
gl_*Matrix
改为自己处理矩阵。一切似乎都很好,除了旋转大约是它应该的80倍。我可以在不更改任何其他代码的情况下切换到使用opengl的矩阵,并且可以进行旋转。完整的源代码已打开。最相关的功能如下:
calculateMatricesFromPlayer :: GameObject a -> WorldMatrices
calculateMatricesFromPlayer p@(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
有没有什么明显的迹象表明我做错了?因为一个圆中有
360度和2*pi
弧度,而pi
大约是3,所以很可能是以大约80的因子计算出来的,就是你使用角度作为sin
的输入,cos
或tan
函数将输入作为弧度,因为360/(2*pi)
约为80。这可能是弧度问题吗