예제 #1
0
파일: Planet.cs 프로젝트: gbohnen/GDD4000
        public Planet(Planets key, Model model)
        {
            PlanetData data = PlanetaryConstants.GetPlanet(key);

            period             = data.Period;
            rotationalVelocity = data.AngularPeriod;
            diameter           = data.Diameter;
            distanceFromSol    = data.OrbitalRadius;
            tiltDegrees        = data.AxialTilt;

            ident = key;
        }
예제 #2
0
        public void DrawMoon(Planets planet, Planet parent, Matrix world, Matrix projection, Matrix view, string technique, float timer)
        {
            PlanetData data = PlanetaryConstants.GetPlanet(planet);

            Matrix translate;
            Matrix scale;
            Matrix localRotation;
            Matrix globalRotation;

            // create local values
            translate      = Matrix.CreateTranslation(new Vector3(parent.Scale * 2, 0, 0));
            scale          = Matrix.CreateScale(data.Diameter);
            globalRotation = Matrix.CreateRotationY(timer / data.Period);
            localRotation  = Matrix.CreateRotationZ(MathHelper.ToRadians(parent.AxialTilt));

            world *= scale;
            world *= localRotation;
            world *= translate;
            world *= globalRotation;

            // match parent values
            translate      = Matrix.CreateTranslation(new Vector3(parent.DistanceFromSol, 0, 0));
            globalRotation = Matrix.CreateRotationY(timer / parent.Period);

            // apply values
            world *= translate;
            world *= globalRotation;

            Matrix[] transforms = new Matrix[planetModel.Bones.Count];
            planetModel.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in planetModel.Meshes)
            {
                foreach (Effect effect in mesh.Effects)
                {
                    effect.CurrentTechnique = Game1.perlinNoiseEffect.Techniques[technique];
                    effect.Parameters["World"].SetValue(world);
                    effect.Parameters["View"].SetValue(view);
                    effect.Parameters["Projection"].SetValue(projection);
                }
                mesh.Draw();
            }
        }