ConditionForceEffect.SetParameters 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置条件力回馈效果的参数。
public:
virtual void SetParameters(float3 direction, float positiveCoefficient, float negativeCoefficient, float maxPositiveMagnitude, float maxNegativeMagnitude, float deadZone, float bias) = SetParameters;
void SetParameters(float3 const& direction, float const& positiveCoefficient, float const& negativeCoefficient, float const& maxPositiveMagnitude, float const& maxNegativeMagnitude, float const& deadZone, float const& bias);
public void SetParameters(Vector3 direction, float positiveCoefficient, float negativeCoefficient, float maxPositiveMagnitude, float maxNegativeMagnitude, float deadZone, float bias);
function setParameters(direction, positiveCoefficient, negativeCoefficient, maxPositiveMagnitude, maxNegativeMagnitude, deadZone, bias)
Public Sub SetParameters (direction As Vector3, positiveCoefficient As Single, negativeCoefficient As Single, maxPositiveMagnitude As Single, maxNegativeMagnitude As Single, deadZone As Single, bias As Single)
参数
- positiveCoefficient
-
Single
float
线条的斜率,描述当输入沿指定轴沿正方向离开中心点时力增加的速度。 范围从 -infinity 到 +infinity。
- negativeCoefficient
-
Single
float
线条的斜率,描述当输入沿指定轴沿负方向从中心点移开时力增加的速度。 范围从 -infinity 到 +infinity。
- maxPositiveMagnitude
-
Single
float
当输入沿指定轴沿正方向偏离中心点时,力回馈的最大幅度。 范围为 0 到 1.0。
- maxNegativeMagnitude
-
Single
float
当输入沿指定轴沿负方向偏离中心点时,力回馈的最大幅度。 范围为 0 到 1.0。
- deadZone
-
Single
float
指定以下不应用力回馈的值。 范围从 0.0 到 1.0,不对称地围绕中心点应用。
- bias
-
Single
float
在效果计算中与中心点的偏移量。 范围为 -1.0 到 1.0。
示例
// Create a spring effect and load it into the device. This is an async operation
// since it might take a brief amount of time for the driver to complete this.
ConditionForceEffect ^ springEffect = ref new ConditionForceEffect(ConditionEffectKind::Spring);
if (springEffect)
{
IAsyncAction ^ action = motor->LoadEffectAsync(springEffect);
concurrency::create_task(action).then([=]()
{
// Make sure the effect was loaded successfully. There is a finite amount
// of storage available for effects in the hardware, so this is expected
// to fail if there is not enough room. Alternatively, the motor might
// not support the requested effect (although this is rare).
if (action->Status == AsyncStatus::Completed)
{
// Set the parameters for the spring effect. Note how the parameters
// can be modified after the effect has been loaded into the hardware.
springEffect->SetParameters(
{ 1.0f, 0.0f, 0.0f }, // Unit vector indicating the effect applies to the X axis
1.0f, -1.0f, // Full strength when the wheel is turned to its maximum angle
0.3f, -0.3f, // Limit the maximum feedback force to 30%
0.025f, // Apply a small dead zone when the wheel is centered
0.0f); // Equal force in both directions
// Go ahead and start the effect, since we want this running all the time
springEffect->StartEffect();
}
});
}
注解
下图演示了参数对 SetParameters 的影响:
![参数对力的影响。](windows.gaming.input.forcefeedback/images/conditionalforceeffect_parameters.png?view=winrt-20348)