Added camera orbit controls.
This commit is contained in:
@ -35,4 +35,15 @@ void cameraOrtho(camera_t *camera,
|
||||
) {
|
||||
matrixIdentity(&camera->projection);
|
||||
matrixOrtho(&camera->projection, left, right, bottom, top, camNear, camFar);
|
||||
}
|
||||
|
||||
void cameraOrbit(camera_t *camera,
|
||||
float distance, float yaw, float pitch,
|
||||
float targetX, float targetY, float targetZ
|
||||
) {
|
||||
float cy = cos(pitch);
|
||||
float x = distance * sin(yaw) * cy;
|
||||
float y = distance * sin(pitch);
|
||||
float z = distance * cos(yaw) * cy;
|
||||
cameraLookAt(camera, x, y, z, targetX, targetY, targetZ);
|
||||
}
|
@ -65,4 +65,20 @@ void cameraPerspective(camera_t *camera,
|
||||
*/
|
||||
void cameraOrtho(camera_t *camera,
|
||||
float left, float right, float bottom, float top, float camNear, float camFar
|
||||
);
|
||||
|
||||
/**
|
||||
* Update a camera to orbit around a point.
|
||||
*
|
||||
* @param camera Camera to update
|
||||
* @param distance Distance from the point
|
||||
* @param yaw Yaw (Y axis) rotation.
|
||||
* @param pitch Pitch (X/Z axis) rotation.
|
||||
* @param targetX X point to orbit around.
|
||||
* @param targetY Y point to orbit around.
|
||||
* @param targetZ Z point to orbit around.
|
||||
*/
|
||||
void cameraOrbit(camera_t *camera,
|
||||
float distance, float yaw, float pitch,
|
||||
float targetX, float targetY, float targetZ
|
||||
);
|
Reference in New Issue
Block a user