Documentation ¶
Index ¶
- type Camera
- type CameraI
- type FreeCamera
- type OrbitCamera
- type RotateCamera
- type TargetCamera
- func (c *TargetCamera) Forward() mgl32.Vec3
- func (c *TargetCamera) GetCurrentZoomPercent() float32
- func (c *TargetCamera) ModelView() mgl32.Mat4
- func (c *TargetCamera) ProjectionOrthographic(width, height float32) mgl32.Mat4
- func (c *TargetCamera) Right() mgl32.Vec3
- func (c *TargetCamera) Up() mgl32.Vec3
- func (c *TargetCamera) Update(delta time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶
type Camera struct { // Entity makes the Camera a part of the world. Note that Entity.Scale is unused. // Entity.Up() is a vector pointing in the direction that the user will see as the top of the screen. entity.Entity // Near and Far are the range to render entities in front of the camera. // If the camera is expected to support zooming, be sure to make them small and large enough the change in position. // For example, if your object is 100 units away and your Zoomer can zoom in to 300%, // and zoom out to 25%, then the you must set Near<33.3 and Far>400 in order to always keep the target in view. Near, Far float32 // Field of view in radians. // This only matters if using a perspective projection and can be ignored if using an orthographic projection. FOV float32 }
Camera is the most basic camera type. It has no built in movement, zoom, or any special features. Its position and rotation can be manipulated via its embedded Entity. Note that the default Up vector is based on the embedded Entity, so you will need to rotate it if the default isn't what you want.
func (*Camera) ModelView ¶
ModelView returns a matrix used to transform from model space to camera coordinates. http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/
func (*Camera) ProjectionOrthographic ¶
ProjectionOrthographic returns a matrix used to transform from camera space to screen space.
func (*Camera) ProjectionPerspective ¶
ProjectionOrthographic returns a matrix used to transform from camera space to screen space. http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/
type FreeCamera ¶
type FreeCamera struct { // Camera is an embedded basic camera struct. Note that Camera.Up is ignored and a value of (0,1,0) is used. // This Up vector is rotated by the Camera.Entity.Rotation, so if you want a different initial rotation then // modify that. Otherwise leave it to the user to modify rotation and position via the Update function. Camera // MoveSpeed determines how much the camera's position can change per second. MoveSpeed float32 // RotateSpeed determines how many radians in total the camera can rotate per second. RotateSpeed float32 }
FreeCamera is a camera that moves freely in space, relative to its own orientation.
func NewFreeCamera ¶
func NewFreeCamera() *FreeCamera
func (*FreeCamera) Update ¶
func (c *FreeCamera) Update(delta time.Duration)
type OrbitCamera ¶
type OrbitCamera struct { Camera // Target is the entity which the OrbitCamera always faces. The OrbitCamera.Camera.Entity.Rotation determines // which direction it faces it from. Target entity.Target // TargetOffset determines how far the camera is positioned from the target. TargetOffset float32 // RotateSpeed determines how many radians in total the camera can rotate per second. RotateSpeed float32 }
OrbitCamera is a camera that always faces a target, but unlike TargetCamera, it moves in an orbit around the target.
func NewOrbitCamera ¶
func NewOrbitCamera(target entity.Target, offset float32) *OrbitCamera
func (*OrbitCamera) Update ¶
func (c *OrbitCamera) Update(delta time.Duration)
type RotateCamera ¶
type RotateCamera struct { Camera // Target is the entity which the OrbitCamera always faces. The OrbitCamera.Camera.Entity.Rotation determines // which direction it faces it from. Target entity.Target // TargetOffset determines how far the camera is positioned from the target. TargetOffset float32 // RotateSpeed determines how many radians in total the camera can rotate per second. RotateSpeed float32 }
RotateCamera is a camera that always faces a target. Unlike TargetCamera which always stays at a fixed position in relation to the target, and unlike OrbitCamera which moves in an orbit around the target, the RotateCamera rotates around a particular axis at the target's location. You can think of its movement like latitude and longitude on the Earth, if the Earth were the target.
func NewRotateCamera ¶
func NewRotateCamera(target entity.Target, offset float32) *RotateCamera
func (*RotateCamera) Update ¶
func (c *RotateCamera) Update(delta time.Duration)
type TargetCamera ¶
type TargetCamera struct { Camera // Target is an entity which the TargetCamera follows. The camera always faces it and stays TargetOffset away from it. Target entity.Target // TargetOffset determines where the camera is positioned in relation to the target. // Camera.Target.Position + Camera.TargetOffset == Camera.Position TargetOffset mgl32.Vec3 // Zoomer handles camera zoom. Zoomer zoom.Zoom }
TargetCamera is a camera that is always positioned at an offset from the target entity. Target Position + Offset = Camera Position. Zoomer can modify the length of the offset. The camera always looks toward the target with the provided Up vector determining what orientation the viewport has. Create one using NewTargetCamera unless you know what you're doing.
func NewTargetCamera ¶
func NewTargetCamera(target entity.Target, offset mgl32.Vec3) *TargetCamera
func (*TargetCamera) Forward ¶
func (c *TargetCamera) Forward() mgl32.Vec3
func (*TargetCamera) GetCurrentZoomPercent ¶
func (c *TargetCamera) GetCurrentZoomPercent() float32
func (*TargetCamera) ModelView ¶
func (c *TargetCamera) ModelView() mgl32.Mat4
ModelView returns a matrix used to transform from model space to camera coordinates. http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/
func (*TargetCamera) ProjectionOrthographic ¶
func (c *TargetCamera) ProjectionOrthographic(width, height float32) mgl32.Mat4
ProjectionOrthographic returns a matrix used to transform from camera space to screen space.
func (*TargetCamera) Right ¶
func (c *TargetCamera) Right() mgl32.Vec3
func (*TargetCamera) Up ¶
func (c *TargetCamera) Up() mgl32.Vec3
Up returns a vector perpendicular to both the Forward and Right vectors. Given the perpendicular constraint, it's the most similar vector to entity.Up as possible. In the event that the the camera's Forward vector is the same as entity.Up, there is no single "most similar to Up" so it defaults to entity.Right.
func (*TargetCamera) Update ¶
func (c *TargetCamera) Update(delta time.Duration)