Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/aquarium/MouseViewEvent.java @ 345:8f71c3e6f11d
Change directory structure Maven standard
author | sugi |
---|---|
date | Wed, 16 Apr 2014 18:26:07 +0900 |
parents | |
children | aefbe41fcf12 |
line wrap: on
line source
package alice.test.topology.aquarium; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; public class MouseViewEvent implements MouseMotionListener { int new_x, new_y; int pre_x, pre_y; ViewChange v; public MouseViewEvent(ViewChange v) { this.v = v; } @Override public void mouseDragged(MouseEvent event) { new_x = event.getX(); new_y = event.getY(); v.theta -= v.sensitivity * (new_y - pre_y); v.phi += v.sensitivity * (new_x - pre_x); v.camera_y = v.distance * (float)Math.sin(v.theta); v.camera_xz = v.distance * (float)Math.cos(v.theta); v.camera_x = v.camera_xz * (float)Math.sin(v.phi); v.camera_z = v.camera_xz * (float)Math.cos(v.phi); v.Vector_camera_pos.x = v.camera_x; v.Vector_camera_pos.y = v.camera_y; v.Vector_camera_pos.z = v.camera_z; v.Transform_camera_pos.setIdentity(); v.Transform_camera_pos.setTranslation(v.Vector_camera_pos); v.Transform_camera_theta.rotX(-v.theta); v.Transform_camera_phi.rotY(v.phi); v.Transform_camera_phi.mul(v.Transform_camera_theta); v.Transform_camera_pos.mul(v.Transform_camera_phi); v.Camera.setTransform(v.Transform_camera_pos); pre_x = event.getX(); pre_y = event.getY(); } @Override public void mouseMoved(MouseEvent event) { pre_x = event.getX(); pre_y = event.getY(); } }