Mercurial > hg > Members > tatsuki > Alice
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/ViewChange.java Thu Sep 20 21:35:23 2012 +0900 @@ -0,0 +1,61 @@ +package alice.test.topology.aquarium; + +import java.awt.*; + +import javax.media.j3d.*; +import javax.vecmath.*; +import com.sun.j3d.utils.universe.*; + +public class ViewChange extends Canvas3D { + + private static final long serialVersionUID = 1L; + float sensitivity; + float distance; + int new_x, new_y; + int pre_x, pre_y; + SimpleUniverse universe; + TransformGroup Camera; + float camera_x, camera_y, camera_z, camera_xz, camera_xy, camera_yz = 0; + float phi = 0;//(float)Math.PI; + float theta = (float)Math.PI/3; + + Transform3D Transform_camera_pos; + Transform3D Transform_camera_phi; + Transform3D Transform_camera_theta; + Vector3f Vector_camera_pos; + + public ViewChange(float Distance, float Sensitivity, GraphicsConfiguration config){ + super(config); + distance = Distance; + sensitivity = Sensitivity; + universe = new SimpleUniverse(this); + ViewingPlatform vp = universe.getViewingPlatform(); + Camera = vp.getViewPlatformTransform(); + + camera_y = distance * (float)Math.sin(theta); + camera_xz = distance * (float)Math.cos(theta); + camera_x = camera_xz * (float)Math.sin(phi); + camera_z = camera_xz * (float)Math.cos(phi); + + Vector_camera_pos = new Vector3f(camera_x, camera_y, camera_z); + Transform_camera_pos = new Transform3D(); + Transform_camera_pos.setTranslation(Vector_camera_pos); + + Transform_camera_phi = new Transform3D(); + Transform_camera_theta = new Transform3D(); + Transform_camera_theta.rotX(-theta); + Transform_camera_phi.rotY(phi); + Transform_camera_theta.mul(Transform_camera_phi); + Transform_camera_pos.mul(Transform_camera_theta); + + Camera.setTransform(Transform_camera_pos); + + MouseViewEvent mouse = new MouseViewEvent(this); + addMouseMotionListener(mouse); + + } + + + +} +