3D-Rotating Algorithm

On 2D-Scene,I can simply use the change in vertical and horizontal position when mouse movement to rotate and translate any object.
But on 3D-Scene,there are some problems occured.

  1. If object is rotated until the x-y plane(default plane) is replaced by the y-z one,then I try to translate object along the horizontal axis by use the horizontal position change when mouse movement. The object is moved into or out of the scene.
  2. Similarly problem occured when I rotated.

Have anyone to give me some agorithm or sampling code to do so.?

Thanks in advance.

amstel.

Jeff Moloffee has a sample space shooter on his website: nehe.gamedev.net. There so called quaternions are used for free movement in space. I didn’t read the code, but from the description it should be, what you are looking for.

Marc