|
*** quite a useful function
Moves the camera on a sphere around the given location.
The point on the sphere is determined according to the mouse location.
This function is very easy to use. Just call it and see how it works.
A typical use would be to call this function before or after each call to 3DSTATE_engine_render()
Parameters:
camera_handle:
the camera handle
center:
the center of the sphere on which the camera will move
The camera will always be directed towards the center
radius:
The radius of the sphere on which the camera moves
The camera will always be at "radius" distance from the center.
activation_trigger:
Sometimes you might want to move the camera only when dragging
with the mouse left button down (for example) as common in 3D modeling programs
In games you might want to move the camera when the mouse move (without any mouse key being pressed)
This parameter is used to tune the way the function works.
The activation_trigger can be any of Windows Virtual-Key Codes
For example VK_LBUTTON (Mouse left button). These constanst are define by Windows
See examples below. Using activation_trigger=0 has the advantage
that by putting the cursor in the middle of the rendering window
we get back to the normal position.
reverse_direction: YES or NO. If YES is given then the direction of the camera movement is reversed
Example A:
Moves around the origin when the mouse moves (no trigger)
Call this code before each render
double center[3]={0,0,0};
DWORD camera=STATE_camera_get_current();
STATE_camera_move_around_point_according_to_mouse_position(camera, center, 10, 0, NO);
Example B:
Moves around the origin when the left mouse button is being dragged
Call this code before each render
double center[3]={0,0,0};
DWORD camera=STATE_camera_get_current();
STATE_camera_move_around_point_according_to_mouse_position(camera, center, 10, VK_LBUTTON, NO);
Example C:
Moves around the origin when the key 'A' on the keyboard is pressed (and the mouse moves)
Call this code before each render
double center[3]={0,0,0};
DWORD camera=STATE_camera_get_current();
STATE_camera_move_around_point_according_to_mouse_position(camera, center, 10, 'A', NO);
Example D:
Moves the camera around a flying airplane.
Call this code before each render
double center[3];
STATE_object_get_location1(my_plane, center);
DWORD camera=STATE_camera_get_current();
STATE_camera_move_around_point_according_to_mouse_position(camera, center, 10, 0, NO);
|