I’m try to program a 3d Rubik Cube using JOGL and I want to know how to deal with the 3D rotation I all ready know the different methods like rotate and Translate I just need a algorithm/ formula to tell the program where to draw the new cube
It’s probably just me but I’ve never seen any built in GL functions for this, so I use my own methods:
x += Sin(DEGREES_TO_RADS * angle);
y += -Cos(DEGREES_TO_RADS * angle);
I have no idea:
z += Tan(DEGREES_TO_RADS * angle); = ?
[quote]I’m try to program a 3d Rubik Cube using JOGL and I want to know how to deal with the 3D rotation I all ready know the different methods like rotate and Translate I just need a algorithm/ formula to tell the program where to draw the new cube
[/quote]
Do a google for “Matrix calculations 3D graphics” or “Vector math 3D graphics” or “Quaternion math” on the net, study them, build a vector math API, or find some example code that looks suitable for your needs. Then apply matrix translations or quat translations to all the vector points you want to rotate.
In other words, what you need is a serious math lesson in 3D vector point manipulation The good news is this is the foundation for 3D graphics and there is tons of info on the net.
Though, you may be able to do it with the basic GL rotate depending on how you do it and what you need. GL under the hood uses the same matrix formulas.
Sorry, no simple answer to this one. But for anyone doing 3D graphics, you really should research the math behind it anyway.
You could also download the vecmath-package (https://vecmath.dev.java.net/) from java3d (https://java3d.dev.java.net/) for this purpose. I don’t know if you can just extract it from the java3d-jars (not testet it), but it was fairly easy to build it for myself. You can find information about this here: https://vecmath.dev.java.net/build-instr.html
Someone told me about a very good book for learning the essentials of things like this. Any know of, or make recommendations of great books to learn the math for people just learning this stuff?