protected static bool ParseMaterial( string parameters, MaterialScriptContext context )
{
// check params for reference to parent material to copy from
// syntax: material name : parentMaterialName
// check params for a colon after the first name and extract the parent name
string[] values = parameters.Split( new char[] { ':' } );
Material basematerial = null;
// create a brand new material
if ( values.Length >= 2 )
{
// if a second parameter exists then assume its the name of the base material
// that this new material should clone from
values[ 1 ] = values[ 1 ].Trim();
// make sure base material exists
basematerial = (Material)MaterialManager.Instance.GetByName( values[ 1 ] );
// if it doesn't exist then report error in log and just create a new material
if ( basematerial == null )
{
LogParseError( context, "parent material:" + values[ 1 ] + " not found for new material:" + values[ 0 ] );
}
}
string materialName = values[ 0 ].Trim();
context.material = (Material)MaterialManager.Instance.Create( materialName, context.groupName );
if ( basematerial != null )
{
// copy parent material details to new material
basematerial.CopyTo( context.material, false );
}
else
{
// remove pre-created technique from defaults
context.material.RemoveAllTechniques();
}
context.material.Origin = context.filename;
// update section
context.section = MaterialScriptSection.Material;
// return true because this must be followed by a {
return true;
}