private void beginTranslate(MouseEvent e) { _xmouse = e.getX(); _ymouse = e.getY(); _canvas = (ViewCanvas)e.getSource(); _canvas.addMouseMotionListener(_mml); _view = (OrbitView)_canvas.getView(); // The mouse z coordinate, read from the depth buffer. The value 1.0 // corresponds to the far clipping plane, which indicates that the // mouse was not pressed on any object rendered into the z-buffer. // In this case, we use the middle value pixel z value 0.5. _zmouse = _canvas.getPixelZ(_xmouse,_ymouse); if (_zmouse==1.0) _zmouse = 0.5; // Pixel-to-unit-sphere transform. Matrix44 cubeToPixel = _canvas.getCubeToPixel(); Matrix44 viewToCube = _canvas.getViewToCube(); Matrix44 viewToPixel = cubeToPixel.times(viewToCube); Matrix44 unitSphereToView = _view.getUnitSphereToView(); Matrix44 unitSphereToPixel = viewToPixel.times(unitSphereToView); Matrix44 pixelToUnitSphere = unitSphereToPixel.inverse(); // The current translate vector. _translate = _view.getTranslate(); // The matrix inverse of the unit-sphere-to-pixel transform, but // with the current translate part removed, because that is the // part that we will change during translate. _translateM = Matrix44.translate(_translate).times(pixelToUnitSphere); // The transformed 3-D pixel (mouse) coordinates. _translateP = _translateM.times(new Point3(_xmouse,_ymouse,_zmouse)); }
float elevation = (float)view.getElevation(); float scale = (float)view.getScale(); Vector3 t = view.getTranslate(); System.out.println("OrbitView: azimuth="+azimuth); System.out.println(" elevation="+elevation); Matrix44 unitSphereToCube = viewToCube.times(unitSphereToView); Matrix44 cubeToUnitSphere = unitSphereToCube.inverse(); Vector3 translate = view.getTranslate(); Matrix44 m = Matrix44.translate(translate).times(cubeToUnitSphere); double xc = 0.0;