示例#1
0
        private void EditMesh(object sender, RoutedEventArgs e)
        {
            if (viewmodel.SelectedMesh == null)
            {
                return;
            }

            string oldName     = viewmodel.SelectedMesh.Name;
            string oldImported = viewmodel.SelectedMesh.ImportedFilename;
            string oldSource   = viewmodel.SelectedMesh.SourceFilename;

            ImportMesh import = new ImportMesh();

            import.setAsset(viewmodel.SelectedMesh);
            import.isEditMode          = true;
            import.AvailableTopologies = new ObservableCollection <Topology>(typeof(Topology).GetEnumValues().Cast <Topology>().ToList());

            var result = import.ShowDialog();

            if (result == true)
            {
                if (oldName != import.asset.Name)
                {
                    var newName = import.asset.Name;

                    import.asset.Name = oldName;

                    //we changed the name, delete the old asset then create a new one
                    System.IO.File.Delete(oldImported);

                    import.asset.Name = newName;
                }
            }
        }
示例#2
0
        private void ImportMesh(object sender, RoutedEventArgs e)
        {
            ImportMesh import = new ImportMesh();

            import.AvailableTopologies = new ObservableCollection <Topology>(typeof(Topology).GetEnumValues().Cast <Topology>().ToList());

            var result = import.ShowDialog();

            if (result == true)
            {
                AssetMetadata.createMeshMetadata(import.asset);
                viewmodel.Meshes.Add(import.asset);
            }
            else
            {
                if (!string.IsNullOrEmpty(import.Error))
                {
                    viewmodel.LogEvent(import.Error);
                }
            }
        }
示例#3
0
        public static bool UpdateAsset(Object asset,
                                       out string error, out string successMessage)
        {
            error          = "";
            successMessage = "";

            if (asset is MeshAsset)
            {
                MeshAsset mesh = asset as MeshAsset;

                var result = ImportMesh.import(mesh.SourceFilename, mesh.ImportedFilename);

                if (string.IsNullOrEmpty(result))
                {
                    successMessage = "Successfully updated mesh: " + mesh.Name;

                    mesh.LastUpdated = DateTime.Now;
                    AssetMetadata.createMeshMetadata(mesh);

                    return(true);
                }
            }
            else if (asset is TextureAsset)
            {
                TextureAsset texture = asset as TextureAsset;

                var result = ImportTexture.import(texture.Format, texture.ChannelMappings, texture.ImportedFilename);

                if (string.IsNullOrEmpty(result))
                {
                    successMessage      = "Successfully updated texture: " + texture.Name;
                    texture.LastUpdated = DateTime.Now;
                    AssetMetadata.createTextureMetadata(texture);

                    return(true);
                }
                else
                {
                    error = "ERROR: Updating texture: " + texture.Name + " failed!" + Environment.NewLine + result;
                }
            }
            else if (asset is ShaderAsset)
            {
                ShaderAsset shader = asset as ShaderAsset;

                var result = ImportShader.import(shader.SourceFilename, shader.ImportedFilename);

                if (string.IsNullOrEmpty(result))
                {
                    successMessage     = "Successfully updated shader: " + shader.Name;
                    shader.LastUpdated = DateTime.Now;
                    AssetMetadata.createShaderMetadata(shader);

                    return(true);
                }
                else
                {
                    error = "ERROR: Updating shader: " + shader.Name + " failed!" + Environment.NewLine + result;
                }
            }
            else if (asset is MaterialAsset)
            {
                MaterialAsset material = asset as MaterialAsset;

                var result = MaterialImporter.Import(material);

                if (result)
                {
                    successMessage       = "Successfully updated material: " + material.Name;
                    material.LastUpdated = DateTime.Now;
                    AssetMetadata.createMaterialMetadata(material);

                    return(true);
                }
                else
                {
                    error = "ERROR: Updating material: " + material.Name + " failed!" + Environment.NewLine;
                }
            }
            else if (asset is StateGroupAsset)
            {
                var stateGroup = asset as StateGroupAsset;

                var result = StateGroupImporter.Import(stateGroup);

                if (result)
                {
                    successMessage         = "Successfully updated state group: " + stateGroup.Name;
                    stateGroup.LastUpdated = DateTime.Now;
                    AssetMetadata.createStateGroupMetadata(stateGroup);

                    return(true);
                }
                else
                {
                    error = "ERROR: Updating state group: " + stateGroup.Name + " failed!" + Environment.NewLine + result;
                }
            }

            return(false);
        }