//Init bool cScene::Init(const std::string &lacNameId, const std::string &lacFile) { macFile = lacFile; mbLoaded = false; //Create an instance of the importer class Assimp::Importer lImporter; //Load the scene const aiScene* lpScene = lImporter.ReadFile( macFile.c_str(), aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); // If the import failed, report it if (!lpScene) { printf( lImporter.GetErrorString() ); return false; } ProcessScene(lpScene); lImporter.FreeScene(); mbLoaded = true; return true; }
// funktionen som startar allting - initierar Maya, h�mtar Mayafilernas namn, g�r igenom scenen, etc... void Exporter::StartExporter(std::string directory_path) { std::cout << "Initializing exporter" << std::endl << std::endl; if (!InitializeMaya()) { std::cout << "Failed to initialize exporter" << std::endl; return; } std::vector<std::string> file_list; if (!GetMayaFilenamesInDirectory((char*)directory_path.c_str(), file_list)) { std::cout << ".mb file not found" << std::endl; return; } char tmp_str[MAX_PATH]; for (auto file = file_list.begin(); file != file_list.end(); file++) { // Formaterar och lagrar tecken och v�rden i en buffer sprintf_s(tmp_str, sizeof(tmp_str), "%s%s", directory_path.c_str(), file->c_str()); ProcessScene(tmp_str); CloseExportFiles(); } return; }
// Consrutor AllKeyer::AllKeyer( GlobalFunc *_global, void *_local, void *_serverData, int &_retval ) : Global(*_global), local(_local), server_data(_serverData), retval(_retval) { // Get some function pointers from LW item_info = CLWItemInfo::New( (LWItemInfo *) Global("LW Item Info 2", GFUSE_TRANSIENT) ); scene_info = CLWSceneInfo::New( (LWSceneInfo *) Global("LW Scene Info", GFUSE_TRANSIENT) ); message = CMessage::New( (MessageFuncs *) Global("Info Messages", GFUSE_TRANSIENT) ); dir_info = (DirInfoFunc *) Global("Directory Info", GFUSE_TRANSIENT); // Make sure the function pointers are non-NULL if( !item_info || !scene_info || !message || !item_info ) { message->Error( "ERROR: Your version of LW is too old. Upgrade!", NULL ); retval = AFUNC_BADGLOBAL; return; } ak = this; // Set a global variable for the AllKeyerPanel // Create the AllKeyerPanel int panel_retval; panel = new AllKeyerPanel( _global, message, panel_retval ); if( panel_retval != AFUNC_OK ) { retval = panel_retval; return; } // Create the OS-specific Directory Class os_dir = new DirInfo(); if( !os_dir ) { message->Error( "ERROR: Unable to initialize directory class!", NULL ); retval = AFUNC_OK; return; } // Open the Main Panel while( panel->OpenMain() == MPS_PROCESS ) { if( TestOptions() ) { // Process the Scenes if( os_dir->HasHeader( "LWSC" ) ) { // Handle LW Scenes ProcessScene(); } else { // Not a scene; assume it's a file list ParseAKB(); } panel->message->Info("Everything's cool!"); } } // retval = DoProcess(); }
bool AURenMesh::LoadFromFileImport( const std::string& strFilename ) { #ifndef NO_ASSIMP Assimp::Importer importer; const aiScene* pScene = importer.ReadFile( strFilename, aiProcessPreset_TargetRealtime_Fast ); if (!pScene || pScene->mNumMeshes == 0) { return false; } ProcessScene(pScene); return true; #else assert( false ); return false; #endif }
cFrame* cAseLoader::Load(std::string& sFolder, std::string& sFileName, stSceneInfo& scene) { m_sFolder = sFolder; fopen_s(&m_fp, (sFolder + sFileName).c_str(), "r"); //stSceneInfo s = {}; while (char* szToken = GetToken()) { if (IsEqual(szToken, ID_SCENE)) ProcessScene(scene); else if (IsEqual(szToken, ID_MATERIAL_LIST)) { ProcessMaterialList(); } else if (IsEqual(szToken, ID_GEOMETRY)) { cFrame* pFrame = ProcessGeomObject(); m_mapFrame[pFrame->m_sNodeName] = pFrame; if (m_pRootFrame) { if (pFrame->m_sParentName.length() > 0) m_mapFrame[pFrame->m_sParentName]->AddChild(pFrame); } else { m_pRootFrame = pFrame; } } } fclose(m_fp); for each(auto p in m_vecMtlTex) { SAFE_RELEASE(p); }
bool FBXScene::LoadScene(const char* filename, std::ostream& output, Vector3& minPos, Vector3& maxPos) { int lFileMajor, lFileMinor, lFileRevision; int i, lAnimStackCount; bool lStatus; FbxIOSettings *ios = FbxIOSettings::Create(mSdkManager, IOSROOT); mSdkManager->SetIOSettings(ios); FbxGeometryConverter lGConverter(mSdkManager); // Create an importer using our sdk manager. FbxImporter* pFBXImporter = FbxImporter::Create(mSdkManager,""); // Initialize the importer by providing a filename. const bool lImportStatus = pFBXImporter->Initialize(filename, -1, mSdkManager->GetIOSettings()); pFBXImporter->GetFileVersion(lFileMajor, lFileMinor, lFileRevision); if( !lImportStatus ) { output << "FBX Importer Error: " << pFBXImporter->GetStatus().GetErrorString() << std::endl; if ( pFBXImporter->GetStatus() == FbxStatus::eInvalidFileVersion ) { output << "FBX version number for file " << filename << " is " << lFileMajor << " " << lFileMinor << " " << lFileRevision << std::endl; } return false; } if (pFBXImporter->IsFBX()) { output << "FBX version number for file " << filename << " is " << lFileMajor << " " << lFileMinor << " " << lFileRevision << std::endl; // From this point, it is possible to access animation stack information without // the expense of loading the entire file. output << "Animation Stack Information" << std::endl; lAnimStackCount = pFBXImporter->GetAnimStackCount(); output << " Number of Animation Stacks: " << lAnimStackCount << std::endl; output << " Current Animation Stack: " << pFBXImporter->GetActiveAnimStackName().Buffer() << std::endl; for(i = 0; i < lAnimStackCount; i++) { FbxTakeInfo* lTakeInfo = pFBXImporter->GetTakeInfo(i); output << " Animation Stack " << i << std::endl; output << " Name: " << lTakeInfo->mName.Buffer() << std::endl; output << " Description: " << lTakeInfo->mDescription.Buffer() << std::endl; output << " Import Name: " << lTakeInfo->mImportName.Buffer() << std::endl; output << " Import State: " << (lTakeInfo->mSelect ? "true" : "false") << std::endl; } } // Import the scene. lStatus = pFBXImporter->Import(mScene); if ( !lStatus ) { output << "Failed Importing FBX!" << std::endl; output << "FBX is password protected!" << std::endl; if ( pFBXImporter->GetStatus() == FbxStatus::ePasswordError ) { output << "FBX is password protected!" << std::endl; } } mFilename = pFBXImporter->GetFileName().Buffer(); // Destroy the importer. pFBXImporter->Destroy(); ios->Destroy(); ProcessScene(mScene); return lStatus; }
bool MeshImportFBX::Import( const char* filename, NVSHARE::MeshImportInterface *callback ) { char message[OUTPUT_TEXT_BUFFER_SIZE+1] = ""; message[OUTPUT_TEXT_BUFFER_SIZE] = '\0'; const char* localName = getFileName( filename ); KString fileName = KString( filename ); KString filePath = fileName.Left( localName - filename ); m_sdkManager = KFbxSdkManager::Create(); if(m_sdkManager == NULL) return false; // Create the importer. int fileFormat = -1; //int registeredCount; //int pluginId; //m_sdkManager->GetIOPluginRegistry()->RegisterReader( CreateFBXImporterReader, GetFBXImporterReaderInfo, // pluginId, registeredCount, FillFBXImporterReaderIOSettings ); m_importer = KFbxImporter::Create( m_sdkManager, "" ); if( !m_sdkManager->GetIOPluginRegistry()->DetectFileFormat( filename, fileFormat ) ) { // Unrecognizable file format. Try to fall back to KFbxImporter::eFBX_BINARY fileFormat = m_sdkManager->GetIOPluginRegistry()->FindReaderIDByDescription( "FBX binary (*.fbx)" );; } m_importer->SetFileFormat( fileFormat ); // Initialize the importer by providing a filename. if( !m_importer->Initialize( filename ) ) return false; // Create the scene. m_scene = KFbxScene::Create( m_sdkManager, "" ); if (m_importer->IsFBX()) { // Set the import states. By default, the import states are always set to // true. The code below shows how to change these states. IOSREF.SetBoolProp(IMP_FBX_MATERIAL, true); IOSREF.SetBoolProp(IMP_FBX_TEXTURE, true); IOSREF.SetBoolProp(IMP_FBX_LINK, true); IOSREF.SetBoolProp(IMP_FBX_SHAPE, true); IOSREF.SetBoolProp(IMP_FBX_GOBO, true); IOSREF.SetBoolProp(IMP_FBX_ANIMATION, true); IOSREF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true); } sprintf_s( message, OUTPUT_TEXT_BUFFER_SIZE, "Importing file %s", filename ); outputMessage( message ); if( !m_importer->Import(m_scene) ) return false; //// Convert Axis System to what is used in this example, if needed //KFbxAxisSystem sceneAxisSystem = m_scene->GetGlobalSettings().GetAxisSystem(); //KFbxAxisSystem ourAxisSystem(sceneAxisSystem.KFbxAxisSystem::ZAxis, KFbxAxisSystem::ParityOdd, KFbxAxisSystem::LeftHanded); //if( sceneAxisSystem != ourAxisSystem ) //{ // ourAxisSystem.ConvertScene(m_scene); //} //// Convert Unit System to what is used in this example, if needed //KFbxSystemUnit sceneSystemUnit = m_scene->GetGlobalSettings().GetSystemUnit(); //if( sceneSystemUnit.GetScaleFactor() != 1.0 ) //{ // // KFbxSystemUnit ourSystemUnit(1.0); // ourSystemUnit.ConvertScene(m_scene); // //} m_callback = callback; ImportSkeleton(); m_takeName = NULL; m_takeInfo = NULL; m_takeNameArray.Clear(); int takeCount = m_importer->GetTakeCount(); int tSelected = -1; for(int t = 0; t < takeCount; t++ ) { m_takeInfo = m_importer->GetTakeInfo(t); m_takeNameArray.Add( &m_takeInfo->mName ); if(m_takeInfo->mSelect) tSelected = t; } if(tSelected == -1 && takeCount > 0) tSelected = 0; if(tSelected >= 0) { m_takeInfo = m_importer->GetTakeInfo(tSelected); m_takeName = m_takeNameArray[tSelected]; m_scene->SetCurrentTake( m_takeName->Buffer() ); if (!ImportAnimation()) { Release(); return false; } } m_scene->FillMaterialArray(m_MaterialArray); ProcessScene(); //// Load the texture data in memory (for supported formats) //LoadSupportedTextures(m_scene, m_textureArray); sprintf_s( message, OUTPUT_TEXT_BUFFER_SIZE, "done!" ); outputMessage( message ); m_scene->Destroy(true, true); m_scene = NULL; m_importer->Destroy(true, true); m_importer = NULL; m_sdkManager->Destroy(); m_sdkManager = NULL; return true; }
sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen) { sector_t * lviewsector; mSceneClearColor[0] = 0.0f; mSceneClearColor[1] = 0.0f; mSceneClearColor[2] = 0.0f; R_SetupFrame (camera); SetViewArea(); // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. double radPitch = ViewPitch.Normalized180().Radians(); double angx = cos(radPitch); double angy = sin(radPitch) * glset.pixelstretch; double alen = sqrt(angx*angx + angy*angy); mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); mAngles.Roll.Degrees = ViewRoll.Degrees; // Scroll the sky mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f; mSky2Pos = (float)fmod(gl_frameMS * level.skyspeed2, 1024.f) * 90.f/256.f; if (camera->player && camera->player-players==consoleplayer && ((camera->player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) && camera==camera->player->mo) { mViewActor=NULL; } else { mViewActor=camera; } // 'viewsector' will not survive the rendering so it cannot be used anymore below. lviewsector = viewsector; // Render (potentially) multiple views for stereo 3d float viewShift[3]; const s3d::Stereo3DMode& stereo3dMode = mainview && toscreen? s3d::Stereo3DMode::getCurrentMode() : s3d::Stereo3DMode::getMonoMode(); stereo3dMode.SetUp(); for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix) { const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix); eye->SetUp(); SetOutputViewport(bounds); Set3DViewport(mainview); mDrawingScene2D = true; mCurrentFoV = fov; // Stereo mode specific perspective projection SetProjection( eye->GetProjection(fov, ratio, fovratio) ); // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper SetViewAngle(ViewAngle); // Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift); s3d::ScopedViewShifter viewShifter(viewShift); SetViewMatrix(ViewPos.X, ViewPos.Y, ViewPos.Z, false, false); gl_RenderState.ApplyMatrices(); clipper.Clear(); angle_t a1 = FrustumAngle(); clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1); ProcessScene(toscreen); if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures. if (mainview && FGLRenderBuffers::IsEnabled()) { mBuffers->BlitSceneToTexture(); UpdateCameraExposure(); BloomScene(); TonemapScene(); ColormapScene(); LensDistortScene(); ApplyFXAA(); // This should be done after postprocessing, not before. mBuffers->BindCurrentFB(); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); DrawBlend(lviewsector); } mDrawingScene2D = false; if (!stereo3dMode.IsMono() && FGLRenderBuffers::IsEnabled()) mBuffers->BlitToEyeTexture(eye_ix); eye->TearDown(); } stereo3dMode.TearDown(); gl_frameCount++; // This counter must be increased right before the interpolations are restored. interpolator.RestoreInterpolations (); return lviewsector; }