Ejemplo n.º 1
0
        public virtual SpaceObject CreateSolSystem()
        {
            var sol = new Star(
                "Sol", "sun", StellarClass.G, 2, 695700, new Vector2(200,200),

                new Planet("Mercury", "mercury", PlanetType.AirlessRock, 2440, 0.2f, 88),
                new Planet("Venus", "sulfurplanet", PlanetType.CloudyRock, 6052, 0.5f, 200)
                /*new Planet("Earth", "earth", PlanetType.Earth, 6371, new OrbitalParameters(10e6d, 0.016d, 102.947, 358.17f.DegreeToRadian()),
                    new Planet("Luna", "moon", PlanetType.AirlessRock, 1737, new OrbitalParameters(384.399e3, 0.0549, 0, 0))
                ) ,
                new Planet("Mars", "mars", PlanetType.Desert, 3000, new OrbitalParameters(),
                    new Planet("Phobos", "phobos", PlanetType.Asteroid, 500, new OrbitalParameters()),
                    new Planet("Deimos", "deimos", PlanetType.Asteroid, 500, new OrbitalParameters())
                ),
                //new AsteroidBelt("Asteroid Belt", ...)
                new Planet("Ceres", "rockplanet", PlanetType.AirlessRock, 3000, new OrbitalParameters()),
                new Planet("Jupiter", "jupiter", PlanetType.Jupiter, 1000, new OrbitalParameters(),
                    new Planet("Europa", "tundraplanet", PlanetType.Jupiter, 1000, new OrbitalParameters()),
                    new Planet("Ganymede", "primordialplanet", PlanetType.Jupiter, 1000, new OrbitalParameters()),
                    new Planet("Io", "sulfurplanet", PlanetType.Jupiter, 1000, new OrbitalParameters()),
                    new Planet("Callisto", "crystalplanet", PlanetType.Jupiter, 1000, new OrbitalParameters())
                )*/
            );

            return sol;
        }
        private void DrawStar(Entity entity, Star star)
        {
            var xform = entity.GetComponent<Transform>();
            var inverse = new Vector2(1, -1) * 0.01f;

            //_starGlowEffect.View = Matrix.CreateLookAt(new Vector3(_camera.Transform.Position * inverse, 100), new Vector3(_camera.Transform.Position * inverse, 0), Vector3.UnitY) * Matrix.CreateScale(_camera.Zoom);
            _starGlowEffect.View = _camera.GetViewMatrix(1.0f);

            _starGlowEffect.World = Matrix.CreateScale(new Vector3(50, 50, 1)) * Matrix.CreateTranslation(new Vector3(xform.Position, ZPosition));
            _starGlowEffect.Alpha = 0.1f;
            foreach (var pass in _starGlowEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                _device.DrawUserPrimitives(PrimitiveType.TriangleStrip, _quad, 0, 2);
            }

            _starGlowEffect.Alpha = 1f;
            _starGlowEffect.World = Matrix.CreateScale(new Vector3(5, 5, 1)) * Matrix.CreateTranslation(new Vector3(xform.Position, ZPosition) * ModelScale);
            //_starGlowEffect.View = _camera.GetViewMatrix(1.0f);

            // draw glow
            foreach (var pass in _starGlowEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                _device.DrawUserPrimitives(PrimitiveType.TriangleStrip, _quad, 0, 2);
            }

            _sphereModel.Meshes[0].MeshParts[0].Effect = _sunEffect;
            _sunEffect.World = Matrix.CreateRotationX(MathHelper.ToRadians(80)) * Matrix.CreateScale(new Vector3(xform.Scale, xform.Scale.X) * ModelScale) * Matrix.CreateTranslation(new Vector3(xform.Position, ZPosition));
            _sunEffect.View = _starGlowEffect.View;

            _sphereModel.Meshes[0].Draw();

            DrawHalo(entity, Matrix.CreateScale(new Vector3(xform.Scale, xform.Scale.X) * ModelScale) * Matrix.CreateTranslation(new Vector3(xform.Position, ZPosition)), _sunEffect.View);
        }