Ejemplo n.º 1
0
        static fbxImporter.USceneNode _LoadFbx(byte[] bins)
        {
            fbxImporter.USceneNode sceneNode = null;
            USceneInfo             sceneInfo = new USceneInfo();
            //IntPtr csPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sceneInfo));
            IntPtr scene = LoadSceneFromMemory(bins, bins.Length);

            if (scene != IntPtr.Zero)
            {
                try
                {
                    sceneInfo = (USceneInfo)Marshal.PtrToStructure(scene, typeof(USceneInfo));
                }
                catch (System.Exception e)
                {
                    //Marshal.FreeHGlobal(csPtr);
                    throw new FbxLoaderException(ErrorCode.StreamDecodeError);
                }
                byte[] localbins = new byte[sceneInfo.sizeofbin];
                Marshal.Copy(sceneInfo.bins, localbins, 0, sceneInfo.sizeofbin);
                sceneNode = Decode <fbxImporter.USceneNode>(localbins);
                ClearUSceneBin(scene);
            }
            return(sceneNode);
        }
Ejemplo n.º 2
0
 static void CreateSceneObject(fbxImporter.USceneNode scene, out GameObject fbx)
 {
     //fbx.transform.localRotation = Quaternion.Euler(270, 0, 0);
     //fbx.name = "name";
     fbx = null;
     if (scene.meshNums == 1)
     {
         fbx = CreateMesh(scene.meshList[0], fbx);
     }
     else
     {
         fbx = new GameObject(scene.meshList[0].name);
         fbx.transform.localRotation = Quaternion.Euler(270, 0, 0);
         for (int i = 0; i < scene.meshNums; ++i)
         {
             var child = CreateMesh(scene.meshList[i], fbx);
             if (child != null)
             {
                 child.transform.parent = fbx.transform;
             }
         }
     }
 }