gaubtas123

07-07-2015, 12:40 PM

Hello, normally I wouldn't post but I really can't find a clear answer anywhere on the internet. Basically I got a vector, then multiply it by a matrix and then I want to do something some action to restore it back to the way it was. It looks something like this.

glm::vec4 b = transform.GetMVP(camera) * glm::vec4(model.positions[i], 1.0);

b.x = mx * b.w;

b.y = my * b.w;

glm::vec4 c = (some magic function that does opposite what multiplying by a matrix does) * b;

//transform.GetMVP(camera) is the 4x4 matrix

Solved the problem using glm:: project/Unproject. Feeling stupid now. Sorry for the thread.

glm::vec4 b = transform.GetMVP(camera) * glm::vec4(model.positions[i], 1.0);

b.x = mx * b.w;

b.y = my * b.w;

glm::vec4 c = (some magic function that does opposite what multiplying by a matrix does) * b;

//transform.GetMVP(camera) is the 4x4 matrix

Solved the problem using glm:: project/Unproject. Feeling stupid now. Sorry for the thread.