Hi all,
I’m trying to rotate an object around an axis (cube around Y), and I actually did it, but the thing is that it is rotating around one of its edges.
Using simple rotation matrix:
[ATTACH=CONFIG]921[/ATTACH]
Angle is changing in cycle, then I am just sending updated matrix to the vertex shader and multiplying on each vertex.
Vertex shader:
#version 330 core
layout(location = 0) in vec3 VertexPosition;
in vec2 texcoord;
uniform vec4 Translation;
uniform mat4 MVP;
uniform mat3 Rotation;
out vec2 fragTexcoord;
void main(){
gl_Position = MVP * ( ( vec4( VertexPosition * Rotation, 1 ) + Translation ));
fragTexcoord = texcoord;
}
Screenshots:
[ATTACH=CONFIG]922[/ATTACH] [ATTACH=CONFIG]923[/ATTACH]
Can someone explain me how to rotate my cube around an axis that comes through centers of oposite sides?