public void Draw(Camera camera) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect be in mesh.Effects) { be.EnableDefaultLighting(); be.Projection = camera.projection; be.View = camera.view; be.World = GetWorld() * mesh.ParentBone.Transform; } mesh.Draw(); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here modelManager = new ModelManager(this); Components.Add(modelManager); camera = new Camera(this, new Vector3(0, 0, 300), Vector3.Zero, Vector3.Up); Components.Add(camera); modelManager.Enabled = false; modelManager.Visible = false; // Splash screen component splashScreen = new SplashScreen(this); Components.Add(splashScreen); splashScreen.SetData("Welcome to Space Defender!\n Mohammed Aljobory" , currentGameState); base.Initialize(); }