protected override void OnClone( HighLevelMaterial sourceMaterial ) { base.OnClone( sourceMaterial ); ShaderBaseMaterial source = (ShaderBaseMaterial)sourceMaterial; //General blending = source.blending; lighting = source.lighting; ambientLighting = source.ambientLighting; doubleSided = source.doubleSided; useNormals = source.useNormals; receiveShadows = source.receiveShadows; receiveSimpleShadows = source.receiveSimpleShadows; alphaRejectFunction = source.alphaRejectFunction; alphaRejectValue = source.alphaRejectValue; alphaToCoverage = source.alphaToCoverage; fadingByDistanceRange = source.fadingByDistanceRange; allowFog = source.allowFog; depthWrite = source.depthWrite; depthTest = source.depthTest; softParticles = source.softParticles; softParticlesFadingLength = source.softParticlesFadingLength; depthOffset = source.depthOffset; halfLambert = source.halfLambert; //Diffuse diffuseColor = source.diffuseColor; diffusePower = source.diffusePower; diffuseScaleDynamic = source.diffuseScaleDynamic; diffuseVertexColor = source.diffuseVertexColor; diffuse1Map.OnClone( source.diffuse1Map ); diffuse2Map.OnClone( source.diffuse2Map ); diffuse3Map.OnClone( source.diffuse3Map ); diffuse4Map.OnClone( source.diffuse4Map ); //Reflection reflectionColor = source.reflectionColor; reflectionPower = source.reflectionPower; reflectionScaleDynamic = source.reflectionScaleDynamic; reflectionMap.OnClone( source.reflectionMap ); reflectionSpecificCubemap = source.ConvertToFullPath( source.ReflectionSpecificCubemap ); reflectionBoxParallaxCorrectedCubemaps = source.reflectionBoxParallaxCorrectedCubemaps; //Emission emissionColor = source.emissionColor; emissionPower = source.emissionPower; emissionScaleDynamic = source.emissionScaleDynamic; emissionMap.OnClone( source.emissionMap ); //Specular specularColor = source.specularColor; specularPower = source.specularPower; specularScaleDynamic = source.specularScaleDynamic; specularMap.OnClone( source.specularMap ); specularShininess = source.specularShininess; //Translucency translucencyColor = source.translucencyColor; translucencyPower = source.translucencyPower; translucencyDynamic = source.translucencyDynamic; translucencyMap.OnClone( source.translucencyMap ); translucencyClearness = source.translucencyClearness; //Height normalMap.OnClone( source.normalMap ); heightMap.OnClone( source.heightMap ); heightFromNormalMapAlpha = source.heightFromNormalMapAlpha; displacementTechnique = source.displacementTechnique; heightScale = source.heightScale; }
protected override bool OnLoad( TextBlock block ) { if( !base.OnLoad( block ) ) return false; //General { if( block.IsAttributeExist( "blending" ) ) blending = (MaterialBlendingTypes)Enum.Parse( typeof( MaterialBlendingTypes ), block.GetAttribute( "blending" ) ); if( block.IsAttributeExist( "lighting" ) ) lighting = bool.Parse( block.GetAttribute( "lighting" ) ); if( block.IsAttributeExist( "ambientLighting" ) ) ambientLighting = bool.Parse( block.GetAttribute( "ambientLighting" ) ); if( block.IsAttributeExist( "doubleSided" ) ) doubleSided = bool.Parse( block.GetAttribute( "doubleSided" ) ); //old version compatibility if( block.IsAttributeExist( "culling" ) ) doubleSided = !bool.Parse( block.GetAttribute( "culling" ) ); if( block.IsAttributeExist( "useNormals" ) ) useNormals = bool.Parse( block.GetAttribute( "useNormals" ) ); if( block.IsAttributeExist( "receiveShadows" ) ) receiveShadows = bool.Parse( block.GetAttribute( "receiveShadows" ) ); if( block.IsAttributeExist( "receiveSimpleShadows" ) ) receiveSimpleShadows = bool.Parse( block.GetAttribute( "receiveSimpleShadows" ) ); if( block.IsAttributeExist( "alphaRejectFunction" ) ) alphaRejectFunction = (CompareFunction)Enum.Parse( typeof( CompareFunction ), block.GetAttribute( "alphaRejectFunction" ) ); if( block.IsAttributeExist( "alphaRejectValue" ) ) alphaRejectValue = byte.Parse( block.GetAttribute( "alphaRejectValue" ) ); if( block.IsAttributeExist( "alphaToCoverage" ) ) alphaToCoverage = bool.Parse( block.GetAttribute( "alphaToCoverage" ) ); if( block.IsAttributeExist( "fadingByDistanceRange" ) ) fadingByDistanceRange = Range.Parse( block.GetAttribute( "fadingByDistanceRange" ) ); if( block.IsAttributeExist( "allowFog" ) ) allowFog = bool.Parse( block.GetAttribute( "allowFog" ) ); if( block.IsAttributeExist( "depthWrite" ) ) depthWrite = bool.Parse( block.GetAttribute( "depthWrite" ) ); if( block.IsAttributeExist( "depthTest" ) ) depthTest = bool.Parse( block.GetAttribute( "depthTest" ) ); if( block.IsAttributeExist( "softParticles" ) ) softParticles = bool.Parse( block.GetAttribute( "softParticles" ) ); if( block.IsAttributeExist( "softParticlesFadingLength" ) ) softParticlesFadingLength = float.Parse( block.GetAttribute( "softParticlesFadingLength" ) ); if( block.IsAttributeExist( "depthOffset" ) ) depthOffset = float.Parse( block.GetAttribute( "depthOffset" ) ); if( block.IsAttributeExist( "halfLambert" ) ) halfLambert = bool.Parse( block.GetAttribute( "halfLambert" ) ); } //Diffuse { //old version compatibility if( block.IsAttributeExist( "diffuseScale" ) ) { diffuseColor = ColorValue.Parse( block.GetAttribute( "diffuseScale" ) ); float power = Math.Max( Math.Max( diffuseColor.Red, diffuseColor.Green ), diffuseColor.Blue ); if( power > 1 ) { diffuseColor.Red /= power; diffuseColor.Green /= power; diffuseColor.Blue /= power; diffusePower = power; } } if( block.IsAttributeExist( "diffuseColor" ) ) diffuseColor = ColorValue.Parse( block.GetAttribute( "diffuseColor" ) ); if( block.IsAttributeExist( "diffusePower" ) ) diffusePower = float.Parse( block.GetAttribute( "diffusePower" ) ); if( block.IsAttributeExist( "diffuseScaleDynamic" ) ) diffuseScaleDynamic = bool.Parse( block.GetAttribute( "diffuseScaleDynamic" ) ); if( block.IsAttributeExist( "diffuseVertexColor" ) ) diffuseVertexColor = bool.Parse( block.GetAttribute( "diffuseVertexColor" ) ); TextBlock diffuse1MapBlock = block.FindChild( "diffuse1Map" ); if( diffuse1MapBlock != null ) diffuse1Map.Load( diffuse1MapBlock ); TextBlock diffuse2MapBlock = block.FindChild( "diffuse2Map" ); if( diffuse2MapBlock != null ) diffuse2Map.Load( diffuse2MapBlock ); TextBlock diffuse3MapBlock = block.FindChild( "diffuse3Map" ); if( diffuse3MapBlock != null ) diffuse3Map.Load( diffuse3MapBlock ); TextBlock diffuse4MapBlock = block.FindChild( "diffuse4Map" ); if( diffuse4MapBlock != null ) diffuse4Map.Load( diffuse4MapBlock ); //old version compatibility if( block.IsAttributeExist( "diffuseMap" ) ) diffuse1Map.Texture = block.GetAttribute( "diffuseMap" ); } //Reflection { if( block.IsAttributeExist( "reflectionScale" ) ) { reflectionColor = ColorValue.Parse( block.GetAttribute( "reflectionScale" ) ); float power = Math.Max( Math.Max( reflectionColor.Red, reflectionColor.Green ), Math.Max( reflectionColor.Blue, reflectionColor.Alpha ) ); if( power > 1 ) { reflectionColor /= power; reflectionPower = power; } } if( block.IsAttributeExist( "reflectionColor" ) ) reflectionColor = ColorValue.Parse( block.GetAttribute( "reflectionColor" ) ); if( block.IsAttributeExist( "reflectionPower" ) ) reflectionPower = float.Parse( block.GetAttribute( "reflectionPower" ) ); if( block.IsAttributeExist( "reflectionScaleDynamic" ) ) reflectionScaleDynamic = bool.Parse( block.GetAttribute( "reflectionScaleDynamic" ) ); TextBlock reflectionMapBlock = block.FindChild( "reflectionMap" ); if( reflectionMapBlock != null ) reflectionMap.Load( reflectionMapBlock ); if( block.IsAttributeExist( "reflectionSpecificCubemap" ) ) reflectionSpecificCubemap = block.GetAttribute( "reflectionSpecificCubemap" ); //old version compatibility if( block.IsAttributeExist( "reflectionMap" ) ) reflectionMap.Texture = block.GetAttribute( "reflectionMap" ); if( block.IsAttributeExist( "reflectionBoxParallaxCorrectedCubemaps" ) ) reflectionBoxParallaxCorrectedCubemaps = bool.Parse( block.GetAttribute( "reflectionBoxParallaxCorrectedCubemaps" ) ); } //Emission { if( block.IsAttributeExist( "emissionScale" ) ) { emissionColor = ColorValue.Parse( block.GetAttribute( "emissionScale" ) ); float power = Math.Max( Math.Max( emissionColor.Red, emissionColor.Green ), Math.Max( emissionColor.Blue, emissionColor.Alpha ) ); if( power > 1 ) { emissionColor /= power; emissionPower = power; } } if( block.IsAttributeExist( "emissionColor" ) ) emissionColor = ColorValue.Parse( block.GetAttribute( "emissionColor" ) ); if( block.IsAttributeExist( "emissionPower" ) ) emissionPower = float.Parse( block.GetAttribute( "emissionPower" ) ); if( block.IsAttributeExist( "emissionScaleDynamic" ) ) emissionScaleDynamic = bool.Parse( block.GetAttribute( "emissionScaleDynamic" ) ); TextBlock emissionMapBlock = block.FindChild( "emissionMap" ); if( emissionMapBlock != null ) emissionMap.Load( emissionMapBlock ); //old version compatibility if( block.IsAttributeExist( "emissionMap" ) ) emissionMap.Texture = block.GetAttribute( "emissionMap" ); } //Specular { if( block.IsAttributeExist( "specularScale" ) ) { specularColor = ColorValue.Parse( block.GetAttribute( "specularScale" ) ); float power = Math.Max( Math.Max( specularColor.Red, specularColor.Green ), Math.Max( specularColor.Blue, specularColor.Alpha ) ); if( power > 1 ) { specularColor /= power; specularPower = power; } } if( block.IsAttributeExist( "specularColor" ) ) specularColor = ColorValue.Parse( block.GetAttribute( "specularColor" ) ); if( block.IsAttributeExist( "specularPower" ) ) specularPower = float.Parse( block.GetAttribute( "specularPower" ) ); if( block.IsAttributeExist( "specularScaleDynamic" ) ) specularScaleDynamic = bool.Parse( block.GetAttribute( "specularScaleDynamic" ) ); TextBlock specularMapBlock = block.FindChild( "specularMap" ); if( specularMapBlock != null ) specularMap.Load( specularMapBlock ); if( block.IsAttributeExist( "specularShininess" ) ) specularShininess = float.Parse( block.GetAttribute( "specularShininess" ) ); //old version compatibility if( block.IsAttributeExist( "specularMap" ) ) specularMap.Texture = block.GetAttribute( "specularMap" ); } //Translucency { if( block.IsAttributeExist( "translucencyColor" ) ) translucencyColor = ColorValue.Parse( block.GetAttribute( "translucencyColor" ) ); if( block.IsAttributeExist( "translucencyPower" ) ) translucencyPower = float.Parse( block.GetAttribute( "translucencyPower" ) ); if( block.IsAttributeExist( "translucencyDynamic" ) ) translucencyDynamic = bool.Parse( block.GetAttribute( "translucencyDynamic" ) ); TextBlock translucencyMapBlock = block.FindChild( "translucencyMap" ); if( translucencyMapBlock != null ) translucencyMap.Load( translucencyMapBlock ); if( block.IsAttributeExist( "translucencyClearness" ) ) translucencyClearness = float.Parse( block.GetAttribute( "translucencyClearness" ) ); } //Height { TextBlock normalMapBlock = block.FindChild( "normalMap" ); if( normalMapBlock != null ) normalMap.Load( normalMapBlock ); TextBlock heightMapBlock = block.FindChild( "heightMap" ); if( heightMapBlock != null ) heightMap.Load( heightMapBlock ); if( block.IsAttributeExist( "heightFromNormalMapAlpha" ) ) heightFromNormalMapAlpha = bool.Parse( block.GetAttribute( "heightFromNormalMapAlpha" ) ); if( block.IsAttributeExist( "displacementTechnique" ) ) { displacementTechnique = (DisplacementTechniques)Enum.Parse( typeof( DisplacementTechniques ), block.GetAttribute( "displacementTechnique" ) ); } if( block.IsAttributeExist( "heightScale" ) ) heightScale = float.Parse( block.GetAttribute( "heightScale" ) ); //old version compatibility if( block.IsAttributeExist( "normalMap" ) ) normalMap.Texture = block.GetAttribute( "normalMap" ); if( block.IsAttributeExist( "heightMap" ) ) heightMap.Texture = block.GetAttribute( "heightMap" ); } return true; }