【问题标题】:Is GLKMatrix4Translate correct?GLKMatrix4Translate 是否正确?
【发布时间】:2012-05-01 23:29:34
【问题描述】:

我不确定我是不是对事情有误解,或者我只是累了。 考虑下面的两行代码。

GLKMatrix4 projection = GLKMatrix4Translate(_perspective, 0, 0, -5);
GLKMatrix4 projection = GLKMatrix4Multiply(_perspective, GLKMatrix4MakeTranslation(0, 0, -5));    

我希望它们是等价的。但他们不是。 GLKMatrix4Translate 的来源是:

static __inline__ GLKMatrix4 GLKMatrix4Translate(GLKMatrix4 matrix, float tx, float ty, float tz)
{
    GLKMatrix4 m = { matrix.m[0], matrix.m[1], matrix.m[2], matrix.m[3],
                     matrix.m[4], matrix.m[5], matrix.m[6], matrix.m[7],
                     matrix.m[8], matrix.m[9], matrix.m[10], matrix.m[11],
                     matrix.m[0] * tx + matrix.m[4] * ty + matrix.m[8] * tz + matrix.m[12],
                     matrix.m[1] * tx + matrix.m[5] * ty + matrix.m[9] * tz + matrix.m[13],
                     matrix.m[2] * tx + matrix.m[6] * ty + matrix.m[10] * tz + matrix.m[14],
                     matrix.m[15] };
    return m;
}

但是我希望最后一行是:

matrix.m[3] * tx + matrix.m[7] * ty + matrix.m[11] * tz + m[15];

我是正确的,还是在疲倦的迷雾中?

【问题讨论】:

标签: glkit


【解决方案1】:

我认为您是对的,翻译中一定存在错误。我使用 MakeTranslation+Multiply 而不是 Translate 函数,因为 m[15] 始终保持不变。

【讨论】:

    猜你喜欢
    • 2010-11-20
    • 2019-12-05
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    • 2019-11-15
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多