本文整理汇总了C#中Axiom.Serialization.MaterialScriptContext类的典型用法代码示例。如果您正苦于以下问题:C# MaterialScriptContext类的具体用法?C# MaterialScriptContext怎么用?C# MaterialScriptContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaterialScriptContext类属于Axiom.Serialization命名空间,在下文中一共展示了MaterialScriptContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseBindingType
protected static bool ParseBindingType( string parameters, MaterialScriptContext context )
{
switch ( parameters.ToLower() )
{
case "texture":
context.textureUnit.BindingType = TextureBindingType.Fragment;
break;
case "vertex":
context.textureUnit.BindingType = TextureBindingType.Vertex;
break;
default:
LogParseError( context, "Invalid binding type option - {0}", parameters );
break;
}
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:16,代码来源:MaterialSerializer.cs
示例2: ParseAmbient
protected static bool ParseAmbient( string parameters, MaterialScriptContext context )
{
string[] values = parameters.Split( new char[] { ' ', '\t' } );
// must be 1, 3 or 4 parameters
if ( values.Length == 1 )
{
if ( values[ 0 ].ToLower() == "vertexcolour" ||
values[ 0 ].ToLower() == "vertexcolor" )
{
context.pass.VertexColorTracking |= TrackVertexColor.Ambient;
}
else
{
LogParseError( context, "Bad ambient attribute, single parameter flag must be 'vertexcolour' or 'vertexcolor'." );
}
}
else if ( values.Length == 3 || values.Length == 4 )
{
context.pass.Ambient = StringConverter.ParseColor( values );
context.pass.VertexColorTracking &= ~TrackVertexColor.Ambient;
}
else
{
LogParseError( context, "Bad ambient attribute, wrong number of parameters (expected 1, 3 or 4)." );
}
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:29,代码来源:MaterialSerializer.cs
示例3: ParseCullSoftware
protected static bool ParseCullSoftware( string parameters, MaterialScriptContext context )
{
// lookup the real enum equivalent to the script value
object val = ScriptEnumAttribute.Lookup( parameters, typeof( ManualCullingMode ) );
// if a value was found, assign it
if ( val != null )
{
context.pass.ManualCullingMode = (ManualCullingMode)val;
}
else
{
string legalValues = ScriptEnumAttribute.GetLegalValues( typeof( ManualCullingMode ) );
LogParseError( context, "Bad cull_software attribute, valid parameters are {0}.", legalValues );
}
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:18,代码来源:MaterialSerializer.cs
示例4: ParseLodDistances
protected static bool ParseLodDistances( string parameters, MaterialScriptContext context )
{
context.material.LodStrategy = LodStrategyManager.Instance.GetStrategy( DistanceLodStrategy.StrategyName );
string[] values = parameters.Split( new char[] { ' ', '\t' } );
LodValueList lodDistances = new LodValueList();
for ( int i = 0; i < values.Length; i++ )
{
lodDistances.Add( StringConverter.ParseFloat( values[ i ] ) );
}
context.material.SetLodLevels( lodDistances );
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:17,代码来源:MaterialSerializer.cs
示例5: ParseLodIndex
protected static bool ParseLodIndex( string parameters, MaterialScriptContext context )
{
context.technique.LodIndex = int.Parse( parameters );
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:6,代码来源:MaterialSerializer.cs
示例6: ParseTextureUnit
protected static bool ParseTextureUnit( string parameters, MaterialScriptContext context )
{
// create a new texture unit
context.textureUnit = context.pass.CreateTextureUnitState();
// get the texture unit name
string[] values = parameters.Split( new char[] { ' ', '\t' } );
if ( values.Length > 0 && values[ 0 ].Length > 0 )
context.textureUnit.Name = values[ 0 ];
// update section
context.section = MaterialScriptSection.TextureUnit;
// increase texture unit level depth
context.stateLev++;
// return true because this must be followed by a {
return true;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:19,代码来源:MaterialSerializer.cs
示例7: ParseSetTextureAlias
protected static bool ParseSetTextureAlias( string parameters, MaterialScriptContext context )
{
// get the texture alias
string[] values = parameters.Split( new char[] { ' ', '\t' } );
if ( values.Length != 2 )
{
LogParseError( context, "Invalid set_texture_alias entry - expected 2 parameters." );
return true;
}
// update section
if ( context.textureAliases.ContainsKey( values[ 0 ] ) )
{
context.textureAliases[ values[ 0 ] ] = values[ 1 ];
}
else
{
context.textureAliases.Add( values[ 0 ], values[ 1 ] );
}
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:22,代码来源:MaterialSerializer.cs
示例8: ParseProgramMorphAnimation
protected static bool ParseProgramMorphAnimation( string parameters, MaterialScriptContext context )
{
context.programDef.supportsMorphAnimation = bool.Parse( parameters );
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:6,代码来源:MaterialSerializer.cs
示例9: ParseProgramPoseAnimation
protected static bool ParseProgramPoseAnimation( string parameters, MaterialScriptContext context )
{
context.programDef.poseAnimationCount = ushort.Parse( parameters );
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:6,代码来源:MaterialSerializer.cs
示例10: ParseProgramSource
protected static bool ParseProgramSource( string parameters, MaterialScriptContext context )
{
// source filename, preserve case
context.programDef.source = parameters;
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:7,代码来源:MaterialSerializer.cs
示例11: ParseProgramSyntax
protected static bool ParseProgramSyntax( string parameters, MaterialScriptContext context )
{
context.programDef.syntax = parameters.ToLower();
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:6,代码来源:MaterialSerializer.cs
示例12: ParseParamNamedAuto
protected static bool ParseParamNamedAuto( string parameters, MaterialScriptContext context )
{
// skip this if the program is not supported or could not be found
if ( context.program == null || !context.program.IsSupported )
{
return false;
}
string[] values = parameters.Split( new char[] { ' ', '\t' } );
if ( values.Length != 2 && values.Length != 3 )
{
LogParseError( context, "Invalid param_named_auto attribute - expected 2 or 3 parameters." );
return false;
}
// get start index
try
{
int index = context.programParams.GetParamIndex( values[ 0 ] );
ProcessAutoProgramParam( index, "param_named_auto", values, context );
}
catch ( Exception ex )
{
LogParseError( context, "Invalid param_named_auto attribute - {0}.", ex.Message );
return false;
}
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:31,代码来源:MaterialSerializer.cs
示例13: ParseParamIndexedAuto
protected static bool ParseParamIndexedAuto( string parameters, MaterialScriptContext context )
{
// skip this if the program is not supported or could not be found
if ( context.program == null || !context.program.IsSupported )
{
return false;
}
string[] values = parameters.Split( new char[] { ' ', '\t' } );
if ( values.Length != 2 && values.Length != 3 )
{
LogParseError( context, "Invalid param_indexed_auto attribute - expected at 2 or 3 parameters." );
return false;
}
// get start index
int index = int.Parse( values[ 0 ] );
ProcessAutoProgramParam( index, "param_indexed_auto", values, context );
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:23,代码来源:MaterialSerializer.cs
示例14: ParseWaveXForm
protected static bool ParseWaveXForm( string parameters, MaterialScriptContext context )
{
string[] values = parameters.Split( new char[] { ' ', '\t' } );
if ( values.Length != 6 )
{
LogParseError( context, "Bad wave_xform attribute, wrong number of parameters (expected 6)." );
return false;
}
TextureTransform transType = 0;
WaveformType waveType = 0;
// check the transform type
object val = ScriptEnumAttribute.Lookup( values[ 0 ], typeof( TextureTransform ) );
if ( val == null )
{
string legalValues = ScriptEnumAttribute.GetLegalValues( typeof( TextureTransform ) );
LogParseError( context, "Bad wave_xform attribute, valid transform type values are {0}.", legalValues );
return false;
}
transType = (TextureTransform)val;
// check the wavetype
val = ScriptEnumAttribute.Lookup( values[ 1 ], typeof( WaveformType ) );
if ( val == null )
{
string legalValues = ScriptEnumAttribute.GetLegalValues( typeof( WaveformType ) );
LogParseError( context, "Bad wave_xform attribute, valid waveform type values are {0}.", legalValues );
return false;
}
waveType = (WaveformType)val;
// set the transform animation
context.textureUnit.SetTransformAnimation(
transType,
waveType,
StringConverter.ParseFloat( values[ 2 ] ),
StringConverter.ParseFloat( values[ 3 ] ),
StringConverter.ParseFloat( values[ 4 ] ),
StringConverter.ParseFloat( values[ 5 ] ) );
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:49,代码来源:MaterialSerializer.cs
示例15: ParseTechnique
protected static bool ParseTechnique( string parameters, MaterialScriptContext context )
{
// create a new technique
context.technique = context.material.CreateTechnique();
// update section
context.section = MaterialScriptSection.Technique;
// increate technique level depth
context.techLev++;
// get the technique name
string[] values = parameters.Split( new char[] { ' ', '\t' } );
if ( values.Length > 0 && values[ 0 ].Length > 0 )
context.technique.Name = values[ 0 ];
// return true because this must be followed by a {
return true;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:20,代码来源:MaterialSerializer.cs
示例16: ParseDefaultParams
protected static bool ParseDefaultParams( string parameters, MaterialScriptContext context )
{
context.section = MaterialScriptSection.DefaultParameters;
// should be a brace next
return true;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:7,代码来源:MaterialSerializer.cs
示例17: ParsePass
protected static bool ParsePass( string parameters, MaterialScriptContext context )
{
// get the pass name
string[] values = parameters.Split( new char[] { ' ', '\t' } );
// if params is not empty then see if the pass name already exists
if ( values.Length > 0 && values[ 0 ].Length > 0 && context.technique.PassCount > 0 )
{
// find the pass with name = params
Pass foundPass = context.technique.GetPass( values[ 0 ] );
if ( foundPass != null )
context.passLev = foundPass.Index;
else
// name was not found so a new pass is needed
// position pass level to the end index
// a new pass will be created later on
context.passLev = context.technique.PassCount;
}
else
{
// increase the pass level depth;
context.passLev++;
}
if ( context.technique.PassCount > context.passLev )
{
context.pass = context.technique.GetPass( context.passLev );
}
else
{
// create a new pass
context.pass = context.technique.CreatePass();
if ( values.Length > 0 && values[ 0 ].Length > 0 )
context.pass.Name = values[ 0 ];
}
// update section
context.section = MaterialScriptSection.Pass;
// return true because this must be followed by a {
return true;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:42,代码来源:MaterialSerializer.cs
示例18: ProcessManualProgramParam
/// <summary>
///
/// </summary>
/// <param name="index"></param>
/// <param name="commandName"></param>
/// <param name="parameters"></param>
/// <param name="context"></param>
protected static void ProcessManualProgramParam( int index, string commandName, string[] parameters, MaterialScriptContext context )
{
// NB we assume that the first element of vecparams is taken up with either
// the index or the parameter name, which we ignore
int dims, roundedDims;
bool isFloat = false;
string type = parameters[ 1 ].ToLower();
if ( type == "matrix4x4" )
{
dims = 16;
isFloat = true;
}
else if ( type.IndexOf( "float" ) != -1 )
{
if ( type == "float" )
{
dims = 1;
}
else
{
// the first 5 letters are "float", get the dim indicator at the end
// this handles entries like 'float4'
dims = int.Parse( type.Substring( 5 ) );
}
isFloat = true;
}
else if ( type.IndexOf( "int" ) != -1 )
{
if ( type == "int" )
{
dims = 1;
}
else
{
// the first 5 letters are "int", get the dim indicator at the end
dims = int.Parse( type.Substring( 3 ) );
}
}
else
{
LogParseError( context, "Invalid {0} attribute - unrecognized parameter type {1}.", commandName, type );
return;
}
// make sure we have enough params for this type's size
if ( parameters.Length != 2 + dims )
{
LogParseError( context, "Invalid {0} attribute - you need {1} parameters for a parameter of type {2}", commandName, 2 + dims, type );
return;
}
// Round dims to multiple of 4
if ( dims % 4 != 0 )
{
roundedDims = dims + 4 - ( dims % 4 );
}
else
{
roundedDims = dims;
}
int i = 0;
// now parse all the values
if ( isFloat )
{
float[] buffer = new float[ roundedDims ];
// do specified values
for ( i = 0; i < dims; i++ )
{
buffer[ i ] = StringConverter.ParseFloat( parameters[ i + 2 ] );
}
// fill up to multiple of 4 with zero
for ( ; i < roundedDims; i++ )
{
buffer[ i ] = 0.0f;
}
context.programParams.SetConstant( index, buffer );
}
else
{
int[] buffer = new int[ roundedDims ];
// do specified values
for ( i = 0; i < dims; i++ )
{
buffer[ i ] = int.Parse( parameters[ i + 2 ] );
//.........这里部分代码省略.........
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:101,代码来源:MaterialSerializer.cs
示例19: ParseTextureAlias
protected static bool ParseTextureAlias( string parameters, MaterialScriptContext context )
{
Debug.Assert( context.textureUnit != null );
// get the texture alias
string[] values = parameters.Split( new char[] { ' ', '\t' } );
if ( values.Length != 1 )
{
LogParseError( context, "Invalid texture_alias entry - expected 1 parameter." );
return true;
}
// update section
context.textureUnit.TextureNameAlias = values[ 0 ];
return false;
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:17,代码来源:MaterialSerializer.cs
示例20: ProcessAutoProgramParam
/// <summary>
///
/// </summary>
/// <param name="index"></param>
/// <param name="commandName"></param>
/// <param name="parameters"></param>
/// <param name="context"></param>
protected static void ProcessAutoProgramParam( int index, string commandName, string[] parameters, MaterialScriptContext context )
{
bool extras = false;
object val = ScriptEnumAttribute.Lookup( parameters[ 1 ], typeof( GpuProgramParameters.AutoConstantType ) );
if ( val != null )
{
bool isFloat = false;
GpuProgramParameters.AutoConstantType constantType = (GpuProgramParameters.AutoConstantType)val;
// these types require extra data
if ( constantType == GpuProgramParameters.AutoConstantType.LightDiffuseColor ||
constantType == GpuProgramParameters.AutoConstantType.LightSpecularColor ||
constantType == GpuProgramParameters.AutoConstantType.LightAttenuation ||
constantType == GpuProgramParameters.AutoConstantType.LightPosition ||
constantType == GpuProgramParameters.AutoConstantType.LightDirection ||
constantType == GpuProgramParameters.AutoConstantType.LightPositionObjectSpace ||
constantType == GpuProgramParameters.AutoConstantType.LightDirectionObjectSpace ||
constantType == GpuProgramParameters.AutoConstantType.Custom )
{
extras = true;
isFloat = false;
}
else if ( constantType == GpuProgramParameters.AutoConstantType.Time_0_X ||
constantType == GpuProgramParameters.AutoConstantType.SinTime_0_X )
{
extras = true;
isFloat = true;
}
// do we require extra data for this parameter?
if ( extras )
{
if ( parameters.Length != 3 )
{
LogParseError( context, "Invalid {0} attribute - Expected 3 parameters.", commandName );
return;
}
}
if ( isFloat && extras )
context.programParams.SetAutoConstant( index, constantType, float.Parse( parameters[ 2 ] ) );
else if ( extras )
context.programParams.SetAutoConstant( index, constantType, int.Parse( parameters[ 2 ] ) );
else if ( constantType == GpuProgramParameters.AutoConstantType.Time )
{
if ( parameters.Length == 3 )
context.programParams.SetAutoConstant( index, constantType, float.Parse( parameters[ 2 ] ) );
else
context.programParams.SetAutoConstant( index, constantType, 1.0f );
}
else
context.programParams.SetAutoConstant( index, constantType, 0 );
}
else
{
string legalValues = ScriptEnumAttribute.GetLegalValues( typeof( GpuProgramParameters.AutoConstantType ) );
LogParseError( context, "Bad auto gpu program param - Invalid param type '{0}', valid values are {1}.", parameters[ 1 ], legalValues );
return;
}
}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:70,代码来源:MaterialSerializer.cs
注:本文中的Axiom.Serialization.MaterialScriptContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论