//--------------------------------------------------------------- void DocumentExporter::exportMaxScene() { mStreamWriter.startDocument(); createExporters(); exportAsset(); exportEffects(); exportMaterials(); exportGeometries(); exportControllers(); exportCameras(); exportLights(); exportImages(); exportVisualScenes(); if ( mOptions.getExportAnimations() ) exportAnimations(); exportScene(); deleteExporters(); mStreamWriter.endDocument(); const ExportSceneGraph::XRefSceneGraphList& sceneGraphList = mExportSceneGraph->getXRefSceneGraphList(); for ( ExportSceneGraph::XRefSceneGraphList::const_iterator it = sceneGraphList.begin(); it!=sceneGraphList.end(); ++it ) { NativeString outputFileName(NativeString(getXRefOutputPath(*it))); DocumentExporter document(mMaxInterface, it->exportSceneGraph, outputFileName, mOptions, mExportOnlySelected); document.exportMaxScene(); } }
bool ConverterImpl::convert() { bool ret = true; ret = ret && importScene(); ret = ret && convertToT3D(); ret = ret && exportScene(); cleanup(); return ret; }
MainWindow::MainWindow() { m_drawing = new DrawingArea(this); setCentralWidget(m_drawing); createStatusBar(); this->resize(1000, 800); parseAction = new QAction(tr("&Parse File"), this); parseAction->setStatusTip(tr("Open a trace file for parsing")); exportAction = new QAction(tr("&Export Scene"), this); exportAction->setStatusTip(tr("Export the current scene")); createToolBar(); connect(parseAction, SIGNAL(triggered()), this, SLOT(parseFile())); connect(exportAction, SIGNAL(triggered()), this, SLOT(exportScene())); connect(m_spinBox, SIGNAL(valueChanged(int)), this, SLOT(timeChanged(int))); connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(timeChanged(int))); }
ExportDialog::ExportDialog(GLWidget *widget, QWidget *parent) : QDialog(parent),glWidget(widget){ setWindowTitle(tr("Export")); bar=new QProgressBar; bar->setValue(bar->minimum()); makeTimeGroupBox(); makeSizeGroupBox(); makeExportGroupBox(); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(exportScene())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); QVBoxLayout *layout=new QVBoxLayout; layout->addWidget(timeOutGb); layout->addWidget(sizeOutGb); layout->addWidget(exportFileGb); layout->addWidget(bar); layout->addWidget(buttonBox); setLayout(layout); setFixedSize(sizeHint()); }
void ModelBaker::outputBakedFST() { // Output FST file, copying over input mappings if available QString outputFSTFilename = !_mappingURL.isEmpty() ? _mappingURL.fileName() : _modelURL.fileName(); auto extensionStart = outputFSTFilename.indexOf("."); if (extensionStart != -1) { outputFSTFilename.resize(extensionStart); } outputFSTFilename += ".baked.fst"; QString outputFSTURL = _bakedOutputDir + "/" + outputFSTFilename; auto outputMapping = _mapping; outputMapping[FST_VERSION_FIELD] = FST_VERSION; outputMapping[FILENAME_FIELD] = _bakedModelURL.fileName(); outputMapping.remove(TEXDIR_FIELD); outputMapping.remove(COMMENT_FIELD); if (!_materialMappingJSON.isEmpty()) { outputMapping[MATERIAL_MAPPING_FIELD] = QJsonDocument(_materialMappingJSON).toJson(QJsonDocument::Compact); } hifi::ByteArray fstOut = FSTReader::writeMapping(outputMapping); QFile fstOutputFile { outputFSTURL }; if (!fstOutputFile.open(QIODevice::WriteOnly)) { handleError("Failed to open file '" + outputFSTURL + "' for writing"); return; } if (fstOutputFile.write(fstOut) == -1) { handleError("Failed to write to file '" + outputFSTURL + "'"); return; } _outputFiles.push_back(outputFSTURL); _outputMappingURL = outputFSTURL; exportScene(); qCDebug(model_baking) << "Finished baking, emitting finished" << _modelURL; emit finished(); }
void cv::viz::InteractorStyle::OnKeyDown() { CV_Assert("Interactor style not initialized. Please call Initialize() before continuing" && init_); FindPokedRenderer(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1]); // Save the initial windows width/height if (win_size_[0] == -1 || win_size_[1] == -1) win_size_ = Vec2i(Interactor->GetRenderWindow()->GetSize()); bool alt = Interactor->GetAltKey() != 0; std::string key(Interactor->GetKeySym()); if (key.find("XF86ZoomIn") != std::string::npos) zoomIn(); else if (key.find("XF86ZoomOut") != std::string::npos) zoomOut(); switch (Interactor->GetKeyCode()) { case 'h': case 'H': { std::cout << "| Help:\n" "-------\n" " p, P : switch to a point-based representation\n" " w, W : switch to a wireframe-based representation (where available)\n" " s, S : switch to a surface-based representation (where available)\n" "\n" " j, J : take a .PNG snapshot of the current window view\n" " k, K : export scene to Wavefront .obj format\n" " ALT + k, K : export scene to VRML format\n" " c, C : display current camera/window parameters\n" " f, F : fly to point mode, hold the key and move mouse where to fly\n" "\n" " e, E : exit the interactor\n" " q, Q : stop and call VTK's TerminateApp\n" "\n" " +/- : increment/decrement overall point size\n" " +/- [+ ALT] : zoom in/out \n" "\n" " r, R [+ ALT] : reset camera [to viewpoint = {0, 0, 0} -> center_{x, y, z}]\n" "\n" " ALT + s, S : turn stereo mode on/off\n" " ALT + f, F : switch between maximized window mode and original size\n" "\n" << std::endl; break; } // Switch representation to points case 'p': case 'P': { vtkSmartPointer<vtkActorCollection> ac = CurrentRenderer->GetActors(); vtkCollectionSimpleIterator ait; for (ac->InitTraversal(ait); vtkActor* actor = ac->GetNextActor(ait); ) for (actor->InitPathTraversal(); vtkAssemblyPath* path = actor->GetNextPath(); ) { vtkActor* apart = vtkActor::SafeDownCast(path->GetLastNode()->GetViewProp()); apart->GetProperty()->SetRepresentationToPoints(); } break; } // Save a PNG snapshot case 'j': case 'J': saveScreenshot(cv::format("screenshot-%d.png", (unsigned int)time(0))); break; // Export scene as in obj or vrml format case 'k': case 'K': { String format = alt ? "scene-%d.vrml" : "scene-%d"; exportScene(cv::format(format.c_str(), (unsigned int)time(0))); break; } // display current camera settings/parameters case 'c': case 'C': { vtkSmartPointer<vtkCamera> cam = Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetActiveCamera(); Vec2d clip(cam->GetClippingRange()); Vec3d focal(cam->GetFocalPoint()), pos(cam->GetPosition()), view(cam->GetViewUp()); Vec2i win_pos(Interactor->GetRenderWindow()->GetPosition()); Vec2i win_size(Interactor->GetRenderWindow()->GetSize()); double angle = cam->GetViewAngle () / 180.0 * CV_PI; String data = cv::format("clip(%f,%f) focal(%f,%f,%f) pos(%f,%f,%f) view(%f,%f,%f) angle(%f) winsz(%d,%d) winpos(%d,%d)", clip[0], clip[1], focal[0], focal[1], focal[2], pos[0], pos[1], pos[2], view[0], view[1], view[2], angle, win_size[0], win_size[1], win_pos[0], win_pos[1]); std::cout << data.c_str() << std::endl; break; } case '=': { zoomIn(); break; } case 43: // KEY_PLUS { if (alt) zoomIn(); else { vtkSmartPointer<vtkActorCollection> ac = CurrentRenderer->GetActors(); vtkCollectionSimpleIterator ait; for (ac->InitTraversal(ait); vtkActor* actor = ac->GetNextActor(ait); ) for (actor->InitPathTraversal(); vtkAssemblyPath* path = actor->GetNextPath(); ) { vtkActor* apart = vtkActor::SafeDownCast(path->GetLastNode()->GetViewProp()); float psize = apart->GetProperty()->GetPointSize(); if (psize < 63.0f) apart->GetProperty()->SetPointSize(psize + 1.0f); } } break; } case 45: // KEY_MINUS { if (alt) zoomOut(); else { vtkSmartPointer<vtkActorCollection> ac = CurrentRenderer->GetActors(); vtkCollectionSimpleIterator ait; for (ac->InitTraversal(ait); vtkActor* actor = ac->GetNextActor(ait); ) for (actor->InitPathTraversal(); vtkAssemblyPath* path = actor->GetNextPath(); ) { vtkActor* apart = vtkActor::SafeDownCast(path->GetLastNode()->GetViewProp()); float psize = apart->GetProperty()->GetPointSize(); if (psize > 1.0f) apart->GetProperty()->SetPointSize(psize - 1.0f); } } break; } // Switch between maximize and original window size case 'f': case 'F': { if (alt) { Vec2i screen_size(Interactor->GetRenderWindow()->GetScreenSize()); Vec2i win_size(Interactor->GetRenderWindow()->GetSize()); // Is window size = max? if (win_size == max_win_size_) { Interactor->GetRenderWindow()->SetSize(win_size_.val); Interactor->GetRenderWindow()->SetPosition(win_pos_.val); Interactor->GetRenderWindow()->Render(); Interactor->Render(); } // Set to max else { win_pos_ = Vec2i(Interactor->GetRenderWindow()->GetPosition()); win_size_ = win_size; Interactor->GetRenderWindow()->SetSize(screen_size.val); Interactor->GetRenderWindow()->Render(); Interactor->Render(); max_win_size_ = Vec2i(Interactor->GetRenderWindow()->GetSize()); } } else { AnimState = VTKIS_ANIM_ON; Interactor->GetPicker()->Pick(Interactor->GetEventPosition()[0], Interactor->GetEventPosition()[1], 0.0, CurrentRenderer); vtkSmartPointer<vtkAbstractPropPicker> picker = vtkAbstractPropPicker::SafeDownCast(Interactor->GetPicker()); if (picker) if (picker->GetPath()) Interactor->FlyTo(CurrentRenderer, picker->GetPickPosition()); AnimState = VTKIS_ANIM_OFF; } break; } // 's'/'S' w/out ALT case 's': case 'S': { if (alt) { vtkSmartPointer<vtkRenderWindow> window = Interactor->GetRenderWindow(); if (!window->GetStereoRender()) { static Vec2i red_blue(4, 3), magenta_green(2, 5); window->SetAnaglyphColorMask (stereo_anaglyph_mask_default_ ? red_blue.val : magenta_green.val); stereo_anaglyph_mask_default_ = !stereo_anaglyph_mask_default_; } window->SetStereoRender(!window->GetStereoRender()); Interactor->Render(); } else Superclass::OnKeyDown(); break; } case 'o': case 'O': { vtkSmartPointer<vtkCamera> cam = CurrentRenderer->GetActiveCamera(); cam->SetParallelProjection(!cam->GetParallelProjection()); CurrentRenderer->Render(); break; } // Overwrite the camera reset case 'r': case 'R': { if (!alt) { Superclass::OnKeyDown(); break; } WidgetActorMap::iterator it = widget_actor_map_->begin(); // it might be that some actors don't have a valid transformation set -> we skip them to avoid a seg fault. for (; it != widget_actor_map_->end(); ++it) { vtkProp3D * actor = vtkProp3D::SafeDownCast(it->second); if (actor && actor->GetUserMatrix()) break; } vtkSmartPointer<vtkCamera> cam = CurrentRenderer->GetActiveCamera(); // if a valid transformation was found, use it otherwise fall back to default view point. if (it != widget_actor_map_->end()) { vtkMatrix4x4* m = vtkProp3D::SafeDownCast(it->second)->GetUserMatrix(); cam->SetFocalPoint(m->GetElement(0, 3) - m->GetElement(0, 2), m->GetElement(1, 3) - m->GetElement(1, 2), m->GetElement(2, 3) - m->GetElement(2, 2)); cam->SetViewUp (m->GetElement(0, 1), m->GetElement(1, 1), m->GetElement(2, 1)); cam->SetPosition(m->GetElement(0, 3), m->GetElement(1, 3), m->GetElement(2, 3)); } else { cam->SetPosition(0, 0, 0); cam->SetFocalPoint(0, 0, 1); cam->SetViewUp(0, -1, 0); } // go to the next actor for the next key-press event. if (it != widget_actor_map_->end()) ++it; else it = widget_actor_map_->begin(); CurrentRenderer->SetActiveCamera(cam); CurrentRenderer->ResetCameraClippingRange(); CurrentRenderer->Render(); break; } case 'q': case 'Q': { Interactor->ExitCallback(); return; } default: { Superclass::OnKeyDown(); break; } } KeyboardEvent event(KeyboardEvent::KEY_DOWN, Interactor->GetKeySym(), Interactor->GetKeyCode(), getModifiers()); if (keyboardCallback_) keyboardCallback_(event, keyboard_callback_cookie_); Interactor->Render(); }
//--------------------------------------------------------------- void DocumentExporter::exportCurrentScene ( bool selectionOnly ) { mIsImport = false; // Create the import/export library helpers. createLibraries(); mStreamWriter.startDocument(); // Build the scene graph if ( mSceneGraph->create ( selectionOnly ) ) { // Export the asset of the document. exportAsset(); if ( !ExportOptions::exportMaterialsOnly () ) { // Start by caching the expressions that will be sampled mSceneGraph->sampleAnimationExpressions(); if (!ExportOptions::exportAnimations() || ExportOptions::exportPolygonMeshes()) { // Export the lights. mLightExporter->exportLights(); // Export the cameras. mCameraExporter->exportCameras(); // Export the material URLs and get the material list MaterialMap* materialMap = mMaterialExporter->exportMaterials(); // Export the effects (materials) const ImageMap* imageMap = mEffectExporter->exportEffects(materialMap); // Export the images mImageExporter->exportImages(imageMap); } // Export the controllers. Must be done before the geometries, to decide, which // geometries have to be exported (for example, if the controller need an invisible // geometry, we also have to export it). mControllerExporter->exportControllers(); // Don't export Physics if required PhysX plugin is not loaded if (ExportOptions::exportPhysics() && !PhysXExporter::CheckPhysXPluginVersion()) { MGlobal::displayError(MString("Physics not exported. Minimum PhysX plugin version: ") + PhysXExporter::GetRequiredPhysXPluginVersion()); MGlobal::displayError(MString("Installed version: ") + PhysXExporter::GetInstalledPhysXPluginVersion()); ExportOptions::setExportPhysics(false); } // Export PhysX to XML before exporting geometries if (ExportOptions::exportPhysics() && !mPhysXExporter->generatePhysXXML()) { // Don't try to export Physics if xml export has failed ExportOptions::setExportPhysics(false); MGlobal::displayError(MString("Error while exporting PhysX scene to XML. Physics not exported.")); } // Export the geometries mGeometryExporter->exportGeometries(); // Export the LOD mLODExporter->exportLODs(mVisualSceneExporter); bool physicsSceneExported = false; if (ExportOptions::exportPhysics()) { // Export PhysX physicsSceneExported = mPhysXExporter->exportPhysicsLibraries(); } saveParamClip(); // Export the visual scene bool visualSceneExported = mVisualSceneExporter->exportVisualScenes(); // Export the animations if (ExportOptions::exportAnimations()) { const AnimationClipList* animationClips = mAnimationExporter->exportAnimations(); // Export the animation clips mAnimationClipExporter->exportAnimationClips(animationClips); } restoreParamClip(); // Export the scene exportScene(visualSceneExported, physicsSceneExported); // Export the light probes. mLightProbeExporter->exportLightProbes(); } else { // Export the material URLs and get the material list MaterialMap* materialMap = mMaterialExporter->exportMaterials(); // Export the effects (materials) const ImageMap* imageMap = mEffectExporter->exportEffects ( materialMap ); // Export the images mImageExporter->exportImages ( imageMap ); } } mStreamWriter.endDocument(); }
void ModelBaker::texturesFinished() { embedTextureMetaData(); exportScene(); }