public void Draw(Camera_Manager m_CameraManager) { Matrix[] transforms; int v, h; //Move & rotate the model itself as a whole m_model.Root.Transform = Matrix.CreateFromQuaternion(m_quatModelRotation) * Matrix.CreateTranslation(m_vecModelLoc); //Draw the model, a model can have multiple meshes, so loop //We're using CopyAbsoluteBoneTransformsTo so that we retain relative positioning of meshes //in the model. transforms = new Matrix[m_model.Bones.Count]; m_model.CopyAbsoluteBoneTransformsTo(transforms); for (h = 0; h < m_model.Meshes.Count; h++) { ModelMesh mesh = m_model.Meshes[h]; //This is where the mesh orientation is set, as well as our camera and projection for (v = 0; v < mesh.Effects.Count; v++) { BasicEffect effect = (BasicEffect)mesh.Effects[v]; effect.EnableDefaultLighting(); effect.World = transforms[mesh.ParentBone.Index]; effect.View = m_CameraManager.ActiveCamera.View; effect.Projection = m_CameraManager.ActiveCamera.Projection; } //Draw the mesh, will use the effects set above. mesh.Draw(); } }
protected override void Initialize() { CameraManager = new Camera_Manager(this); Components.Add(CameraManager); InputManager = new Input_Manager(this); Components.Add(InputManager); CameraManager.Initialize(GraphicsDevice.Viewport); this.IsMouseVisible = true; base.Initialize(); }