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

Method UpdateRepresentation

Rendering/VR/vtkVRControlsHelper.cxx:123–272  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

121
122//------------------------------------------------------------------------------
123void vtkVRControlsHelper::UpdateRepresentation()
124{
125 this->NeedUpdate = false;
126 if (!this->Enabled)
127 {
128 return;
129 }
130
131 if (this->Renderer && this->Renderer->GetRenderWindow() &&
132 this->Renderer->GetRenderWindow()->GetInteractor())
133 {
134 vtkVRRenderWindow* renWin = static_cast<vtkVRRenderWindow*>(this->Renderer->GetRenderWindow());
135 if (!renWin)
136 {
137 return;
138 }
139
140 // Update physical scale
141 double physicalScale = renWin->GetPhysicalScale();
142
143 // Get the active controller device
144 vtkEventDataDevice controller = this->Device;
145
146 // Hide controls tooltips if the controller is off
147 vtkVRModel* mod = renWin->GetModelForDevice(controller);
148 if (!mod)
149 {
150 this->LabelVisible = false;
151 return;
152 }
153
154 // Get the controls offset position in the controller local coordinate system
155 if (this->ControlPositionLC[0] == 0. && this->ControlPositionLC[1] == 0. &&
156 this->ControlPositionLC[2] == 0.)
157 {
158 this->InitControlPosition();
159 }
160
161 // Controller position and world orientation
162 double* ptrans = renWin->GetPhysicalTranslation();
163 this->LastEventPosition[0] += this->LastPhysicalTranslation[0] - ptrans[0];
164 this->LastEventPosition[1] += this->LastPhysicalTranslation[1] - ptrans[1];
165 this->LastEventPosition[2] += this->LastPhysicalTranslation[2] - ptrans[2];
166 const double* controllerPositionWC = this->LastEventPosition;
167 const double* wxyz = this->LastEventOrientation;
168
169 // todo use ivar here
170 this->TempTransform->Identity();
171 this->TempTransform->RotateWXYZ(wxyz[0], wxyz[1], wxyz[2], wxyz[3]);
172
173 double* frameForward = this->Renderer->GetActiveCamera()->GetDirectionOfProjection();
174 // Controller up direction in WC
175 double* controllerUpWC = this->TempTransform->TransformDoubleVector(0.0, 1.0, 0.0);
176
177 // Compute scale factor. It reaches its max value when the control button
178 // faces the camera. This results in tooltips popping from the controller.
179 double dotFactor = -vtkMath::Dot(controllerUpWC, frameForward);
180

Callers 2

RenderOpaqueGeometryMethod · 0.95

Calls 15

GetPhysicalScaleMethod · 0.80
GetModelForDeviceMethod · 0.80
RotateWXYZMethod · 0.80
GetActiveCameraMethod · 0.80
GetViewUpMethod · 0.80
DotFunction · 0.50
CrossFunction · 0.50
NormalizeFunction · 0.50
NormFunction · 0.50
GetRenderWindowMethod · 0.45
GetInteractorMethod · 0.45

Tested by

no test coverage detected