------------------------------------------------------------------------------
| 284 | |
| 285 | //------------------------------------------------------------------------------ |
| 286 | void vtkInteractorStyleJoystickActor::Spin() |
| 287 | { |
| 288 | if (this->CurrentRenderer == nullptr || this->InteractionProp == nullptr) |
| 289 | { |
| 290 | return; |
| 291 | } |
| 292 | |
| 293 | vtkRenderWindowInteractor* rwi = this->Interactor; |
| 294 | vtkCamera* cam = this->CurrentRenderer->GetActiveCamera(); |
| 295 | |
| 296 | // Get the axis to rotate around = vector from eye to origin |
| 297 | double* obj_center = this->InteractionProp->GetCenter(); |
| 298 | |
| 299 | double motion_vector[3]; |
| 300 | double view_point[3]; |
| 301 | |
| 302 | if (cam->GetParallelProjection()) |
| 303 | { |
| 304 | // If parallel projection, want to get the view plane normal... |
| 305 | cam->ComputeViewPlaneNormal(); |
| 306 | cam->GetViewPlaneNormal(motion_vector); |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | // Perspective projection, get vector from eye to center of actor |
| 311 | cam->GetPosition(view_point); |
| 312 | motion_vector[0] = view_point[0] - obj_center[0]; |
| 313 | motion_vector[1] = view_point[1] - obj_center[1]; |
| 314 | motion_vector[2] = view_point[2] - obj_center[2]; |
| 315 | vtkMath::Normalize(motion_vector); |
| 316 | } |
| 317 | |
| 318 | double disp_obj_center[3]; |
| 319 | |
| 320 | this->ComputeWorldToDisplay(obj_center[0], obj_center[1], obj_center[2], disp_obj_center); |
| 321 | |
| 322 | double* center = this->CurrentRenderer->GetCenter(); |
| 323 | |
| 324 | double yf = (rwi->GetEventPosition()[1] - disp_obj_center[1]) / center[1]; |
| 325 | |
| 326 | if (yf > 1.0) |
| 327 | { |
| 328 | yf = 1.0; |
| 329 | } |
| 330 | else if (yf < -1.0) |
| 331 | { |
| 332 | yf = -1.0; |
| 333 | } |
| 334 | |
| 335 | double newAngle = vtkMath::DegreesFromRadians(asin(yf)) / this->MotionFactor; |
| 336 | |
| 337 | double scale[3]; |
| 338 | scale[0] = scale[1] = scale[2] = 1.0; |
| 339 | |
| 340 | double** rotate = new double*[1]; |
| 341 | rotate[0] = new double[4]; |
| 342 | |
| 343 | rotate[0][0] = newAngle; |
nothing calls this directly
no test coverage detected