Example #1
0
        void SaveAnimationState( TextBlock block )
        {
            if( currentAnimationItem != null && !currentAnimationItem.Removed )
            {
                TextBlock itemBlock = block.AddChild( "currentAnimationItem" );

                MeshObjectAnimationController.AnimationItem item = currentAnimationItem;

                itemBlock.SetAttribute( "animationBaseName", item.AnimationBaseName );
                itemBlock.SetAttribute( "allowRandomAnimationNumber",
                    item.AllowRandomAnimationNumber.ToString() );
                itemBlock.SetAttribute( "loop", item.Loop.ToString() );
                itemBlock.SetAttribute( "velocity", item.Velocity.ToString() );
                itemBlock.SetAttribute( "weight", item.Weight.ToString() );
                itemBlock.SetAttribute( "timePosition", item.TimePosition.ToString() );
            }

            if( forceAnimationRemainingTime != 0 )
            {
                block.SetAttribute( "forceAnimationRemainingTime",
                    forceAnimationRemainingTime.ToString() );
            }
        }
Example #2
0
            public void Save( TextBlock block )
            {
                if( scroll != Vec2.Zero )
                    block.SetAttribute( "scroll", scroll.ToString() );
                if( scale != new Vec2( 1, 1 ) )
                    block.SetAttribute( "scale", scale.ToString() );
                if( rotate != 0 )
                    block.SetAttribute( "rotate", rotate.ToString() );
                if( dynamicParameters )
                    block.SetAttribute( "dynamicParameters", dynamicParameters.ToString() );

                if( animation.IsDataExists() )
                {
                    TextBlock animationBlock = block.AddChild( "animation" );
                    animation.Save( animationBlock );
                }
            }
Example #3
0
File: Gun.cs Project: whztt07/SDK
            public bool Save( TextBlock block )
            {
                //fireObjects
                if( fireObjects.Count != 0 )
                {
                    TextBlock fireObjectsBlock = block.AddChild( "fireObjects" );
                    if( !fireObjects.Save( fireObjectsBlock ) )
                        return false;
                }

                return true;
            }
