Пример #1
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();
            }
        }
Пример #2
0
 public void Draw(BaseCamera camera)
 {
     ExplosionParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix());
     ExplosionSmokeParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix());
     EnergyParticles.SetCamera(camera.GetViewMatrix(), camera.GetProjectionMatrix());
 }
Пример #3
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();
                }
            }
        }
Пример #4
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();
            }
        }