Even though you’re 13, if you’re into this stuff, I recommend reading Lengyel’s book, “Mathematics for 3D Game Programming and Computer Graphics”. It’s good learning material and when I look up the most common stuff, this is the book I go to. If you’re not solid in 3D math, don’t slip anything. Read it, understand it and be amazed at how awesome math is.
i often copy it from elsewhere and change bits around to learn what certain pieces do
That’s fine if you’re trying to figure out what a specific funtion does. However, if you want to really do 3D programming, there is absolutely no way around the appropriate math portions.
I actually work more with lwjgl rather than opengl, though the calls/code are the same.
The interface doesn’t change how the encapsulated GL calls operate. LWJGL is just a wrapper usable with Java (since OpenGL implementations are usually implemented in C and LWJGL needs to interface with the C library through the JNI).
I also don’t go to school (i am 13)
At that age, aren’t you supposed to go to school? (Don’t know where you’re coming from.)
Regarding your problem at hand, for now, it should suffice to know that matrix rotation leads to rotation of a position around the origin, i.e. (0, 0, 0, 1), of the current coordinate system. There is nothing you can change about that, but there’s a simple trick to rotate around an arbitrary point in space: you translate the center of your object to the origin, then rotate, and then translate it back to whatever position you want it to be located at. If the original and resulting position are the same, you effectively rotated around your objects center.
Now, a translation is nothing more than moving a point from one place to another. To achieve the above, in 3D you’ll need a 3D vector to describe the direction of the translation and the distance you want to translate the object. The distance is implicit - it is the length of the translation vector. So, if you have a vertex at position (1, 1, 1) and want to translate it to the origin, you’ll need a translation vector (-1, -1, -1). The resulting position will be (0, 0, 0) (because (1,1, 1) + (-1, -1, -1) = (0, 0, 0))
To translate it back to where it came from, you’ll need to translate in the inverse direction, i.e. you need to negate the translation vector: (-1, -1, -1) then becomes -1 * (-1, -1, -1) = (1, 1, 1). Apply that to the current position (0, 0, 0) and you’ll get (0, 0, 0) + (1, 1, 1) = (1, 1, 1). And where back to our original position.
Does that make sense to you? Does it help?