public MSIMonitor() { msi = new AfterBurner(); }
protected void Load(string name, InstancingType instancing) { if (name == null || name == string.Empty) { return; } // load description ModelDescription desc = game.Content.Load <ModelDescription>(".\\Content\\Models\\" + name + "Desc"); LocalRotation = Quaternion.CreateFromAxisAngle(desc.BaseRotationAxis, MathHelper.ToRadians(desc.BaseRotationAngle)); // load fbx Microsoft.Xna.Framework.Graphics.Model model = game.Content.Load <Microsoft.Xna.Framework.Graphics.Model>(".\\Content\\Models\\" + desc.BaseFBX); // process meshes foreach (ModelMesh modelmesh in model.Meshes) { // wrap ModelMesh in adapter IMesh mesh; switch (instancing) { case InstancingType.None: mesh = new ModelMeshAdapterMesh(game, modelmesh); break; case InstancingType.Constants: mesh = new ConstantsInstancingModelMeshAdapterMesh(game, modelmesh); break; case InstancingType.Hardware: mesh = new HardwareInstancingModelMeshAdapterMesh(game, modelmesh); break; default: throw new Exception(); } mesh.Parent = this; meshes.Add(mesh); // get material name. prefer the one with the mesh's name before * string materialName = ""; foreach (MeshMaterial matdesc in desc.Materials) { if (matdesc.MeshName == modelmesh.Name) { materialName = matdesc.MaterialName; break; } if (matdesc.MeshName == "*") { if (materialName == "") { materialName = matdesc.MaterialName; } } } // load material Material material = Material.Create(game, materialName, instancing); materials.Add(material); // tell the mesh which effect to use mesh.Effect = material.Effect; } // get weapon slots foreach (WeaponDescription weapon in desc.Weapons) { WeaponSlot slot = new WeaponSlot( (WeaponType)Enum.Parse(typeof(WeaponType), weapon.WeaponType, false), weapon.Position, weapon.RotationAxis, weapon.RotationAngle, weapon.Scaling); weaponSlots.Add(slot); } // get collision shapes foreach (Box box in desc.CollisionShapes.Boxes) { BoxShapeData shape = new BoxShapeData(); shape.Dimensions = box.Size; Matrix m = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(box.OffsetRotationAxis, box.OffsetRotationAngle)); m.Translation = box.OffsetPosition; shape.Offset = m; shape.Material.Friction = desc.Friction; shape.Material.Bounciness = desc.Bounciness; shape.Material.Hardness = desc.Hardness; collisionShapes.Add(shape); } foreach (Capsule capsule in desc.CollisionShapes.Capsules) { CapsuleShapeData shape = new CapsuleShapeData(); shape.Radius = capsule.Radius; shape.Length = capsule.Length; Matrix m = Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(capsule.OffsetRotationAxis, capsule.OffsetRotationAngle)); m.Translation = capsule.OffsetPosition; shape.Offset = m; shape.Material.Friction = desc.Friction; shape.Material.Bounciness = desc.Bounciness; shape.Material.Hardness = desc.Hardness; collisionShapes.Add(shape); } foreach (Sphere sphere in desc.CollisionShapes.Spheres) { SphereShapeData shape = new SphereShapeData(); shape.Radius = sphere.Radius; Matrix m = Matrix.CreateTranslation(sphere.OffsetPosition); shape.Offset = m; shape.Material.Friction = desc.Friction; shape.Material.Bounciness = desc.Bounciness; shape.Material.Hardness = desc.Hardness; collisionShapes.Add(shape); } wreckageModels = desc.Wreckages; // get particle effects if (game.World != null) { foreach (ParticleEffectDescription effect in desc.ParticleEffects) { IEffect fx = game.Effects.CreateEffect(effect.EffectName); fx.Parent = this; fx.LocalPosition = effect.Position; fx.LocalRotation = Quaternion.CreateFromAxisAngle(effect.RotationAxis, effect.RotationAngle); fx.LocalScale = effect.Scaling; game.World.AddEffect(fx); particleEffects.Add(fx); // for calling Destroy() later fx.Play(); } } // afterburner foreach (AfterBurnerEffectDescription ab in desc.AfterBurnerEffects) { AfterBurner a = new AfterBurner(game); a.Parent = this; a.LocalPosition = ab.Position; a.LocalScale = ab.Scaling; a.LocalRotation = Quaternion.CreateFromAxisAngle(ab.RotationAxis, ab.RotationAngle); a.LoadTheContent(); afterBurnerEffects.Add(a); } // get animations foreach (MeshAnimation anim in desc.Animations) { foreach (IMesh mesh in meshes) { if (mesh.Name == anim.MeshName) { mesh.Animation = anim; break; // inner foreach } } } // mass mass = desc.Mass; // base rotation LocalRotation = Quaternion.CreateFromAxisAngle(desc.BaseRotationAxis, desc.BaseRotationAngle); // save name this.name = name; }