Sha256: 4ec81085645de0a512e8993af2107411ab52930480dd6daf9f34391da66ff6a3

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Mittsu
  class OpenGLHemisphereLight < OpenGLLight
    TYPE = :hemi

    class Cache < Struct.new(:length, :count, :sky_colors, :ground_colors, :positions)
      def initialize
        super(0, 0, [], [], [])
      end

      def reset
        self.length = 0
      end
    end

    def setup_specific(index)
      offset = index * 3

      @_direction.set_from_matrix_position(@light.matrix_world)
      @_direction.normalize

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

      sky_color = @light.color
      ground_color = @light.ground_color

      OpenGLHelper.set_color_linear(@cache.sky_colors, offset, sky_color, @light.intensity )
      OpenGLHelper.set_color_linear(@cache.ground_colors, offset, ground_color, @light.intensity)
    end

    def self.null_remaining_lights(cache)
      super(cache, cache.ground_colors)
      super(cache, cache.sky_colors)
    end

    def to_sym
      :hemi
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mittsu-0.1.2 lib/mittsu/renderers/opengl/lights/opengl_hemisphere_light.rb