コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 public void Draw(BaseCamera camera, ref RenderTarget2D shadowRenderTarget)
 {
     if (Active)
     {
         if (HitTest)
         {
             world = lastWorld;
         }
         DrawModel(camera, false, ref shadowRenderTarget);
     }
 }
コード例 #4
0
 public void Draw(BaseCamera camera, ref RenderTarget2D shadowRenderTarget)
 {
     if (Active)
     {
         if (HitTest)
         {
             world = lastWorld;
         }
         DrawModel(camera, false, ref shadowRenderTarget);
     }
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
 public LightSource(Vector3 _lightDirection, BaseCamera _camera)
 {
     LightDirection = _lightDirection;
     camera         = _camera;
 }
コード例 #8
0
 public void Draw(BaseCamera camera)
 {
     ExplosionParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix());
     ExplosionSmokeParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix());
     EnergyParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix());
 }
コード例 #9
0
ファイル: Map.cs プロジェクト: thestonefox/XNA-Alien-Lander
        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);
            }
        }
コード例 #10
0
        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();
                }
            }
        }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
 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);
 }
コード例 #13
0
 public LightSource(Vector3 _lightDirection, BaseCamera _camera)
 {
     LightDirection = _lightDirection;
     camera = _camera;
 }