Recommended Posts

I've been trying for days to rotate a cube based on the mouse position just like this one:
http://images.flashkit.com/movies/3D/Engines/Real-Tim-Ryan_Whe-1937/Real-Tim-Ryan_Whe-1937.swf
I can't get it to do a full 360, it just kinda wiggles... I think i have the formula right, but I believe I'm missing something.
Formula(?)
y1 = oldY * cos(newX) + oldZ * sin(newX)
z1 = oldY * -sin(newX) + oldZ * cos(newX)
x1 = oldX * cos(newY) + z1 * -sin(newY)
z2 = oldX * sin(newX) + z1 * cos(newY)
x2 = x1 * cos(-newX) + y1 * sin(-newX)
y2 = x1 * -sin(-newX) + y1 * cos(-newX)
I'm rendering the cube on a 500x500 form, with the mouse relative to the center. I scaled the mouse position by 1000, so the min/max value is -/+ 0.25.
I know I have to track the angle, and update it based on the mouse position, but after looking at the forums and googling I'm still confused..
heres my current code: