Class: Engine::Components::OrthographicCamera
Instance Attribute Summary collapse
#game_object
Instance Method Summary
collapse
#look_at, #ortho, #perspective
#_erase!, #destroy!, #destroyed?, destroyed_components, erase_destroyed_components, method_added, #renderer?, #set_game_object, #start, #ui_renderer?
allowed_class?, get_class, included, register_class, #uuid
Instance Attribute Details
#far ⇒ Object
Returns the value of attribute far.
6
7
8
|
# File 'lib/engine/components/orthographic_camera.rb', line 6
def far
@far
end
|
#near ⇒ Object
Returns the value of attribute near.
6
7
8
|
# File 'lib/engine/components/orthographic_camera.rb', line 6
def near
@near
end
|
Instance Method Details
#awake ⇒ Object
10
11
12
13
|
# File 'lib/engine/components/orthographic_camera.rb', line 10
def awake
@near ||= 0
Engine::Camera.instance = self
end
|
#destroy ⇒ Object
15
16
17
|
# File 'lib/engine/components/orthographic_camera.rb', line 15
def destroy
Engine::Camera.instance = nil if Engine::Camera.instance == self
end
|
#inverse_vp_matrix ⇒ Object
37
38
39
|
# File 'lib/engine/components/orthographic_camera.rb', line 37
def inverse_vp_matrix
@inverse_vp_matrix ||= matrix.inverse
end
|
#matrix ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/engine/components/orthographic_camera.rb', line 19
def matrix
@matrix ||=
begin
right = game_object.right
up = game_object.up
forward = game_object.forward
view_matrix = Matrix[
[right[0], right[1], right[2], -right.dot(game_object.pos)],
[up[0], up[1], up[2], -up.dot(game_object.pos)],
[forward[0], forward[1], forward[2], -forward.dot(game_object.pos)],
[0, 0, 0, 1]
]
(projection * view_matrix).transpose
end
end
|
#position ⇒ Object
41
42
43
|
# File 'lib/engine/components/orthographic_camera.rb', line 41
def position
game_object.pos
end
|
#projection ⇒ Object
45
46
47
48
49
|
# File 'lib/engine/components/orthographic_camera.rb', line 45
def projection
half_w = @width / 2.0
half_h = @height / 2.0
ortho(-half_w, half_w, -half_h, half_h, @near, @far)
end
|
#update(delta_time) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/engine/components/orthographic_camera.rb', line 51
def update(delta_time)
if game_object.rotation != @rotation || game_object.pos != @pos
@matrix = nil
@inverse_vp_matrix = nil
end
@rotation = game_object.rotation.dup
@pos = game_object.pos.dup
end
|