------------------------------------------------------------------------------
| 345 | |
| 346 | //------------------------------------------------------------------------------ |
| 347 | const char* vtkWebApplication::GetWebGLSceneMetaData(vtkRenderWindow* view) |
| 348 | { |
| 349 | if (!view) |
| 350 | { |
| 351 | vtkErrorMacro("No view specified."); |
| 352 | return nullptr; |
| 353 | } |
| 354 | |
| 355 | // We use the camera focal point to be the center of rotation |
| 356 | double centerOfRotation[3]; |
| 357 | vtkCamera* cam = view->GetRenderers()->GetFirstRenderer()->GetActiveCamera(); |
| 358 | cam->GetFocalPoint(centerOfRotation); |
| 359 | |
| 360 | if (this->Internals->ViewWebGLMap.find(view) == this->Internals->ViewWebGLMap.end()) |
| 361 | { |
| 362 | this->Internals->ViewWebGLMap[view] = vtkSmartPointer<vtkWebGLExporter>::New(); |
| 363 | } |
| 364 | |
| 365 | std::stringstream globalIdAsString; |
| 366 | globalIdAsString << this->Internals->ObjectIdMap->GetGlobalId(view); |
| 367 | |
| 368 | vtkWebGLExporter* webglExporter = this->Internals->ViewWebGLMap[view]; |
| 369 | webglExporter->parseScene(view->GetRenderers(), globalIdAsString.str().c_str(), VTK_PARSEALL); |
| 370 | |
| 371 | vtkInternals::WebGLObjId2IndexMap webglMap; |
| 372 | for (int i = 0; i < webglExporter->GetNumberOfObjects(); ++i) |
| 373 | { |
| 374 | vtkWebGLObject* wObj = webglExporter->GetWebGLObject(i); |
| 375 | if (wObj && wObj->isVisible()) |
| 376 | { |
| 377 | vtkInternals::WebGLObjCacheValue val; |
| 378 | val.ObjIndex = i; |
| 379 | for (int j = 0; j < wObj->GetNumberOfParts(); ++j) |
| 380 | { |
| 381 | val.BinaryParts[j] = ""; |
| 382 | } |
| 383 | webglMap[wObj->GetId()] = val; |
| 384 | } |
| 385 | } |
| 386 | this->Internals->WebGLExporterObjIdMap[webglExporter] = webglMap; |
| 387 | webglExporter->SetCenterOfRotation(static_cast<float>(centerOfRotation[0]), |
| 388 | static_cast<float>(centerOfRotation[1]), static_cast<float>(centerOfRotation[2])); |
| 389 | return webglExporter->GenerateMetadata(); |
| 390 | } |
| 391 | |
| 392 | //------------------------------------------------------------------------------ |
| 393 | const char* vtkWebApplication::GetWebGLBinaryData(vtkRenderWindow* view, const char* id, int part) |
no test coverage detected