Sha256: 4d389d3dd12416142d2495873d581dbc2784793213ff6ff7969fcd9fb7952c13

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

module Mittsu
  class DirectionalLight
    TYPE = :directional

    class Cache < Struct.new(:length, :count, :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)
      @_vector3.set_from_matrix_position(target.matrix_world)
      @_direction.sub(@_vector3)
      @_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.colors, offset, color, intensity)
    end

    def to_sym
      :directional
    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/directional_light.rb
mittsu-opengl-0.5.0 lib/mittsu/opengl_implementation/lights/directional_light.rb