camera

package
v0.0.0-...-b63c11a Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2018 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package camera contains common camera types used for rendering 3D scenes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Camera

type Camera struct {
	core.Node // Embedded Node
	// contains filtered or unexported fields
}

Camera is the base camera which is normally embedded in other camera types.

func (*Camera) GetCamera

func (cam *Camera) GetCamera() *Camera

GetCamera satisfies the ICamera interface.

func (*Camera) Initialize

func (cam *Camera) Initialize()

Initialize initializes the base camera. Normally used by other camera types which embed this base camera.

func (*Camera) LookAt

func (cam *Camera) LookAt(target *math32.Vector3)

LookAt rotates the camera to look at the specified target position. This method does not support objects with rotated and/or translated parent(s). TODO: maybe move method to Node, or create similar in Node.

func (*Camera) Project

func (cam *Camera) Project(v *math32.Vector3) (*math32.Vector3, error)

Project satisfies the ICamera interface and must be implemented for specific camera types.

func (*Camera) SetRaycaster

func (cam *Camera) SetRaycaster(rc *core.Raycaster, x, y float32) error

SetRaycaster satisfies the ICamera interface and must be implemented for specific camera types.

func (*Camera) SetUp

func (cam *Camera) SetUp(up *math32.Vector3)

SetUp sets the camera up vector.

func (*Camera) Target

func (cam *Camera) Target() math32.Vector3

Target get the current target position.

func (*Camera) Unproject

func (cam *Camera) Unproject(v *math32.Vector3) (*math32.Vector3, error)

Unproject satisfies the ICamera interface and must be implemented for specific camera types.

func (*Camera) Up

func (cam *Camera) Up() math32.Vector3

Up get the current camera up vector.

func (*Camera) ViewMatrix

func (cam *Camera) ViewMatrix(m *math32.Matrix4)

ViewMatrix returns the current view matrix of this camera.

type ICamera

type ICamera interface {
	GetCamera() *Camera
	ViewMatrix(*math32.Matrix4)
	ProjMatrix(*math32.Matrix4)
	Project(*math32.Vector3) (*math32.Vector3, error)
	Unproject(*math32.Vector3) (*math32.Vector3, error)
	SetRaycaster(rc *core.Raycaster, x, y float32) error
}

ICamera is interface for all camera types.

type Orthographic

type Orthographic struct {
	Camera // Embedded camera
	// contains filtered or unexported fields
}

Orthographic is an orthographic camera.

func NewOrthographic

func NewOrthographic(left, right, top, bottom, near, far float32) *Orthographic

NewOrthographic creates and returns a pointer to a new orthographic camera with the specified parameters.

func (*Orthographic) Planes

func (cam *Orthographic) Planes() (left, right, top, bottom, near, far float32)

Planes returns the coordinates of the camera planes.

func (*Orthographic) ProjMatrix

func (cam *Orthographic) ProjMatrix(m *math32.Matrix4)

ProjMatrix satisfies the ICamera interface.

func (*Orthographic) SetZoom

func (cam *Orthographic) SetZoom(zoom float32)

SetZoom sets the zoom factor of the camera.

func (*Orthographic) Zoom

func (cam *Orthographic) Zoom() float32

Zoom returns the zoom factor of the camera.

type Perspective

type Perspective struct {
	Camera // Embedded camera
	// contains filtered or unexported fields
}

Perspective is a perspective camera.

func NewPerspective

func NewPerspective(fov, aspect, near, far float32) *Perspective

NewPerspective creates and returns a pointer to a new perspective camera with the specified parameters.

func (Perspective) Aspect

func (cam Perspective) Aspect() float32

Aspect returns the current camera aspect ratio.

func (*Perspective) Far

func (cam *Perspective) Far() float32

Far returns the current camera far plane Z coordinate.

func (*Perspective) Fov

func (cam *Perspective) Fov() float32

Fov returns the current camera FOV (field of view) in degrees.

func (*Perspective) Near

func (cam *Perspective) Near() float32

Near returns the current camera near plane Z coordinate.

func (*Perspective) ProjMatrix

func (cam *Perspective) ProjMatrix(m *math32.Matrix4)

ProjMatrix satisfies the ICamera interface.

func (*Perspective) Project

func (cam *Perspective) Project(v *math32.Vector3) (*math32.Vector3, error)

Project transforms the specified position from world coordinates to this camera projected coordinates.

func (*Perspective) SetAspect

func (cam *Perspective) SetAspect(aspect float32)

SetAspect sets the camera aspect ratio (width/height).

func (*Perspective) SetFov

func (cam *Perspective) SetFov(fov float32)

SetFov sets the camera field of view in degrees.

func (*Perspective) SetRaycaster

func (cam *Perspective) SetRaycaster(rc *core.Raycaster, sx, sy float32) error

SetRaycaster sets the specified raycaster with this camera position in world coordinates pointing to the direction defined by the specified coordinates unprojected using this camera.

func (*Perspective) Unproject

func (cam *Perspective) Unproject(v *math32.Vector3) (*math32.Vector3, error)

Unproject transforms the specified position from camera projected coordinates to world coordinates.

Directories

Path Synopsis
Package control implements controllers for cameras
Package control implements controllers for cameras

Jump to

Keyboard shortcuts

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