Exemplo n.º 1
0
        public Planet(Vector3 Position, float Scale, float ParentMass, Vector3 OrbitalPlaneNormal)
            : base()
        {
            Body.CreateUVSphere(32, 32, out ModelVertices, out ModelIndices);
            effect = Manager.TexturedEffect;

            NoiseMap = Manager.WrappedNoiseTextures[MyGame.random.Next(Manager.WrappedNoiseTextures.Length)];
            Color[] StaticNoise = Manager.GenerateStaticNoise(5, 5);
            for (int i = 0; i < StaticNoise.Length; i++)
            {
                StaticNoise[i] = Color.Lerp(planetColors[MyGame.random.Next(planetColors.Length)]
                                            , StaticNoise[i]
                                            , 0.1f * (float)MyGame.random.NextDouble());
            }
            ColorMap = new Texture2D(MyGame.graphics.GraphicsDevice, 5, 5);
            ColorMap.SetData <Color>(StaticNoise);

            RotationAxis    = Manager.GetRandomNormal();
            RotationTime    = (float)MyGame.random.NextDouble();
            Bounds          = new BoundingSphere(Position, 2.0f * Scale);
            this.Transforms = new ScalePositionRotation(
                Scale
                , Position
                , Matrix.CreateFromAxisAngle(RotationAxis, RotationTime));
            Mass = 10.0f * (float)(4.0 / 3.0 * Math.PI * Math.Pow(Transforms.Scale, 3.0));

            this.Velocity = Body.GetRandomInitialOrbitVelocity(Position, OrbitalPlaneNormal, ParentMass, Mass);
        }
Exemplo n.º 2
0
        public Moon(Vector3 Position, float Scale, float ParentMass)
            : base()
        {
            Body.CreateUVSphere(16, 16, out ModelVertices, out ModelIndices);
            effect = Manager.TexturedEffect;

            Color[] StaticNoise = Manager.GenerateStaticNoise(5, 5);
            NoiseMap = new Texture2D(MyGame.graphics.GraphicsDevice, 5, 5);
            NoiseMap.SetData <Color>(StaticNoise);
            NoiseMap    = Manager.SphericalWrap(NoiseMap);
            StaticNoise = Manager.GenerateStaticNoise(5, 5);
            ColorMap    = new Texture2D(MyGame.graphics.GraphicsDevice, 5, 5);
            ColorMap.SetData <Color>(StaticNoise);

            RotationAxis    = Manager.GetRandomNormal();
            RotationTime    = (float)MyGame.random.NextDouble();
            Bounds          = new BoundingSphere(Position, Scale);
            this.Transforms = new ScalePositionRotation(
                Scale
                , Position
                , Matrix.CreateFromAxisAngle(RotationAxis, RotationTime));
            Mass = (float)(4.0 / 3.0 * Math.PI * Math.Pow(Transforms.Scale, 3.0));

            //Set the initial velocity
            Velocity = Body.GetRandomInitialOrbitVelocity(Transforms.Position, null
                                                          , ParentMass, Mass);
        }
Exemplo n.º 3
0
        private Asteroid(Vector3 Position, float Scale, Vector3 OrbitalPlaneNormal, float ParentMass)
            : base()
        {
            AsteroidVertices = null;

            //Create a unique asteroid Model
            //First establish the 6 Vertices of the tetrahedron
            Vertices.Add(new Vertex(new Vector3(0, 0.5f + (float)MyGame.random.NextDouble(), 0), 0));
            Vertices.Add(new Vertex(new Vector3(0.5f + (float)MyGame.random.NextDouble(), 0, 0), 1));
            Vertices.Add(new Vertex(new Vector3(0, 0, 0.5f + (float)MyGame.random.NextDouble()), 2));
            Vertices.Add(new Vertex(new Vector3(-0.5f - (float)MyGame.random.NextDouble(), 0, 0), 3));
            Vertices.Add(new Vertex(new Vector3(0, 0, -0.5f - (float)MyGame.random.NextDouble()), 4));
            Vertices.Add(new Vertex(new Vector3(0, -0.5f - (float)MyGame.random.NextDouble(), 0), 5));
            //Next establish the 12 Edges of the tetrahedron
            Edges.Add(new Edge(Vertices[0], Vertices[1]));
            Edges.Add(new Edge(Vertices[0], Vertices[2]));
            Edges.Add(new Edge(Vertices[0], Vertices[3]));
            Edges.Add(new Edge(Vertices[0], Vertices[4]));
            Edges.Add(new Edge(Vertices[1], Vertices[2]));
            Edges.Add(new Edge(Vertices[2], Vertices[3]));
            Edges.Add(new Edge(Vertices[3], Vertices[4]));
            Edges.Add(new Edge(Vertices[4], Vertices[1]));
            Edges.Add(new Edge(Vertices[1], Vertices[5]));
            Edges.Add(new Edge(Vertices[2], Vertices[5]));
            Edges.Add(new Edge(Vertices[3], Vertices[5]));
            Edges.Add(new Edge(Vertices[4], Vertices[5]));
            //Next establish the 8 Faces/Triangles of the tetrahedron
            Triangles.Add(new Triangle(Edges[0], Edges[1], Edges[4]));
            Triangles.Add(new Triangle(Edges[1], Edges[2], Edges[5]));
            Triangles.Add(new Triangle(Edges[2], Edges[3], Edges[6]));
            Triangles.Add(new Triangle(Edges[3], Edges[0], Edges[7]));
            Triangles.Add(new Triangle(Edges[8], Edges[9], Edges[4]));
            Triangles.Add(new Triangle(Edges[9], Edges[10], Edges[5]));
            Triangles.Add(new Triangle(Edges[10], Edges[11], Edges[6]));
            Triangles.Add(new Triangle(Edges[11], Edges[8], Edges[7]));

            int DetailLevel = MyGame.random.Next(4, 5);

            for (int i = 0; i < DetailLevel; i++)
            {
                IncreaseVertexCount();
            }

            ConvertPartsToPrimitive(Color.Brown);
            ModelDeclaration = new VertexDeclaration(MyGame.graphics.GraphicsDevice, VertexPositionNormalColor.VertexElements);

            RotationAxis    = Manager.GetRandomNormal();
            RotationTime    = (float)MyGame.random.NextDouble();
            Bounds          = new BoundingSphere(Position, Scale);
            this.Transforms = new ScalePositionRotation(
                Scale
                , Position
                , Matrix.CreateFromAxisAngle(RotationAxis, RotationTime));
            Mass = (float)(4.0 / 3.0 * Math.PI * Math.Pow(Transforms.Scale, 3.0));

            this.Velocity = Body.GetRandomInitialOrbitVelocity(Position, OrbitalPlaneNormal, ParentMass, Mass);
        }