public void Export(LandTableSA2 landTable, string filePath)
        {
            TextureNames = landTable.Textures.Select(x => x.Name).ToList();
            Scene        = CreateDefaultScene();
            Initialize(null);

            foreach (var model in landTable.Models)
            {
                mCurrentModel = model;
                ConvertRootNode(model.RootNode);
            }

            ExportCollada(Scene, filePath);
        }
Пример #2
0
        public LandTableSA2 Import(string path, string texturePakPath = null)
        {
            var landTable = new LandTableSA2();
            var aiScene   = AssimpHelper.ImportScene(path, false);
            var meshNodes = FindMeshNodes(aiScene.RootNode);

            // Convert textures & build materials
            var convertMaterialsAndTextures = ConvertMaterialsAndTextures(Path.GetDirectoryName(path), aiScene.Materials, texturePakPath);

            landTable.TexturePakFileName = Path.GetFileNameWithoutExtension(texturePakPath);
            landTable.Textures           = convertMaterialsAndTextures.TextureReferences;

            var displayModels   = new List <LandModelSA2>();
            var collisionModels = new List <LandModelSA2>();

            foreach (var aiMeshNode in meshNodes)
            {
                if (!aiMeshNode.Name.Contains("hkRB"))
                {
                    displayModels.Add(ConvertDisplayModel(aiScene, convertMaterialsAndTextures.MaterialBuildInfos, aiMeshNode));
                }
                else
                {
                    collisionModels.Add(ConvertCollisionModel(aiScene, convertMaterialsAndTextures.MaterialBuildInfos, aiMeshNode));
                    displayModels.Add(ConvertDisplayModel(aiScene, convertMaterialsAndTextures.MaterialBuildInfos, aiMeshNode));
                    //var collisionModel = new LandModelSA2();
                    //collisionModel.Flags |= SurfaceFlags.Collidable;
                    //collisionModel.RootNode = ConvertNode( aiMeshNode, aiScene.Meshes, convertMaterialsAndTextures.MaterialBuildInfos,
                    //                                       ConvertCollisionGeometry );

                    //var collisionGeometry = ( Basic.Geometry )collisionModel.RootNode.Geometry;
                    //collisionModel.Bounds = collisionGeometry.Bounds;

                    //collisionModels.Add( collisionModel );
                }
            }

            landTable.Models.AddRange(displayModels);
            landTable.Models.AddRange(collisionModels);

            return(landTable);
        }