Ejemplo n.º 1
0
/*
Imports all the scene data and creates the mesh and bone instances from it
*/
void SceneImporter::loadFile()
{
	bool lResult = false;
	if (mImporter->Import(mScene) == true)
	{
		// Convert Axis System to what is used in this example, if needed
		FbxAxisSystem SceneAxisSystem = mScene->GetGlobalSettings().GetAxisSystem();
		FbxAxisSystem OurAxisSystem(FbxAxisSystem::eYAxis, FbxAxisSystem::eParityOdd, FbxAxisSystem::eRightHanded);
		if (SceneAxisSystem != OurAxisSystem)
		{
			OurAxisSystem.ConvertScene(mScene);
		}

		// Convert Unit System to what is used in this example, if needed
		FbxSystemUnit SceneSystemUnit = mScene->GetGlobalSettings().GetSystemUnit();
		if (SceneSystemUnit.GetScaleFactor() != 1.0)
		{
			//The unit in this example is centimeter.
			FbxSystemUnit::cm.ConvertScene(mScene);
		}

		// Get the list of all the animation stack.
		mScene->FillAnimStackNameArray(mAnimStackNameArray);
		// Create the animator
		Animator::create(mScene);

		// Convert mesh, NURBS and patch into triangle mesh
		FbxGeometryConverter lGeomConverter(mSdkManager);
		lGeomConverter.Triangulate(mScene, /*replace*/true);

		// Split meshes per material, so that we only have one material per mesh (for VBO support)
		lGeomConverter.SplitMeshesPerMaterial(mScene, /*replace*/true);
		// Extract all bone nodes
		extractBonesRecursive(mScene->GetRootNode());

		// Load all meshes from scene
		FbxAMatrix lDummyGlobalPosition;

		// Extract all meshes
		loadCacheRecursive(mScene->GetRootNode());

		// Load all the animation keyframe data
		Animator::get()->precacheAnimationData();
	}

	// Destroy the importer to release the file.
	mImporter->Destroy();
	mImporter = NULL;
}
Ejemplo n.º 2
0
FbxScene* FBXLoader::LoadScene(const char* aFile)
{
	// Create an importer using the SDK manager.
	FbxImporter* lImporter = FbxImporter::Create(myFbxManager,"");

	// Use the first argument as the filename for the importer.
	if(!lImporter->Initialize(aFile, -1, myFbxManager->GetIOSettings())) 
	{ 
		printf("Call to FbxImporter::Initialize() failed.\n"); 
		printf("Error returned: %s\n\n", lImporter->GetStatus().GetErrorString()); 
		std::string errorMessage = "Could not find fbx file: " + std::string(aFile);
		FBX_LOG(errorMessage.c_str());
		MessageBoxA(nullptr, errorMessage.c_str(), "ERROR", 0);
		//DL_ASSERT("Fbx file not found. Check the debug logger!");
	}

	// Create a new scene so that it can be populated by the imported file.
	FbxScene* lScene = FbxScene::Create(myFbxManager, "myScene");

	// Import the contents of the file into the scene.
	lImporter->Import(lScene);

	// The file is imported; so get rid of the importer.a
	lImporter->Destroy();

	FbxGeometryConverter lGeomConverter(myFbxManager);

	lGeomConverter.Triangulate(lScene, /*replace*/true);

	//FbxMesh mesh;
	//mesh.GenerateTangentsData(
	//lGeomConverter.Comp
	//lGeomConverter.tr
	// Split meshes per material, so that we only have one material per mesh (for VBO support)
	lGeomConverter.SplitMeshesPerMaterial(lScene, /*replace*/true);
	return lScene;
}
Ejemplo n.º 3
0
BGameObject * BImporter::loadObject(string pPath)
{
    //do i really need importer??
    mImporter = FbxImporter::Create(lSdkManager,"");
    int lFileFormat = -1;
	const char* mFileName = pPath.c_str();
    if (!lSdkManager->GetIOPluginRegistry()->DetectReaderFileFormat(mFileName, lFileFormat) )
    {
        // Unrecognizable file format. Try to fall back to FbxImporter::eFBX_BINARY
        lFileFormat = lSdkManager->GetIOPluginRegistry()->FindReaderIDByDescription( "FBX binary (*.fbx)" );;
    }

	if(mImporter->Initialize(pPath.c_str(), lFileFormat) == true)
    {

    }
    //else error
    //mScene->GetRootNode()


        if (mImporter->Import(lScene) == true)
        {
			printf("Importing...");
            // Convert Axis System to what is used in this example, if needed
            FbxAxisSystem SceneAxisSystem = lScene->GetGlobalSettings().GetAxisSystem();
            FbxAxisSystem OurAxisSystem(FbxAxisSystem::eYAxis, FbxAxisSystem::eParityOdd, FbxAxisSystem::eRightHanded);
            if( SceneAxisSystem != OurAxisSystem )
            {
                OurAxisSystem.ConvertScene(lScene);
            }

            // Convert Unit System to what is used in this example, if needed
            FbxSystemUnit SceneSystemUnit = lScene->GetGlobalSettings().GetSystemUnit();
            if( SceneSystemUnit.GetScaleFactor() != 1.0 )
            {
                //The unit in this example is centimeter.
                FbxSystemUnit::cm.ConvertScene( lScene);
            }

            // Get the list of all the animation stack.
            lScene->FillAnimStackNameArray(mAnimStackNameArray);
            // Convert mesh, NURBS and patch into triangle mesh
			FbxGeometryConverter lGeomConverter(lSdkManager);
			lGeomConverter.Triangulate(lScene, true);

			// Split meshes per material, so that we only have one material per mesh (for VBO support)
			lGeomConverter.SplitMeshesPerMaterial(lScene, true);


			BGameObject *lGameObject = prepareVBOMeshes(lScene);
            return lGameObject;
            // Bake the scene for one frame
            //LoadCacheRecursive(mScelGeomConverterne, mCurrentAnimLayer, mFileName, mSupportVBO);

            // Convert any .PC2 point cache data into the .MC format for
            // vertex cache deformer playback.
            //PreparePointCacheData(mScene, mCache_Start, mCache_Stop);

            // Get the list of pose in the scene
            //FillPoseArray(mScene, mPoseArray);

            // Initialize the frame period.
            //mFrameTime.SetTime(0, 0, 0, 1, 0, lScene->GetGlobalSettings().GetTimeMode());
            //lResult = true;
        }
        printf("Cant import this object");
        return NULL;
}