本文整理汇总了C#中Effect.SetDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.SetDirection方法的具体用法?C# Effect.SetDirection怎么用?C# Effect.SetDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Effect
的用法示例。
在下文中一共展示了Effect.SetDirection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Stretch
public static void Stretch(double[] F)
{
//Console.WriteLine("Stretch");
EffectObject eo = null;
//EffectInformation ei;
Effect e;
int[] axis = new int[1];
int[] direction = new int[axis.Length];
foreach (EffectInformation ei in devices[0].GetEffects(EffectType.All))
{
//Console.WriteLine(DInputHelper.GetTypeCode(ei.EffectType));
if (DInputHelper.GetTypeCode(ei.EffectType) == (int) EffectType.ConstantForce)
{
e = new Effect();
e.SetDirection(direction);
e.SetAxes(new int[1]);
e.EffectType = EffectType.ConstantForce;
e.Duration = 200000; //1000000=1s
e.Gain = 10000;
e.Constant = new ConstantForce();
e.Constant.Magnitude = (int) -F[0];
e.SamplePeriod = 0;
e.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger;
e.TriggerRepeatInterval = (int)DI.Infinite;
e.Flags = EffectFlags.ObjectOffsets | EffectFlags.Spherical;
e.UsesEnvelope = false;
eo = new EffectObject(ei.EffectGuid, e, devices[0]);
eo.Start(1);
}
}
}
示例2: InitializeForce
public static EffectObject InitializeForce( Device Dev, EffectType Type,
int[] Axis, int Magnitude, EffectFlags Flags, int Duration)
{
EffectObject eo = null;
Effect e;
foreach ( EffectInformation ei in Dev.GetEffects( EffectType.All ) )
{
if ( DInputHelper.GetTypeCode( ei.EffectType ) == (int)Type )
{
e = new Effect();
e.SetDirection( new int[Axis.Length] );
e.SetAxes( new int[1] ); //this is the offending line in the Microsoft examples
//setting axes to 2 causes the dreaded "Value does not fall within expected range" error
//this is evidently a bug in Managed DirectX, at least affecting some game pads,
//and this is the only workaround I've found.
//I have not been able to successfully load FFE files in Managed DirectX
//due to this same problem (presumably, in the inner initialization code
//when loading from FFE, it is trying to load two axes there, as well).
//This problem exists with all verys of Managed DirectX, as far as I can tell,
//at least up through March 2008 when this example was written.
e.EffectType = Type;
e.ConditionStruct = new Condition[Axis.Length];
e.Duration = Duration;
e.Gain = 10000;
e.Constant = new ConstantForce();
e.Constant.Magnitude = Magnitude;
e.SamplePeriod = 0;
e.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger;
e.TriggerRepeatInterval = (int)DI.Infinite;
e.Flags = Flags;
e.UsesEnvelope = false;
// Create the effect, using the passed in guid.
eo = new EffectObject( ei.EffectGuid, e, Dev );
}
}
return eo;
}
示例3: ChangeDirection
/// <summary>
/// Changes the direction of an effect.
/// </summary>
private void ChangeDirection(int[] direction)
{
Effect eff = new Effect();
eff.Flags = EffectFlags.Cartesian | EffectFlags.ObjectOffsets;
effectSelected.GetParameters(ref eff, EffectParameterFlags.AllParams);
eff.SetDirection(direction);
// Some feedback drivers will fail when setting parameters that aren't supported by
// an effect. DirectInput will will in turn pass back the driver error to the application.
// Since these are hardware specific error messages that can't be handled individually,
// the app will ignore any failures returned to SetParameters().
try
{
effectSelected.SetParameters(eff, EffectParameterFlags.Direction | EffectParameterFlags.Start);
}
catch(InputException){}
}
示例4: FillEffStruct
/// <summary>
/// Fills in generic values in an effect struct.
/// </summary>
private Effect FillEffStruct(EffectType eif)
{
Effect eff = new Effect();
// Allocate some memory for directions and axis.
eff.SetDirection(new int[axis.Length]);
eff.SetAxes(new int[axis.Length]);
eff.EffectType = eif;
eff.ConditionStruct = new Condition[axis.Length];
eff.Duration = (int)DI.Infinite;
eff.Gain = 10000;
eff.SamplePeriod = 0;
eff.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger;
eff.TriggerRepeatInterval = (int)DI.Infinite;
eff.Flags = EffectFlags.ObjectOffsets | EffectFlags.Cartesian;
eff.SetAxes(axis);
return eff;
}
示例5: Connect
//.........这里部分代码省略.........
device.Properties.AutoCenter = false;
}
//Set axis mode absolute.
device.Properties.AxisModeAbsolute = true;
//Acquire joystick for capturing.
device.Acquire();
//Configure axes
int[] axis = null;
foreach (DeviceObjectInstance doi in device.Objects)
{
//Set axes ranges.
if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
{
device.Properties.SetRange(
ParameterHow.ById,
doi.ObjectId,
new InputRange(-5000, 5000));
}
int[] temp;
// Get info about first two FF axii on the device
if ((doi.Flags & (int)ObjectInstanceFlags.Actuator) != 0)
{
if (axis != null)
{
temp = new int[axis.Length + 1];
axis.CopyTo(temp, 0);
axis = temp;
}
else
{
axis = new int[1];
}
// Store the offset of each axis.
axis[axis.Length - 1] = doi.Offset;
if (axis.Length == 2)
{
break;
}
}
}
//See if joystick supports ConstantForce and set it.
foreach (EffectInformation ei in device.GetEffects(EffectType.All))
{
//If the joystick supports ConstantForce, then apply it.
if (DInputHelper.GetTypeCode(ei.EffectType)
== (int)EffectType.ConstantForce)
{
// Fill in some generic values for the effect.
e = new Effect();
e.SetDirection(new int[axis.Length]);
e.SetAxes(new int[axis.Length]);
e.ConditionStruct = new Condition[axis.Length];
e.EffectType = EffectType.ConstantForce;
e.Constant = new ConstantForce();
e.Constant.Magnitude = 10000;
e.Duration = (int)DI.Infinite;
e.Gain = 10000;
e.SamplePeriod = 0;
e.TriggerButton = (int)Microsoft.DirectX.DirectInput.Button.NoTrigger;
e.TriggerRepeatInterval = (int)DI.Infinite;
e.Flags = EffectFlags.ObjectOffsets | EffectFlags.Cartesian;
e.SetAxes(axis);
var dd = e.GetDirection();
dd[0] = -100;
dd[1] = 100;
e.SetDirection(dd);
// Create the effect, using the passed in guid.
eo = new EffectObject(ei.EffectGuid, e, device);
eo.Start(1, EffectStartFlags.NoDownload);
force_ei = ei;
break;
}
}
if (eo == null)
{
return JOYSTICK_TYPE.NO_FORCE_FEEDBACK;
}
return JOYSTICK_TYPE.FORCE_FEEDBACK;
}