private void InitializeModels() { Texture2D texture = null; //MoveableModelObject playerActor = null; Transform3D transform = null; Model model = null; ModelObject modelObject = null; CollidableObject collidableObj = null; PawnCollidableObject collObj = null; ZoneObject zoneObj = null; CameraZoneObject camObj = null; #region Player Model model = this.modelDictionary["player"]; transform = new Transform3D(new Vector3(-100, 10, 0), new Vector3(-90, 0, 0), 0.15f * Vector3.One, Vector3.UnitX, Vector3.UnitY); this.playerActor = new PlayerObject("player", ObjectType.Player, transform, this.animatedModelEffect, null, model, Color.White, 1f, KeyData.Player_Keys, 3.75f, 11.5f, 1f, 1f, new Vector3(0, 0, 0)); this.playerActor.Enable(false, 100); this.objectManager.Add(this.playerActor); #endregion #region ExitDoor Model model = this.modelDictionary["door"]; transform = new Transform3D(new Vector3(140, 0, 0), Vector3.Zero, 1f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); this.doorActor = new PawnCollidableObject("door", ObjectType.Door, transform, this.texturedModelEffect, null, model, Color.White, 1f); Vector3 scales = new Vector3(12, 250, 25); this.doorActor.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), new MaterialProperties()); this.doorActor.Enable(true, 2000); this.objectManager.Add(this.doorActor); #endregion #region EntranceDoor Model model = this.modelDictionary["door"]; transform = new Transform3D(new Vector3(-300, 0, 0), Vector3.Zero, 1f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); collObj = new PawnCollidableObject("door", ObjectType.Entrance, transform, this.texturedModelEffect, null, model, Color.White, 1f); collObj.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), new MaterialProperties()); collObj.Enable(true, 2000); this.objectManager.Add(collObj); #endregion texture = Content.Load<Texture2D>("Assets\\Textures\\Game\\white"); #region Room Model model = this.modelDictionary["room"]; transform = new Transform3D(new Vector3(0, 0, 0), new Vector3(0,180,0), 1f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); MaterialProperties material = new MaterialProperties(1f, 0.1f, 0.05f); collidableObj = new CollidableObject("room", ObjectType.Room, transform, this.texturedModelEffect, null, model, Color.White, 1); //floor scales = new Vector3(300, 1, 300); collidableObj.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), material); collidableObj.Enable(true, 2000); this.objectManager.Add(collidableObj); scales = new Vector3(10, 100, 300); transform = new Transform3D(new Vector3(152, 0, 0), Vector3.Zero, scales, -Vector3.UnitZ, Vector3.UnitY); zoneObj = new ZoneObject("roomwallback", ObjectType.Room, transform, this.primitiveEffect, Color.Red, 1, true); zoneObj.AddPrimitive(new Box(transform.Translation, Matrix.Identity, transform.Scale)); zoneObj.Enable(); this.objectManager.Add(zoneObj); transform = new Transform3D(new Vector3(-152, 0, 0), Vector3.Zero, scales, -Vector3.UnitZ, Vector3.UnitY); zoneObj = new ZoneObject("roomwallfront", ObjectType.Room, transform, this.primitiveEffect, Color.Red, 1, true); zoneObj.AddPrimitive(new Box(transform.Translation, Matrix.Identity, transform.Scale)); zoneObj.Enable(); this.objectManager.Add(zoneObj); scales = new Vector3(300, 100, 5); transform = new Transform3D(new Vector3(0, 0, 130), Vector3.Zero, scales, -Vector3.UnitZ, Vector3.UnitY); zoneObj = new ZoneObject("roomwallright", ObjectType.Room, transform, this.primitiveEffect, Color.Red, 1, true); zoneObj.AddPrimitive(new Box(transform.Translation, Matrix.Identity, transform.Scale)); zoneObj.Enable(); this.objectManager.Add(zoneObj); transform = new Transform3D(new Vector3(0, 0, -130), Vector3.Zero, scales, -Vector3.UnitZ, Vector3.UnitY); zoneObj = new ZoneObject("roomwallleft", ObjectType.Room, transform, this.primitiveEffect, Color.Red, 1, true); zoneObj.AddPrimitive(new Box(transform.Translation, Matrix.Identity, transform.Scale)); zoneObj.Enable(); this.objectManager.Add(zoneObj); #endregion #region Rotationthingy Model model = this.modelDictionary["rotation"]; transform = new Transform3D(new Vector3(0, -57, 0), Vector3.Zero, 0.6f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); this.rotator = new PawnCollidableObject("RotationThingy", ObjectType.Rotation, transform, this.texturedModelEffect, null, model, Color.White, 1); Matrix rot; this.rotator.AddPrimitive(new Capsule(transform.Translation - new Vector3(0, 0, 20 * 0.6f), Matrix.Identity, 2.5f * 0.6f, 40 * 0.6f), new MaterialProperties()); Matrix.CreateRotationY(MathHelper.ToRadians(90), out rot); this.rotator.AddPrimitive(new Capsule(transform.Translation - new Vector3(20 *0.6f, 0, 0), rot, 2.5f * 0.6f, 40 * 0.6f), new MaterialProperties()); this.rotator.Enable(true, 200); this.objectManager.Add(this.rotator); #endregion //Walls are initialized after Rotator because of their dependancy on Rotator (see RotatorController) //Maybe we should rather go for a more active approach meaning Rotator gets everything which is gonna rotate around it and rotates it #region Wall right Model model = this.modelDictionary["wall"]; transform = new Transform3D(new Vector3(-4f, -1.8f, -69.8f), new Vector3(0, 90, 0), 1f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); wall1 = new PawnCollidableObject("Wall1", ObjectType.Wall, transform, this.texturedModelEffect, null, model, Color.Gray, 1); wall1.Add(new RotatorController("wall1Rotator", wall1, true, this.rotator)); scales = new Vector3(300, 100, 12); wall1.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), material); wall1.Enable(true, 2000); this.objectManager.Add(wall1); #endregion #region Wall left Model model = this.modelDictionary["wall"]; transform = new Transform3D(new Vector3(-4f, -1.8f, 69.8f), new Vector3(0,90,0), 1f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); wall2 = new PawnCollidableObject("Wall2", ObjectType.Wall, transform, this.texturedModelEffect, null, model, Color.White, 1); wall2.Add(new RotatorController("wall2Rotator", wall2, true, this.rotator)); wall2.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), material); wall2.Enable(true, 2000); this.objectManager.Add(wall2); #endregion texture = Content.Load<Texture2D>("Assets/skin/Brick_Tut_35"); #region Pressure Plate Exit Model model = this.modelDictionary["plate"]; scales = new Vector3(12.5f, 2.5f, 12.5f); transform = new Transform3D(new Vector3(125, 0, 0), new Vector3(0, 90, 0), Vector3.One * 0.5f, -Vector3.UnitZ, Vector3.UnitY); step1 = new PawnCollidableObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); step1.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), new MaterialProperties()); step1.Enable(true, 2000); this.objectManager.Add(step1); #endregion #region Pressure Plate Right Up Model transform = new Transform3D(new Vector3(26, 0, 110), Vector3.Zero, Vector3.One * 0.5f, -Vector3.UnitZ, Vector3.UnitY); step4 = new PawnCollidableObject("PressurePlate4", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); step4.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), new MaterialProperties()); step4.Enable(true, 2000); this.objectManager.Add(step4); #endregion #region Pressure Plate Right Down Model transform = new Transform3D(new Vector3(-36, 0, 110), Vector3.Zero, Vector3.One * 0.5f, -Vector3.UnitZ, Vector3.UnitY); step5 = new PawnCollidableObject("PressurePlate5", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); step5.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), new MaterialProperties()); step5.Enable(true, 2000); this.objectManager.Add(step5); #endregion #region Pressure Plate Left Up Model transform = new Transform3D(new Vector3(26, 0, -110), Vector3.Zero, Vector3.One*0.5f, -Vector3.UnitZ, Vector3.UnitY); step2 = new PawnCollidableObject("PressurePlate2", ObjectType.Plate, transform, this.texturedModelEffect, null, model, Color.White, 1); step2.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), new MaterialProperties()); step2.Enable(true, 2000); this.objectManager.Add(step2); #endregion #region Pressure Plate Left Down Model transform = new Transform3D(new Vector3(-36, 0, -110), Vector3.Zero, Vector3.One * 0.5f, -Vector3.UnitZ, Vector3.UnitY); step3 = new PawnCollidableObject("PressurePlate3", ObjectType.Plate, transform, this.texturedModelEffect, null, model, Color.White, 1); step3.AddPrimitive(new Box(transform.Translation, Matrix.Identity, scales), new MaterialProperties()); step3.Enable(true, 2000); this.objectManager.Add(step3); #endregion #region Traps model = this.modelDictionary["trap"]; transform = new Transform3D(new Vector3(80, 20f, 105), Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap1 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect,texture, model, Color.White, 1); this.objectManager.Add(trap1); transform = new Transform3D(new Vector3(80, 20f, 115), Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap2 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(trap2); transform = new Transform3D(new Vector3(80, 20f, -105), Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap3 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(trap3); transform = new Transform3D(new Vector3(80, 20f, -115), Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap4 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(trap4); transform = new Transform3D(new Vector3(-90, 20f, 105), -Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap5 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(trap5); transform = new Transform3D(new Vector3(-90, 20f, 115), -Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap6 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(trap6); transform = new Transform3D(new Vector3(-90, 20f, -105), -Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap7 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(trap7); transform = new Transform3D(new Vector3(-90, 20f, -115), -Vector3.UnitZ * 90, 0.5f * Vector3.One, -Vector3.UnitZ, Vector3.UnitY); trap8 = new PawnModelObject("PressurePlate1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(trap8); #endregion #region Arrow model = this.modelDictionary["arrow"]; transform = new Transform3D(new Vector3(80, 20f, 105), Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow1 = new PawnModelObject("Arrow1", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow1); transform = new Transform3D(new Vector3(80, 20f, 115), Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow2 = new PawnModelObject("Arrow2", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow2); transform = new Transform3D(new Vector3(80, 20f, -105), Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow3 = new PawnModelObject("Arrow3", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow3); transform = new Transform3D(new Vector3(80, 20f, -115), Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow4 = new PawnModelObject("Arrow4", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow4); transform = new Transform3D(new Vector3(-90, 20f, 105), -Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow5 = new PawnModelObject("Arrow5", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow5); transform = new Transform3D(new Vector3(-90, 20f, 115), -Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow6 = new PawnModelObject("Arrow6", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow6); transform = new Transform3D(new Vector3(-90, 20f, -105), -Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow7 = new PawnModelObject("Arrow7", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow7); transform = new Transform3D(new Vector3(-90, 20f, -115), -Vector3.UnitZ * 90, Vector3.One, -Vector3.UnitZ, Vector3.UnitY); arrow8 = new PawnModelObject("Arrow8", ObjectType.Plate, transform, this.texturedModelEffect, texture, model, Color.White, 1); this.objectManager.Add(arrow8); scales = new Vector3(300, 100, 20); #endregion rotator.Add(new OffsetController("offset controller 2", rotator, true, new Vector3(0, 50, 0))); rotator.Add(new RotorController("rotor Controller", this.rotator, true)); doorActor.Add(new OffsetController("offset vontroller 7", doorActor, true, new Vector3(0, -110, 0))); step1.Add(new OffsetController("offset controller 1", step1, true, new Vector3(0, -3, 0))); step2.Add(new OffsetController("offset controller 3", step2, true, new Vector3(0, -3, 0))); step3.Add(new OffsetController("offset controller 4", step3, true, new Vector3(0, -3, 0))); step4.Add(new OffsetController("offset controller 5", step4, true, new Vector3(0, -3, 0))); step5.Add(new OffsetController("offset controller 6", step5, true, new Vector3(0, -3, 0))); trap1.Add(new OffsetController("offset controller 7", trap1, true, new Vector3(-20, 0, 0))); trap2.Add(new OffsetController("offset controller 8", trap2, true, new Vector3(-20, 0, 0))); trap3.Add(new OffsetController("offset controller 9", trap3, true, new Vector3(-20, 0, 0))); trap4.Add(new OffsetController("offset controller 10", trap4, true, new Vector3(-20, 0, 0))); trap5.Add(new OffsetController("offset controller 11", trap5, true, new Vector3(20, 0, 0))); trap6.Add(new OffsetController("offset controller 12", trap6, true, new Vector3(20, 0, 0))); trap7.Add(new OffsetController("offset controller 13", trap7, true, new Vector3(20, 0, 0))); trap8.Add(new OffsetController("offset controller 14", trap8, true, new Vector3(20, 0, 0))); arrow1.Add(new OffsetController("offset controller 7", arrow1, true, new Vector3(-200, 0, 0), 0.2f)); arrow2.Add(new OffsetController("offset controller 8", arrow2, true, new Vector3(-200, 0, 0), 0.2f)); arrow3.Add(new OffsetController("offset controller 9", arrow3, true, new Vector3(-200, 0, 0), 0.2f)); arrow4.Add(new OffsetController("offset controller 10", arrow4, true, new Vector3(-200, 0, 0), 0.2f)); arrow5.Add(new OffsetController("offset controller 11", arrow5, true, new Vector3(200, 0, 0), 0.2f)); arrow6.Add(new OffsetController("offset controller 12", arrow6, true, new Vector3(200, 0, 0), 0.2f)); arrow7.Add(new OffsetController("offset controller 13", arrow7, true, new Vector3(200, 0, 0), 0.2f)); arrow8.Add(new OffsetController("offset controller 14", arrow8, true, new Vector3(200, 0, 0), 0.2f)); }
//allows developer to specify the type of collidable object to be used as basis for the camera public CollidableFirstPersonCameraController(string id, ControllerType controllerType, Keys[] moveKeys, float moveSpeed, float strafeSpeed, float rotationSpeed, ManagerParameters managerParameters, IActor parentActor, float radius, float height, float accelerationRate, float decelerationRate, float mass, float jumpHeight, Vector3 translationOffset, PlayerObject collidableObject) : base(id, controllerType, moveKeys, moveSpeed, strafeSpeed, rotationSpeed, managerParameters) { this.Radius = radius; this.height = height; this.AccelerationRate = accelerationRate; this.DecelerationRate = decelerationRate; this.Mass = mass; this.JumpHeight = jumpHeight; //allows us to tweak the camera position within the player object this.translationOffset = translationOffset; /* Create the collidable player object which comes with a collision skin and position the parentActor (i.e. the camera) inside the player object. * notice that we don't pass any effect, model or texture information, since in 1st person perspective we dont want to look from inside a model. * Therefore, we wont actually render any drawn object - the effect, texture, model (and also Color) information are unused. * * This code allows the user to pass in their own PlayerObject (e.g. HeroPlayerObject) to be used for the collidable object basis for the camera. */ if (collidableObject != null) { this.playerObject = collidableObject; } else { this.playerObject = new PlayerObject(this.ID + " - player object", ActorType.CollidableCamera, (parentActor as Actor3D).Transform, null, null, this.MoveKeys, radius, height, accelerationRate, decelerationRate, jumpHeight, translationOffset, this.ManagerParameters.KeyboardManager); } playerObject.Enable(false, mass); }