Sha256: 17dd59c44a6f9757ac0470a46051c7f39b6a2326877b15ed0e054efa2761f38d

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

module Mittsu
  class HemisphereLight
    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(matrix_world)
      @_direction.normalize

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

      OpenGL::Helper.set_color_linear(@cache.sky_colors, offset, color, intensity)
      OpenGL::Helper.set_color_linear(@cache.ground_colors, offset, ground_color, 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

2 entries across 2 versions & 1 rubygems

Version Path
mittsu-opengl-0.5.1 lib/mittsu/opengl_implementation/lights/hemisphere_light.rb
mittsu-opengl-0.5.0 lib/mittsu/opengl_implementation/lights/hemisphere_light.rb