protected static bool ParseSceneBlend( string parameters, MaterialScriptContext context )
{
string[] values = parameters.ToLower().Split( new char[] { ' ', '\t' } );
switch ( values.Length )
{
case 1:
// e.g. scene_blend add
// lookup the real enum equivalent to the script value
object val = ScriptEnumAttribute.Lookup( values[ 0 ], typeof( SceneBlendType ) );
// if a value was found, assign it
if ( val != null )
{
context.pass.SetSceneBlending( (SceneBlendType)val );
}
else
{
string legalValues = ScriptEnumAttribute.GetLegalValues( typeof( SceneBlendType ) );
LogParseError( context, "Bad scene_blend attribute, valid values for the 2nd parameter are {0}.", legalValues );
return false;
}
break;
case 2:
// e.g. scene_blend source_alpha one_minus_source_alpha
// lookup the real enums equivalent to the script values
object srcVal = ScriptEnumAttribute.Lookup( values[ 0 ], typeof( SceneBlendFactor ) );
object destVal = ScriptEnumAttribute.Lookup( values[ 1 ], typeof( SceneBlendFactor ) );
// if both values were found, assign them
if ( srcVal != null && destVal != null )
{
context.pass.SetSceneBlending( (SceneBlendFactor)srcVal, (SceneBlendFactor)destVal );
}
else
{
string legalValues = ScriptEnumAttribute.GetLegalValues( typeof( SceneBlendFactor ) );
if ( srcVal == null )
{
LogParseError( context, "Bad scene_blend attribute, valid src blend factor values are {0}.", legalValues );
}
if ( destVal == null )
{
LogParseError( context, "Bad scene_blend attribute, valid dest blend factor values are {0}.", legalValues );
}
}
break;
default:
context.pass.SetSceneBlending( SceneBlendFactor.Zero, SceneBlendFactor.Zero );
LogParseError( context, "Bad scene_blend attribute, wrong number of parameters (expected 1 or 2)." );
break;
}
return false;
}