Exemple #1
0
        public override void Initialize()
        {
            base.Initialize();
            StarField starField1 = this;
            Mesh      mesh1      = new Mesh();

            mesh1.AlwaysOnTop = true;
            mesh1.DepthWrites = false;
            mesh1.Blending    = new BlendingMode?(BlendingMode.Additive);
            mesh1.Culling     = CullMode.None;
            Mesh      mesh2      = mesh1;
            StarField starField2 = this;
            FakePointSpritesEffect pointSpritesEffect1 = new FakePointSpritesEffect();

            pointSpritesEffect1.ForcedProjectionMatrix = new Matrix?(Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(75f), this.CameraManager.AspectRatio, 0.1f, 1000f));
            FakePointSpritesEffect pointSpritesEffect2;
            FakePointSpritesEffect pointSpritesEffect3 = pointSpritesEffect2 = pointSpritesEffect1;

            starField2.StarEffect = pointSpritesEffect2;
            FakePointSpritesEffect pointSpritesEffect4 = pointSpritesEffect3;

            mesh2.Effect = (BaseEffect)pointSpritesEffect4;
            Mesh mesh3 = mesh1;

            starField1.StarsMesh = mesh3;
            if (this.HasHorizontalTrails)
            {
                StarField starField3 = this;
                Mesh      mesh4      = new Mesh();
                mesh4.AlwaysOnTop = true;
                mesh4.DepthWrites = false;
                mesh4.Blending    = new BlendingMode?(BlendingMode.Additive);
                Mesh mesh5 = mesh4;
                HorizontalTrailsEffect horizontalTrailsEffect1 = new HorizontalTrailsEffect();
                horizontalTrailsEffect1.ForcedProjectionMatrix = this.StarEffect.ForcedProjectionMatrix;
                HorizontalTrailsEffect horizontalTrailsEffect2 = horizontalTrailsEffect1;
                mesh5.Effect = (BaseEffect)horizontalTrailsEffect2;
                Mesh mesh6 = mesh4;
                starField3.TrailsMesh = mesh6;
            }
            this.AddStars();
            if (this.FollowCamera)
            {
                return;
            }
            this.StarEffect.ForcedViewMatrix = new Matrix?(Matrix.CreateLookAt(Vector3.Zero, Vector3.UnitZ, Vector3.Up));
            if (!this.HasHorizontalTrails)
            {
                return;
            }
            (this.TrailsMesh.Effect as HorizontalTrailsEffect).ForcedViewMatrix = this.StarEffect.ForcedViewMatrix;
        }
Exemple #2
0
 public void Draw()
 {
     if (!this.FollowCamera)
     {
         this.StarsMesh.Position = this.AdditionalZoom * Vector3.Forward * 125f - 2400f * Vector3.Forward;
         this.StarsMesh.Scale    = new Vector3(1f + this.AdditionalScale, 1f + this.AdditionalScale, 1f);
     }
     else if (!this.GameState.InFpsMode)
     {
         FakePointSpritesEffect pointSpritesEffect = this.StarEffect;
         StarField starField1 = this;
         StarField starField2 = this;
         Matrix?   nullable1  = new Matrix?();
         Matrix?   nullable2  = nullable1;
         starField2.savedViewMatrix = nullable2;
         Matrix?nullable3;
         Matrix?nullable4 = nullable3 = nullable1;
         starField1.savedViewMatrix = nullable3;
         Matrix?nullable5 = nullable4;
         pointSpritesEffect.ForcedViewMatrix = nullable5;
         this.StarsMesh.Position             = this.CameraManager.InterpolatedCenter * 0.5f;
         this.StarsMesh.Scale = new Vector3((float)(112.5 / ((double)this.CameraManager.Radius / (double)SettingsManager.GetViewScale(this.GraphicsDevice) + 40.0)));
         if (this.HasHorizontalTrails)
         {
             this.TrailsMesh.Position = this.StarsMesh.Position;
             this.TrailsMesh.Scale    = this.StarsMesh.Scale = new Vector3((float)(65.0 / ((double)this.CameraManager.Radius / (double)SettingsManager.GetViewScale(this.GraphicsDevice) + 25.0)));
         }
     }
     else if (this.CameraManager.ProjectionTransition)
     {
         if (this.CameraManager.Viewpoint != Viewpoint.Perspective)
         {
             this.StarEffect.ForcedViewMatrix = new Matrix?(Matrix.Lerp(this.CameraManager.View, this.CameraManager.View, Easing.EaseOut((double)this.CameraManager.ViewTransitionStep, EasingType.Quadratic)));
         }
         else if (!this.savedViewMatrix.HasValue)
         {
             this.savedViewMatrix = new Matrix?(this.CameraManager.View);
         }
     }
     this.StarsMesh.Material.Opacity = this.Opacity;
     this.StarsMesh.Draw();
     if (!this.Enabled || !this.HasHorizontalTrails)
     {
         return;
     }
     this.TrailsMesh.Draw();
 }