------------------------------------------------------------------------------
| 211 | |
| 212 | //------------------------------------------------------------------------------ |
| 213 | void vtkVRMenuRepresentation::BuildRepresentation() |
| 214 | { |
| 215 | vtkVRRenderWindow* renWin = static_cast<vtkVRRenderWindow*>(this->Renderer->GetRenderWindow()); |
| 216 | double physicalScale = renWin->GetPhysicalScale(); |
| 217 | |
| 218 | if (this->GetMTime() > this->BuildTime) |
| 219 | { |
| 220 | // Compute camera position and orientation |
| 221 | vtkCamera* cam = this->Renderer->GetActiveCamera(); |
| 222 | cam->GetPosition(this->PlacedPos); |
| 223 | double* dop = cam->GetDirectionOfProjection(); |
| 224 | vtkMath::Normalize(dop); |
| 225 | |
| 226 | renWin->GetPhysicalViewUp(this->PlacedVUP); |
| 227 | double vupdot = vtkMath::Dot(dop, this->PlacedVUP); |
| 228 | if (fabs(vupdot) < 0.999) |
| 229 | { |
| 230 | this->PlacedDOP[0] = dop[0] - this->PlacedVUP[0] * vupdot; |
| 231 | this->PlacedDOP[1] = dop[1] - this->PlacedVUP[1] * vupdot; |
| 232 | this->PlacedDOP[2] = dop[2] - this->PlacedVUP[2] * vupdot; |
| 233 | vtkMath::Normalize(this->PlacedDOP); |
| 234 | } |
| 235 | else |
| 236 | { |
| 237 | renWin->GetPhysicalViewDirection(this->PlacedDOP); |
| 238 | } |
| 239 | vtkMath::Cross(this->PlacedDOP, this->PlacedVUP, this->PlacedVRight); |
| 240 | |
| 241 | vtkNew<vtkMatrix4x4> rot; |
| 242 | for (int i = 0; i < 3; ++i) |
| 243 | { |
| 244 | rot->SetElement(0, i, this->PlacedVRight[i]); |
| 245 | rot->SetElement(1, i, this->PlacedVUP[i]); |
| 246 | rot->SetElement(2, i, -this->PlacedDOP[i]); |
| 247 | } |
| 248 | rot->Transpose(); |
| 249 | vtkTransform::GetOrientation(this->PlacedOrientation, rot); |
| 250 | |
| 251 | this->BuildTime.Modified(); |
| 252 | } |
| 253 | |
| 254 | // Set frame distance to camera |
| 255 | double frameDistance = physicalScale * 1.5; // 1.5 meters |
| 256 | |
| 257 | double fov = this->Renderer->GetActiveCamera()->GetViewAngle(); |
| 258 | double psize = frameDistance * 0.03 * 2.0 * atan(fov * 0.5); // 3% of fov |
| 259 | double tscale = psize / 55.0; // about 55 pixel high texture map |
| 260 | |
| 261 | // Frame position |
| 262 | double frameCenter[3]; |
| 263 | |
| 264 | long count = 0; |
| 265 | for (auto& menu : this->Menus) |
| 266 | { |
| 267 | double shift = count - this->CurrentOption; |
| 268 | long icurr = std::lround(this->CurrentOption); |
| 269 | |
| 270 | if (count == icurr) |
no test coverage detected