2014-02-09 61 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.