MCPcopy Create free account
hub / github.com/Kitware/VTK / ComputeMatrix

Method ComputeMatrix

Rendering/VR/vtkVRPanelRepresentation.cxx:327–369  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

325
326//------------------------------------------------------------------------------
327void 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//------------------------------------------------------------------------------
372int vtkVRPanelRepresentation::RenderOpaqueGeometry(vtkViewport* v)

Callers 1

RenderOpaqueGeometryMethod · 0.95

Calls 12

GetActiveCameraMethod · 0.80
GetVTKWindowMethod · 0.80
GetUserMatrixMethod · 0.80
GetPhysicalScaleMethod · 0.80
GetInverseMethod · 0.45
GetScaleMethod · 0.45
SetScaleMethod · 0.45
GetPositionMethod · 0.45
SetPositionMethod · 0.45
DeepCopyMethod · 0.45

Tested by

no test coverage detected