twn_draw.h: new camera api
This commit is contained in:
@ -1,22 +0,0 @@
|
||||
#ifndef TWN_CAMERA_H
|
||||
#define TWN_CAMERA_H
|
||||
|
||||
#include "twn_types.h"
|
||||
#include "twn_engine_api.h"
|
||||
|
||||
/* TODO: make it cached? */
|
||||
/* for example, perspective matrix only needs recaluclation on FOV change */
|
||||
|
||||
/* first person camera class */
|
||||
typedef struct Camera {
|
||||
Vec3 pos; /* eye position */
|
||||
Vec3 target; /* normalized target vector */
|
||||
Vec3 up; /* normalized up vector */
|
||||
float fov; /* field of view, in radians */
|
||||
} Camera;
|
||||
|
||||
TWN_API Matrix4 camera_look_at(const Camera *camera);
|
||||
|
||||
TWN_API Matrix4 camera_perspective(const Camera *const camera);
|
||||
|
||||
#endif
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "twn_types.h"
|
||||
#include "twn_option.h"
|
||||
#include "twn_camera.h"
|
||||
#include "twn_engine_api.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
@ -76,8 +75,21 @@ TWN_API void draw_triangle(char const *path,
|
||||
// Vec2 scaling,
|
||||
// Rect uvs);
|
||||
|
||||
/* pushes a camera state to be used for all future unfurl_* commands */
|
||||
TWN_API void draw_camera(const Camera *camera);
|
||||
/* sets a perspective 3d camera to be used for all 3d commands */
|
||||
TWN_API void draw_camera(Vec3 position, float fov, Vec3 up, Vec3 direction);
|
||||
|
||||
/* same as draw_camera(), but with specific use case */
|
||||
/* direction and up vectors are inferred from roll, pitch and yaw parameters (in radians) */
|
||||
/* return value is direction and up vectors, so that you can use them in logic (such as controllers) */
|
||||
typedef struct DrawCameraFromPrincipalAxesResult {
|
||||
Vec3 direction;
|
||||
Vec3 up;
|
||||
} DrawCameraFromPrincipalAxesResult;
|
||||
DrawCameraFromPrincipalAxesResult TWN_API draw_camera_from_principal_axes(Vec3 position,
|
||||
float fov,
|
||||
float roll,
|
||||
float pitch,
|
||||
float yaw);
|
||||
|
||||
/* expects '*' masks that will be expanded to 6 names: 'up', 'down', 'east', 'west', 'north' and 'south' */
|
||||
TWN_API void draw_skybox(const char *paths);
|
||||
|
Reference in New Issue
Block a user