------------------------------------------------------------------------------
| 325 | |
| 326 | //------------------------------------------------------------------------------ |
| 327 | void vtkVRPanelRepresentation::ComputeMatrix(vtkRenderer* ren) |
| 328 | { |
| 329 | // check whether or not need to rebuild the matrix |
| 330 | // only rebuild on left eye otherwise we get two different |
| 331 | // poses for two eyes |
| 332 | vtkCamera* cam = ren->GetActiveCamera(); |
| 333 | if (this->CoordinateSystem != World && cam->GetLeftEye()) |
| 334 | { |
| 335 | vtkVRRenderWindow* rw = static_cast<vtkVRRenderWindow*>(ren->GetVTKWindow()); |
| 336 | |
| 337 | if (this->CoordinateSystem == HMD) |
| 338 | { |
| 339 | vtkTransform* vt = cam->GetViewTransformObject(); |
| 340 | vt->GetInverse(this->TextActor->GetUserMatrix()); |
| 341 | |
| 342 | if (rw->GetPhysicalScale() != this->LastScale) |
| 343 | { |
| 344 | double ratio = rw->GetPhysicalScale() / this->LastScale; |
| 345 | double* scale = this->TextActor->GetScale(); |
| 346 | this->TextActor->SetScale(scale[0] * ratio, scale[1] * ratio, scale[2] * ratio); |
| 347 | double* pos = this->TextActor->GetPosition(); |
| 348 | this->TextActor->SetPosition(pos[0] * ratio, pos[1] * ratio, -0.5 * rw->GetPhysicalScale()); |
| 349 | this->LastScale = rw->GetPhysicalScale(); |
| 350 | } |
| 351 | else |
| 352 | { |
| 353 | double* pos = this->TextActor->GetPosition(); |
| 354 | this->TextActor->SetPosition(pos[0], pos[1], -0.5 * rw->GetPhysicalScale()); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | vtkEventDataDevice device = this->CoordinateSystem == LeftController |
| 359 | ? vtkEventDataDevice::LeftController |
| 360 | : vtkEventDataDevice::RightController; |
| 361 | |
| 362 | vtkNew<vtkMatrix4x4> deviceToWorldMatrix; |
| 363 | if (rw->GetDeviceToWorldMatrixForDevice(device, deviceToWorldMatrix)) |
| 364 | { |
| 365 | // transform the text to the devices location in world coordinates |
| 366 | this->TextActor->GetUserMatrix()->DeepCopy(deviceToWorldMatrix); |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | //------------------------------------------------------------------------------ |
| 372 | int vtkVRPanelRepresentation::RenderOpaqueGeometry(vtkViewport* v) |
no test coverage detected