Example #1
0
        private void EditStateGroup(object sender, RoutedEventArgs e)
        {
            if (viewmodel.SelectedStateGroup == null)
            {
                return;
            }

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

            var editor = new StateGroupEditor(viewmodel.SelectedStateGroup);

            editor.AvailableVertexShaders = viewmodel.Shaders;

            editor.AvailableGeometryShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                             s.Combination == ShaderCombination.VertexGeometry || s.Combination == ShaderCombination.VertexGeometryPixel));

            editor.AvailablePixelShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                          s.Combination == ShaderCombination.VertexPixel || s.Combination == ShaderCombination.VertexGeometryPixel));

            var result = editor.ShowDialog();

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

                    editor.asset.Name = oldName;

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

                    editor.asset.Name = newName;
                }
                else
                {
                    AssetMetadata.createStateGroupMetadata(viewmodel.SelectedStateGroup);
                }
            }
        }
Example #2
0
        private void CreateStateGroup(object sender, RoutedEventArgs e)
        {
            StateGroupEditor editor = new StateGroupEditor();

            editor.AvailableVertexShaders = viewmodel.Shaders;

            editor.AvailableGeometryShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                             s.Combination == ShaderCombination.VertexGeometry || s.Combination == ShaderCombination.VertexGeometryPixel));

            editor.AvailablePixelShaders = new ObservableCollection <ShaderAsset>(viewmodel.Shaders.Where(s =>
                                                                                                          s.Combination == ShaderCombination.VertexPixel || s.Combination == ShaderCombination.VertexGeometryPixel));

            var result = editor.ShowDialog();

            if (result == true)
            {
                AssetMetadata.createStateGroupMetadata(editor.asset);

                viewmodel.StateGroups.Add(editor.asset);
            }
        }
Example #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);
        }