Auto en unity
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
usingMicrosoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
usingMicrosoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace _3DGame
{
///
/// This is a game component that implements IUpdateable.
///
public class Camera :Microsoft.Xna.Framework.GameComponent
{
//Camera Matrices
public Matrix view { get; protected set; }
public Matrix projection {get; protected set;}
publicVector3 cameraPosition { get; protected set; }
Vector3 cameraDirection;
Vector3 cameraUp;
float speed = 3;
#if(!XBOX360)
//Mouse support
MouseStateprevMouseState;
#endif
//max yaw/pitch variables
float totalYaw = MathHelper.PiOver4 / 2;
float currentYaw = 0;
float totalPitch = MathHelper.PiOver4 / 2;
floatcurrentPitch = 0;
private void CreateLookAt()
{
view = Matrix.CreateLookAt(cameraPosition, cameraPosition + cameraDirection, cameraUp);
}public Camera(Game game, Vector3 pos, Vector3 target, Vector3 up)
: base(game)
{
// TODO: Construct any child components here
//view =Matrix.CreateLookAt(pos, target, up);
//Build camera view matrix
cameraPosition = pos;
cameraDirection = target - pos;
cameraDirection.Normalize();cameraUp = up;
CreateLookAt();
projection = Matrix.CreatePerspectiveFieldOfView(
MathHelper.PiOver4,
(float)game.Window.ClientBounds.Width /...
Regístrate para leer el documento completo.