矩阵规模问题

时间:2015-08-28 20:36:16

标签: c++ opengl

我正在尝试应用规模,但没有任何反应。看起来scale()矩阵不正确?我试着简单地复制公式,但是id没有帮助。

enter image description here

GLM ::规模(MAT4,VEC3);

任何帮助都会表示赞赏。

void specialKey(int key, int x, int y) {
    switch (key) {
    case 100: //left
        if (transop == view) Transform::left(amount, eye, up);
        else if (transop == scale)
        {
            sx -= amount * 0.01;
            std::cout << "left scale";
        }
        break;
    case 101: //up
        if (transop == view) Transform::up(amount, eye, up);
        else if (transop == scale) sy += amount * 0.01;
        break;
    case 102: //right
        if (transop == view) Transform::left(-amount, eye, up);
        else if (transop == scale) sx += amount * 0.01;
        break;
    case 103: //down
        if (transop == view) Transform::up(-amount, eye, up);
        else if (transop == scale) sy -= amount * 0.01;
        break;
    }
    glutPostRedisplay();
}
mat4 Transform::scale(const float &sx, const float &sy, const float &sz) 
{

        glm::mat4 mat = glm::mat4(
            glm::vec4(sx, 0.0f, 0.0f, 0.0f),
            glm::vec4(0.0f, sy, 0.0f, 0.0f),
            glm::vec4(0.0f, 0.0f, sz, 0.0f),
            glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)
        );
        glm::vec3 vec_scale = vec3(2.0f);
        mat4 ret = glm::scale(mat, vec_scale);

    return ret;
}

0 个答案:

没有答案