本文整理汇总了C#中InputState.IsKeyDown方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsKeyDown方法的具体用法?C# InputState.IsKeyDown怎么用?C# InputState.IsKeyDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState.IsKeyDown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveBonesWithMouse
private void MoveBonesWithMouse(InputState input)
{
float rotationFB = input.Mouse.Delta.Y / 120;
float rotationLR = input.Mouse.Delta.X / 120;
switch (selectedSkinnedSphere.boundingSphereName)
{
case "Character1_LeftUpLeg":
{
#region Mouse
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt))
{
Matrix transfrom = Matrix.CreateRotationX(rotationFB);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl))
{
Matrix transfrom = Matrix.CreateRotationY(rotationLR);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift))
{
Matrix transfrom = Matrix.CreateRotationZ(rotationLR);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
#endregion
break;
}
case "Character1_LeftLeg":
{
#region Mouse
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt))
{
Matrix transfrom = Matrix.CreateRotationX(rotationFB);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl))
{
Matrix transfrom = Matrix.CreateRotationY(rotationLR);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift))
{
Matrix transfrom = Matrix.CreateRotationZ(rotationLR);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
#endregion
break;
}
case "Character1_LeftFoot":
{
#region Mouse
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt))
{
Matrix transfrom = Matrix.CreateRotationX(rotationFB);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl))
{
Matrix transfrom = Matrix.CreateRotationY(rotationLR);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift))
{
Matrix transfrom = Matrix.CreateRotationZ(rotationLR);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
#endregion
break;
}
case "Character1_RightUpLeg":
{
#region Mouse
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt))
{
Matrix transfrom = Matrix.CreateRotationX(rotationFB);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl))
{
Matrix transfrom = Matrix.CreateRotationY(rotationLR);
UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)] =
transfrom * UpdatedPlayer.boneTransforms[getSkinningBoneIndex(selectedSkinnedSphere.boundingSphereName)];
}
//.........这里部分代码省略.........
示例2: 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 *
//.........这里部分代码省略.........