示例#1
0
        //Is called when user moves to another tabs; Here the shapes are being updated
        void Planets_SelectionChanged(object sender, EventArgs e)
        {
            switch (SelectedIndex)
            {
                case 0: //Mercury
                    Planet = new Sphere(Vector3.Zero, 1, PRECISEMENT, tMercury, GraphicsDevice);
                    Reset(); break;
                case 1: //Venus
                    Planet = new Sphere(Vector3.Zero, 1.2f, PRECISEMENT, tVenus, GraphicsDevice);
                    Reset(); break;
                case 2: //Earth
                    Earth_Init();
                    Reset(); break;
                case 3: //Mars
                    Planet = new Sphere(Vector3.Zero, 1.3f, PRECISEMENT, tMars, GraphicsDevice);
                    Planet.Rotate(-Vector3.UnitZ, MARS_OBLIQUITY);
                    Moon = new Ellipsoid(new Vector3(0, 0, 2.5f), 0.1f, 1.2f, 0.83f, 1, PRECISEMENT/3+1, tPhobos, GraphicsDevice); //Phobos
                    Moon.RotateComposition(-Vector3.UnitZ, MARS_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble()*MathHelper.Pi);
                    Moon2 = new Ellipsoid(new Vector3(0, 0, 4), 0.07f, 1.22f, 1, 0.85f, PRECISEMENT/3+1, tDeimos, GraphicsDevice); //Deimos
                    Moon2.RotateComposition(-Vector3.UnitZ, MARS_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Reset(); break;
                case 4: //Jupiter
                    Planet = new Ellipsoid(Vector3.Zero, 2f, 1.06f, 1, 1.06f, PRECISEMENT, tJupiter, GraphicsDevice);
                    Moon = new Sphere(new Vector3(0, 0, 3.5f), 0.1f, PRECISEMENT/3+1, tEuropa, GraphicsDevice); //Europa
                    Moon.Rotate(Planet.Axis, -(float)randomAngle.NextDouble()*MathHelper.Pi);
                    Moon2 = new Sphere(new Vector3(0, 0, 3f), 0.11f, PRECISEMENT/3+1, tIo, GraphicsDevice); //Io
                    Moon2.Rotate(Planet.Axis, -(float)randomAngle.NextDouble()*MathHelper.Pi);
                    Moon3 = new Sphere(new Vector3(0, 0, 4.3f), 0.17f, PRECISEMENT/3+2, tGanymede, GraphicsDevice); //Ganymede
                    Moon3.Rotate(Planet.Axis, -(float)randomAngle.NextDouble()*MathHelper.Pi);
                    Moon4 = new Sphere(new Vector3(0, 0, 5.5f), 0.14f, PRECISEMENT/3+2, tCallisto, GraphicsDevice); //Callisto
                    Moon4.Rotate(Planet.Axis, -(float)randomAngle.NextDouble()*MathHelper.Pi);
                    Reset(); break;
                case 5: //Saturn
                    Planet = new Ellipsoid(Vector3.Zero, 1.8f, 1.1f, 1, 1.1f, PRECISEMENT, tSaturn, GraphicsDevice);
                    Planet.Rotate(-Vector3.UnitZ, SATURN_OBLIQUITY);
                    for (int i = 0; i < SaturnRing.Length; i++)
                    {
                        SaturnRing[i] = new FlatRingSector(Planet.Center, 2.7f, 0.9f, 1, MathHelper.TwoPi / SaturnRing.Length, tSaturnRing, GraphicsDevice);
                        SaturnRing[i].RotateComposition(-Vector3.UnitZ, SATURN_OBLIQUITY, Planet.Axis, MathHelper.TwoPi / SaturnRing.Length * i);
                    }
                    Moon = new Sphere(new Vector3(0, 0, 4f), 0.15f, PRECISEMENT/3+3, tTitan, GraphicsDevice); //Titan
                    Moon.RotateComposition(-Vector3.UnitZ, SATURN_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon2 = new Sphere(new Vector3(0, 0, 3f), 0.03f, PRECISEMENT/6, tRhea, GraphicsDevice); //Rhea
                    Moon2.RotateComposition(-Vector3.UnitZ, SATURN_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon3 = new Sphere(new Vector3(0, 0, 2.6f), 0.027f, PRECISEMENT/6, tDione, GraphicsDevice); //Dione
                    Moon3.RotateComposition(-Vector3.UnitZ, SATURN_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon4 = new Sphere(new Vector3(0, 0, 2.45f), 0.023f, PRECISEMENT/6, tTethys, GraphicsDevice); //Tethys
                    Moon4.RotateComposition(-Vector3.UnitZ, SATURN_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon5 = new Sphere(new Vector3(0, 0, 7f), 0.06f, PRECISEMENT/3+3, tIapetus, GraphicsDevice); //Iapetus
                    MoonAxis = (Vector3)My.Quaternion.Rotate(Planet.Axis, Vector3.UnitZ, SATURN_OBLIQUITY - IAPETUS_SATURN_OBLIQUITY);
                    Moon5.RotateComposition(-Vector3.UnitZ, IAPETUS_SATURN_OBLIQUITY, MoonAxis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon6 = new Sphere(new Vector3(0, 0, 2.3f), 0.015f, PRECISEMENT/6, tEnceladus, GraphicsDevice); //Enceladus
                    Moon6.RotateComposition(-Vector3.UnitZ, SATURN_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon7 = new Sphere(new Vector3(0, 0, 2.1f), 0.01f, PRECISEMENT/6, tMimas, GraphicsDevice); //Mimas
                    Moon7.RotateComposition(-Vector3.UnitZ, SATURN_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);

                    //To see rings at once:
                    Planet.Rotate(Vector3.UnitX, 0.1f);Moon.Rotate(Vector3.UnitX, 0.1f);Moon2.Rotate(Vector3.UnitX, 0.1f);
                    Moon3.Rotate(Vector3.UnitX, 0.1f);Moon4.Rotate(Vector3.UnitX, 0.1f);Moon5.Rotate(Vector3.UnitX, 0.1f);
                    Moon6.Rotate(Vector3.UnitX, 0.1f);Moon7.Rotate(Vector3.UnitX, 0.1f);
                    foreach (FlatRingSector f in SaturnRing) f.Rotate(Vector3.UnitX, 0.1f);
                    Reset(); break;
                case 6: //Uranus
                    Planet = new Sphere(Vector3.Zero, 1.7f, PRECISEMENT, tUranus, GraphicsDevice);
                    Planet.Rotate(-Vector3.UnitZ, URANUS_OBLIQUITY);

                    Moon = new Sphere(new Vector3(0, 0, 3.5f), 0.11f, PRECISEMENT/3+1, tTitania, GraphicsDevice); //Titania
                    Moon.RotateComposition(-Vector3.UnitZ, URANUS_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon2 = new Sphere(new Vector3(0, 0, 3.8f), 0.11f, PRECISEMENT/3+1, tOberon, GraphicsDevice); //Oberon
                    Moon2.RotateComposition(-Vector3.UnitZ, URANUS_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon3 = new Sphere(new Vector3(0, 0, 2.6f), 0.09f, PRECISEMENT/3+1, tAriel, GraphicsDevice); //Ariel
                    Moon3.RotateComposition(-Vector3.UnitZ, URANUS_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon4 = new Sphere(new Vector3(0, 0, 3f), 0.09f, PRECISEMENT/3+1, tUmbriel, GraphicsDevice); //Umbriel
                    Moon4.RotateComposition(-Vector3.UnitZ, URANUS_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon5 = new Sphere(new Vector3(0, 0, 2.4f), 0.05f, PRECISEMENT/3+1, tMiranda, GraphicsDevice); //Miranda
                    Moon5.RotateComposition(-Vector3.UnitZ, URANUS_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Reset(); break;
                case 7: //Neptune
                    Planet = new Sphere(Vector3.Zero, 1.6f, PRECISEMENT, tNeptune, GraphicsDevice);
                    Planet.Rotate(-Vector3.UnitZ, NEPTUNE_OBLIQUITY);

                    Moon = new Sphere(new Vector3(0, 0, 2.6f), 0.14f, PRECISEMENT/2-1, tTriton, GraphicsDevice); //Triton
                    MoonAxis = (Vector3)My.Quaternion.Rotate(Planet.Axis, Vector3.UnitZ, SATURN_OBLIQUITY - TRITON_NEPTUNE_OBLIQUITY);
                    Moon.RotateComposition(-Vector3.UnitZ, TRITON_NEPTUNE_OBLIQUITY, MoonAxis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon2 = new Ellipsoid(new Vector3(0, 0, 5f), 0.04f, 1, 1.1f, 1, PRECISEMENT/4, tNereid, GraphicsDevice); //Nereid
                    Moon2.RotateComposition(-Vector3.UnitZ, NEPTUNE_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
                    Moon3 = new Sphere(new Vector3(0, 0, 2f), 0.05f, PRECISEMENT/4, tProteus, GraphicsDevice); //Proteus
                    Moon3.RotateComposition(-Vector3.UnitZ, NEPTUNE_OBLIQUITY, Planet.Axis, -(float)randomAngle.NextDouble() * MathHelper.Pi);

                    Reset(); break;
            }
        }
示例#2
0
 //Is called from two places in code
 void Earth_Init()
 {
     Planet = new Sphere(Vector3.Zero, 1.5f, PRECISEMENT, tEarth, GraphicsDevice);
     Planet.Rotate(-Vector3.UnitZ, EARTH_OBLIQUITY);
     Moon = new Sphere(new Vector3(3.5f, 0, 0), 0.25f, PRECISEMENT / 2+2, tMoon, GraphicsDevice);
     MoonAxis = (Vector3)My.Quaternion.Rotate(Planet.Axis, Vector3.UnitZ, EARTH_OBLIQUITY - MOON_EARTH_OBLIQUITY);
     Moon.RotateComposition(-Vector3.UnitZ, MOON_EARTH_OBLIQUITY, MoonAxis, -(float)randomAngle.NextDouble() * MathHelper.Pi);
 }