GLUtil-0.8.6: Miscellaneous OpenGL utilities.

Safe HaskellNone
LanguageHaskell98

Graphics.GLUtil.Camera3D

Contents

Description

A Camera represents a coordinate frame into which 3D points may be transformed. For rendering purposes, it is often helpful to combine a transformation matrix computed from a Camera by camMatrix -- that transforms points into the camera's coordinate frame -- with a perspective projection matrix, as created by projectionMatrix.

Synopsis

Camera movement

data Camera a Source

A Camera may be translated and rotated to provide a coordinate frame into which 3D points may be transformed.

Constructors

Camera 

Fields

forward :: V3 a
 
upward :: V3 a
 
rightward :: V3 a
 
orientation :: Quaternion a
 
location :: V3 a
 

panRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a Source

Pan a camera view (turn side-to-side) by an angle given in radians. Panning is about the world's up-axis as captured by the initial camera state (e.g. the positive Y axis for fpsCamera).

pan :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a Source

Pan a camera view (turn side-to-side) by an angle given in degrees. Panning is about the world's up-axis as captured by the initial camera state (e.g. the positive Y axis for fpsCamera).

tiltRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a Source

Tilt a camera view (up-and-down) by an angle given in radians. Tilting is about the camera's horizontal axis (e.g. the positive X axis for fpsCamera).

tilt :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a Source

Tilt a camera view (up-and-down) by an angle given in degrees. Tilting is about the camera's horizontal axis (e.g. the positive X axis for fpsCamera).

rollRad :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a Source

Roll a camera view about its view direction by an angle given in radians. Rolling is about the camera's forward axis (e.g. the negative Z axis for fpsCamera).

roll :: (Epsilon a, RealFloat a) => a -> Camera a -> Camera a Source

Roll a camera view about its view direction by an angle given in degrees. Rolling is about the camera's forward axis (e.g. the negative Z axis for fpsCamera).

dolly :: (Conjugate a, Epsilon a, RealFloat a) => V3 a -> Camera a -> Camera a Source

Translate a camera's position by the given vector.

Camera initialization

rosCamera :: (Epsilon a, RealFloat a) => Camera a Source

A camera at the origin with its up-axis coincident with the positive Z axis. This is the convention used by the ROS robotics platform.

fpsCamera :: (Epsilon a, RealFloat a) => Camera a Source

A camera at the origin with its up-axis coincident with the positive Y axis. This is the convention used by "first-person shooter" (fps) video games.

Matrices

projectionMatrix :: (Conjugate a, Epsilon a, RealFloat a) => a -> a -> a -> a -> M44 a Source

projectionMatrix fov aspect near far produces a perspective projection matrix with the specified vertical field of view (FOV), given in radians, aspect ratio, and near and far clipping planes.

orthoMatrix :: (Num a, Fractional a) => a -> a -> a -> a -> a -> a -> M44 a Source

orthoMatrix left right top bottom near far produces a parallel projection matrix with the specified left, right, top, bottom, near and far clipping planes.

camMatrix :: (Conjugate a, Epsilon a, RealFloat a) => Camera a -> M44 a Source

Produce a transformation matrix from a Camera. This matrix transforms homogenous points into the camera's coordinate frame.

Miscellaneous

deg2rad :: RealFloat a => a -> a Source

Convert degrees to radians.