Esempio n. 1
0
        private void EditTexture(object sender, RoutedEventArgs e)
        {
            if (viewmodel.SelectedTexture == null)
            {
                return;
            }

            string oldName     = viewmodel.SelectedTexture.Name;
            string oldImported = viewmodel.SelectedTexture.ImportedFilename;

            ImportTexture import = new ImportTexture();

            import.setAsset(viewmodel.SelectedTexture);
            import.isEditMode = true;

            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;
                }
            }
        }
Esempio n. 2
0
        private void ImportTexture(object sender, RoutedEventArgs e)
        {
            ImportTexture import = new ImportTexture();

            var result = import.ShowDialog();

            if (result == true)
            {
                AssetMetadata.createTextureMetadata(import.asset);
                viewmodel.Textures.Add(import.asset);
            }
        }
Esempio n. 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);
        }