【问题标题】:OpenGL rotation too sensitiveOpenGL旋转太敏感
【发布时间】:2014-02-09 01:48:43
【问题描述】:

我最近从使用已弃用的 gl_*Matrix 切换到自己处理矩阵。一切似乎都运行良好,除了旋转大约是应有的 80 倍。我可以切换到使用 opengl 的矩阵而不更改任何其他代码,并且旋转很好。完整的源代码在Github。最相关的功能在这里:

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

有什么明显的我做错了吗?

【问题讨论】:

  • 这可能是弧度问题

标签: opengl haskell matrix linear-algebra


【解决方案1】:

由于圆中有360 度数和2*pi 弧度,pi 大约为 3,因此您使用度数作为sin 的输入似乎很有可能超出了大约 80 倍, costan 函数将输入作为弧度,因为 360/(2*pi) 约为 80。

【讨论】:

    猜你喜欢
    • 2012-03-11
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多