Platform SDK: DirectX |
You can modify the parameters of an effect, in some cases even while the effect is playing. You do this by using the IDirectInputEffect::SetParameters method.
The dwDynamicParams member of the DIEFFECTINFO structure tells you which effect parameters can be changed while an effect is playing. If you attempt to modify an effect parameter that cannot be modified while the effect is playing and the effect is still playing, DirectInput normally stops the effect, updates the parameters, and restarts the effect. You can override this default behavior by passing the DIEP_NORESTART flag.
The following code example changes the magnitude of the constant force that was set in the example under Creating an Effect.
DIEFFECT diEffect; // Parameters for effect DICONSTANTFORCE diConstantForce; // type-specific parameters. diConstantForce.lMagnitude = 5000; diEffect.dwSize = sizeof(DIEFFECT); diEffect.cbTypeSpecificParams = sizeof(DICONSTANTFORCE); diEffect.lpvTypeSpecificParams = &diConstantForce; hr = lpdiEffect->SetParameters(&diEffect, DIEP_TYPESPECIFICPARAMS);
The flag ensures that the transfer of data from the DIEFFECT structure is restricted to the relevant members so that you do not have to initialize the entire structure and so that the minimum possible amount of data needs to be sent to the device.
You can modify the parameters of an effect, in some cases even while the effect is playing. You do this by using the DirectInputEffect.SetParameters method.
To find out which effect parameters can be changed while an effect is playing, call the DirectInputEnumEffects.GetDynamicParams method.
If you attempt to modify an effect parameter that cannot be modified while the effect is playing and the effect is still playing, DirectInput normally stops the effect, updates the parameters, and restarts the effect. You can override this default behavior by passing the DIEP_NORESTART flag to SetParameters.
The following code example changes the magnitude of a constant force represented by the DirectInputEffect object dieff, which was created using the global DIEFFECT type effectinfo:
effectinfo.constantForce.lMagnitude = 5000 Call dieff.SetParameters(effectinfo, DIEP_TYPESPECIFICPARAMS)
You must set the DIEP_TYPESPECIFICPARAMS flag if you are changing the condition, constantforce, periodicforce, or rampforce members of DIEFFECT.