Exemple #1
0
 public override void Draw(BoundingFrustum VisibleArea, Vector3 Position)
 {
     //Draw the Glow
     Manager.ResetFor2D();
     MyGame.graphics.GraphicsDevice.VertexDeclaration = GlowDeclaration;
     Manager.OrdinaryEffect.CurrentTechnique          = Manager.OrdinaryEffect.Techniques["Glow"];
     Manager.OrdinaryEffect.Parameters["CameraPosition"].SetValue(Manager.CameraFocus + Manager.CameraLocation);
     Manager.OrdinaryEffect.Parameters["CameraUpVector"].SetValue(Manager.CameraUp);
     Manager.OrdinaryEffect.Parameters["PointSpriteSize"].SetValue(Transforms.Scale * 2.0f);
     Manager.OrdinaryEffect.Parameters["PositionValue"].SetValue(Transforms.Position);
     Manager.OrdinaryEffect.Parameters["Offset"].SetValue(RotationTime / 40.0f);
     Manager.OrdinaryEffect.Begin();
     Manager.OrdinaryEffect.CurrentTechnique.Passes.First <EffectPass>().Begin();
     MyGame.graphics.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>(
         PrimitiveType.TriangleList
         , Glow
         , 0
         , Glow.Length
         , GlowIndex
         , 0
         , GlowIndex.Length / 3);
     Manager.OrdinaryEffect.CurrentTechnique.Passes.First <EffectPass>().End();
     Manager.OrdinaryEffect.End();
     //Draw the Star, Planets, Asteroids, Etc.
     Manager.ResetFor3D();
     Manager.TexturedEffect.CurrentTechnique = Manager.TexturedEffect.Techniques["Textured"];
     Manager.TexturedEffect.Parameters["InputTexture"].SetValue(NoiseMap);
     Manager.TexturedEffect.Parameters["InputTextureInterpolation"].SetValue(0.0f);
     Manager.TexturedEffect.Parameters["ColorMapTexture"].SetValue(ColorMap);
     Manager.TexturedEffect.Parameters["TextureAlphaThreshold"].SetValue(0.0f);
     base.Draw(VisibleArea, Position);
 }
        public override void Draw(BoundingFrustum VisibleArea, Vector3 Position)
        {
            Manager.ResetFor3D();
            Manager.DiffuseEffect.CurrentTechnique = Manager.DiffuseEffect.Techniques["DiffuseFast"];
            MyGame.graphics.GraphicsDevice.RenderState.CullMode = CullMode.None;
            MyGame.graphics.GraphicsDevice.VertexDeclaration    = ModelDeclaration;
            //Set the direction of the light to be away from Vector3.Zero
            Manager.DiffuseEffect.Parameters["AmbientIntensity"].SetValue(0.25f);
            Manager.DiffuseEffect.Parameters["LightDirection"].SetValue(
                Vector3.Transform(
                    Vector3.Normalize(-Transforms.Position)
                    , Matrix.Invert(Transforms.Rotation)));
            Matrix transform = Transforms.Rotation
                               * Matrix.CreateScale(Transforms.Scale)
                               * Matrix.CreateTranslation(Transforms.Position + Position);

            Manager.DiffuseEffect.Parameters["World"].SetValue(transform);
            Manager.DiffuseEffect.Begin();
            Manager.DiffuseEffect.CurrentTechnique.Passes.First <EffectPass>().Begin();
            MyGame.graphics.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionNormalColor>(
                PrimitiveType.TriangleList
                , AsteroidVertices
                , 0
                , AsteroidVertices.Length
                , AsteroidIndices
                , 0
                , AsteroidIndices.Length / 3);
            Manager.DiffuseEffect.CurrentTechnique.Passes.First <EffectPass>().End();
            Manager.DiffuseEffect.End();
            base.Draw(VisibleArea, Position);
            MyGame.graphics.GraphicsDevice.RenderState.CullMode = CullMode.CullCounterClockwiseFace;
        }
 public override void Draw(BoundingFrustum VisibleArea, Vector3 Position)
 {
     Manager.ResetFor3D();
     Manager.TexturedEffect.CurrentTechnique = Manager.TexturedEffect.Techniques["TextureDiffuse"];
     Manager.TexturedEffect.Parameters["InputTexture"].SetValue(NoiseMap);
     Manager.TexturedEffect.Parameters["ColorMapTexture"].SetValue(ColorMap);
     Manager.TexturedEffect.Parameters["TextureAlphaThreshold"].SetValue(0.0f);
     //Set the direction of the light to be away from the parent
     Manager.TexturedEffect.Parameters["LightDirection"].SetValue(
         Vector3.Transform(
             Vector3.Normalize(-Transforms.Position)
             , Matrix.Invert(Transforms.Rotation)));
     Manager.TexturedEffect.Parameters["AmbientIntensity"].SetValue(0.15f);
     Manager.TexturedEffect.Parameters["ViewDirection"].SetValue(
         Vector3.Transform(
             Vector3.Normalize(Manager.CameraFocus + Manager.CameraLocation)
             , Matrix.Invert(Transforms.Rotation)));
     Manager.TexturedEffect.Parameters["SpecularIntensity"].SetValue(1f);
     base.Draw(VisibleArea, Position);
 }