Class: MagicaVoxel::Material

Inherits:
Chunk
  • Object
show all
Defined in:
lib/magica_voxel/material.rb

Overview

The Chunk type MATL

Since:

  • 0.1.0

Constant Summary

Constants inherited from Chunk

Chunk::TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Chunk

#each, header, #initialize, read

Constructor Details

This class inherits a constructor from MagicaVoxel::Chunk

Instance Attribute Details

#idObject (readonly)

Since:

  • 0.1.0



9
10
11
# File 'lib/magica_voxel/material.rb', line 9

def id
  @id
end

#propertiesObject (readonly)

Since:

  • 0.1.0



9
10
11
# File 'lib/magica_voxel/material.rb', line 9

def properties
  @properties
end

Instance Method Details

#attNumber

TODO: Att

Returns:

  • (Number)

Since:

  • 0.2.0



61
62
63
# File 'lib/magica_voxel/material.rb', line 61

def att
  @att ||= @properties['_att'].to_f
end

#fluxNumber

TODO: Flux

Returns:

  • (Number)

Since:

  • 0.2.0



70
71
72
# File 'lib/magica_voxel/material.rb', line 70

def flux
  @flux ||= @properties['_flux'].to_f
end

#inspectObject

:nodoc:

Since:

  • 0.1.0



86
87
88
89
90
91
92
93
# File 'lib/magica_voxel/material.rb', line 86

def inspect
  '#<MagicaVoxel::Material ' \
    "id=#{id}, type=#{type}, " \
    "weight=#{weight}, roughness=#{roughness}, " \
    "specular=#{specular}, ior=#{ior}, " \
    "att=#{att}, flux=#{flux}, " \
    "plastic=#{plastic?}>"
end

#iorNumber

Index of Refraction

Returns:

  • (Number)

Since:

  • 0.2.0



52
53
54
# File 'lib/magica_voxel/material.rb', line 52

def ior
  @ior ||= @properties['_ior'].to_f
end

#plastic?TureClass|FalseClass

TODO: Plastic

Returns:

  • (TureClass|FalseClass)

Since:

  • 0.1.0



79
80
81
# File 'lib/magica_voxel/material.rb', line 79

def plastic?
  @properties['_plastic'] == '1'
end

#roughnessNumber

Roughness

Returns:

  • (Number)

Since:

  • 0.2.0



34
35
36
# File 'lib/magica_voxel/material.rb', line 34

def roughness
  @roughness ||= @properties['_rough'].to_f
end

#specularNumber

Specular

Returns:

  • (Number)

Since:

  • 0.2.0



43
44
45
# File 'lib/magica_voxel/material.rb', line 43

def specular
  @specular ||= @properties['_spec'].to_f
end

#typeString

Material Type

Returns:

  • (String)

Since:

  • 0.1.0



16
17
18
# File 'lib/magica_voxel/material.rb', line 16

def type
  @type ||= @properties['_type'][1..-1]
end

#weightNumber

Weight

Returns:

  • (Number)

Since:

  • 0.2.0



25
26
27
# File 'lib/magica_voxel/material.rb', line 25

def weight
  @weight ||= @properties['_weight'].to_f
end