CC_FILE_ERROR FBXFilter::saveToFile(ccHObject* entity, QString filename, SaveParameters& parameters) { if (!entity) return CC_FERR_BAD_ARGUMENT; std::vector<ccGenericMesh*> meshes; if (entity->isKindOf(CC_TYPES::MESH)) { meshes.push_back(static_cast<ccGenericMesh*>(entity)); } else if (entity->isA(CC_TYPES::HIERARCHY_OBJECT)) { for (unsigned i=0; i<entity->getChildrenNumber(); ++i) { ccHObject* child = entity->getChild(i); if (child->isKindOf(CC_TYPES::MESH)) meshes.push_back(static_cast<ccGenericMesh*>(child)); } } if (meshes.empty()) { return CC_FERR_NO_SAVE; } //The first thing to do is to create the FBX Manager which is the object allocator for almost all the classes in the SDK FbxManager* lSdkManager = FbxManager::Create(); if( !lSdkManager ) { ccLog::Warning("[FBX] Error: Unable to create FBX Manager!"); return CC_FERR_CONSOLE_ERROR; } else { ccLog::Print("[FBX] Autodesk FBX SDK version %s", lSdkManager->GetVersion()); } try { //Create an IOSettings object. This object holds all import/export settings. FbxIOSettings* ios = FbxIOSettings::Create(lSdkManager, IOSROOT); lSdkManager->SetIOSettings(ios); //Load plugins from the executable directory (optional) //FbxString lPath = FbxGetApplicationDirectory(); //lSdkManager->LoadPluginsDirectory(lPath.Buffer()); //Create an FBX scene. This object holds most objects imported/exported from/to files. FbxScene* lScene = FbxScene::Create(lSdkManager, "My Scene"); if( !lScene ) { ccLog::Warning("[FBX] Error: Unable to create FBX scene!"); return CC_FERR_CONSOLE_ERROR; } // create scene info { FbxDocumentInfo* sceneInfo = FbxDocumentInfo::Create(lSdkManager,"SceneInfo"); sceneInfo->mTitle = qPrintable(QString("Mesh: ") + (meshes.size() == 1 ? meshes[0]->getName() : QString("Multiple meshes"))); sceneInfo->mAuthor = "CloudCompare"; sceneInfo->mRevision = "rev. 1.0"; sceneInfo->mKeywords = "cloudcompare mesh"; // we need to add the sceneInfo before calling AddThumbNailToScene because // that function is asking the scene for the sceneInfo. lScene->SetSceneInfo(sceneInfo); } //create thumbnail //{ // FbxThumbnail* lThumbnail = FbxThumbnail::Create(lScene,""); // lThumbnail->SetDataFormat(FbxThumbnail::eRGB_24); // lThumbnail->SetSize(FbxThumbnail::e64x64); // lThumbnail->SetThumbnailImage(cSceneThumbnail); // if (lScene->GetSceneInfo()) // { // lScene->GetSceneInfo()->SetSceneThumbnail(lThumbnail); // } //} // Build the node tree. FbxNode* lRootNode = lScene->GetRootNode(); { for (size_t i=0; i<meshes.size(); ++i) { FbxNode* meshNode = ToFbxMesh(meshes[i],lScene,filename,i); if (meshNode) lRootNode->AddChild(meshNode); else ccLog::Warning(QString("[FBX] Failed to convert mesh '%1' to FBX mesh/node!").arg(meshes[i]->getName())); } } int fileFormat = -1; //Display a combox box to let the user choose the export file format { FbxManager* pSdkManager = FbxManager::GetDefaultManager(); int lFormatCount = pSdkManager ? pSdkManager->GetIOPluginRegistry()->GetWriterFormatCount() : 0; if (lFormatCount > 0) { if (s_defaultOutputFormat.isEmpty()) { try { QMessageBox msgBox(QMessageBox::Question,"FBX format","Choose output format:"); QMap<QAbstractButton*,int> buttons; for (int lFormatIndex=0; lFormatIndex<lFormatCount; lFormatIndex++) { if (pSdkManager->GetIOPluginRegistry()->WriterIsFBX(lFormatIndex)) { FbxString lDesc = pSdkManager->GetIOPluginRegistry()->GetWriterFormatDescription(lFormatIndex); QPushButton *button = msgBox.addButton(lDesc.Buffer(), QMessageBox::AcceptRole); buttons[button] = lFormatIndex; } } msgBox.exec(); //get the right format fileFormat = buttons[msgBox.clickedButton()]; } catch(...) { } } else { //try to find the default output format as set by the user for (int lFormatIndex=0; lFormatIndex<lFormatCount; lFormatIndex++) { if (pSdkManager->GetIOPluginRegistry()->WriterIsFBX(lFormatIndex)) { FbxString lDesc = pSdkManager->GetIOPluginRegistry()->GetWriterFormatDescription(lFormatIndex); QString sanitizedDesc = SanitizeFBXFormatString(lDesc.Buffer()); if (s_defaultOutputFormat == sanitizedDesc) { ccLog::Print(QString("[FBX] Default output file format: %1").arg(sanitizedDesc)); fileFormat = lFormatIndex; break; } } } //if we failed to find the specified file format, warn the user and display the list of supported formats if (fileFormat < 0) { ccLog::Warning(QString("[FBX] File format '%1' not supported").arg(s_defaultOutputFormat)); ccLog::Print("[FBX] Supported output formats:"); for (int lFormatIndex=0; lFormatIndex<lFormatCount; lFormatIndex++) { if (pSdkManager->GetIOPluginRegistry()->WriterIsFBX(lFormatIndex)) { FbxString lDesc = pSdkManager->GetIOPluginRegistry()->GetWriterFormatDescription(lFormatIndex); ccLog::Print(QString("\t- %1").arg(SanitizeFBXFormatString(lDesc.Buffer()))); } } } } } } // Save the scene. bool lResult = SaveScene(lSdkManager, lScene, qPrintable(filename),fileFormat); // Destroy all objects created by the FBX SDK. if( lSdkManager ) lSdkManager->Destroy(); return lResult ? CC_FERR_NO_ERROR : CC_FERR_CONSOLE_ERROR; } catch(...) { ccLog::Warning("[FBX] FBX SDK has thrown an unknown exception!"); return CC_FERR_THIRD_PARTY_LIB_EXCEPTION; } }
EditorMainWindow::EditorMainWindow(EditorApplication* app, QWidget* parent) : QMainWindow(parent) , mApplication(app) , mEntityTreeDock(NULL) , mSpawnersDock(NULL) , mPropertyEditorDock(NULL) { mUpdateTimer = new QTimer(this); connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(EmitQueuedMessages())); mUpdateTimer->start(100); // register local message pump to receive messages from game message pump dtEntity::MessageFunctor functor(&mMessagePump, &dtEntity::MessagePump::EnqueueMessage); dtEntity::EntityManager& em = mApplication->GetEntityManager(); em.RegisterForMessages(dtEntity::ToolsUpdatedMessage::TYPE, functor); em.RegisterForMessages(dtEntity::SceneLoadedMessage::TYPE, functor); em.RegisterForMessages(dtEntity::SceneUnloadedMessage::TYPE, functor); em.RegisterForMessages(dtEntity::MapLoadedMessage::TYPE, functor); em.RegisterForMessages(dtEntity::MapUnloadedMessage::TYPE, functor); mMessagePump.RegisterForMessages(dtEntity::ToolsUpdatedMessage::TYPE, dtEntity::MessageFunctor(this, &EditorMainWindow::OnToolsUpdated)); mMessagePump.RegisterForMessages(dtEntity::SceneLoadedMessage::TYPE, dtEntity::MessageFunctor(this, &EditorMainWindow::OnSceneLoaded)); mMessagePump.RegisterForMessages(dtEntity::SceneUnloadedMessage::TYPE, dtEntity::MessageFunctor(this, &EditorMainWindow::OnSceneUnloaded)); mMessagePump.RegisterForMessages(dtEntity::MapLoadedMessage::TYPE, dtEntity::MessageFunctor(this, &EditorMainWindow::OnMapLoaded)); mMessagePump.RegisterForMessages(dtEntity::MapUnloadedMessage::TYPE, dtEntity::MessageFunctor(this, &EditorMainWindow::OnMapUnloaded)); setMinimumSize(800, 600); layout()->setContentsMargins(0, 0, 0, 0); setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks | QMainWindow::VerticalTabs); setWindowTitle("dtEntity Editor"); createActions(); createMenus(); createToolBars(); CreateDockWidgets(); connect(this, SIGNAL(LoadScene(const QString&)), app, SLOT(LoadScene(const QString&))); connect(this, SIGNAL(NewScene()), app, SLOT(NewScene())); connect(this, SIGNAL(SaveScene(QString)), app, SLOT(SaveScene(QString))); }
void HandleBarcode(){ //save if(barcode == 0) SaveScene(); //load else if(barcode == 1) LoadScene(); //add cube else if(barcode == 2){ OpenGLObject another_obj; another_obj.translate_object(0, objects.size()*10, 0); objects.push_back(another_obj); } //delete cube else if(barcode == 3){ //prompt them to make sure they're sure cout << "\n***ARE YOU SURE YOU WANT TO DELETE CURRENTLY SELECTED OBJECT?***\n\n"; string answer; cin >> answer; if(answer == "Yes" || answer == "yes" || answer == "y"){ //only let them do it if they have more than one cube on the screen if(objects.size() > 1){ for(int i=0; i < objects.size(); i++) objects[i].reset_colors(); control_mode = 0; mode = 0; objects.erase(objects.begin() + object_selection); object_selection = 0; } } }
bool Build_FBX_Model( const double* geo_transform, const std::string& output_pathname ) { // Create the model FbxManager* sdk_manager = NULL; FbxScene* scene = NULL; InitializeSdkObjects( sdk_manager, scene ); // Register our new mesh // Save the scene const char* opath = output_pathname.c_str(); bool result = SaveScene( sdk_manager, scene, opath ); // Clean up DestroySdkObjects( sdk_manager, result ); }
XCALL_( int ) Activate( int version, GlobalFunc *global, LWLayoutGeneric *local, void *serverData) { if ( version != LWLAYOUTGENERIC_VERSION ) return AFUNC_BADVERSION; SaveScene(global); return AFUNC_OK; }
int main(int argc, char** argv) { KFbxSdkManager* lSdkManager = NULL; KFbxScene* lScene = NULL; bool lResult; // Prepare the FBX SDK. InitializeSdkObjects(lSdkManager, lScene); // Create the scene. lResult = CreateScene(lSdkManager, lScene); if(lResult == false) { printf("\n\nAn error occurred while creating the scene...\n"); DestroySdkObjects(lSdkManager); return 0; } // Save the scene. // The example can take an output file name as an argument. if(argc > 1) { lResult = SaveScene(lSdkManager, lScene, argv[1]); } // A default output file name is given otherwise. else { lResult = SaveScene(lSdkManager, lScene, SAMPLE_FILENAME); } if(lResult == false) { printf("\n\nAn error occurred while saving the scene...\n"); DestroySdkObjects(lSdkManager); return 0; } // Destroy all objects created by the FBX SDK. DestroySdkObjects(lSdkManager); return 0; }
void QtMainWindow::SetupActions() { QtMainWindowHandler *actionHandler = QtMainWindowHandler::Instance(); //File connect(ui->menuFile, SIGNAL(triggered(QAction *)), actionHandler, SLOT(FileMenuTriggered(QAction *))); connect(ui->actionNewScene, SIGNAL(triggered()), actionHandler, SLOT(NewScene())); connect(ui->actionOpenScene, SIGNAL(triggered()), actionHandler, SLOT(OpenScene())); connect(ui->actionOpenProject, SIGNAL(triggered()), actionHandler, SLOT(OpenProject())); connect(ui->actionSaveScene, SIGNAL(triggered()), actionHandler, SLOT(SaveScene())); connect(ui->actionSaveToFolder, SIGNAL(triggered()), actionHandler, SLOT(SaveToFolderWithChilds())); ui->actionExportPVRIOS->setData(GPU_POWERVR_IOS); ui->actionExportPVRAndroid->setData(GPU_POWERVR_ANDROID); ui->actionExportTegra->setData(GPU_TEGRA); ui->actionExportMali->setData(GPU_MALI); ui->actionExportAdreno->setData(GPU_ADRENO); ui->actionExportPNG->setData(GPU_UNKNOWN); connect(ui->menuExport, SIGNAL(triggered(QAction *)), actionHandler, SLOT(ExportMenuTriggered(QAction *))); connect(ui->actionReloadAll, SIGNAL(triggered()), actionHandler, SLOT(RepackAndReloadTextures())); //View connect(ui->actionRestoreViews, SIGNAL(triggered()), actionHandler, SLOT(RestoreViews())); //Tools connect(ui->actionMaterialEditor, SIGNAL(triggered()), actionHandler, SLOT(Materials())); connect(ui->actionTextureConverter, SIGNAL(triggered()), actionHandler, SLOT(ConvertTextures())); connect(ui->actionHeightMapEditor, SIGNAL(triggered()), actionHandler, SLOT(HeightmapEditor())); connect(ui->actionTileMapEditor, SIGNAL(triggered()), actionHandler, SLOT(TilemapEditor())); connect(ui->actionRulerTool, SIGNAL(triggered()), actionHandler, SLOT(RulerTool())); connect(ui->actionShowSettings, SIGNAL(triggered()), actionHandler, SLOT(ShowSettings())); connect(ui->actionSquareTextures, SIGNAL(triggered()), actionHandler, SLOT(SquareTextures())); connect(ui->actionShowMipmapLevel, SIGNAL(triggered()), actionHandler, SLOT(ReplaceZeroMipmaps())); #if defined (__DAVAENGINE_MACOS__) ui->menuTools->removeAction(ui->actionBeast); #else //#if defined (__DAVAENGINE_MACOS__) connect(ui->actionBeast, SIGNAL(triggered()), actionHandler, SLOT(Beast())); #endif //#if defined (__DAVAENGINE_MACOS__) //Edit connect(ui->actionConvertToShadow, SIGNAL(triggered()), actionHandler, SLOT(ConvertToShadow())); //Temporary hided for development-qa branch ui->actionEnableCameraLight->setVisible(false); ui->actionEnableCameraLight->setChecked(EditorSettings::Instance()->GetShowEditorCamerLight()); connect(ui->actionEnableCameraLight, SIGNAL(triggered()), actionHandler, SLOT(CameraLightTrigerred())); //Help connect(ui->actionHelp, SIGNAL(triggered()), actionHandler, SLOT(OpenHelp())); }
void BiLiOBSMainWid::mSave(const char *file) { SaveScene(); SaveAudioDeviceConfig(); SaveFrontendHotkeys(); mBasicConfig.Save(); #if 0 obs_data_array_t *sceneOrder = mSaveSceneListOrder(); obs_data_t *saveData = GenerateSaveData(sceneOrder); if (!obs_data_save_json_safe(saveData, file, "tmp", "bak")) blog(LOG_ERROR, "Could not save scene data to %s", file); obs_data_release(saveData); obs_data_array_release(sceneOrder); #endif }
CC_FILE_ERROR FBXFilter::saveToFile(ccHObject* entity, const char* filename) { if (!entity) return CC_FERR_BAD_ARGUMENT; std::vector<ccGenericMesh*> meshes; if (entity->isKindOf(CC_MESH)) { meshes.push_back(static_cast<ccGenericMesh*>(entity)); } else if (entity->isA(CC_HIERARCHY_OBJECT)) { for (unsigned i=0; i<entity->getChildrenNumber(); ++i) { ccHObject* child = entity->getChild(i); if (child->isKindOf(CC_MESH)) meshes.push_back(static_cast<ccGenericMesh*>(child)); } } if (meshes.empty()) { return CC_FERR_NO_SAVE; } //The first thing to do is to create the FBX Manager which is the object allocator for almost all the classes in the SDK FbxManager* lSdkManager = FbxManager::Create(); if( !lSdkManager ) { ccLog::Warning("[FBX] Error: Unable to create FBX Manager!"); return CC_FERR_CONSOLE_ERROR; } else { ccLog::Print("[FBX] Autodesk FBX SDK version %s", lSdkManager->GetVersion()); } //Create an IOSettings object. This object holds all import/export settings. FbxIOSettings* ios = FbxIOSettings::Create(lSdkManager, IOSROOT); lSdkManager->SetIOSettings(ios); //Load plugins from the executable directory (optional) //FbxString lPath = FbxGetApplicationDirectory(); //lSdkManager->LoadPluginsDirectory(lPath.Buffer()); //Create an FBX scene. This object holds most objects imported/exported from/to files. FbxScene* lScene = FbxScene::Create(lSdkManager, "My Scene"); if( !lScene ) { ccLog::Warning("[FBX] Error: Unable to create FBX scene!"); return CC_FERR_CONSOLE_ERROR; } // create scene info { FbxDocumentInfo* sceneInfo = FbxDocumentInfo::Create(lSdkManager,"SceneInfo"); sceneInfo->mTitle = qPrintable(QString("Mesh: ") + (meshes.size() == 1 ? meshes[0]->getName() : QString("Multiple meshes"))); sceneInfo->mAuthor = "CloudCompare"; sceneInfo->mRevision = "rev. 1.0"; sceneInfo->mKeywords = "cloudcompare mesh"; // we need to add the sceneInfo before calling AddThumbNailToScene because // that function is asking the scene for the sceneInfo. lScene->SetSceneInfo(sceneInfo); } //create thumbnail //{ // FbxThumbnail* lThumbnail = FbxThumbnail::Create(lScene,""); // lThumbnail->SetDataFormat(FbxThumbnail::eRGB_24); // lThumbnail->SetSize(FbxThumbnail::e64x64); // lThumbnail->SetThumbnailImage(cSceneThumbnail); // if (lScene->GetSceneInfo()) // { // lScene->GetSceneInfo()->SetSceneThumbnail(lThumbnail); // } //} // Build the node tree. FbxNode* lRootNode = lScene->GetRootNode(); { for (size_t i=0; i<meshes.size(); ++i) { FbxNode* meshNode = ToFbxMesh(meshes[i],lScene); if (meshNode) lRootNode->AddChild(meshNode); else ccLog::Warning(QString("[FBX] Failed to convert mesh '%1' to FBX mesh/node!").arg(meshes[i]->getName())); } } // Save the scene. bool lResult = SaveScene(lSdkManager, lScene, filename); // Destroy all objects created by the FBX SDK. if( lSdkManager ) lSdkManager->Destroy(); return lResult ? CC_FERR_NO_ERROR : CC_FERR_CONSOLE_ERROR; }
/******************************************************************************* 函 数 名: SceneEEPROM_Set 功能说明: 写入一个场景 参 数: unit: 单元位置 area: 区域位置(0~4) num: 情景号 data[0]: 场景内容长度 data[1~n]: 场景内容 返 回 值: 存储结果 *******************************************************************************/ u32 SceneEEPROM_Set(u8 unit, u8 area, u8 num, u8 *data) { u8 flag = 0x00; flag = FindScene(unit,area,num); if (Check_PositionRange(flag) != SceneEEPROMSave_Seat(data[0])) //相同场景号的情况下,所需要的存储空间内存块不同,需要重新申请 { DelOneScene(flag); // SceneEEPROMData_Clr(flag); //清除之前存储标识 #if (SCENCETIME_EN > 0u) SceneEEPROMTimeFlag_Clr(flag); #endif flag = SCENEFLAG_DEFAULT_VALUE; } if(SCENEFLAG_DEFAULT_VALUE == flag)//未找到该场景,场景还没有申请空间 { SceneEEPROMData_Seat(data[0], &flag); //申请一个存储空间 if (flag == SCENEFLAG_DEFAULT_VALUE) { return EEPROM_RAND_ERR; } SaveScene(unit,area,num,flag);// // gSceneIndex[(flag-1)/8] |= 1<<((flag-1)%8); // WriteDataToEEPROM(SCENESAVEFLAG_START_ADD + (flag-1) / 8, 1, &gSceneIndex[(flag-1)/8]); WriteDataToEEPROM(SCENEFLAG_START_ADD + 1 +SCENE_INDEXEX_SPACE*(flag-1), sizeof(gSceneBuff)/SCENE_MAX_NUM,(u8 *)&gSceneBuff[flag-1]);// } /////////////////TEST/////////////////////// SceneIndexes.sceneAddr = flag; //////////////////TEST////////////////////// SceneEEPROMData_Save(SceneEEPROMSave_Addr(flag), data); //////////////////////////////////////////////////////////////////// #if 0 ReadDataFromEEPROM(SCENEFLAG_START_ADD + (UNIT_SCENEFLAG_SPACE * unit) + (AREA_SCENEFLAG_SPACE * area) + (SCENEFLAG_SPACE * num), sizeof(flag), (u8 *)&flag); if (Check_PositionRange(flag) != SceneEEPROMSave_Seat(data[0])) //相同场景号的情况下,所需要的存储空间内存块不同,需要重新申请 { SceneEEPROMData_Clr(flag); //清除之前存储标识 #if (SCENCETIME_EN > 0u) SceneEEPROMTimeFlag_Clr(flag); #endif flag = SCENEFLAG_DEFAULT_VALUE; } if (flag == SCENEFLAG_DEFAULT_VALUE) //场景还没有申请空间 { SceneEEPROMData_Seat(data[0], &flag); //申请一个存储空间 if (flag == SCENEFLAG_DEFAULT_VALUE) { return EEPROM_RAND_ERR; } WriteDataToEEPROM(SCENEFLAG_START_ADD + (UNIT_SCENEFLAG_SPACE * unit) + (AREA_SCENEFLAG_SPACE * area) + (SCENEFLAG_SPACE * num), sizeof(flag), (u8 *)&flag); } SceneEEPROMData_Save(SceneEEPROMSave_Addr(flag), data); #endif //////////////////////////////////////////////////////////////////// return COMPLETE; }