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
package sample; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import my3d._line_art3d; import my3d._math3d; import my3d._math3d._transform; import my3d._scene3d; import my3d._shape3d; public class _bokutou extends Application { public static void main(String... args) { Application.launch(args); } private static final int VIEW_W = 400, VIEW_H = 300; private GraphicsContext gc; private _line_art3d line_art; @Override public void start(Stage stage) throws Exception { BorderPane pane = new BorderPane(); Scene scene = new Scene(pane); stage.setScene(scene); Canvas view = new Canvas(VIEW_W, VIEW_H); pane.setCenter(view); gc = view.getGraphicsContext2D(); // 情景の設定 _scene3d scene3d = new _scene3d(); scene3d.angle(-20, -10); scene3d.position(0, 0, 100); scene3d.add_angle_listener(stage.getScene(), () -> draw()); // ラインアート情報の作成 line_art = new _line_art3d(gc, VIEW_W, VIEW_H, scene3d.get_transform()); _transform tf_toushin, tf_tsuka; _shape3d toushin, tsuka, border; // 刀身の追加 tf_toushin = new _transform(0, 0, -30, 0, 0, 0); toushin = _shape3d.create_box(6, 60, 2, tf_toushin); line_art.add_shape(toushin); // 柄の追加 tf_tsuka = new _transform(0, 45, 0, 0, -10, 0); _math3d.mul(tf_toushin, tf_tsuka, tf_tsuka); tsuka = _shape3d.create_box(10, 3, 10, tf_tsuka); line_art.add_shape(tsuka); // 境界線の追加 border = _shape3d.border(toushin, tsuka); line_art.add_shape(border); draw(); stage.show(); } private void draw() { line_art.draw(); } }