Class: PBRT::ParameterList
- Inherits:
-
Object
- Object
- PBRT::ParameterList
- Defined in:
- lib/pbrt/parameter_list.rb
Class Method Summary collapse
- .allow_shapes_to_override_materials!(params, type_signature) ⇒ Object
- .from(params, type_signature) ⇒ Object
Instance Method Summary collapse
-
#initialize(name_value_pairs) ⇒ ParameterList
constructor
A new instance of ParameterList.
- #to_s ⇒ Object
Constructor Details
#initialize(name_value_pairs) ⇒ ParameterList
Returns a new instance of ParameterList.
23 24 25 |
# File 'lib/pbrt/parameter_list.rb', line 23 def initialize(name_value_pairs) @name_value_pairs = name_value_pairs end |
Class Method Details
.allow_shapes_to_override_materials!(params, type_signature) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pbrt/parameter_list.rb', line 33 def self.allow_shapes_to_override_materials!(params, type_signature) return unless type_signature[:allow_material_overrides] type_signature.delete(:allow_material_overrides) surplus = params.keys - type_signature.keys surplus.each do |key| type = Builder::Material::ALL_PARAMS[key] type_signature[key] = type if type end end |
.from(params, type_signature) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pbrt/parameter_list.rb', line 3 def self.from(params, type_signature) allow_shapes_to_override_materials!(params, type_signature) Signature.new(type_signature).check(params) pairs = params.map do |name, value| type = type_signature[name] type, value = Texture.unpack(type, value) if type == :spectrum || value.is_a?(Spectrum) type, value = Spectrum.unpack(value) end [Parameter.new(type, name), Values.new(value)] end new(pairs.to_h) end |
Instance Method Details
#to_s ⇒ Object
27 28 29 30 31 |
# File 'lib/pbrt/parameter_list.rb', line 27 def to_s @name_value_pairs.map do |parameter, values| [parameter.to_s, "[#{values}]"].join(" ") end.join(" ") end |