Mercurial > hg > Members > tatsuki > Alice
comparison src/alice/test/topology/aquarium/ViewChange.java @ 141:4c71bbfe557d working
add mouse event
author | sugi |
---|---|
date | Thu, 20 Sep 2012 21:35:23 +0900 |
parents | |
children | 287aae21e7d8 |
comparison
equal
deleted
inserted
replaced
140:b51d3bf971e7 | 141:4c71bbfe557d |
---|---|
1 package alice.test.topology.aquarium; | |
2 | |
3 import java.awt.*; | |
4 | |
5 import javax.media.j3d.*; | |
6 import javax.vecmath.*; | |
7 import com.sun.j3d.utils.universe.*; | |
8 | |
9 public class ViewChange extends Canvas3D { | |
10 | |
11 private static final long serialVersionUID = 1L; | |
12 float sensitivity; | |
13 float distance; | |
14 int new_x, new_y; | |
15 int pre_x, pre_y; | |
16 SimpleUniverse universe; | |
17 TransformGroup Camera; | |
18 float camera_x, camera_y, camera_z, camera_xz, camera_xy, camera_yz = 0; | |
19 float phi = 0;//(float)Math.PI; | |
20 float theta = (float)Math.PI/3; | |
21 | |
22 Transform3D Transform_camera_pos; | |
23 Transform3D Transform_camera_phi; | |
24 Transform3D Transform_camera_theta; | |
25 Vector3f Vector_camera_pos; | |
26 | |
27 public ViewChange(float Distance, float Sensitivity, GraphicsConfiguration config){ | |
28 super(config); | |
29 distance = Distance; | |
30 sensitivity = Sensitivity; | |
31 universe = new SimpleUniverse(this); | |
32 ViewingPlatform vp = universe.getViewingPlatform(); | |
33 Camera = vp.getViewPlatformTransform(); | |
34 | |
35 camera_y = distance * (float)Math.sin(theta); | |
36 camera_xz = distance * (float)Math.cos(theta); | |
37 camera_x = camera_xz * (float)Math.sin(phi); | |
38 camera_z = camera_xz * (float)Math.cos(phi); | |
39 | |
40 Vector_camera_pos = new Vector3f(camera_x, camera_y, camera_z); | |
41 Transform_camera_pos = new Transform3D(); | |
42 Transform_camera_pos.setTranslation(Vector_camera_pos); | |
43 | |
44 Transform_camera_phi = new Transform3D(); | |
45 Transform_camera_theta = new Transform3D(); | |
46 Transform_camera_theta.rotX(-theta); | |
47 Transform_camera_phi.rotY(phi); | |
48 Transform_camera_theta.mul(Transform_camera_phi); | |
49 Transform_camera_pos.mul(Transform_camera_theta); | |
50 | |
51 Camera.setTransform(Transform_camera_pos); | |
52 | |
53 MouseViewEvent mouse = new MouseViewEvent(this); | |
54 addMouseMotionListener(mouse); | |
55 | |
56 } | |
57 | |
58 | |
59 | |
60 } | |
61 |