void shaderControlSlider_SliderMoved( object sender, Slider slider )
{
int sliderIndex = -1;
for ( int i = 0; i < ControlsPerPage; i++ )
{
if ( shaderControls[ i ] == slider )
{
sliderIndex = i;
break;
}
}
Utilities.Contract.Requires( sliderIndex != -1 );
int index = currentPage * ControlsPerPage + sliderIndex;
ShaderControl activeShaderDef = materialControlsContainer[ currentMaterial ].GetShaderControl( index );
float val = slider.Value;
if ( activePass != null )
{
switch ( activeShaderDef.Type )
{
case ShaderType.GpuVertex:
case ShaderType.GpuFragment:
{
GpuProgramParameters activeParameters =
( activeShaderDef.Type == ShaderType.GpuVertex ) ?
activeVertexParameters : activeFragmentParameters;
if ( activeParameters != null )
{
int idx = activeParameters.GetParamIndex( activeShaderDef.ParamName );
activeShaderDef.PhysicalIndex = idx;
GpuProgramParameters.FloatConstantEntry entry;
entry = activeParameters.GetNamedFloatConstant( activeShaderDef.ParamName );
entry.val[ activeShaderDef.ElementIndex ] = val;
activeParameters.SetConstant( activeShaderDef.PhysicalIndex, entry.val );
}
}
break;
case ShaderType.MatSpecular:
{
//// get the specular values from the material pass
ColorEx oldSpec = activePass.Specular;
switch ( activeShaderDef.ElementIndex )
{
case 0:
oldSpec.r = val;
break;
case 1:
oldSpec.g = val;
break;
case 2:
oldSpec.b = val;
break;
case 3:
oldSpec.a = val;
break;
}
activePass.Specular = oldSpec;
}
break;
case ShaderType.MatDiffuse:
{
//// get the specular values from the material pass
ColorEx oldSpec = activePass.Diffuse;
switch ( activeShaderDef.ElementIndex )
{
case 0:
oldSpec.r = val;
break;
case 1:
oldSpec.g = val;
break;
case 2:
oldSpec.b = val;
break;
case 3:
oldSpec.a = val;
break;
}
activePass.Diffuse = oldSpec;
}
break;
case ShaderType.MatAmbient:
{
//// get the specular values from the material pass
ColorEx oldSpec = activePass.Ambient;
switch ( activeShaderDef.ElementIndex )
{
case 0:
oldSpec.r = val;
break;
case 1:
oldSpec.g = val;
break;
case 2:
oldSpec.b = val;
break;
case 3:
oldSpec.a = val;
break;
}
activePass.Ambient = oldSpec;
}
break;
case ShaderType.MatShininess:
{
//// get the specular values from the material pass
activePass.Shininess = val;
}
break;
}
}
}
/// <summary>