Class: Mittsu::OpenGLSpotLight

Inherits:
OpenGLLight show all
Defined in:
lib/mittsu/renderers/opengl/lights/opengl_spot_light.rb

Defined Under Namespace

Classes: Cache

Constant Summary collapse

TYPE =
:spot

Instance Attribute Summary

Attributes inherited from OpenGLLight

#camera_helper

Attributes inherited from OpenGLObject3D

#active, #model_view_matrix, #morph_target_influences

Instance Method Summary collapse

Methods inherited from OpenGLLight

#initialize, null_remaining_lights, #project, #setup, #type

Methods inherited from OpenGLObject3D

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

Constructor Details

This class inherits a constructor from Mittsu::OpenGLLight

Instance Method Details

#setup_specific(index) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mittsu/renderers/opengl/lights/opengl_spot_light.rb', line 15

def setup_specific(index)
  offset = index * 3

  OpenGLHelper.set_color_linear(@cache.colors, offset, @light.color, @light.intensity)

  @_direction.set_from_matrix_position(@light.matrix_world)

  positions = @cache.positions
  positions[offset]     = @_direction.x
  positions[offset + 1] = @_direction.y
  positions[offset + 2] = @_direction.z

  @cache.distances[index] = @light.distance

  @_vector3.set_from_matrix_position(@light.target.matrix_world)
  @_direction.sub(@_vector3)
  @_direction.normalize

  directions = @cache.directions
  directions[offset]     = @_direction.x
  directions[offset + 1] = @_direction.y
  directions[offset + 2] = @_direction.z

  @cache.angles_cos[index] = Math.cos(@light.angle)
  @cache.exponents[index] = @light.exponent;
  @cache.decays[index] = @light.distance.zero? ? 0.0 : @light.decay
end

#to_symObject



43
44
45
# File 'lib/mittsu/renderers/opengl/lights/opengl_spot_light.rb', line 43

def to_sym
  :spot
end