fps

package
v0.0.0-...-00121b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package camera provides implementations of different camera models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FPS

type FPS struct {
	Pos    mgl32.Vec3
	Target mgl32.Vec3
	Up     mgl32.Vec3
	Right  mgl32.Vec3
	Fov    float32
	Near   float32
	Far    float32
	// contains filtered or unexported fields
}

FPS moves in the view direction while the viewing direction can be changed.

func Make

func Make(width, height int, pos mgl32.Vec3, speed, fov, near, far float32) FPS

Make creates a FPS with the viewport of width and height and a radius from the origin. It assumes a field of view of 45 degrees and a near and far plane at 0.1 and 100.0 respectively.

func MakeDefault

func MakeDefault(width, height int, pos mgl32.Vec3, speed float32) FPS

MakeDefault creates a FPS camera with the viewport of width and height and a position. It assumes a field of view of 45 degrees and a near and far plane at 0.1 and 100.0 respectively.

func New

func New(width, height int, pos mgl32.Vec3, speed, fov, near, far float32) *FPS

New creates a reference to a FPS with the viewport of width and height and a radius from the origin. It assumes a field of view of 45 degrees and a near and far plane at 0.1 and 100.0 respectively.

func NewDefault

func NewDefault(width, height int, pos mgl32.Vec3, speed float32) *FPS

NewDefault creates a reference to a FPS camera with the viewport of width and height and a position. It assumes a field of view of 45 degrees and a near and far plane at 0.1 and 100.0 respectively.

func (*FPS) GetOrtho

func (camera *FPS) GetOrtho() mgl32.Mat4

GetOrtho returns the orthographic projection of the camera.

func (*FPS) GetPerspective

func (camera *FPS) GetPerspective() mgl32.Mat4

GetPerspective returns the perspective projection of the camera.

func (*FPS) GetPos

func (camera *FPS) GetPos() mgl32.Vec3

GetPos returns the position of the camera in worldspace

func (*FPS) GetView

func (camera *FPS) GetView() mgl32.Mat4

GetView returns the view matrix of the camera.

func (*FPS) GetViewPerspective

func (camera *FPS) GetViewPerspective() mgl32.Mat4

GetViewPerspective returns P*V.

func (*FPS) OnCursorPosMove

func (camera *FPS) OnCursorPosMove(x, y, dx, dy float64) bool

OnCursorPosMove is a callback handler that is called every time the cursor moves.

func (*FPS) OnKeyPress

func (camera *FPS) OnKeyPress(key, action, mods int) bool

OnKeyPress is a callback handler that is called every time a keyboard key is pressed.

func (*FPS) OnMouseButtonPress

func (camera *FPS) OnMouseButtonPress(leftPressed, rightPressed bool) bool

OnMouseButtonPress is a callback handler that is called every time a mouse button is pressed or released.

func (*FPS) OnMouseScroll

func (camera *FPS) OnMouseScroll(x, y float64) bool

OnMouseScroll is a callback handler that is called every time the mouse wheel moves.

func (*FPS) Rotate

func (camera *FPS) Rotate(theta, phi float32)

Rotate adds delta angles in degrees to the theta and phi angles. Where theta is the vertical angle and phi the horizontal angle.

func (*FPS) SetPos

func (camera *FPS) SetPos(pos mgl32.Vec3)

SetPos updates the target point of the camera. It requires to call Update to take effect.

func (*FPS) Update

func (camera *FPS) Update()

Update recalculates the position of the camera. Call it every time after calling Rotate or Zoom.

func (*FPS) Zoom

func (camera *FPS) Zoom(distance float32)

Zoom changes the radius of the camera to the target point.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL