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


C# InputState.IsKeyUp方法代码示例

本文整理汇总了C#中InputState.IsKeyUp方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsKeyUp方法的具体用法?C# InputState.IsKeyUp怎么用?C# InputState.IsKeyUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InputState的用法示例。


在下文中一共展示了InputState.IsKeyUp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleInput

        public void HandleInput(InputState input)
        {
            // -- Select Gizmo Mode -- //
            if (input.WasKeyPressed(Keys.D1))
            {
                ActiveMode = GizmoMode.Translate;
            }
            else if (input.WasKeyPressed(Keys.D2))
            {
                ActiveMode = GizmoMode.Rotate;
            }
            else if (input.WasKeyPressed(Keys.D3))
            {
                ActiveMode = GizmoMode.NonUniformScale;
            }
            else if (input.WasKeyPressed(Keys.D4))
            {
                ActiveMode = GizmoMode.UniformScale;
            }

            // -- Cycle TransformationSpaces -- //
            if (input.WasKeyPressed(Keys.Space))
            {
                if (ActiveSpace == TransformSpace.Local)
                    ActiveSpace = TransformSpace.World;
                else
                    ActiveSpace = TransformSpace.Local;
            }

            // -- Cycle PivotTypes -- //
            if (input.WasKeyPressed(Keys.P))
            {
                if (ActivePivot == PivotType.WorldOrigin)
                    ActivePivot = PivotType.ObjectCenter;
                else
                    ActivePivot++;
            }

            // -- Toggle PrecisionMode -- //
            if (input.IsKeyDown(Keys.LeftShift))
            {
                precisionMode = true;
            }
            else
                precisionMode = false;

            // -- Toggle Snapping -- //
            if (input.WasKeyPressed(Keys.C))
            {
                SnapEnabled = !SnapEnabled;
            }
            if (input.Mouse.WasButtonPressed(Framework.MouseButtons.Left) && ActiveAxis == GizmoAxis.None)
            {
                // add to selection or clear current selection
                if (input.IsKeyUp(addToSelection) && input.IsKeyUp(removeFromSelection) || input.IsKeyDown(Keys.LeftAlt))
                {
                    Selection.Clear();
                }

                PickObject(input.Mouse.Position, input.IsKeyDown(removeFromSelection));
            }
            else if (input.WasKeyPressed(Keys.R))
            {
                Selection.Clear();
            }

            if (Enabled)
            {
                if (input.Mouse.WasButtonPressed(Framework.MouseButtons.Left))
                {
                    // reset for intersection (plane vs. ray)
                    intersectPosition = Vector3.Zero;
                    // reset for snapping
                    translationScaleSnapDelta = Vector3.Zero;
                    rotationSnapDelta = 0;
                }

                lastIntersectionPosition = intersectPosition;

                if (input.Mouse.WasButtonHeld(Framework.MouseButtons.Left) && ActiveAxis != GizmoAxis.None)
                {
                    if (ActiveMode == GizmoMode.Translate || ActiveMode == GizmoMode.NonUniformScale || ActiveMode == GizmoMode.UniformScale)
                    {
                        #region Translate & Scale
                        Vector3 delta = Vector3.Zero;
                        Ray ray = Engine.ray;

                        Matrix transform = Matrix.Invert(rotationMatrix);
                        ray.Position = Vector3.Transform(ray.Position, transform);
                        ray.Direction = Vector3.TransformNormal(ray.Direction, transform);

                        if (ActiveAxis == GizmoAxis.X || ActiveAxis == GizmoAxis.XY)
                        {
                            Plane plane = new Plane(Vector3.Forward, Vector3.Transform(position,
                                Matrix.Invert(rotationMatrix)).Z);

                            float? intersection = ray.Intersects(plane);
                            if (intersection.HasValue)
                            {
                                intersectPosition = (ray.Position + (ray.Direction *
//.........这里部分代码省略.........
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:101,代码来源:GizmoComponent.cs


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