Class: CyberarmEngine::OrthographicCamera
- Inherits:
-
Object
- Object
- CyberarmEngine::OrthographicCamera
- Defined in:
- lib/cyberarm_engine/opengl/orthographic_camera.rb
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#left ⇒ Object
Returns the value of attribute left.
-
#max_view_distance ⇒ Object
Returns the value of attribute max_view_distance.
-
#min_view_distance ⇒ Object
Returns the value of attribute min_view_distance.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#position ⇒ Object
Returns the value of attribute position.
-
#right ⇒ Object
Returns the value of attribute right.
-
#top ⇒ Object
Returns the value of attribute top.
-
#zoom ⇒ Object
Returns the value of attribute zoom.
Instance Method Summary collapse
-
#draw ⇒ Object
Immediate mode renderering fallback.
-
#initialize(position:, right:, top:, orientation: Vector.new(0, 0, 0), zoom: 1, left: 0, bottom: 0, min_view_distance: 0.1, max_view_distance: 200.0) ⇒ OrthographicCamera
constructor
A new instance of OrthographicCamera.
- #projection_matrix ⇒ Object
- #view_matrix ⇒ Object
Constructor Details
#initialize(position:, right:, top:, orientation: Vector.new(0, 0, 0), zoom: 1, left: 0, bottom: 0, min_view_distance: 0.1, max_view_distance: 200.0) ⇒ OrthographicCamera
Returns a new instance of OrthographicCamera.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 6 def initialize( position:, right:, top:, orientation: Vector.new(0, 0, 0), zoom: 1, left: 0, bottom: 0, min_view_distance: 0.1, max_view_distance: 200.0 ) @position = position @orientation = orientation @zoom = zoom @left = left @right = right @bottom = bottom @top = top @min_view_distance = min_view_distance @max_view_distance = max_view_distance end |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def bottom @bottom end |
#left ⇒ Object
Returns the value of attribute left.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def left @left end |
#max_view_distance ⇒ Object
Returns the value of attribute max_view_distance.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def max_view_distance @max_view_distance end |
#min_view_distance ⇒ Object
Returns the value of attribute min_view_distance.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def min_view_distance @min_view_distance end |
#orientation ⇒ Object
Returns the value of attribute orientation.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def orientation @orientation end |
#position ⇒ Object
Returns the value of attribute position.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def position @position end |
#right ⇒ Object
Returns the value of attribute right.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def right @right end |
#top ⇒ Object
Returns the value of attribute top.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def top @top end |
#zoom ⇒ Object
Returns the value of attribute zoom.
3 4 5 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 3 def zoom @zoom end |
Instance Method Details
#draw ⇒ Object
Immediate mode renderering fallback
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 26 def draw glMatrixMode(GL_PROJECTION) glLoadIdentity glOrtho(@left, @right, @bottom, @top, @min_view_distance, @max_view_distance) glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) glRotatef(@orientation.x, 1, 0, 0) glRotatef(@orientation.y, 0, 1, 0) glTranslatef(-@position.x, -@position.y, -@position.z) glMatrixMode(GL_MODELVIEW) glLoadIdentity end |
#projection_matrix ⇒ Object
38 39 40 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 38 def projection_matrix Transform.orthographic(@left, @right, @bottom, @top, @min_view_distance, @max_view_distance) end |
#view_matrix ⇒ Object
42 43 44 |
# File 'lib/cyberarm_engine/opengl/orthographic_camera.rb', line 42 def view_matrix Transform.translate_3d(@position * -1) * Transform.rotate_3d(@orientation) end |