当前位置: 首页>>代码示例>>C#>>正文


C# Effect.SetDirection方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:33,代码来源:DirectInputWrapper.cs

示例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;
        }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:42,代码来源:DirectInputWrapper.cs

示例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){}
        }
开发者ID:hcaltenco,项目名称:SID-Source,代码行数:21,代码来源:frmMain.cs

示例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;
        }
开发者ID:hcaltenco,项目名称:SID-Source,代码行数:23,代码来源:frmMain.cs

示例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;
        }
开发者ID:parhansson,项目名称:KMotionX,代码行数:101,代码来源:ForceFeedbackJoystick.cs


注:本文中的Effect.SetDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。