Closed Pinkolik closed 4 years ago
Code looks good to me. Can you provide a full MCVE (minimal complete and verifiable example)?
Do the cubePositions[]
possibly change? And what does shader.setMatrix4f(...)
look like?
Here's the full project. Don't worry, it's small, only main programm class and two helper classes. worlds.zip As far as I can see cubePositions[] are not modified in any way. And shader.setMatrix4f(...) looks like this:
public void setMatrix4f(final String name, final FloatBuffer matrix4f) {
int location = glGetUniformLocation(shaderProgramId, name);
glUniformMatrix4fv(location, false, matrix4f);
}
Okay, the problem is that the rotation axis in your Matrix4f.rotate(4-floats) call in your code is not normalized/unit. See the JavaDocs of this method:
The axis described by the three components needs to be a unit vector.
Normalization solved the problem, thank you very much! I will check javadocs first from now on.
Hello! I've been studying OpenGL with help of this great site https://learnopengl.com/. And yesterday I got to the lesson about coordinate systems (https://learnopengl.com/Getting-started/Coordinate-Systems) when I encountered a problem, which I think can be related to JOML. You see, I'm coding in Java so I use LWJGL and JOML. I think I've done all steps correctly but my result is different from the one desribed in the lesson. I'm not too good in matricies and algebra, so I'm stuck and can't figure out what's wrong. Here's how it looks like: (https://imgur.com/a/QjJO1Rh) You can notice that it looks like the cubes move towards the camera and grow in diagonal. I'm sure that's not correct. I've tried all kinds of rotations, but I always get this result. So I hope you could help me. Here's my code of the main loop.
And here's my vertex shader:
Thank you in advance!