void AssetImporter::convert(std::wstring& path) { Assimp::Importer importer; std::string assetPath(path.begin(), path.end()); const aiScene* scene = importer.ReadFile(assetPath.c_str(), aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_GenUVCoords | aiProcess_GenSmoothNormals | aiProcess_ValidateDataStructure | aiProcess_ImproveCacheLocality | aiProcess_OptimizeMeshes | aiProcess_SortByPType); if (!scene) { std::string error("Failed to import asset: " + assetPath); perror(error.c_str()); return; } performConversion(scene); //GRAPHICS::RESOURCES::Mesh* meshArr = loadMeshes(d3dDevice, scene); //GRAPHICS::RESOURCES::Material* materialArr = loadMaterials(d3dDevice, scene); //nextNode(d3dDevice, scene, scene->mRootNode, scene->mRootNode->mTransformation, meshArr, materialArr, outScene); //loadLights(d3dDevice, outScene, scene); //delete[] meshArr; //delete[] materialArr; }
void AssetImporter::importScene( ID3D11Device* d3dDevice, std::wstring& path, GRAPHICS::Scene& outScene ) { Assimp::Importer importer; std::string assetPath(path.begin(), path.end()); const aiScene* scene = importer.ReadFile(assetPath.c_str(), aiProcess_ConvertToLeftHanded | aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_FlipWindingOrder | aiProcess_GenUVCoords | aiProcess_GenSmoothNormals | aiProcess_SortByPType); if (!scene) { printf("Failed to import asset: %s", assetPath.c_str()); } GRAPHICS::RESOURCES::Mesh* meshArr = loadMeshes(d3dDevice, scene); GRAPHICS::RESOURCES::Material* materialArr = loadMaterials(d3dDevice, scene); nextNode(d3dDevice, scene, scene->mRootNode, scene->mRootNode->mTransformation, meshArr, materialArr, outScene); loadLights(d3dDevice, outScene, scene); delete[] meshArr; delete[] materialArr; }
void fsExperiments::setupParams() { fs::path paramsXml( getAssetPath( "params.xml" )); if ( paramsXml.empty() ) { #if defined( CINDER_MAC ) fs::path assetPath( getResourcePath() / "assets" ); #else fs::path assetPath( getAppPath() / "assets" ); #endif createDirectories( assetPath ); paramsXml = assetPath / "params.xml" ; } params::PInterfaceGl::load( paramsXml ); GlobalData& data = GlobalData::get(); data.mParams = params::PInterfaceGl( "Parameters", Vec2i( 200, 300 ) ); data.mParams.addPersistentSizeAndPosition(); data.mParams.addParam( "Fps", &mFps, "", false ); data.mParams.addPersistentParam( "Background", &mBackground, Color::gray( .1 ) ); // effect params setup mCurrentEffect = 0; vector< string > effectNames; for ( vector< fsExpRef >::iterator it = mEffects.begin(); it != mEffects.end(); ++it ) { effectNames.push_back( (*it)->getName() ); } data.mParams.addParam( "Effect", effectNames, &mCurrentEffect ); for ( vector< fsExpRef >::iterator it = mEffects.begin(); it != mEffects.end(); ++it ) { (*it)->setupParams(); } }
void ProjectTool::OnMenuEvent(wxCommandEvent& evt) { if (evt.GetId() == MENU_IMPORT_MESH) { ImportMeshWizard* wizard = new ImportMeshWizard(mFrame); // Set initial import path, the user can change it. wxString importPath = mSelectedModule->getModulePath(); importPath.Append("/meshes"); wizard->importPath->SetPath(importPath); if (wizard->RunWizard(wizard->m_pages[0])) { wxString assetID = wizard->assetID->GetValue(); wxString meshPath = wizard->meshFilePath->GetFileName().GetFullPath(); wxString meshFile = wizard->meshFilePath->GetFileName().GetFullName(); wxString importPath = wizard->importPath->GetPath(); // Copy file (optional) if (wizard->copyMeshCheck->GetValue()) { wxString moduleMeshPath(importPath); moduleMeshPath.Append("/"); moduleMeshPath.Append(meshFile); Torque::Platform.createPath(moduleMeshPath.c_str()); Torque::Platform.pathCopy(meshPath.c_str(), moduleMeshPath.c_str(), false); meshPath = moduleMeshPath; } // Make path relative to module directory. char buf[1024]; const char* fullPath = Torque::Platform.makeFullPathName(meshPath.c_str(), buf, sizeof(buf), NULL); StringTableEntry relativePath = Torque::Platform.makeRelativePathName(fullPath, importPath); // Create full import path. importPath.Append("/"); importPath.Append(assetID); importPath.Append(".asset.taml"); // Create asset definition. Torque::Scene.createMeshAsset(assetID.c_str(), relativePath, importPath.c_str()); Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, importPath.c_str()); refresh(); } wizard->Destroy(); } if (evt.GetId() == MENU_IMPORT_TEXTURE) { ImportTextureWizard* wizard = new ImportTextureWizard(mFrame); // Set initial import path, the user can change it. wxString importPath = mSelectedModule->getModulePath(); importPath.Append("/textures"); wizard->importPath->SetPath(importPath); if (wizard->RunWizard(wizard->m_pages[0])) { wxString assetID = wizard->assetID->GetValue(); wxString texturePath = wizard->textureFilePath->GetFileName().GetFullPath(); wxString textureFile = wizard->textureFilePath->GetFileName().GetFullName(); wxString importPath = wizard->importPath->GetPath(); // Copy file (optional) if (wizard->copyTextureCheck->GetValue()) { wxString moduleTexturePath(importPath); moduleTexturePath.Append("/"); moduleTexturePath.Append(textureFile); Torque::Platform.createPath(moduleTexturePath.c_str()); Torque::Platform.pathCopy(texturePath.c_str(), moduleTexturePath.c_str(), false); texturePath = moduleTexturePath; } // Make path relative to module directory. char buf[1024]; const char* fullPath = Torque::Platform.makeFullPathName(texturePath.c_str(), buf, sizeof(buf), NULL); StringTableEntry relativePath = Torque::Platform.makeRelativePathName(fullPath, importPath); // Create full import path. importPath.Append("/"); importPath.Append(assetID); importPath.Append(".asset.taml"); // Create asset definition. Torque::Scene.createTextureAsset(assetID.c_str(), relativePath, importPath.c_str()); Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, importPath.c_str()); refresh(); } wizard->Destroy(); } if (evt.GetId() == MENU_NEW_MATERIAL) { NewMaterialWizard* wizard = new NewMaterialWizard(mFrame); // Set initial import path, the user can change it. wxString defaultSavePath = mSelectedModule->getModulePath(); defaultSavePath.Append("/materials"); wizard->savePath->SetPath(defaultSavePath); if (wizard->RunWizard(wizard->m_pages[0])) { wxString assetID = wizard->assetID->GetValue(); wxString savePath = wizard->savePath->GetPath(); wxString assetPath(""); assetPath.Append(savePath); assetPath.Append("/"); assetPath.Append(assetID); assetPath.Append(".asset.taml"); wxString templateFileName(""); templateFileName.Append(assetID); templateFileName.Append(".taml"); wxString templatePath(""); templatePath.Append(savePath); templatePath.Append("/"); templatePath.Append(templateFileName); // Create material template and then asset. Torque::Scene.createMaterialTemplate(templatePath.c_str()); Torque::Scene.createMaterialAsset(assetID.c_str(), templateFileName.c_str(), assetPath.c_str()); Torque::AssetDatabaseLink.addDeclaredAsset(mSelectedModule, assetPath.c_str()); refresh(); } } }