Skip to content

atl/sm/camera

import "atl/sm/camera"

The game camera (sm.camera). Reading works anywhere; setters require a scripted state.

func Position() sm.Vec3
func Rotation() sm.Quat
func Direction() sm.Vec3
func Right() sm.Vec3
func Up() sm.Vec3

The camera's position, rotation and directions.

func Fov() float64
func DefaultFov() float64

The current and default field of view in degrees.

func DefaultPosition() sm.Vec3
func DefaultRotation() sm.Quat

The camera's default position and rotation.

func CurrentState() int

The current state as a number (compare with State values).

func SetState(s State)

Switches camera state. Set a scripted state (e.g. CutsceneTP) to control position, rotation and fov; set Default to give control back.

func SetStateByName(name string)

Switches camera state by engine name (sm.camera.state[name]), for states not in the enum, e.g. "forcedFP".

func SetPosition(p sm.Vec3)
func SetRotation(q sm.Quat)
func SetDirection(d sm.Vec3)
func SetFov(fov float64)

Sets position, rotation, direction or fov while in a scripted state.

func Shake(strength float64)

Shakes the camera with the given strength.

func SetPullback(step, seatedStep int)

Sets the third person zoom steps (on foot / seated).

func SetSeatLockedPullback(distance float64)
func SetSeatLockedUpOffset(offset float64)
func SetSeatLockedLocalDirection(d sm.Vec3)
func SetSeatLockedLocalUp(up sm.Vec3)

Settings for SeatLockedCamera: pullback distance, up offset and local orientation.

func SetUnseatDirection(worldDirection *sm.Vec3)

Which way the character faces after leaving the seat (nil for the default).

func SphereCast(radius float64, start, direction sm.Vec3) float64

How far a sphere can travel from start along direction before hitting something.

type State int

Camera modes (sm.camera.state).

const (
Default State = 1
CutsceneFP State = 2
CutsceneTP State = 3
ForcedTP State = 4
GyroSeatFP State = 5
GyroSeatTP State = 6
ScriptedTP State = 7
SeatLockedCamera State = 8
)
type Pullback struct {
Step, SeatedStep int
}

Third person zoom steps.

func ReadPullback() Pullback

Reads the third person zoom steps.