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
package my3d; import my3d._math3d.*; import my3d._slider_dialog.*; public abstract class _viewer3d2 extends _viewer3d { @Override protected void init_menu() { double[] balance = vp.get_light_balance(); _vector v = vp.sun_vector; double round_x = Math.atan2(-v.y, Math.sqrt(v.z * v.z + v.x * v.x)); double round_y = Math.atan2(v.x, v.z); _slider_dialog light_dlg = new _slider_dialog(stage, "光源", (values) -> { vp.set_light_balance(values[0], values[1], values[2]); double tx = values[3]; double ty = values[4]; vp.sun_vector.set( Math.cos(tx) * Math.sin(ty), -Math.sin(tx), Math.cos(tx) * Math.cos(ty)); repaint(); }, new _slider_data("環境光", 0, 1, balance[0]), new _slider_data("前照灯", 0, 1, balance[1]), new _slider_data("太陽光", 0, 1, balance[2]), new _slider_data("太陽光(垂直の向き)", -Math.PI / 2, Math.PI / 2, round_x), new _slider_data("太陽光(水平の向き)", Math.PI, -Math.PI, round_y) ); add_param_menu((index) -> { if (!light_dlg.isShowing()) light_dlg.showAndWait(); }, "光源" ); } }