Original Post
Hey, would you help me a bit? I'm struggling with making matrices to rotate about point. My rotation part of the matrix construction looks like that:
I pass origin for rotation instead of scaling part of the matrix, and then, in vertex shader i do:
1) subtract origin from vertex
2) rotate vertex
3) add origin to vertex
It works, but it sucks. too much operations, ugly code;
I want to pass to my shader matrices that already do rotation about specific point. but really i need someone's help here. how can i make above matrix to rotate about specific point? i couldn't find any descriprion adoptable in my case.
i use opengl, if it matters.
boneMatrices[offs + 0] = cos(rx) * cos(ry);
boneMatrices[offs + 1] = -cos(rz) * sin(rx) - cos(rx)*sin(ry)*sin(rz);
boneMatrices[offs + 2] = cos(rx) * cos(rz) * sin(ry) + sin(rx) * sin(rz);
boneMatrices[offs + 4] = cos(ry) * sin(rx);
boneMatrices[offs + 5] = cos(rx) * cos(rz) - sin(rx)*sin(ry)*sin(rz);
boneMatrices[offs + 6] = cos(rz) * sin(rx) * sin(ry) - cos(rx) * sin(rz);
boneMatrices[offs + 8] = -sin(ry);
boneMatrices[offs + 9] = cos(ry) * sin(rz);
boneMatrices[offs + 10] = cos(ry) * cos(rz);
I pass origin for rotation instead of scaling part of the matrix, and then, in vertex shader i do:
1) subtract origin from vertex
2) rotate vertex
3) add origin to vertex
It works, but it sucks. too much operations, ugly code;
I want to pass to my shader matrices that already do rotation about specific point. but really i need someone's help here. how can i make above matrix to rotate about specific point? i couldn't find any descriprion adoptable in my case.
i use opengl, if it matters.