In OpenGL for Java, Matrix4f has a transform() method. I am trying to look at an example using this, but want to translate it into using GLM. But I cannot find an equivalent to transform() in GLM, nor do I grasp what transform() really does.
For example:
In Java:
Vector4f direction = new Vector4f(x, y, z, 1);
Matrix4f rotationMatrix = new Matrix4f();
… set rotationMatrix …
Matrix4f.transform(rotationMatrix, direction, direction);
With GLM in C++:
vec4 direction = vec4(x, y, z, 1);
mat4 rotationMatrix = mat4();
… set rotationMatrix …
??? What to use instead of transform() ???
The GLM provides the *-operator. It can be used similar the operators in OpenGL Shading Language (GLSL) e.g.:
vec4 direction = vec4(x, y, z, 1.0f);
mat4 rotationMatrix = mat4(1.0f);
direction = rotationMatrix * direction;
Note, if you want to construct an Identity matrix then you'e to pass a single scalar (1.0) to the constructor of mat4 (e.g. mat4(1.0f)). mat4() constructs an uninitialized matrix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With