简体   繁体   English

OpenGL 4x4矩阵通过X轴移动对象

[英]OpenGL 4x4 Matrix move object by X-axis

I have an object in 2D scene in my iOS app. 我的iOS应用程序中的2D场景中有一个对象。 Position of the object is given by matrix 对象的位置由矩阵给出

Vect3F translation = Vect3F(0.0f, 0.0f, 0.0f);

Matrix44F translationMatrix({
            1, 0, 0, translation[0],
            0, 1, 0, translation[1],
            0, 0, 1, translation[2],
            0, 0, 0, 1
});

I need to move the object by X-axis by 10 points. 我需要将对象沿X轴移动10点。 How do I achieve that? 我该如何实现? I am new to OpenGL. 我是OpenGL新手。

You need to change translation vector. 您需要更改翻译向量。 X coordinate is the first. X坐标为第一个。 Try this: 尝试这个:

Vect3F translation = Vect3F(10.0f, 0.0f, 0.0f);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM