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
package my3d;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.stage.FileChooser;
import my3d._shape3d2.*;
public abstract class _viewer3d7 extends _viewer3d6 {
private _texture target_texture;
public void set_target_texture(_texture tex) {
target_texture = tex;
}
@Override
public void init_menu() {
super.init_menu();
_viewport3d3 vp3 = (_viewport3d3)vp;
ArrayList<MenuItem> items = add_setting_menu((index) -> {
vp3.set_texture_enable(!vp3.is_texture_enable());
repaint();
},
"---", "cテクスチャ"
);
((CheckMenuItem)items.get(0)).setSelected(vp3.is_texture_enable());
if (target_texture == null) return;
FileChooser texture_chooser = new FileChooser();
texture_chooser.setTitle("テクスチャ");
texture_chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(
"画像(*.gif, *.jpg)", Arrays.asList("*.gif", "*.jpg")));
add_param_menu((index) -> {
File file = texture_chooser.showOpenDialog(stage);
if (file != null) {
texture_chooser.setInitialDirectory(file.getParentFile());
Image image = new Image(file.toURI().toString());
if (image != null)
target_texture.set_image(image);
repaint();
}
},
"テクスチャ"
);
}
}