(MouseEvent e)
| 271 | } |
| 272 | |
| 273 | public void mouseDragged(MouseEvent e) |
| 274 | { |
| 275 | if (ren.VisibleActorCount() == 0) |
| 276 | return; |
| 277 | int x = e.getX(); |
| 278 | int y = e.getY(); |
| 279 | // rotate |
| 280 | if (this.InteractionMode == 1) |
| 281 | { |
| 282 | cam.Azimuth(lastX - x); |
| 283 | cam.Elevation(y - lastY); |
| 284 | cam.OrthogonalizeViewUp(); |
| 285 | resetCameraClippingRange(); |
| 286 | if (this.LightFollowCamera == 1) |
| 287 | { |
| 288 | lgt.SetPosition(cam.GetPosition()); |
| 289 | lgt.SetFocalPoint(cam.GetFocalPoint()); |
| 290 | } |
| 291 | } |
| 292 | // translate |
| 293 | if (this.InteractionMode == 2) |
| 294 | { |
| 295 | double FPoint[]; |
| 296 | double PPoint[]; |
| 297 | double APoint[] = new double[3]; |
| 298 | double RPoint[]; |
| 299 | double focalDepth; |
| 300 | |
| 301 | // get the current focal point and position |
| 302 | FPoint = cam.GetFocalPoint(); |
| 303 | PPoint = cam.GetPosition(); |
| 304 | |
| 305 | // calculate the focal depth since we'll be using it a lot |
| 306 | ren.SetWorldPoint(FPoint[0], FPoint[1], FPoint[2], 1.0); |
| 307 | ren.WorldToDisplay(); |
| 308 | focalDepth = ren.GetDisplayPoint()[2]; |
| 309 | |
| 310 | APoint[0] = rw.GetSize()[0] / 2.0 + (x - lastX); |
| 311 | APoint[1] = rw.GetSize()[1] / 2.0 - (y - lastY); |
| 312 | APoint[2] = focalDepth; |
| 313 | ren.SetDisplayPoint(APoint); |
| 314 | ren.DisplayToWorld(); |
| 315 | RPoint = ren.GetWorldPoint(); |
| 316 | if (RPoint[3] != 0.0) |
| 317 | { |
| 318 | RPoint[0] = RPoint[0] / RPoint[3]; |
| 319 | RPoint[1] = RPoint[1] / RPoint[3]; |
| 320 | RPoint[2] = RPoint[2] / RPoint[3]; |
| 321 | } |
| 322 | |
| 323 | /* |
| 324 | * Compute a translation vector, moving everything 1/2 the distance |
| 325 | * to the cursor. (Arbitrary scale factor) |
| 326 | */ |
| 327 | cam.SetFocalPoint((FPoint[0] - RPoint[0]) / 2.0 + FPoint[0], |
| 328 | (FPoint[1] - RPoint[1]) / 2.0 + FPoint[1], (FPoint[2] - RPoint[2]) / 2.0 + FPoint[2]); |
| 329 | cam.SetPosition((FPoint[0] - RPoint[0]) / 2.0 + PPoint[0], |
| 330 | (FPoint[1] - RPoint[1]) / 2.0 + PPoint[1], (FPoint[2] - RPoint[2]) / 2.0 + PPoint[2]); |
nothing calls this directly
no test coverage detected