gamnit :: ParallelLightCamera :: _light
gamnit :: ParallelLightCamera :: light
gamnit :: ParallelLightCamera :: light=
gamnit :: ParallelLightCamera :: rotation_matrix
Rotation matrix produced by the current rotation of the cameragamnit $ ParallelLightCamera :: SELF
Type of this instance, automatically specialized in every classgamnit $ ParallelLightCamera :: check_position_changed
Hasposition
changed from position_cache
? Update the cache at the same time
gamnit $ ParallelLightCamera :: mvp_matrix
The Model-View-Projection matrix created by this cameragamnit :: ParallelLightCamera :: _light
gamnit :: Camera :: _mvp_matrix_cache
gamnit :: Camera :: _position_cache
gamnit :: Camera :: check_position_changed
Hasposition
changed from position_cache
? Update the cache at the same time
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
gamnit :: Camera :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
gamnit :: ParallelLightCamera :: light
gamnit :: ParallelLightCamera :: light=
gamnit :: Camera :: mvp_matrix
The Model-View-Projection matrix created by this cameragamnit :: Camera :: mvp_matrix_cache
gamnit :: Camera :: mvp_matrix_cache=
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).gamnit :: Camera :: position_cache
gamnit :: Camera :: position_cache=
gamnit :: ParallelLightCamera :: rotation_matrix
Rotation matrix produced by the current rotation of the camera
private class ParallelLightCamera
super Camera
var light: ParallelLight
# Rotation matrix produced by the current rotation of the camera
fun rotation_matrix: Matrix
do
var view = new Matrix.identity(4)
view.rotate(light.yaw, 0.0, 1.0, 0.0)
view.rotate(light.pitch, 1.0, 0.0, 0.0)
return view
end
private fun create_mvp_matrix: Matrix
do
var near = -light.depth/2.0
var far = light.depth/2.0
var view = new Matrix.identity(4)
view.translate(-position.x, -position.y, -position.z)
view = view * rotation_matrix
var projection = new Matrix.orthogonal(-light.width/2.0, light.width/2.0,
-light.height/2.0, light.height/2.0,
near, far)
return view * projection
end
redef fun mvp_matrix
do
var m = mvp_matrix_cache
if m == null or check_position_changed then
m = create_mvp_matrix
mvp_matrix_cache = m
end
return m
end
private var pitch_cache = 0.0
private var yaw_cache = 0.0
private var width_cache = 0.0
private var height_cache = 0.0
private var depth_cache = 0.0
redef fun check_position_changed
do
if super then return true
if light.pitch != pitch_cache or
light.yaw != yaw_cache or
light.width != width_cache or
light.height != height_cache or
light.depth != depth_cache then
pitch_cache = light.pitch
yaw_cache = light.yaw
width_cache = light.width
height_cache = light.height
depth_cache = light.depth
return true
end
return false
end
end
lib/gamnit/depth/more_lights.nit:47,1--110,3