private void RenderScene(Matrix viewMatrix, Matrix projectionMatrix) { //draw coord translated coord cross basicEffect.World = Matrix.CreateTranslation(2, 5, 6); basicEffect.View = viewMatrix; basicEffect.Projection = projectionMatrix; basicEffect.TextureEnabled = false; basicEffect.Begin(); foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Begin(); cCross.DrawUsingPresetEffect(); pass.End(); } basicEffect.End(); //draw model in front of mirror Matrix worldMatrix = Matrix.CreateScale(0.05f) * Matrix.CreateRotationY(MathHelper.Pi) * Matrix.CreateTranslation(0, 0, 5); myModel.CopyAbsoluteBoneTransformsTo(modelTransforms); foreach (ModelMesh mesh in myModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix; effect.View = viewMatrix; effect.Projection = projectionMatrix; } mesh.Draw(); } //draw model behind mirror (this model should not be seen in the mirror!) worldMatrix = Matrix.CreateScale(0.05f) * Matrix.CreateRotationX(MathHelper.PiOver2) * Matrix.CreateTranslation(0, 2, -10); myModel.CopyAbsoluteBoneTransformsTo(modelTransforms); foreach (ModelMesh mesh in myModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix; effect.View = viewMatrix; effect.Projection = projectionMatrix; } mesh.Draw(); } }
protected override void Draw(GameTime gameTime) { device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0); basicEffect.World = Matrix.Identity; basicEffect.View = viewMatrix; basicEffect.Projection = projectionMatrix; basicEffect.Begin(); foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes) { pass.Begin(); cCross.DrawUsingPresetEffect(); pass.End(); } basicEffect.End(); base.Draw(gameTime); }