class Mittsu::OrthographicCamera

Attributes

bottom[RW]
far[RW]
left[RW]
near[RW]
right[RW]
top[RW]
zoom[RW]

Public Class Methods

new(left, right, top, bottom, near = 0.1, far = 2000.0) click to toggle source
Calls superclass method Mittsu::Camera::new
# File lib/mittsu/cameras/orthographic_camera.rb, line 5
def initialize(left, right, top, bottom, near = 0.1, far = 2000.0)
  super()

  @type = 'OrthographicCamera'

  @zoom = 1.0

  @left = left.to_f
  @right = right.to_f
  @top = top.to_f
  @bottom = bottom.to_f

  @near = near.to_f
  @far = far.to_f

  update_projection_matrix
end

Public Instance Methods

clone() click to toggle source
Calls superclass method Mittsu::Camera#clone
# File lib/mittsu/cameras/orthographic_camera.rb, line 32
def clone
  camera = Mittsu::OrthographicCamera.new
  super(camera)

  camera.zoom = zoom

  camera.left = left
  camera.right = right
  camera.top = top
  camera.bottom = bottom

  camera.near = near
  camera.far = far

  camera.projection_matrix.copy()

  camera
end
update_projection_matrix() click to toggle source
# File lib/mittsu/cameras/orthographic_camera.rb, line 23
def update_projection_matrix
  dx = (right - left) / (2.0 * zoom)
  dy = (top - bottom) / (2.0 * zoom)
  cx = (right + left) / 2.0
  cy = (top + bottom) / 2.0

  projection_matrix.make_orthographic(cx - dx, cx + dx, cy + dy, cy - dy, near, far)
end

Protected Instance Methods

jsonify() click to toggle source
Calls superclass method
# File lib/mittsu/cameras/orthographic_camera.rb, line 53
def jsonify
  data = super
  data[:left] = self.left
  data[:right] = self.right
  data[:top] = self.top
  data[:bottom] = self.bottom
  data[:near] = self.near
  data[:far] = self.far
  data
end