Sha256: 9e7d5eb82296b055a8686d4ac7d473327e47403a7fce79370c2497c430ceba51

Contents?: true

Size: 851 Bytes

Versions: 16

Compression:

Stored size: 851 Bytes

Contents

module Mittsu
  class PointLight
    TYPE = :point

    class Cache < Struct.new(:length, :count, :colors, :distances, :positions, :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)

      @_vector3.set_from_matrix_position(matrix_world)

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

      # distance is 0 if decay is 0, because there is no attenuation at all.
      @cache.distances[index] = distance
      @cache.decays[index] = distance.zero? ? 0.0 : decay
    end

    def to_sym
      :point
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

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