camera_view
Provides a camera view transformation matrix that can can be controlled using the arrow keys, or the W, S, A, D keys, and the mouse.
var mat4 cameraView;
The controls can be customized using a handful of macros that can be optionally defined before including this library:
- CAMERA_VIEW_VELOCITY – the speed of the camera's movement in units per second (default = 1).
- CAMERA_VIEW_ANGULAR_VELOCITY – the mouse sensitivity of the camera's rotation in radians per pixel.
- CAMERA_VIEW_BUTTON – the mouse button that has to be held in order to rotate the camera. Can be defined blank to not require any mouse button. left_button is the default.
Example
#include <affine_transform>
param float cameraSpeed = 1.0 : logrange();
#define CAMERA_VIEW_VELOCITY cameraSpeed
#include <camera_view>
vec4 vertexShader(in vec3 coord) {
vec3 viewCoord = (cameraView*vec4(coord, 1.0)).xyz;
return projectPerspectiveHFOV(viewCoord, 1.0, 0.001, 1000.0);
}