Class: GlimR::Model
- Inherits:
-
SceneObject
- Object
- SceneObject
- GlimR::Model
- Defined in:
- lib/glimr/renderer/model.rb
Overview
A Model is a convenience SceneObject that has its own transform, material, texture, shader, and geometry.
The state nodes are attached to the Model after super initialization and form a five-node subtree ordered like this (from top to bottom): transform - material - texture - shader - geometry.
Model delegates many accessors to the corresponding state nodes
Example:
m = Model.new
m.texture.load('foo.jpg')
m.position = [10, 20, 30]
m.texcoords = make texcoords
m.vertices = make vertices
Direct Known Subclasses
Instance Attribute Summary collapse
-
#geometry ⇒ Object
Returns the value of attribute geometry.
-
#material ⇒ Object
Returns the value of attribute material.
-
#shader ⇒ Object
Returns the value of attribute shader.
-
#texture ⇒ Object
Returns the value of attribute texture.
-
#transform ⇒ Object
Returns the value of attribute transform.
Attributes inherited from SceneObject
#children, #drawables, #mtime, #parent, #viewport
Attributes included from EventListener
#event_listeners, #listener_count
Instance Method Summary collapse
- #absolute_transform ⇒ Object
- #apply ⇒ Object
-
#initialize(*a, &b) ⇒ Model
constructor
A new instance of Model.
- #inspect ⇒ Object
- #pop_state ⇒ Object
- #push_state ⇒ Object
Methods inherited from SceneObject
#<<, #absolute_geometry, #absolute_material, #absolute_shader, #absolute_texture, #absolute_transform_for_drawing, #add_drawables, #attach, #clone, #default_config, #detach, #detach_self, #remove_drawables, #render, #replace_node, #root, #touch!, #visible
Methods included from Configurable
Methods included from EventListener
#add_event_listener, #decrement_listener_count, #dispatch_event, #event_root, #increment_listener_count, #method_missing, #multicast_event, #process_event, #remove_event_listener
Constructor Details
#initialize(*a, &b) ⇒ Model
Returns a new instance of Model.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/glimr/renderer/model.rb', line 35 def initialize(*a,&b) @transform = Transform.new @material = Material.new @texture = Texture.new @shader = Shader.new @geometry = Geometry.new super attach @material @material.attach @texture @texture.attach @shader @shader.attach @geometry end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GlimR::EventListener
Instance Attribute Details
#geometry ⇒ Object
Returns the value of attribute geometry.
29 30 31 |
# File 'lib/glimr/renderer/model.rb', line 29 def geometry @geometry end |
#material ⇒ Object
Returns the value of attribute material.
29 30 31 |
# File 'lib/glimr/renderer/model.rb', line 29 def material @material end |
#shader ⇒ Object
Returns the value of attribute shader.
29 30 31 |
# File 'lib/glimr/renderer/model.rb', line 29 def shader @shader end |
#texture ⇒ Object
Returns the value of attribute texture.
29 30 31 |
# File 'lib/glimr/renderer/model.rb', line 29 def texture @texture end |
#transform ⇒ Object
Returns the value of attribute transform.
29 30 31 |
# File 'lib/glimr/renderer/model.rb', line 29 def transform @transform end |
Instance Method Details
#absolute_transform ⇒ Object
63 64 65 66 |
# File 'lib/glimr/renderer/model.rb', line 63 def absolute_transform @transform.instance_variable_set :@parent , @parent @transform.absolute_transform end |
#apply ⇒ Object
58 59 60 61 |
# File 'lib/glimr/renderer/model.rb', line 58 def apply @transform.apply super end |
#inspect ⇒ Object
97 98 99 |
# File 'lib/glimr/renderer/model.rb', line 97 def inspect super[0..-2] + "::#{ [@transform, @material, @texture, @shader, @geometry].map{|i|i.inspect[9..-2]}.join("::") }>" end |
#pop_state ⇒ Object
53 54 55 56 |
# File 'lib/glimr/renderer/model.rb', line 53 def pop_state @transform.pop_state super end |
#push_state ⇒ Object
48 49 50 51 |
# File 'lib/glimr/renderer/model.rb', line 48 def push_state @transform.push_state super end |