Class: Hate::Graphics::Camera
- Inherits:
-
Object
- Object
- Hate::Graphics::Camera
- Defined in:
- lib/hate/graphics/camera.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#x ⇒ Object
Returns the value of attribute x.
-
#xl ⇒ Object
Returns the value of attribute xl.
-
#y ⇒ Object
Returns the value of attribute y.
-
#yl ⇒ Object
Returns the value of attribute yl.
-
#z ⇒ Object
Returns the value of attribute z.
-
#zl ⇒ Object
Returns the value of attribute zl.
Instance Method Summary collapse
-
#initialize(angle = 45.0, near = 0.1, far = 100.0) ⇒ Camera
constructor
A new instance of Camera.
- #is_default? ⇒ Boolean
- #reshape(x, y) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(angle = 45.0, near = 0.1, far = 100.0) ⇒ Camera
Returns a new instance of Camera.
9 10 11 12 13 14 |
# File 'lib/hate/graphics/camera.rb', line 9 def initialize(angle=45.0, near=0.1, far=100.0) @angle, @near, @far = angle, near, far @x, @y, @z = 0.0, 1.0, 0.0 @xl, @yl, @zl = 0.0, 1.0, -1.0 @default = true end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
7 8 9 |
# File 'lib/hate/graphics/camera.rb', line 7 def default @default end |
#x ⇒ Object
Returns the value of attribute x.
5 6 7 |
# File 'lib/hate/graphics/camera.rb', line 5 def x @x end |
#xl ⇒ Object
Returns the value of attribute xl.
6 7 8 |
# File 'lib/hate/graphics/camera.rb', line 6 def xl @xl end |
#y ⇒ Object
Returns the value of attribute y.
5 6 7 |
# File 'lib/hate/graphics/camera.rb', line 5 def y @y end |
#yl ⇒ Object
Returns the value of attribute yl.
6 7 8 |
# File 'lib/hate/graphics/camera.rb', line 6 def yl @yl end |
#z ⇒ Object
Returns the value of attribute z.
5 6 7 |
# File 'lib/hate/graphics/camera.rb', line 5 def z @z end |
#zl ⇒ Object
Returns the value of attribute zl.
6 7 8 |
# File 'lib/hate/graphics/camera.rb', line 6 def zl @zl end |
Instance Method Details
#is_default? ⇒ Boolean
16 17 18 |
# File 'lib/hate/graphics/camera.rb', line 16 def is_default? @default end |
#reshape(x, y) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/hate/graphics/camera.rb', line 20 def reshape(x, y) glMatrixMode(GL_PROJECTION) glLoadIdentity glViewport(0, 0, x, y) gluPerspective(@angle, x / y, @near, @far) glMatrixMode(GL_MODELVIEW) end |
#run ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/hate/graphics/camera.rb', line 28 def run glLoadIdentity gluLookAt( @x, @y, @z, @x + @xl, 1.0, @z + @zl, 0.0, 1.0, 0.0 ) end |