Class: Cosmos::GlScene
Instance Attribute Summary collapse
-
#bounds ⇒ Object
Returns the value of attribute bounds.
-
#center ⇒ Object
Returns the value of attribute center.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#projection ⇒ Object
Returns the value of attribute projection.
-
#shapes ⇒ Object
readonly
Returns the value of attribute shapes.
-
#zoom ⇒ Object
Returns the value of attribute zoom.
Instance Method Summary collapse
- #append(shape) ⇒ Object
- #draw(viewer) ⇒ Object
- #each ⇒ Object
- #hit(viewer) ⇒ Object
- #identify(index) ⇒ Object
-
#initialize ⇒ GlScene
constructor
A new instance of GlScene.
Constructor Details
#initialize ⇒ GlScene
Returns a new instance of GlScene.
23 24 25 26 27 28 29 30 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 23 def initialize @shapes = [] @bounds = GlBounds.new(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0) @zoom = 1.0 @orientation = Quaternion.new([0.0, 0.0, 0.0, 1.0]) @center = [0.0, 0.0, 0.0] @projection = :PARALLEL end |
Instance Attribute Details
#bounds ⇒ Object
Returns the value of attribute bounds.
17 18 19 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 17 def bounds @bounds end |
#center ⇒ Object
Returns the value of attribute center.
20 21 22 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 20 def center @center end |
#orientation ⇒ Object
Returns the value of attribute orientation.
19 20 21 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 19 def orientation @orientation end |
#projection ⇒ Object
Returns the value of attribute projection.
21 22 23 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 21 def projection @projection end |
#shapes ⇒ Object (readonly)
Returns the value of attribute shapes.
16 17 18 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 16 def shapes @shapes end |
#zoom ⇒ Object
Returns the value of attribute zoom.
18 19 20 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 18 def zoom @zoom end |
Instance Method Details
#append(shape) ⇒ Object
67 68 69 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 67 def append(shape) @shapes << shape end |
#draw(viewer) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 32 def draw(viewer) @shapes.each do |shape| if shape.color[3] > 0.96 shape.draw(viewer) end end @shapes.each do |shape| if shape.color[3] <= 0.96 shape.draw(viewer) end end end |
#each ⇒ Object
61 62 63 64 65 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 61 def each @shapes.each do |shape| yield shape end end |
#hit(viewer) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 45 def hit(viewer) GL.PushName(0xffffffff); @shapes.each_with_index do |shape, index| GL.LoadName(index) shape.hit(viewer) end GL.PopName() end |
#identify(index) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/cosmos/gui/opengl/gl_scene.rb', line 54 def identify(index) if @shapes[index] return @shapes[index].identify end return nil end |