Example #4
0
        protected override void OnSave( TextBlock block )
        {
            base.OnSave( block );

            //General
            {
                if( blending != MaterialBlendingTypes.Opaque )
                    block.SetAttribute( "blending", blending.ToString() );

                if( !lighting )
                    block.SetAttribute( "lighting", lighting.ToString() );

                if( !ambientLighting )
                    block.SetAttribute( "ambientLighting", ambientLighting.ToString() );

                if( doubleSided )
                    block.SetAttribute( "doubleSided", doubleSided.ToString() );

                if( !useNormals )
                    block.SetAttribute( "useNormals", useNormals.ToString() );

                if( !receiveShadows )
                    block.SetAttribute( "receiveShadows", receiveShadows.ToString() );

                if( receiveSimpleShadows )
                    block.SetAttribute( "receiveSimpleShadows", receiveSimpleShadows.ToString() );

                if( alphaRejectFunction != CompareFunction.AlwaysPass )
                    block.SetAttribute( "alphaRejectFunction", alphaRejectFunction.ToString() );

                if( alphaRejectValue != 127 )
                    block.SetAttribute( "alphaRejectValue", alphaRejectValue.ToString() );

                if( alphaToCoverage )
                    block.SetAttribute( "alphaToCoverage", alphaToCoverage.ToString() );

                if( fadingByDistanceRange != new Range( 0, 0 ) )
                    block.SetAttribute( "fadingByDistanceRange", fadingByDistanceRange.ToString() );

                if( !allowFog )
                    block.SetAttribute( "allowFog", allowFog.ToString() );

                if( !depthWrite )
                    block.SetAttribute( "depthWrite", depthWrite.ToString() );

                if( !depthTest )
                    block.SetAttribute( "depthTest", depthTest.ToString() );

                if( softParticles )
                    block.SetAttribute( "softParticles", softParticles.ToString() );

                if( softParticlesFadingLength != 1 )
                    block.SetAttribute( "softParticlesFadingLength", softParticlesFadingLength.ToString() );

                if( depthOffset != 0 )
                    block.SetAttribute( "depthOffset", depthOffset.ToString() );

                if( halfLambert )
                    block.SetAttribute( "halfLambert", halfLambert.ToString() );
            }

            //Diffuse
            {
                if( diffuseColor != new ColorValue( 1, 1, 1 ) )
                    block.SetAttribute( "diffuseColor", diffuseColor.ToString() );
                if( diffusePower != 1 )
                    block.SetAttribute( "diffusePower", diffusePower.ToString() );

                if( diffuseScaleDynamic )
                    block.SetAttribute( "diffuseScaleDynamic", diffuseScaleDynamic.ToString() );

                if( diffuseVertexColor )
                    block.SetAttribute( "diffuseVertexColor", diffuseVertexColor.ToString() );

                if( diffuse1Map.IsDataExists() )
                {
                    TextBlock diffuse1MapBlock = block.AddChild( "diffuse1Map" );
                    diffuse1Map.Save( diffuse1MapBlock );
                }

                if( diffuse2Map.IsDataExists() )
                {
                    TextBlock diffuse2MapBlock = block.AddChild( "diffuse2Map" );
                    diffuse2Map.Save( diffuse2MapBlock );
                }

                if( diffuse3Map.IsDataExists() )
                {
                    TextBlock diffuse3MapBlock = block.AddChild( "diffuse3Map" );
                    diffuse3Map.Save( diffuse3MapBlock );
                }

                if( diffuse4Map.IsDataExists() )
                {
                    TextBlock diffuse4MapBlock = block.AddChild( "diffuse4Map" );
                    diffuse4Map.Save( diffuse4MapBlock );
                }
            }

            //Reflection
            {
                if( reflectionColor != new ColorValue( 0, 0, 0 ) )
                    block.SetAttribute( "reflectionColor", reflectionColor.ToString() );
                if( reflectionPower != 1 )
                    block.SetAttribute( "reflectionPower", reflectionPower.ToString() );

                if( reflectionScaleDynamic )
                    block.SetAttribute( "reflectionScaleDynamic", reflectionScaleDynamic.ToString() );

                if( reflectionMap.IsDataExists() )
                {
                    TextBlock reflectionMapBlock = block.AddChild( "reflectionMap" );
                    reflectionMap.Save( reflectionMapBlock );
                }

                if( !string.IsNullOrEmpty( reflectionSpecificCubemap ) )
                    block.SetAttribute( "reflectionSpecificCubemap", reflectionSpecificCubemap );

                if( reflectionBoxParallaxCorrectedCubemaps )
                    block.SetAttribute( "reflectionBoxParallaxCorrectedCubemaps", reflectionBoxParallaxCorrectedCubemaps.ToString() );
            }

            //Emission
            {
                if( emissionColor != new ColorValue( 0, 0, 0 ) )
                    block.SetAttribute( "emissionColor", emissionColor.ToString() );
                if( emissionPower != 1 )
                    block.SetAttribute( "emissionPower", emissionPower.ToString() );

                if( emissionScaleDynamic )
                    block.SetAttribute( "emissionScaleDynamic", emissionScaleDynamic.ToString() );

                if( emissionMap.IsDataExists() )
                {
                    TextBlock emissionMapBlock = block.AddChild( "emissionMap" );
                    emissionMap.Save( emissionMapBlock );
                }
            }

            //Specular
            {
                if( specularColor != new ColorValue( 0, 0, 0 ) )
                    block.SetAttribute( "specularColor", specularColor.ToString() );
                if( specularPower != 1 )
                    block.SetAttribute( "specularPower", specularPower.ToString() );

                if( specularScaleDynamic )
                    block.SetAttribute( "specularScaleDynamic", specularScaleDynamic.ToString() );

                if( specularMap.IsDataExists() )
                {
                    TextBlock specularMapBlock = block.AddChild( "specularMap" );
                    specularMap.Save( specularMapBlock );
                }

                if( specularShininess != 20 )
                    block.SetAttribute( "specularShininess", specularShininess.ToString() );
            }

            //Translucency
            {
                if( translucencyColor != new ColorValue( 0, 0, 0 ) )
                    block.SetAttribute( "translucencyColor", translucencyColor.ToString() );
                if( translucencyPower != 1 )
                    block.SetAttribute( "translucencyPower", translucencyPower.ToString() );

                if( translucencyDynamic )
                    block.SetAttribute( "translucencyDynamic", translucencyDynamic.ToString() );

                if( translucencyMap.IsDataExists() )
                {
                    TextBlock translucencyMapBlock = block.AddChild( "translucencyMap" );
                    translucencyMap.Save( translucencyMapBlock );
                }

                if( translucencyClearness != 4f )
                    block.SetAttribute( "translucencyClearness", translucencyClearness.ToString() );
            }

            //Height
            {
                if( normalMap.IsDataExists() )
                {
                    TextBlock normalMapBlock = block.AddChild( "normalMap" );
                    normalMap.Save( normalMapBlock );
                }

                if( heightFromNormalMapAlpha )
                    block.SetAttribute( "heightFromNormalMapAlpha", heightFromNormalMapAlpha.ToString() );

                if( heightMap.IsDataExists() )
                {
                    TextBlock heightMapBlock = block.AddChild( "heightMap" );
                    heightMap.Save( heightMapBlock );
                }

                if( displacementTechnique != DisplacementTechniques.ParallaxOcclusionMapping )
                    block.SetAttribute( "displacementTechnique", displacementTechnique.ToString() );

                if( heightScale != .04f )
                    block.SetAttribute( "heightScale", heightScale.ToString() );
            }
        }
