Class: Mittsu::MeshLambertMaterial

Inherits:
Material
  • Object
show all
Includes:
OpenGLMaterialBasics
Defined in:
lib/mittsu/materials/mesh_lambert_material.rb,
lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb

Overview

parameters:

color: <hex>,
emissive: <hex>,
opacity: <float>,

map: Texture.new( <Image> ),

light_map: Texture.( <Image> ),

specular_map: Texture.new( <Image> ),

alpha_map: Texture.new( <Image> ),

env_map: TextureCube.new( [posx, negx, posy, negy, posz, negz]),
combine: Multiply,
reflectivity: <float>,
refraction_ratio: <float>,

shading: SmoothShading,
blending: NormalBlending,
depth_test: <bool>,
depth_write: <bool>,

wireframe: <boolean>,
wireframe_linewidth: <float>,

vertex_colors: NoColors / VertexColors / FaceColors,

skinning: <bool>,
morph_targets: <bool>,
morph_normals: <bool>,

fog: <bool>

Instance Attribute Summary collapse

Attributes inherited from Material

#alpha_map, #alpha_test, #attributes, #blend_dst, #blend_dst_alpha, #blend_equation, #blend_equation_alpha, #blend_src, #blend_src_alpha, #blending, #bump_map, #color, #color_write, #combine, #default_attribute_values, #defines, #depth_test, #depth_write, #env_map, #fog, #fragment_shader, #id, #light_map, #lights, #map, #metal, #morph_normals, #morph_targets, #name, #normal_map, #opacity, #overdraw, #polygon_offset, #polygon_offset_factor, #polygon_offset_units, #program, #reflectivity, #refraction_ratio, #shader, #shadow_pass, #side, #size_attenuation, #skinning, #specular_map, #transparent, #type, #uniforms, #uniforms_list, #uuid, #vertex_colors, #vertex_shader, #visible, #wireframe, #wrap_around

Instance Method Summary collapse

Methods included from OpenGLMaterialBasics

#get_uv_scale_map, #refresh_env_map_uniforms, #refresh_map_uniforms, #refresh_other_uniforms, #refresh_uniforms_basic

Methods inherited from Material

#clear_custom_attributes, #custom_attributes_dirty?, #dispose, #init, #needs_camera_position_uniform?, #needs_face_normals?, #needs_update=, #needs_update?, #set, #set_values, #to_json, #update

Methods included from EventDispatcher

#add_event_listener, #dispatch_event, #has_event_listener, #remove_event_listener

Constructor Details

#initialize(parameters = {}) ⇒ MeshLambertMaterial



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/mittsu/materials/mesh_lambert_material.rb', line 42

def initialize(parameters = {})
  super()

  @type = 'MeshLambertMaterial'

  @color = Color.new(0xffffff) # diffuse
  @emissive = Color.new(0x000000)

  @wrap_around = false
  @wrap_rbg = Vector3.new(1.0, 1.0, 1.0)

  @map = nil

  @light_map = nil

  @specular_map = nil

  @alpha_map = nil

  @env_map = nil
  @combine = MultiplyOperation
  @reflectivity = 1.0
  @refraction_ratio = 0.98

  @fog = true

  @shading = SmoothShading

  @wireframe = false
  @wireframe_linewidth = 1.0
  @wireframe_linecap = :round
  @wireframe_linejoin = :round

  @vertex_colors = NoColors

  @skinning = false
  @morph_targets = false
  @morph_normals = false

  self.set_values(parameters)
end

Instance Attribute Details

#emissiveObject

Returns the value of attribute emissive.



40
41
42
# File 'lib/mittsu/materials/mesh_lambert_material.rb', line 40

def emissive
  @emissive
end

#shadingObject

Returns the value of attribute shading.



40
41
42
# File 'lib/mittsu/materials/mesh_lambert_material.rb', line 40

def shading
  @shading
end

#wireframe_linecapObject

Returns the value of attribute wireframe_linecap.



40
41
42
# File 'lib/mittsu/materials/mesh_lambert_material.rb', line 40

def wireframe_linecap
  @wireframe_linecap
end

#wireframe_linejoinObject

Returns the value of attribute wireframe_linejoin.



40
41
42
# File 'lib/mittsu/materials/mesh_lambert_material.rb', line 40

def wireframe_linejoin
  @wireframe_linejoin
end

#wireframe_linewidthObject

Returns the value of attribute wireframe_linewidth.



40
41
42
# File 'lib/mittsu/materials/mesh_lambert_material.rb', line 40

def wireframe_linewidth
  @wireframe_linewidth
end

Instance Method Details

#cloneObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/mittsu/materials/mesh_lambert_material.rb', line 84

def clone
  material = MeshLambertMaterial.new

  super(material)

  material.color.copy(@color)
  material.emissive.copy(@color)

  material.wrap_around = @wrap_around
  material.wrap_rgb.copy(@wrap_rbg)

  material.map = @map

  material.light_map = @light_map

  material.specular_map = @specular_map

  material.alpha_map = @alpha_map

  material.env_map = @env_map
  material.combine = @combine
  material.reflectivity = @reflectivity
  material.refraction_ratio = @refraction_ratio

  material.fog = @fog

  material.shading = @shading

  material.wireframe = @wireframe
  material.wireframe_linewidth = @wireframe_linewidth
  material.wireframe_linecap = @wireframe_linecap
  material.wireframe_linejoin = @wireframe_linejoin

  material.vertex_colors = @vertex_colors

  material.skinning = @skinning
  material.morph_targets = @morph_targets
  material.morph_normals = @morph_normals

  material
end

#init_shaderObject



25
26
27
# File 'lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb', line 25

def init_shader
  @shader = ShaderLib.create_shader(shader_id)
end

#needs_lights?Boolean



21
22
23
# File 'lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb', line 21

def needs_lights?
  true
end

#needs_view_matrix_uniform?Boolean



17
18
19
# File 'lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb', line 17

def needs_view_matrix_uniform?
  true
end

#refresh_uniforms(uniforms) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb', line 7

def refresh_uniforms(uniforms)
  refresh_uniforms_basic(uniforms)

  uniforms['emissive'].value = emissive

  if wrap_around
    uniforms['wrapRGB'].value.copy(wrap_rgb)
  end
end

#shader_idObject



29
30
31
# File 'lib/mittsu/renderers/opengl/materials/mesh_lambert_material.rb', line 29

def shader_id
  :lambert
end