A camera with a point of view on the world

Introduced properties

fun display: GamnitDisplay

gamnit :: Camera :: display

The host GamnitDisplay
protected fun display=(display: GamnitDisplay)

gamnit :: Camera :: display=

The host GamnitDisplay
abstract fun mvp_matrix: Matrix

gamnit :: Camera :: mvp_matrix

The Model-View-Projection matrix created by this camera
fun position: Point3d[Float]

gamnit :: Camera :: position

Position of this camera in world space
protected fun position=(position: Point3d[Float])

gamnit :: Camera :: position=

Position of this camera in world space

Redefined properties

redef type SELF: Camera

gamnit $ Camera :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun display: GamnitDisplay

gamnit :: Camera :: display

The host GamnitDisplay
protected fun display=(display: GamnitDisplay)

gamnit :: Camera :: display=

The host GamnitDisplay
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
abstract fun mvp_matrix: Matrix

gamnit :: Camera :: mvp_matrix

The Model-View-Projection matrix created by this camera
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun position: Point3d[Float]

gamnit :: Camera :: position

Position of this camera in world space
protected fun position=(position: Point3d[Float])

gamnit :: Camera :: position=

Position of this camera in world space
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram gamnit::Camera Camera core::Object Object gamnit::Camera->core::Object gamnit::EulerCamera EulerCamera gamnit::EulerCamera->gamnit::Camera gamnit::UICamera UICamera gamnit::UICamera->gamnit::Camera

Parents

interface Object

core :: Object

The root of the class hierarchy.

Children

class EulerCamera

gamnit :: EulerCamera

Simple camera with perspective oriented with Euler angles (pitch, yaw, roll)
class UICamera

gamnit :: UICamera

Orthogonal camera to draw UI objects with services to work with screens of different sizes

Class definitions

gamnit $ Camera
# A camera with a point of view on the world
abstract class Camera

	# TODO make this a physical object in the world

	# The host `GamnitDisplay`
	var display: GamnitDisplay

	# Position of this camera in world space
	var position = new Point3d[Float](0.0, 0.0, 0.0)

	# The Model-View-Projection matrix created by this camera
	#
	# This method should only be called by the display at the moment
	# of drawing to the screen.
	fun mvp_matrix: Matrix is abstract
end
lib/gamnit/cameras.nit:23,1--39,3

gamnit :: cameras_cache $ Camera
redef class Camera
	private var mvp_matrix_cache: nullable Matrix = null

	private var position_cache = new Point3d[Float](0.0, 0.0, 0.0)

	# Has `position` changed from `position_cache`? Update the cache at the same time
	private fun check_position_changed: Bool
	do
		if position.x != position_cache.x or
		   position.y != position_cache.y or
		   position.z != position_cache.z then
			position_cache.x = position.x
			position_cache.y = position.y
			position_cache.z = position.z
			return true
		end
		return false
	end
end
lib/gamnit/cameras_cache.nit:20,1--38,3