Example #5
0
            public virtual void Save( TextBlock block )
            {
                if( !string.IsNullOrEmpty( texture ) )
                    block.SetAttribute( "texture", texture );

                if( texCoord != TexCoordIndexes.TexCoord0 )
                    block.SetAttribute( "texCoord", texCoord.ToString() );

                if( clamp )
                    block.SetAttribute( "clamp", clamp.ToString() );

                if( transform.IsDataExists() )
                {
                    TextBlock transformBlock = block.AddChild( "transform" );
                    transform.Save( transformBlock );
                }
            }
        public void SaveCustomConfig()
        {
            var block = new TextBlock();
            var controlBloc = block.AddChild("Controls");

            //var deadzone = controlBloc.AddChild("DeadZone");
            var keyBlockDz = DeadZone.ToString();
            block.SetAttribute("DeadZone", keyBlockDz);

            foreach (GameControlItem item in Items)
            {
                var currentKeyBlock = controlBloc.AddChild(item.ControlKey.ToString());
                //keybord Setting
                if (item.BindedKeyboardMouseValues.Count > 0)
                {
                    var keyboardBlock = currentKeyBlock.AddChild("Keyboard");
                    foreach (var keyboardvalue in item.BindedKeyboardMouseValues)
                    {
                        var keyBlock = keyboardBlock.AddChild("Item");
                        SystemKeyboardMouseValue.Save(keyboardvalue, keyBlock);
                    }
                }
                //Joystick setting
                if (item.BindedJoystickValues.Count > 0)
                {
                    var joystickBlock = currentKeyBlock.AddChild("Joystick");
                    foreach (var joystickvalue in item.BindedJoystickValues)
                    {
                        var keyBlock = joystickBlock.AddChild("Item");
                        SystemJoystickValue.Save(joystickvalue, keyBlock);
                    }
                }
            }

            string fileName = VirtualFileSystem.GetRealPathByVirtual(keyconfig);
            try
            {
                string directoryName = Path.GetDirectoryName(fileName);
                if (directoryName != "" && !Directory.Exists(directoryName))
                    Directory.CreateDirectory(directoryName);
                using (StreamWriter writer = new StreamWriter(fileName))
                {
                    writer.Write(block.DumpToString());
                }
            }
            catch
            {
                Log.Fatal(string.Format("Saving file failed \"{0}\".", fileName));
                return;
            }
        }
