Search code examples
javaopengl3drotationrubiks-cube

What is the best way to rotate cube in Opengl


I have a Rubik's cube displayed using OpenGl in a Java Eclipse application and I want to "rotate" this cube in response to mouse events.

I started with a "naive" (isn't it ?) solution as described here: OpenGL - moving camera with mouse. With such solution in addition to the problem described (my problem is maybe the same ???) when I rotate 90 degrees according X-Axis to get 'upside front' i am not to rotate anymore according initial Y-Axis to get the new front on the right. Because of the first 90 degrees rotaion I will have now to rotate according to Z to get expected behavior.

May be using gluLookAt utility method is easiest than using modeling transformation in this case ?


Solution

  • Would arcball make you happy ? (it should)

    (I don't usually link to NeHe, but this one is independent from openGL)