Exemplo n.º 1
0
        public Solsystem()
        {
            graphics = new GraphicsDeviceManager(this);
                Content.RootDirectory = "Content";

                input = new InputHandler(this);
                this.Components.Add(input);

                camera = new Camera(this);
                this.Components.Add(camera);

                //                          Name,     Model,  Scale,       DistanceFromSun,                 RS,      OS,    moonCount
                planetArray[0] = new Planet("Mercury", null, scaleMercury, new Vector3(20.0f, 0.0f, 0.0f), 0.0001f, 1.0000f, 0);
                planetArray[1] = new Planet("Venus", null, scaleVenus, new Vector3(40.0f, 0.0f, 0.0f), 0.4f, 0.9f, 0);

                planetArray[2] = new Planet("Earth", null, scaleTerra, new Vector3(60.0f, 0.0f, 0.0f), 0.06f, 0.8f, 1);
                planetArray[2].MoonArray[0] = new Moon("The Moon", 0.2f, new Vector3(4.0f, 0.0f, 0.0f), 0.1f, 0.1f);

                planetArray[3] = new Planet("Mars", null, scaleMars, new Vector3(80.0f, 0.0f, 0.0f), 0.4f, 0.7f, 2);
                planetArray[3].MoonArray[0] = new Moon("Deimos", 0.2f, new Vector3(4.0f, 0.0f, 0.0f), 0.3f, 2.0f);
                planetArray[3].MoonArray[1] = new Moon("Phobos", 0.2f, new Vector3(8.0f, 0.0f, 0.0f), 0.1f, 0.1f);

                planetArray[4] = new Planet("Jupiter", null, scaleJupiter, new Vector3(100.0f, 0.0f, 0.0f), 0.4f, 0.6f, 4);
                planetArray[4].MoonArray[0] = new Moon("Lo", 0.2f, new Vector3(4.0f, 0.0f, 0.0f), 0.2f, 1.0f);
                planetArray[4].MoonArray[1] = new Moon("Europa", 0.2f, new Vector3(8.0f, 0.0f, 0.0f), 0.9f, 0.2f);
                planetArray[4].MoonArray[2] = new Moon("Genymede", 0.2f, new Vector3(12.0f, 0.0f, 0.0f), 0.5f, 0.7f);
                planetArray[4].MoonArray[3] = new Moon("Callisto", 0.2f, new Vector3(16.0f, 0.0f, 0.0f), 1.2f, 0.1f);

                planetArray[5] = new Planet("Saturn", null, scaleSaturn, new Vector3(120.0f, 0.0f, 0.0f), 0.4f, 0.5f, 9);
                planetArray[5].MoonArray[0] = new Moon("Mimas", 0.2f, new Vector3(4.0f, 0.0f, 0.0f), 0.1f, 0.1f);
                planetArray[5].MoonArray[1] = new Moon("Enceladus", 0.2f, new Vector3(8.0f, 0.0f, 0.0f), 0.2f, 0.2f);
                planetArray[5].MoonArray[2] = new Moon("Tethys", 0.2f, new Vector3(12.0f, 0.0f, 0.0f), 0.4f, 0.3f);
                planetArray[5].MoonArray[3] = new Moon("Dione", 0.2f, new Vector3(16.0f, 0.0f, 0.0f), 0.6f, 0.4f);
                planetArray[5].MoonArray[4] = new Moon("Rhea", 0.2f, new Vector3(20.0f, 0.0f, 0.0f), 0.8f, 0.5f);
                planetArray[5].MoonArray[5] = new Moon("Titan", 0.2f, new Vector3(24.0f, 0.0f, 0.0f), 1.0f, 0.6f);
                planetArray[5].MoonArray[6] = new Moon("Hyperion", 0.2f, new Vector3(28.0f, 0.0f, 0.0f), 1.2f, 0.7f);
                planetArray[5].MoonArray[7] = new Moon("Lapetus", 0.2f, new Vector3(32.0f, 0.0f, 0.0f), 1.4f, 0.8f);
                planetArray[5].MoonArray[8] = new Moon("Phoebe", 0.2f, new Vector3(36.0f, 0.0f, 0.0f), 1.6f, 0.9f);

                planetArray[6] = new Planet("Uranus", null, scaleUranus, new Vector3(140.0f, 0.0f, 0.0f), 0.4f, 0.4f, 5);
                planetArray[6].MoonArray[0] = new Moon("Miranda", 0.2f, new Vector3(8.0f, 0.0f, 0.0f), 0.4f, 0.5f);
                planetArray[6].MoonArray[1] = new Moon("Ariel", 0.2f, new Vector3(12.0f, 0.0f, 0.0f), 0.6f, 0.3f);
                planetArray[6].MoonArray[2] = new Moon("Umbriel", 0.2f, new Vector3(16.0f, 0.0f, 0.0f), 0.8f, 0.6f);
                planetArray[6].MoonArray[3] = new Moon("Titania", 0.2f, new Vector3(20.0f, 0.0f, 0.0f), 1.0f, 0.1f);
                planetArray[6].MoonArray[4] = new Moon("Oberon", 0.2f, new Vector3(24.0f, 0.0f, 0.0f), 1.2f, 0.4f);

                planetArray[7] = new Planet("Neptune", null, scaleNeptune, new Vector3(160.0f, 0.0f, 0.0f), 0.4f, 0.3f, 3);
                planetArray[7].MoonArray[0] = new Moon("Proteus", 0.2f, new Vector3(4.0f, 0.0f, 0.0f), 0.2f, 0.5f);
                planetArray[7].MoonArray[1] = new Moon("Triton", 0.2f, new Vector3(8.0f, 0.0f, 0.0f), 0.4f, 0.2f);
                planetArray[7].MoonArray[2] = new Moon("Nereid", 0.2f, new Vector3(12.0f, 0.0f, 0.0f), 0.6f, 1.0f);

                this.IsFixedTimeStep = true;
        }
Exemplo n.º 2
0
        private void DrawPlanet(GameTime gameTime, Planet planet)
        {
            Matrix matRotateY, matScale, matOrbTranslation, matOrbRotation;
                Matrix _world = matrixStrack.Peek();

                matScale = Matrix.CreateScale(planet.PlanetScale[0] / SUN_MASS, planet.PlanetScale[1] / SUN_MASS, planet.PlanetScale[0] / SUN_MASS);

                matRotateY = Matrix.CreateRotationY(planet.PlanetRotY);
                planet.PlanetRotY += (float)gameTime.ElapsedGameTime.Milliseconds / 5000.0f;
                planet.PlanetRotY = planet.PlanetRotY % (float)(2 * Math.PI);

                matOrbTranslation = Matrix.CreateTranslation(planet.PlanetDistanceToSun);
                planet.PlanetOrbitY += (planet.PlanetOrbitSpeed / 60);
                planet.PlanetOrbitY = planet.PlanetOrbitY % (float)(2 * Math.PI);
                matOrbRotation = Matrix.CreateRotationY(planet.PlanetOrbitY);

                world = matScale * matRotateY * matOrbTranslation * matOrbRotation * _world;
                matrixStrack.Push(world);

                effect.World = world;

                planet.PlanetPosition = Matrix.Invert(world).Translation;
                planet.PlanetModel.Draw(world, camera.View, camera.Projection);
        }