Sha256: 1c3482fe362f74a3ac74905c1e157bc6640018ef615ede3970704f3a93733421

Contents?: true

Size: 1.19 KB

Versions: 13

Compression:

Stored size: 1.19 KB

Contents

module Mittsu
  class SpotLight
    TYPE = :spot

    class Cache < Struct.new(:length, :count, :colors, :directions, :distances, :positions, :exponents, :angles_cos, :decays)
      def initialize
        super(0, 0, [], [], [], [], [], [], [])
      end

      def reset
        self.length = 0
      end
    end

    def setup_specific(index)
      offset = index * 3

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

      @_direction.set_from_matrix_position(matrix_world)

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

      @cache.distances[index] = distance

      @_vector3.set_from_matrix_position(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(angle)
      @cache.exponents[index] = exponent;
      @cache.decays[index] = distance.zero? ? 0.0 : decay
    end

    def to_sym
      :spot
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mittsu-0.3.2 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.3.1 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.3.0 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.2.4 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.2.3 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.2.2 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.2.1 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.2.0 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.1.7 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.1.6 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.1.5 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.1.4 lib/mittsu/renderers/opengl/lights/spot_light.rb
mittsu-0.1.3 lib/mittsu/renderers/opengl/lights/spot_light.rb