Example #7
0
        protected override bool OnSave(TextBlock block)
        {
            if (!base.OnSave(block))
                return false;

            //hitObjects
            if (hitObjects.Count != 0)
            {
                TextBlock hitObjectsBlock = block.AddChild("hitObjects");
                if (!hitObjects.Save(hitObjectsBlock))
                    return false;
            }

            return true;
        }
Example #8
0
        private bool SaveEngineConfig()
        {
            TextBlock block = new TextBlock();

            //Renderer
            {
                EngineComponentManager.ComponentInfo[] components = GetSortedComponentsByType(
                    EngineComponentManager.ComponentTypeFlags.RenderingSystem);

                EngineComponentManager.ComponentInfo component = null;
                if (comboBoxRenderSystems.SelectedIndex != -1)
                    component = components[comboBoxRenderSystems.SelectedIndex];

                TextBlock rendererBlock = block.AddChild("Renderer");
                if (component != null)
                    rendererBlock.SetAttribute("implementationComponent", component.Name);

                //rendering device
                if (component != null && component.Name.Contains("Direct3D"))
                {
                    rendererBlock.SetAttribute("renderingDeviceName", (string)comboBoxRenderingDevices.SelectedItem);
                    rendererBlock.SetAttribute("renderingDeviceIndex", (comboBoxRenderingDevices.SelectedIndex - 1).ToString());
                }

                if (!checkBoxAllowShaders.Checked)
                    rendererBlock.SetAttribute("allowShaders", checkBoxAllowShaders.Checked.ToString());

                //depthBufferAccess
                if (comboBoxDepthBufferAccess.SelectedIndex != -1)
                {
                    rendererBlock.SetAttribute("depthBufferAccess",
                        (comboBoxDepthBufferAccess.SelectedIndex == 1).ToString());
                }

                //fullSceneAntialiasing
                if (comboBoxAntialiasing.SelectedIndex != -1)
                {
                    ComboBoxItem item = (ComboBoxItem)comboBoxAntialiasing.SelectedItem;
                    rendererBlock.SetAttribute("fullSceneAntialiasing", item.Identifier);
                }

                //filtering
                if (comboBoxFiltering.SelectedIndex != -1)
                {
                    RendererWorld.FilteringModes filtering = (RendererWorld.FilteringModes)
                        comboBoxFiltering.SelectedIndex;
                    rendererBlock.SetAttribute("filtering", filtering.ToString());
                }

                //renderTechnique
                if (comboBoxRenderTechnique.SelectedIndex != -1)
                {
                    ComboBoxItem item = (ComboBoxItem)comboBoxRenderTechnique.SelectedItem;
                    rendererBlock.SetAttribute("renderTechnique", item.Identifier);
                }

                //multiMonitorMode
                if (comboBoxVideoMode.SelectedIndex == 1)
                    rendererBlock.SetAttribute("multiMonitorMode", true.ToString());

                //videoMode
                if (comboBoxVideoMode.SelectedIndex >= 2)
                {
                    string[] strings = ((string)comboBoxVideoMode.SelectedItem).
                        Split(new char[] { 'x' });
                    Vec2I videoMode = new Vec2I(int.Parse(strings[0]),
                        int.Parse(strings[1]));
                    rendererBlock.SetAttribute("videoMode", videoMode.ToString());
                }

                //fullScreen
                rendererBlock.SetAttribute("fullScreen", checkBoxFullScreen.Checked.ToString());

                //vertical sync
                rendererBlock.SetAttribute("verticalSync",
                    checkBoxVerticalSync.Checked.ToString());
            }

            //Physics system
            {
                EngineComponentManager.ComponentInfo[] components = GetSortedComponentsByType(
                    EngineComponentManager.ComponentTypeFlags.PhysicsSystem);

                EngineComponentManager.ComponentInfo component = null;
                if (comboBoxPhysicsSystems.SelectedIndex != -1)
                    component = components[comboBoxPhysicsSystems.SelectedIndex];

                if (component != null)
                {
                    TextBlock physicsSystemBlock = block.AddChild("PhysicsSystem");
                    physicsSystemBlock.SetAttribute("implementationComponent", component.Name);
                    //physicsSystemBlock.SetAttribute( "allowHardwareAcceleration",
                    //   checkBoxPhysicsAllowHardwareAcceleration.Checked.ToString() );
                }
            }

            //Sound system
            {
                EngineComponentManager.ComponentInfo[] components = GetSortedComponentsByType(
                    EngineComponentManager.ComponentTypeFlags.SoundSystem);

                EngineComponentManager.ComponentInfo component = null;
                if (comboBoxSoundSystems.SelectedIndex != -1)
                    component = components[comboBoxSoundSystems.SelectedIndex];

                if (component != null)
                {
                    TextBlock soundSystemBlock = block.AddChild("SoundSystem");
                    soundSystemBlock.SetAttribute("implementationComponent", component.Name);
                }
            }

            //Localization
            {
                string language = "Autodetect";
                if (comboBoxLanguages.SelectedIndex > 0)
                    language = (string)comboBoxLanguages.SelectedItem;

                TextBlock localizationBlock = block.AddChild("Localization");
                localizationBlock.SetAttribute("language", language);
                if (!checkBoxLocalizeEngine.Checked)
                    localizationBlock.SetAttribute("localizeEngine", checkBoxLocalizeEngine.Checked.ToString());
                if (!checkBoxLocalizeToolset.Checked)
                    localizationBlock.SetAttribute("localizeToolset", checkBoxLocalizeToolset.Checked.ToString());
            }

            //save file
            {
                string fileName = VirtualFileSystem.GetRealPathByVirtual(
                    "user:Configs/Engine.config");

                try
                {
                    string directoryName = Path.GetDirectoryName(fileName);
                    if (directoryName != "" && !Directory.Exists(directoryName))
                        Directory.CreateDirectory(directoryName);
                    using (StreamWriter writer = new StreamWriter(fileName))
                    {
                        writer.Write(block.DumpToString());
                    }
                }
                catch
                {
                    string text = string.Format("Saving file failed \"{0}\".", fileName);
                    MessageBox.Show(text, "Configurator", MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                    return false;
                }
            }

            return true;
        }
        protected override void OnSave(TextBlock block)
        {
            base.OnSave(block);

            if (!(currentTask is IdleTask))
            {
                TextBlock taskBlock = block.AddChild("currentTask");
                taskBlock.SetAttribute("class", GetTaskClassName(currentTask));
                currentTask._Save(taskBlock);
            }

            if (tasks.Count != 0)
            {
                TextBlock tasksBlock = block.AddChild("tasks");
                foreach (Task task in tasks)
                {
                    TextBlock taskBlock = tasksBlock.AddChild("item");
                    taskBlock.SetAttribute("class", GetTaskClassName(task));
                    task._Save(taskBlock);
                }
            }
        }
Example #10
0
        protected override void OnFormClosing( FormClosingEventArgs e )
        {
            if( DialogResult == DialogResult.OK )
            {
                //save Engine.config

                TextBlock block = new TextBlock();

                //Renderer
                {
                    TextBlock rendererBlock = block.AddChild( "Renderer" );

                    string renderSystemName = "";
                    if( comboBoxRenderSystems.SelectedIndex != -1 )
                        renderSystemName = (string)comboBoxRenderSystems.SelectedItem;

                    if( renderSystemName != "" )
                        rendererBlock.SetAttribute( "renderSystemName", renderSystemName );

                    //maxPixelShaders
                    {
                        EnumTypeConverter enumConverter = new EnumTypeConverter(
                            typeof( RendererWorld.MaxPixelShadersVersions ) );
                        string text = comboBoxMaxPixelShaders.SelectedItem.ToString();
                        RendererWorld.MaxPixelShadersVersions maxPixelShaders =
                            (RendererWorld.MaxPixelShadersVersions)enumConverter.ConvertFromString( text );
                        rendererBlock.SetAttribute( "maxPixelShaders", maxPixelShaders.ToString() );
                    }

                    //maxVertexShaders
                    {
                        EnumTypeConverter enumConverter = new EnumTypeConverter(
                            typeof( RendererWorld.MaxVertexShadersVersions ) );
                        string text = comboBoxMaxVertexShaders.SelectedItem.ToString();
                        RendererWorld.MaxVertexShadersVersions maxVertexShaders =
                            (RendererWorld.MaxVertexShadersVersions)enumConverter.ConvertFromString( text );
                        rendererBlock.SetAttribute( "maxVertexShaders", maxVertexShaders.ToString() );
                    }

                    //fullSceneAntialiasing
                    {
                        int fullSceneAntialiasing = 0;
                        if( comboBoxAntialiasing.SelectedIndex > 0 )
                            fullSceneAntialiasing = int.Parse( (string)comboBoxAntialiasing.SelectedItem );
                        rendererBlock.SetAttribute( "fullSceneAntialiasing",
                            fullSceneAntialiasing.ToString() );
                    }

                    //filtering
                    {
                        EnumTypeConverter enumConverter = new EnumTypeConverter(
                            typeof( RendererWorld.FilteringModes ) );
                        string text = comboBoxFiltering.SelectedItem.ToString();
                        RendererWorld.FilteringModes filtering =
                            (RendererWorld.FilteringModes)enumConverter.ConvertFromString( text );
                        rendererBlock.SetAttribute( "filtering", filtering.ToString() );
                    }

                    //renderTechnique
                    if( comboBoxRenderTechnique.SelectedIndex != -1 )
                    {
                        string renderTechnique = "";
                        if( comboBoxRenderTechnique.SelectedIndex != 0 )
                        {
                            renderTechnique =
                                ( (RenderTechniqueItem)comboBoxRenderTechnique.SelectedItem ).Name;
                        }
                        rendererBlock.SetAttribute( "renderTechnique", renderTechnique );
                    }

                    //videoMode
                    if( comboBoxVideoMode.SelectedIndex > 0 )
                    {
                        string[] strings = ( (string)comboBoxVideoMode.SelectedItem ).
                            Split( new char[] { 'x' } );
                        Vec2i videoMode = new Vec2i( int.Parse( strings[ 0 ] ),
                            int.Parse( strings[ 1 ] ) );
                        rendererBlock.SetAttribute( "videoMode", videoMode.ToString() );
                    }

                    //fullScreen
                    rendererBlock.SetAttribute( "fullScreen", checkBoxFullScreen.Checked.ToString() );

                    //vertical sync
                    rendererBlock.SetAttribute( "verticalSync",
                        checkBoxVerticalSync.Checked.ToString() );

                    //allowChangeDisplayFrequency
                    rendererBlock.SetAttribute( "allowChangeDisplayFrequency",
                        checkBoxAllowChangeDisplayFrequency.Checked.ToString() );
                }

                //Physics system
                {
                    string physicsSystemName = "";
                    if( comboBoxPhysicsSystems.SelectedIndex != -1 )
                        physicsSystemName = (string)comboBoxPhysicsSystems.SelectedItem;

                    //physics system name
                    TextBlock physicsSystemBlock = block.AddChild( "PhysicsSystem" );
                    if( physicsSystemName != "" )
                        physicsSystemBlock.SetAttribute( "physicsSystemName", physicsSystemName );
                }

                //Sound system
                {
                    string soundSystemName = "";
                    if( comboBoxSoundSystems.SelectedIndex != -1 )
                        soundSystemName = (string)comboBoxSoundSystems.SelectedItem;

                    TextBlock soundSystemBlock = block.AddChild( "SoundSystem" );
                    if( soundSystemName != "" )
                        soundSystemBlock.SetAttribute( "soundSystemName", soundSystemName );
                }

                //Localization
                {
                    string language = "English";
                    if( comboBoxLanguages.SelectedIndex != -1 )
                        language = (string)comboBoxLanguages.SelectedItem;

                    TextBlock localizationBlock = block.AddChild( "Localization" );
                    localizationBlock.SetAttribute( "language", language );
                }

                //save file
                {
                    string fileName = VirtualFileSystem.GetRealPathByVirtual(
                        "user:Configs/Engine.config" );

                    try
                    {
                        string directoryName = Path.GetDirectoryName( fileName );
                        if( directoryName != "" && !Directory.Exists( directoryName ) )
                            Directory.CreateDirectory( directoryName );
                        using( StreamWriter writer = new StreamWriter( fileName ) )
                        {
                            writer.Write( block.DumpToString() );
                        }
                    }
                    catch
                    {
                        string text = string.Format( "Saving file failed \"{0}\".", fileName );
                        MessageBox.Show( text, "Configurator", MessageBoxButtons.OK,
                            MessageBoxIcon.Warning );
                        e.Cancel = true;
                        return;
                    }
                }
            }

            base.OnFormClosing( e );
        }
Example #11
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnSave(TextBlock)"/>.</summary>
        protected override void OnSave( TextBlock block )
        {
            base.OnSave( block );

            //World serialization: save animation tree.
            if( EntitySystemWorld.Instance.SerializationMode == SerializationModes.World )
            {
                AnimationTree tree = GetFirstAnimationTree();
                if( tree != null )
                {
                    TextBlock treeBlock = block.AddChild( "animationTree" );
                    tree.WorldSave( treeBlock );
                }
            }
        }
        protected override void OnSave( TextBlock block )
        {
            base.OnSave( block );

            //General
            {
                if( blending != MaterialBlendingTypes.Opaque )
                    block.SetAttribute( "blending", blending.ToString() );

                if( !lighting )
                    block.SetAttribute( "lighting", lighting.ToString() );

                if( !culling )
                    block.SetAttribute( "culling", culling.ToString() );

                if( !useNormals )
                    block.SetAttribute( "useNormals", useNormals.ToString() );

                if( !receiveShadows )
                    block.SetAttribute( "receiveShadows", receiveShadows.ToString() );

                if( alphaRejectFunction != CompareFunction.AlwaysPass )
                    block.SetAttribute( "alphaRejectFunction", alphaRejectFunction.ToString() );

                if( alphaRejectValue != 127 )
                    block.SetAttribute( "alphaRejectValue", alphaRejectValue.ToString() );

                if( alphaToCoverage )
                    block.SetAttribute( "alphaToCoverage", alphaToCoverage.ToString() );

                if( fadingByDistanceRange != new Range( 0, 0 ) )
                    block.SetAttribute( "fadingByDistanceRange", fadingByDistanceRange.ToString() );

                if( !allowFog )
                    block.SetAttribute( "allowFog", allowFog.ToString() );

                if( !depthWrite )
                    block.SetAttribute( "depthWrite", depthWrite.ToString() );

                if( !depthTest )
                    block.SetAttribute( "depthTest", depthTest.ToString() );
            }

            //Diffuse
            {
                if( diffuseColor != new ColorValue( 1, 1, 1 ) )
                    block.SetAttribute( "diffuseColor", diffuseColor.ToString() );
                if( diffusePower != 1 )
                    block.SetAttribute( "diffusePower", diffusePower.ToString() );

                if( diffuseScaleDynamic )
                    block.SetAttribute( "diffuseScaleDynamic", diffuseScaleDynamic.ToString() );

                if( diffuseVertexColor )
                    block.SetAttribute( "diffuseVertexColor", diffuseVertexColor.ToString() );

                if( diffuse1Map.IsDataExists() )
                {
                    TextBlock diffuse1MapBlock = block.AddChild( "diffuse1Map" );
                    diffuse1Map.Save( diffuse1MapBlock );
                }

                if( diffuse2Map.IsDataExists() )
                {
                    TextBlock diffuse2MapBlock = block.AddChild( "diffuse2Map" );
                    diffuse2Map.Save( diffuse2MapBlock );
                }

                if( diffuse3Map.IsDataExists() )
                {
                    TextBlock diffuse3MapBlock = block.AddChild( "diffuse3Map" );
                    diffuse3Map.Save( diffuse3MapBlock );
                }

                if( diffuse4Map.IsDataExists() )
                {
                    TextBlock diffuse4MapBlock = block.AddChild( "diffuse4Map" );
                    diffuse4Map.Save( diffuse4MapBlock );
                }
            }

            //Reflection
            {
                if( reflectionColor != new ColorValue( 0, 0, 0 ) )
                    block.SetAttribute( "reflectionColor", reflectionColor.ToString() );
                if( reflectionPower != 1 )
                    block.SetAttribute( "reflectionPower", reflectionPower.ToString() );

                if( reflectionScaleDynamic )
                    block.SetAttribute( "reflectionScaleDynamic", reflectionScaleDynamic.ToString() );

                if( reflectionMap.IsDataExists() )
                {
                    TextBlock reflectionMapBlock = block.AddChild( "reflectionMap" );
                    reflectionMap.Save( reflectionMapBlock );
                }

                if( !string.IsNullOrEmpty( reflectionSpecificCubemap ) )
                    block.SetAttribute( "reflectionSpecificCubemap", reflectionSpecificCubemap );
            }

            //Emission
            {
                if( emissionColor != new ColorValue( 0, 0, 0 ) )
                    block.SetAttribute( "emissionColor", emissionColor.ToString() );
                if( emissionPower != 1 )
                    block.SetAttribute( "emissionPower", emissionPower.ToString() );

                if( emissionScaleDynamic )
                    block.SetAttribute( "emissionScaleDynamic", emissionScaleDynamic.ToString() );

                if( emissionMap.IsDataExists() )
                {
                    TextBlock emissionMapBlock = block.AddChild( "emissionMap" );
                    emissionMap.Save( emissionMapBlock );
                }
            }

            //Specular
            {
                if( specularColor != new ColorValue( 0, 0, 0 ) )
                    block.SetAttribute( "specularColor", specularColor.ToString() );
                if( specularPower != 1 )
                    block.SetAttribute( "specularPower", specularPower.ToString() );

                if( specularScaleDynamic )
                    block.SetAttribute( "specularScaleDynamic", specularScaleDynamic.ToString() );

                if( specularMap.IsDataExists() )
                {
                    TextBlock specularMapBlock = block.AddChild( "specularMap" );
                    specularMap.Save( specularMapBlock );
                }

                if( specularShininess != 20 )
                    block.SetAttribute( "specularShininess", specularShininess.ToString() );
            }

            //Height
            {
                if( normalMap.IsDataExists() )
                {
                    TextBlock normalMapBlock = block.AddChild( "normalMap" );
                    normalMap.Save( normalMapBlock );
                }

                if( heightFromNormalMapAlpha )
                    block.SetAttribute( "heightFromNormalMapAlpha", heightFromNormalMapAlpha.ToString() );

                if( heightMap.IsDataExists() )
                {
                    TextBlock heightMapBlock = block.AddChild( "heightMap" );
                    heightMap.Save( heightMapBlock );
                }

                if( heightScale != .04f )
                    block.SetAttribute( "heightScale", heightScale.ToString() );
            }
        }