Class: AimsProject::Material
- Inherits:
-
Object
- Object
- AimsProject::Material
- Includes:
- Gl
- Defined in:
- lib/aims_project/material.rb
Instance Attribute Summary collapse
-
#alpha ⇒ Object
Returns the value of attribute alpha.
-
#b ⇒ Object
Returns the value of attribute b.
-
#g ⇒ Object
Returns the value of attribute g.
-
#r ⇒ Object
Returns the value of attribute r.
Class Method Summary collapse
Instance Method Summary collapse
- #apply(lighting = true) ⇒ Object
-
#initialize(r, g, b, alpha = 1) ⇒ Material
constructor
A new instance of Material.
Constructor Details
#initialize(r, g, b, alpha = 1) ⇒ Material
Returns a new instance of Material.
12 13 14 15 16 17 |
# File 'lib/aims_project/material.rb', line 12 def initialize(r,g,b,alpha=1) self.r = r self.g = g self.b = b self.alpha = alpha end |
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
6 7 8 |
# File 'lib/aims_project/material.rb', line 6 def alpha @alpha end |
#b ⇒ Object
Returns the value of attribute b.
6 7 8 |
# File 'lib/aims_project/material.rb', line 6 def b @b end |
#g ⇒ Object
Returns the value of attribute g.
6 7 8 |
# File 'lib/aims_project/material.rb', line 6 def g @g end |
#r ⇒ Object
Returns the value of attribute r.
6 7 8 |
# File 'lib/aims_project/material.rb', line 6 def r @r end |
Class Method Details
Instance Method Details
#apply(lighting = true) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/aims_project/material.rb', line 19 def apply(lighting = true) if lighting glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, [self.r, self.g, self.b, self.alpha]) glMaterialfv(GL_FRONT, GL_SPECULAR, [self.r, self.g, self.b, self.alpha]) glMaterialf(GL_FRONT, GL_SHININESS, 50) else glColor3f(self.r, self.g, self.b) end end |