Class: Mittsu::OpenGLLight

Inherits:
OpenGLObject3D show all
Defined in:
lib/mittsu/renderers/opengl/lights/opengl_light.rb

Instance Attribute Summary collapse

Attributes inherited from OpenGLObject3D

#active, #model_view_matrix, #morph_target_influences

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenGLObject3D

#active?, #add_opengl_object, #buffer_material, #init, #init_geometry, #load_uniforms_matrices, #setup_matrices

Constructor Details

#initialize(light, renderer) ⇒ OpenGLLight

Returns a new instance of OpenGLLight.



5
6
7
8
9
10
11
12
13
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 5

def initialize(light, renderer)
  super
  @light = light
  @light_renderer = renderer.light_renderer
  @cache = @light_renderer.cache[type]

  @_direction = Vector3.new
  @_vector3 = Vector3.new
end

Instance Attribute Details

#camera_helperObject

Returns the value of attribute camera_helper.



3
4
5
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 3

def camera_helper
  @camera_helper
end

Class Method Details

.null_remaining_lights(cache, colors = nil) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 40

def self.null_remaining_lights(cache, colors = nil)
  colors ||= cache.colors
  count = [colors.length, cache.count * 3].max
  (cache.length * 3).upto(count - 1).each { |i|
    colors[i] = 0.0
  }
end

Instance Method Details

#projectObject



28
29
30
31
32
33
34
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 28

def project
  return unless @light.visible
  init
  # TODO!!! FIXME!!!
  @renderer.instance_variable_get(:@lights) << @light
  project_children
end

#setupObject



19
20
21
22
23
24
25
26
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 19

def setup
  @cache.count += 1

  return unless @light.visible
  setup_specific(@cache.length)

  @cache.length += 1
end

#setup_specificObject



36
37
38
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 36

def setup_specific
  raise "Unknown Light Impl: #{@light.class} => #{self.class}"
end

#to_symObject



48
49
50
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 48

def to_sym
  :other
end

#typeObject



15
16
17
# File 'lib/mittsu/renderers/opengl/lights/opengl_light.rb', line 15

def type
  self.class::TYPE
end