Class: Mittsu::MeshPhongMaterial

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

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, #shading, #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_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 = {}) ⇒ MeshPhongMaterial

Returns a new instance of MeshPhongMaterial.



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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/mittsu/materials/mesh_phong_material.rb', line 48

def initialize(parameters = {})
  super()

	@type = 'MeshPhongMaterial'

	@color = Color.new(0xffffff) # diffuse
	@emissive = Color.new(0x000000)
	@specular = Color.new(0x111111)
	@shininess = 30.0

	@metal = false

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

	@map = nil

	@light_map = nil

	@bump_map = nil
	@bump_scale = 1.0

	@normal_map = nil
	@normal_scale = Vector2.new(1.0, 1.0)

	@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.



46
47
48
# File 'lib/mittsu/materials/mesh_phong_material.rb', line 46

def emissive
  @emissive
end

#normal_scaleObject

Returns the value of attribute normal_scale.



46
47
48
# File 'lib/mittsu/materials/mesh_phong_material.rb', line 46

def normal_scale
  @normal_scale
end

#shininessObject

Returns the value of attribute shininess.



46
47
48
# File 'lib/mittsu/materials/mesh_phong_material.rb', line 46

def shininess
  @shininess
end

#specularObject

Returns the value of attribute specular.



46
47
48
# File 'lib/mittsu/materials/mesh_phong_material.rb', line 46

def specular
  @specular
end

Instance Method Details

#cloneObject



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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/mittsu/materials/mesh_phong_material.rb', line 100

def clone
  material = MeshPhongMaterial.new

  super(material)

	material.color.copy(@color)
	material.emissive.copy(@emissive)
	material.specular.copy(@specular)
	material.shininess = @shininess

	material.metal = @metal

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

	material.map = @map

	material.light_map = @light_map

	material.bump_map = @bump_map
	material.bump_scale = @bump_scale

	material.normal_map = @normal_map
	material.normal_scale.copy(@normal_scale)

	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



36
37
38
# File 'lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb', line 36

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

#needs_camera_position_uniform?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb', line 24

def needs_camera_position_uniform?
  true
end

#needs_face_normals?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb', line 7

def needs_face_normals?
  false
end

#needs_lights?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb', line 32

def needs_lights?
  true
end

#needs_view_matrix_uniform?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb', line 28

def needs_view_matrix_uniform?
  true
end

#refresh_uniforms(uniforms) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb', line 11

def refresh_uniforms(uniforms)
  refresh_uniforms_basic(uniforms)

  uniforms['shininess'].value = shininess

  uniforms['emissive'].value = emissive
  uniforms['specular'].value = specular

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

#shader_idObject



40
41
42
# File 'lib/mittsu/renderers/opengl/materials/mesh_phong_material.rb', line 40

def shader_id
  :phong
end