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
package sample3d; import javafx.application.Application; import javafx.scene.paint.Color; import my3d._shape3d2; import my3d._shape3d2.*; import my3d._slider_dialog.*; import my3d._viewer3d6; import my3d._viewport3d; import my3d._viewport3d3; import my3d._viewport3d3.*; public class _sample12 extends _viewer3d6 { public static void main(String... args) { Application.launch(args); } private int shape_index = 0; private _shape3d2[] shapes = new _shape3d2[4]; @Override public void init_scene(_viewport3d vp) { _viewport3d3 vp3 = (_viewport3d3)vp; vp3.shading_mode = _shading_mode.Gouraud; _slider.set_tick_response(true); add_app_menu((index) -> { shape_index = index; repaint(); }, "r立方体", "r球", "r円柱", "r円錐" ); shapes[0] = _shape3d2.create_box(1, 1, 1); shapes[1] = _shape3d2.create_ball(1.2, 8); shapes[2] = _shape3d2.create_tube(0.8, 1.2, 16); shapes[3] = _shape3d2.create_corn(1.2, 1.2, 16); _material mat = new _material(Color.CYAN, 10); for (_shape3d2 shape : shapes) shape.material = mat; set_target_material(mat); } @Override public void render(_viewport3d vp) { vp.render_shape(shapes[shape_index]); } }