I'm exploring the seedy underbelly of 3d. And I'm trying to get a camera to orbit a point. This is what I've got so far. The numbers are for percentage system so with virtual resolution it will be very fine movements.
cameraZoom# = 25.0
angleX# = 0
angleY# = 0
prevX# = GetPointerX()
prevY# = GetPointerY()
Do
moveLeft = GetPointerX() < prevX#
moveRight = GetPointerX() > prevX#
moveUp = GetPointerY() < prevY#
moveDown = GetPointerY() > prevY#
If GetRawMouseRightState()
angleX# = angleX# + (0 - moveUp) + moveDown
angleY# = angleY# + (0 - moveLeft) + moveRight
EndIf
x# = (Sin(angleY#) * Cos(angleX#)) * cameraZoom#
y# = Sin(angleX#) * cameraZoom#
z# = (Cos(angleY#) * Cos(angleX#)) * cameraZoom#
SetCameraPosition(1, x#, y#, z#)
SetCameraLookAt(1, 0.0, 0.0, 0.0, 0.0)
prevX# = GetPointerX()
prevY# = GetPointerY()
Sync()
Loop
It works pretty well to start with, but get's kind of weird when you reach the opposite side of the point. So does anyone happen to have a suggestion on how to get a smooth movement all the way around?