public Player(Game game, CarActor carActor, KeyConfig keyboardConfiguration, CameraController cameraController) : base(game) { this.carActor = carActor; this.keyConfig = keyboardConfiguration; this.cameraController = cameraController; }
public CameraController(Game game, CarActor carActor) : base(game) { this.carActor_ = carActor; cameraState_ = new LinkedList<CameraState>(); listener_ = new AudioListener(); SetupCamera(); }
public override void DrawCar(CarActor owner) { // draw the wheels for (int i = 0; i < 2; i++) DrawWheel(owner.Wheels[i], wheelModelLeft, wheelModelTransformsLeft); for (int i = 2; i < 4; i++) DrawWheel(owner.Wheels[i], wheelModelRight, wheelModelTransformsRight); // draw the car itself. foreach (ModelMesh mesh in carModel_.Meshes) { DrawModelMesh(mesh, carModelTransforms_[mesh.ParentBone.Index] * owner.WorldTransform, true); } }
public ParticleController(Game game, CarActor carActor) : base(game) { this.carActor = carActor; particleSystems = new List<ParticleSystem>(); particleSystems.Add(new ParticleSystem(game, game.Content, "Particles/FireSettings")); particleSystems.Add(new ParticleSystem(game, game.Content, "Particles/ProjectileTrailSettings")); fireEmitter = new ParticleEmitter(particleSystems[0], 10f, Vector3.Zero); smokeEmitter = new ParticleEmitter(particleSystems[1], 50f, Vector3.Zero); }
public HUD(Game game, CarActor car, int xEdge, int yEdge) : base(game) { spriteFont = Game.Content.Load<SpriteFont>("GameplayFont"); counter = 0; lapCount = 0; lapPosX = 0; lapPosZ = 0; oldLapPosX = 0; oldLapPosZ = 0; content = game.Content; this.xEdge = xEdge; this.yEdge = yEdge; carActor = car; }
public virtual void Update(CarActor carActor) { // This method can be over-ridden in other classes, i.e. to keep an offset from the target for a chase camera. // This simple camera is fixed in place (but turns to track the target). // Perhaps this method should be made abstract? Vector3 carPos = carActor.WorldTransform.Translation; this.target_ = carPos; //this.target_ = Vector3.Lerp(target_, carPos, lerpFactor_); viewNeedsUpdate_ = true; // lazy eval >> don't actually update the view matrix until needed. //get behind the target: Vector3 rightOri = carActor.WorldTransform.Forward; // TODO: POSSIBLE ERROR SOURCE Vector3 vel = carActor.LinearVelocity + Vector3.UnitY * 3f; currentFov_ = Lerp(currentFov_, fov_ + (vel.Length() / (CarActor.ForwardSpeed * 2f)), 0.1f); switch (cameraState_) { case CameraState.Chase: position_ = Vector3.Lerp(position_, carPos - (rightOri * offset_ * vel.Length() / 14) - (rightOri * offset_ * 3) + (Vector3.UnitY * offset_), lerpFactor_); //this.currentFov_ = Math.Min(car.Body.Velocity.LengthSquared() / 1000 + this.fov_, MathHelper.Pi - 0.1f); //this.projectionNeedsUpdate_ = true; break; case CameraState.Reverse: position_ = Vector3.Lerp(position_, carPos + (rightOri * offset_ * vel.Length() / 7) + (rightOri * offset_ * 7) + (Vector3.UnitY * offset_), lerpFactor_); break; case CameraState.Dynamic: Vector3 velocity = vel; velocity.Normalize(); velocity.Y = 0; position_ = Vector3.Lerp(position_, carPos - (velocity * offset_ * vel.Length() / 16) - (velocity * offset_ * 4) + (Vector3.UnitY * offset_), lerpFactor_); break; case CameraState.TopDown: position_ = Vector3.Lerp(position_, new Vector3(0f, 200f, 30f), lerpFactor_); break; case CameraState.Count: throw new Exception("Logic error; Camera state set to count"); } this.viewNeedsUpdate_ = true; this.projectionNeedsUpdate_ = true; }
public abstract void DrawCar(CarActor owner);