Class: AimsProject::Material

Inherits:
Object
  • Object
show all
Includes:
Gl
Defined in:
lib/aims_project/material.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#alphaObject

Returns the value of attribute alpha.



6
7
8
# File 'lib/aims_project/material.rb', line 6

def alpha
  @alpha
end

#bObject

Returns the value of attribute b.



6
7
8
# File 'lib/aims_project/material.rb', line 6

def b
  @b
end

#gObject

Returns the value of attribute g.



6
7
8
# File 'lib/aims_project/material.rb', line 6

def g
  @g
end

#rObject

Returns the value of attribute r.



6
7
8
# File 'lib/aims_project/material.rb', line 6

def r
  @r
end

Class Method Details

.blackObject



8
9
10
# File 'lib/aims_project/material.rb', line 8

def Material.black
  Material.new(0,0,0)
end

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