1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
package my3d;
import java.util.ArrayList;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.MenuItem;
import javafx.scene.control.RadioMenuItem;
import javafx.scene.paint.Color;
import my3d._shape3d2.*;
import my3d._slider_dialog.*;
import my3d._viewport3d3.*;
public abstract class _viewer3d6 extends _viewer3d5 {
private _material target_material;
private _slider_dialog material_dlg;
public void set_target_material(_material mat) {
target_material = mat;
}
@Override
public void init_menu() {
super.init_menu();
_viewport3d3 vp3 = (_viewport3d3)vp;
ArrayList<_shading_mode> shading_modes = new ArrayList<_shading_mode>();
shading_modes.add(_shading_mode.Flat);
shading_modes.add(_shading_mode.Gouraud);
shading_modes.add(_shading_mode.Phong);
ArrayList<MenuItem> items = add_setting_menu(
(index) -> {
vp3.shading_mode = shading_modes.get(index);
repaint();
},
"---", "rフラット・シェーディング", "rグーロー・シェーディング", "rフォン・シェーディング"
);
((RadioMenuItem)items.get(shading_modes.indexOf(vp3.shading_mode))).
setSelected(true);
if (target_material == null) return;
Color color = target_material.color;
double shininess = target_material.shininess;
if (shininess != 0)
shininess = Math.log(shininess) / Math.log(20);
_slider_dialog material_dlg = new _slider_dialog(stage, "質感",
(values) -> {
double val = values[3];
if (val != 0)
val = Math.pow(20, val);
target_material.color = new Color(values[0], values[1], values[2], 1);
target_material.shininess = val;
repaint();
},
new _slider_data("赤", 0, 1, color.getRed()),
new _slider_data("緑", 0, 1, color.getGreen()),
new _slider_data("青", 0, 1, color.getBlue()),
new _slider_data("光沢", 0, 1, shininess)
);
add_param_menu((index) -> {
if (!material_dlg.isShowing())
material_dlg.showAndWait();
},
"質感"
);
}
}