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
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 _triangle 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(0, 0); scene3d.position(0, -5, 100);
		scene3d.add_angle_listener(stage.getScene(), () -> draw());
		// ラインアート情報の作成
		line_art = new _line_art3d(gc, VIEW_W, VIEW_H, scene3d.get_transform());
		// 2つのトランスフォームを作成する
		_transform tf = new _transform(-90, 0, 0, 0, -10, 0);
		double[][] m_rot5y = new double[3][3];
		_math3d.rot_y(-5, m_rot5y);
		_math3d.mul(m_rot5y, tf.ori, tf.ori);
		_transform tf_rot120z = new _transform(0, 0, 120, 0, 0, 0);
		// 3角形を作る
		_shape3d sh;
		for (int i = 0; i < 3; i++) {
			sh = _shape3d.create_rect(60, 6, tf);
			line_art.add_shape(sh);
			_math3d.mul(tf_rot120z, tf, tf);
		}
		draw();
		stage.show();
	}
	private void draw() {
		line_art.draw();
	}
}