/// <summary> /// Obtiene la direccion a moverse por la camara en base a la entrada de teclado /// </summary> private Vector3 getMovementDirection(TgcD3dInput d3dInput) { Vector3 direction = new Vector3(0.0f, 0.0f, 0.0f); //Forward if (d3dInput.keyDown(Key.W)) { if (!moveForwardsPressed) { moveForwardsPressed = true; currentVelocity = new Vector3(currentVelocity.X, currentVelocity.Y, 0.0f); } direction.Z += 1.0f; } else { moveForwardsPressed = false; } //Backward if (d3dInput.keyDown(Key.S)) { if (!moveBackwardsPressed) { moveBackwardsPressed = true; currentVelocity = new Vector3(currentVelocity.X, currentVelocity.Y, 0.0f); } direction.Z -= 1.0f; } else { moveBackwardsPressed = false; } //Strafe right if (d3dInput.keyDown(Key.D)) { if (!moveRightPressed) { moveRightPressed = true; currentVelocity = new Vector3(0.0f, currentVelocity.Y, currentVelocity.Z); } direction.X += 1.0f; } else { moveRightPressed = false; } //Strafe left if (d3dInput.keyDown(Key.A)) { if (!moveLeftPressed) { moveLeftPressed = true; currentVelocity = new Vector3(0.0f, currentVelocity.Y, currentVelocity.Z); } direction.X -= 1.0f; } else { moveLeftPressed = false; } //Jump if (d3dInput.keyDown(Key.Space)) { if (!moveUpPressed) { moveUpPressed = true; currentVelocity = new Vector3(currentVelocity.X, 0.0f, currentVelocity.Z); } direction.Y += 1.0f; } else { moveUpPressed = false; } //Crouch if (d3dInput.keyDown(Key.LeftControl)) { if (!moveDownPressed) { moveDownPressed = true; currentVelocity = new Vector3(currentVelocity.X, 0.0f, currentVelocity.Z); } direction.Y -= 1.0f; } else { moveDownPressed = false; } return direction; }
/// <summary> /// Obtiene la direccion a moverse por la camara en base a la entrada de teclado /// </summary> private Vector3 getMovementDirection(TgcD3dInput d3dInput) { Vector3 direction = new Vector3(0.0f, 0.0f, 0.0f); //Forward if (d3dInput.keyDown(Key.W)) { if (!moveForwardsPressed) { moveForwardsPressed = true; currentVelocity = new Vector3(currentVelocity.X, currentVelocity.Y, 0.0f); } direction.Z += 1.0f; } else { moveForwardsPressed = false; } //Backward if (d3dInput.keyDown(Key.S)) { if (!moveBackwardsPressed) { moveBackwardsPressed = true; currentVelocity = new Vector3(currentVelocity.X, currentVelocity.Y, 0.0f); } direction.Z -= 1.0f; } else { moveBackwardsPressed = false; } //Strafe right if (d3dInput.keyDown(Key.D)) { if (!moveRightPressed) { moveRightPressed = true; currentVelocity = new Vector3(0.0f, currentVelocity.Y, currentVelocity.Z); } direction.X += 1.0f; } else { moveRightPressed = false; } //Strafe left if (d3dInput.keyDown(Key.A)) { if (!moveLeftPressed) { moveLeftPressed = true; currentVelocity = new Vector3(0.0f, currentVelocity.Y, currentVelocity.Z); } direction.X -= 1.0f; } else { moveLeftPressed = false; } //Jump if (d3dInput.keyDown(Key.Space)) { if (!moveUpPressed) { moveUpPressed = true; currentVelocity = new Vector3(currentVelocity.X, 0.0f, currentVelocity.Z); } direction.Y += 1.0f; } else { moveUpPressed = false; } //Crouch if (d3dInput.keyDown(Key.LeftControl)) { if (!moveDownPressed) { moveDownPressed = true; currentVelocity = new Vector3(currentVelocity.X, 0.0f, currentVelocity.Z); } direction.Y -= 1.0f; } else { moveDownPressed = false; } return(direction); }