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
package sample3d; import javafx.application.Application; import my3d._math3d; import my3d._math3d.*; import my3d._shape3d; import my3d._viewer3d3; import my3d._viewport3d; public class _sample04 extends _viewer3d3 { public static void main(String... args) { Application.launch(args); } private _shape3d tunnel = new _shape3d(); @Override public void init_scene(_viewport3d vp) { set_vert_slider_range(0, 0); set_horz_slider_range(0, 0); set_animation_enable(true); _vector[] va = new _vector[2 * 8]; double t; int j; for (int i = 0; i < 8; i++) { t = i * Math.PI / 4; va[i] = new _vector(Math.cos(t), Math.sin(t), 1); va[i + 8] = new _vector(Math.cos(t), Math.sin(t), -1); j = (i + 1) % 8; tunnel.add_face(i, j, j + 8, i + 8); } tunnel.vertices = va; } @Override public void render(_viewport3d vp) { vp.scene_transform.position.z = 4 * (1 - get_anim_pos()); vp.render_shape(tunnel); } }