本文整理汇总了C#中Axiom.Graphics.GpuProgramParameters.SetConstant方法的典型用法代码示例。如果您正苦于以下问题:C# GpuProgramParameters.SetConstant方法的具体用法?C# GpuProgramParameters.SetConstant怎么用?C# GpuProgramParameters.SetConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axiom.Graphics.GpuProgramParameters
的用法示例。
在下文中一共展示了GpuProgramParameters.SetConstant方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetConstantFloatArray
public void SetConstantFloatArray()
{
float[] expected = new[] { (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom() };
float[] actual;
GpuProgramParameters parameters = new GpuProgramParameters();
//var floatLogical = new GpuLogicalBufferStruct();
//parameters._setLogicalIndexes( floatLogical, new GpuLogicalBufferStruct() );
parameters.SetConstant( 0, expected );
Assert.IsTrue( parameters.GetFloatConstant( 0 ).isSet );
actual = parameters.GetFloatConstant( 0 ).val;
Assert.AreEqual( expected, actual );
}
示例2: UpdateCustomGpuParameter
public void UpdateCustomGpuParameter( GpuProgramParameters.AutoConstantEntry entry, GpuProgramParameters gpuParams )
{
if ( customParams[ entry.Data ] != null )
{
gpuParams.SetConstant( entry.PhysicalIndex, (Vector4)customParams[ entry.Data ] );
}
}
示例3: Clone
public GpuProgramParameters Clone()
{
GpuProgramParameters p = new GpuProgramParameters();
// copy int constants
for ( int i = 0; i < intConstants.Count; i++ )
{
IntConstantEntry e = intConstants[ i ] as IntConstantEntry;
if ( e.isSet )
{
p.SetConstant( i, e.val );
}
}
// copy float constants
for ( int i = 0; i < floatConstants.Count; i++ )
{
FloatConstantEntry e = floatConstants[ i ] as FloatConstantEntry;
if ( e.isSet )
{
p.SetConstant( i, e.val );
}
}
// copy auto constants
for ( int i = 0; i < autoConstantList.Count; i++ )
{
AutoConstantEntry entry = autoConstantList[ i ] as AutoConstantEntry;
p.SetAutoConstant( entry.Clone() );
}
// copy named params
foreach ( string key in namedParams.Keys )
{
p.MapParamNameToIndex( key, namedParams[ key ] );
}
for ( int i = 0; i < paramTypeList.Count; i++ )
{
}
foreach ( ParameterEntry pEntry in paramTypeList )
{
p.AddParameterToDefaultsList( pEntry.ParameterType, pEntry.ParameterName );
}
// copy value members
p.transposeMatrices = transposeMatrices;
p.autoAddParamName = autoAddParamName;
return p;
}
示例4: SetConstantMatrix4
public void SetConstantMatrix4()
{
float[] expected = new[] { (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(),
(float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(),
(float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(),
(float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom() };
float[] actual = new float[16];
GpuProgramParameters parameters = new GpuProgramParameters();
//var floatLogical = new GpuLogicalBufferStruct();
//parameters._setLogicalIndexes( floatLogical, new GpuLogicalBufferStruct() );
parameters.SetConstant( 0, new Matrix4( expected[ 0 ], expected[ 1 ], expected[ 2 ], expected[ 3 ],
expected[ 4 ], expected[ 5 ], expected[ 6 ], expected[ 7 ],
expected[ 8 ], expected[ 9 ], expected[ 10 ], expected[ 11 ],
expected[ 12 ], expected[ 13 ], expected[ 14 ], expected[ 15 ] ) );
GpuProgramParameters.FloatConstantEntry fcEntry;
for (int i = 0; i < 4; i++)
{
fcEntry = parameters.GetFloatConstant(i);
Assert.IsTrue(fcEntry.isSet);
fcEntry.val.CopyTo(actual, i * 4);
}
Assert.AreEqual( expected, actual );
}
示例5: UpdateCustomGpuParameter
/// <summary>
/// Update a custom GpuProgramParameters constant which is derived from
/// information only this Renderable knows.
/// </summary>
/// <remarks>
/// This method allows a Renderable to map in a custom GPU program parameter
/// based on it's own data. This is represented by a GPU auto parameter
/// of AutoConstantType.Custom, and to allow there to be more than one of these per
/// Renderable, the 'data' field on the auto parameter will identify
/// which parameter is being updated. The implementation of this method
/// must identify the parameter being updated, and call a 'SetConstant'
/// method on the passed in <see cref="GpuProgramParameters"/> object, using the details
/// provided in the incoming auto constant setting to identify the index
/// at which to set the parameter.
/// </remarks>
/// <param name="constantEntry">The auto constant entry referring to the parameter being updated.</param>
/// <param name="param">The parameters object which this method should call to set the updated parameters.</param>
public new void UpdateCustomGpuParameter( GpuProgramParameters.AutoConstantEntry constantEntry,
GpuProgramParameters param )
{
if ( constantEntry.Data == MORPH_CUSTOM_PARAM_ID )
{
// Update morph LOD factor
param.SetConstant( constantEntry.PhysicalIndex, this.mLODMorphFactor );
//_writeRawConstant(constantEntry.PhysicalIndex, mLODMorphFactor);
}
else
{
base.UpdateCustomGpuParameter( constantEntry, param );
}
}
示例6: _updateParameter
protected void _updateParameter( GpuProgramParameters programParameters, String paramName, Object value, int sizeInBytes )
{
programParameters.AutoAddParamName = true;
if ( value is Axiom.Math.Matrix4 )
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (Axiom.Math.Matrix4)value );
}
else if ( value is Axiom.Core.ColorEx )
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (Axiom.Core.ColorEx)value );
}
else if ( value is Axiom.Math.Vector3 )
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), ( (Axiom.Math.Vector3)value ) );
}
else if ( value is Axiom.Math.Vector4 )
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (Axiom.Math.Vector4)value );
}
else if ( value is float[] )
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (float[])value );
}
else if ( value is int[] )
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (int[])value );
}
else if ( value is float )
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), new float[] { (float)value, 0.0f, 0.0f, 0.0f } );
}
else
{
programParameters.SetConstant( programParameters.GetParamIndex( paramName ), (float[])value );
}
}
示例7: UpdateCustomGpuParameter
public void UpdateCustomGpuParameter(GpuProgramParameters.AutoConstantEntry entry, GpuProgramParameters gpuParams)
{
if( ( customParams != null ) && ( customParams[entry.data] != null ) ) {
gpuParams.SetConstant(entry.index, (Vector4)customParams[entry.data]);
}
}
示例8: TranslateProgramParameters
public static void TranslateProgramParameters( ScriptCompiler compiler, /*it should be GpuProgramParametersShared*/ GpuProgramParameters parameters, ObjectAbstractNode obj )
{
int animParametricsCount = 0;
foreach ( AbstractNode i in obj.Children )
{
if ( i is PropertyAbstractNode )
{
PropertyAbstractNode prop = (PropertyAbstractNode)i;
LogManager.Instance.Write("TranslateProgramParameters {0}", (Keywords)prop.Id);
switch ( (Keywords)prop.Id )
{
#region ID_SHARED_PARAMS_REF
case Keywords.ID_SHARED_PARAMS_REF:
{
if ( prop.Values.Count != 1 )
{
compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line,
"shared_params_ref requires a single parameter" );
continue;
}
AbstractNode i0 = getNodeAt( prop.Values, 0 );
if ( !( i0 is AtomAbstractNode ) )
{
compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line,
"shared parameter set name expected" );
continue;
}
AtomAbstractNode atom0 = (AtomAbstractNode)i0;
throw new NotImplementedException();
#if UNREACHABLE_CODE
try
{
//TODO
//parameters->addSharedParameters(atom0->value);
}
catch ( AxiomException e )
{
compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line, e.Message );
}
}
break;
#else
}
#endif
#endregion ID_SHARED_PARAMS_REF
#region ID_PARAM_INDEXED || ID_PARAM_NAMED
case Keywords.ID_PARAM_INDEXED:
case Keywords.ID_PARAM_NAMED:
{
if ( prop.Values.Count >= 3 )
{
bool named = ( prop.Id == (uint)Keywords.ID_PARAM_NAMED );
AbstractNode i0 = getNodeAt( prop.Values, 0 ), i1 = getNodeAt( prop.Values, 1 ),
k = getNodeAt( prop.Values, 2 );
if ( !(i0 is AtomAbstractNode) || !(i1 is AtomAbstractNode) )
{
compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line,
"name or index and parameter type expected" );
return;
}
AtomAbstractNode atom0 = (AtomAbstractNode)i0, atom1 = (AtomAbstractNode)i1;
if ( !named && !atom0.IsNumber )
{
compiler.AddError( CompileErrorCode.NumberExpected, prop.File, prop.Line,
"parameter index expected" );
return;
}
string name = string.Empty;
int index = 0;
// Assign the name/index
if ( named )
name = atom0.Value;
else
index = (int)atom0.Number;
// Determine the type
if ( atom1.Value == "matrix4x4" )
{
Matrix4 m;
if ( getMatrix4( prop.Values, 2, out m ) )
{
try
{
if ( named )
parameters.SetNamedConstant( name, m );
else
parameters.SetConstant( index, m );
}
catch
{
compiler.AddError( CompileErrorCode.InvalidParameters, prop.File, prop.Line,
"setting matrix4x4 parameter failed" );
//.........这里部分代码省略.........
示例9: UpdateCustomGpuParameter
public void UpdateCustomGpuParameter(GpuProgramParameters.AutoConstantEntry entry, GpuProgramParameters gpuParams)
{
if (entry.type == AutoConstants.AnimationParametric) {
// Set up to 4 values, or up to limit of hardware animation entries
// Pack into 4-element constants offset based on constant data index
// If there are more than 4 entries, this will be called more than once
Vector4 val = Vector4.Zero;
int animIndex = entry.data * 4;
for (int i = 0; i < 4 &&
animIndex < hardwareVertexAnimVertexData.HWAnimationDataList.Count;
++i, ++animIndex) {
val[i] = hardwareVertexAnimVertexData.HWAnimationDataList[animIndex].Parametric;
}
// set the parametric morph value
gpuParams.SetConstant(entry.index, val);
}
else if (customParams[entry.data] != null) {
gpuParams.SetConstant(entry.index, (Vector4)customParams[entry.data]);
}
}
示例10: _updateParameter
protected void _updateParameter( GpuProgramParameters programParameters, String paramName, Object value,
int sizeInBytes )
{
//programParameters.AutoAddParamName = true;
var idx = programParameters.FindNamedConstantDefinition( paramName ).LogicalIndex;
if ( value is Matrix4 )
{
programParameters.SetConstant( idx, (Matrix4)value );
}
else if ( value is ColorEx )
{
programParameters.SetConstant( idx, (ColorEx)value );
}
else if ( value is Vector3 )
{
programParameters.SetConstant( idx, ( (Vector3)value ) );
}
else if ( value is Vector4 )
{
programParameters.SetConstant( idx, (Vector4)value );
}
else if ( value is float[] )
{
programParameters.SetConstant( idx, (float[])value );
}
else if ( value is int[] )
{
programParameters.SetConstant( idx, (int[])value );
}
else if ( value is float )
{
programParameters.SetConstant( idx, new[]
{
(float)value, 0.0f, 0.0f, 0.0f
} );
}
else
{
programParameters.SetConstant( idx, (float[])value );
}
}
示例11: Clone
public GpuProgramParameters Clone()
{
GpuProgramParameters p = new GpuProgramParameters();
// copy int constants
for ( int i = 0; i < intConstants.Count; i++ )
{
IntConstantEntry e = intConstants[i];
if ( e.isSet )
{
p.SetConstant(i, e.val);
}
}
// copy float constants
p.floatConstantsArray = new float[floatConstantsArray.Length];
Array.Copy(floatConstantsArray, p.floatConstantsArray, floatConstantsArray.Length);
p.floatIsSet = new bool[floatIsSet.Length];
Array.Copy(floatIsSet, p.floatIsSet, floatIsSet.Length);
p.float4VecConstantsCount = float4VecConstantsCount;
p.maxSetCount = maxSetCount;
// copy auto constants
for(int i = 0; i < autoConstantList.Count; i++)
{
AutoConstantEntry entry = autoConstantList[i];
p.SetAutoConstant(entry.Clone());
}
// copy named params
foreach ( DictionaryEntry e in namedParams )
{
p.MapParamNameToIndex(e.Key as string, (int)e.Value);
}
for ( int i = 0; i < paramTypeList.Count; i++ )
{
}
foreach ( ParameterEntry pEntry in paramTypeList )
{
p.AddParameterToDefaultsList(pEntry.ParameterType, pEntry.ParameterName);
}
// copy value members
p.transposeMatrices = transposeMatrices;
p.autoAddParamName = autoAddParamName;
return p;
}