public void Draw(BaseCamera camera) { if (Active) { if (HitTest) { world = lastWorld; } // Copy any parent transforms. // Draw the model. A model can have multiple meshes, so loop. for (int meshIndex = 0; meshIndex < mesh.Meshes.Count; meshIndex++) { meshM = mesh.Meshes[meshIndex]; // This is where the mesh orientation is set, as well // as our camera and projection. foreach (BasicEffect effect in meshM.Effects) { effect.EnableDefaultLighting(); if (elementsWorldMatrix.Length == 0) { effect.World = transforms[meshM.ParentBone.Index] * world; } else { effect.World = transforms[meshM.ParentBone.Index] * elementsWorldMatrix[meshIndex] * world; } effect.View = camera.GetViewMatrix(); effect.Projection = camera.GetProjectionMatrix(); } // Draw the mesh, using the effects set above. meshM.Draw(); } } }
public void DrawShadow(BaseCamera camera, ref RenderTarget2D shadowRenderTarget) { Game.GraphicsDevice.SetRenderTarget(shadowRenderTarget); Game.GraphicsDevice.Clear(Color.White); DrawModel(camera, true, ref shadowRenderTarget); Game.GraphicsDevice.SetRenderTarget(null); }
public void Draw(BaseCamera camera, ref RenderTarget2D shadowRenderTarget) { if (Active) { if (HitTest) { world = lastWorld; } DrawModel(camera, false, ref shadowRenderTarget); } }
public void Draw(BaseCamera camera, ref RenderTarget2D shadowRenderTarget) { for (int c = 0; c < blocks.Length; c++) { blocks[c].Draw(camera, ref shadowRenderTarget); } for (int c = 0; c < peeps.Length; c++) { peeps[c].Draw(camera, ref shadowRenderTarget); } for (int c = 0; c < powerups.Length; c++) { powerups[c].Draw(camera, ref shadowRenderTarget); } }
protected void DrawModel(BaseCamera camera, bool createShadowMap, ref RenderTarget2D shadowRenderTarget) { lightViewProjection = light.CreateLightViewProjectionMatrix(); techniqueName = createShadowMap ? "CreateShadowMap" : "DrawWithShadowMap"; for (int meshIndex = 0; meshIndex < mesh.Meshes.Count; meshIndex++) { meshM = mesh.Meshes[meshIndex]; // Do the world stuff. // Scale * transform * pos * rotation if (elementsWorldMatrix.Length == 0) { meshWorld = transforms[meshM.ParentBone.Index] * world; } else { meshWorld = transforms[meshM.ParentBone.Index] * elementsWorldMatrix[meshIndex] * world; } foreach (Effect effect in meshM.Effects) { effect.CurrentTechnique = effect.Techniques[techniqueName]; effect.Parameters["World"].SetValue(meshWorld); effect.Parameters["View"].SetValue(camera.GetViewMatrix()); effect.Parameters["Projection"].SetValue(camera.GetProjectionMatrix()); effect.Parameters["LightDirection"].SetValue(light.LightDirection); effect.Parameters["LightViewProj"].SetValue(lightViewProjection); if (createShadowMap == false) { effect.Parameters["ShadowMap"].SetValue(shadowRenderTarget); } } meshM.Draw(); } }
public LightSource(Vector3 _lightDirection, BaseCamera _camera) { LightDirection = _lightDirection; camera = _camera; }
public void Draw(BaseCamera camera) { ExplosionParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix()); ExplosionSmokeParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix()); EnergyParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix()); }
public void Draw(BaseCamera camera) { if (Active) { if (HitTest) { world = lastWorld; } // Copy any parent transforms. // Draw the model. A model can have multiple meshes, so loop. for(int meshIndex = 0; meshIndex < mesh.Meshes.Count; meshIndex++) { meshM = mesh.Meshes[meshIndex]; // This is where the mesh orientation is set, as well // as our camera and projection. foreach (BasicEffect effect in meshM.Effects) { effect.EnableDefaultLighting(); if (elementsWorldMatrix.Length == 0) { effect.World = transforms[meshM.ParentBone.Index] * world; } else { effect.World = transforms[meshM.ParentBone.Index] * elementsWorldMatrix[meshIndex] * world; } effect.View = camera.GetViewMatrix(); effect.Projection = camera.GetProjectionMatrix(); } // Draw the mesh, using the effects set above. meshM.Draw(); } } }
protected void DrawModel(BaseCamera camera, bool createShadowMap, ref RenderTarget2D shadowRenderTarget) { lightViewProjection = light.CreateLightViewProjectionMatrix(); techniqueName = createShadowMap ? "CreateShadowMap" : "DrawWithShadowMap"; for(int meshIndex = 0; meshIndex < mesh.Meshes.Count; meshIndex++) { meshM = mesh.Meshes[meshIndex]; // Do the world stuff. // Scale * transform * pos * rotation if (elementsWorldMatrix.Length == 0) { meshWorld = transforms[meshM.ParentBone.Index] * world; } else { meshWorld = transforms[meshM.ParentBone.Index] * elementsWorldMatrix[meshIndex] * world; } foreach (Effect effect in meshM.Effects) { effect.CurrentTechnique = effect.Techniques[techniqueName]; effect.Parameters["World"].SetValue(meshWorld); effect.Parameters["View"].SetValue(camera.GetViewMatrix()); effect.Parameters["Projection"].SetValue(camera.GetProjectionMatrix()); effect.Parameters["LightDirection"].SetValue(light.LightDirection); effect.Parameters["LightViewProj"].SetValue(lightViewProjection); if (createShadowMap == false) { effect.Parameters["ShadowMap"].SetValue(shadowRenderTarget); } } meshM.Draw(); } }