public Galaxy(Vector3 Position) : base() { Body.CreateUVSphere(32, 32, out ModelVertices, out ModelIndices); effect = Manager.TexturedEffect; GalaxyTexture = Manager.GeneratePerlinNoise(MyGame.random.Next(10, 25)); GalaxyTexture = Manager.SpiralWarp(GalaxyTexture); Color[] colorScheme = Manager.GenerateStaticNoise(5, 5); ColorMap = new Texture2D(MyGame.graphics.GraphicsDevice , 5 , 5); ColorMap.SetData <Color>(colorScheme); RotationAxis = Manager.GetRandomNormal(); RotationTime = (float)MyGame.random.NextDouble(); Bounds = new BoundingSphere(Position, 10000.0f); this.Transforms = new ScalePositionRotation( 100.0f , Position , Matrix.CreateFromAxisAngle(RotationAxis, RotationTime)); Mass = 1000.0f * (float)(4.0 / 3.0 * Math.PI * Math.Pow(Transforms.Scale, 3.0)); }
public Background() { //Initialize the Grid int xCoord = -127; for (int i = 0; i < 255; i++) { Lines[i * 3] = new VertexPositionColor( new Vector3(xCoord, 0, -127) , new Color(Color.MidnightBlue, 0.0f)); Lines[i * 3 + 1] = new VertexPositionColor( new Vector3(xCoord, 0, 0) , new Color(Color.DeepSkyBlue , 1.0f - Math.Abs(xCoord * 2.0f) / 255.0f)); Lines[i * 3 + 2] = new VertexPositionColor( new Vector3(xCoord, 0, 127) , new Color(Color.DodgerBlue, 0.0f)); xCoord++; } for (int i = 255; i < 510; i++) { Lines[i * 3] = new VertexPositionColor( new Vector3(-127, 0, xCoord) , new Color(Color.DarkBlue, 0.0f)); Lines[i * 3 + 1] = new VertexPositionColor( new Vector3(0, 0, xCoord) , new Color(Color.Blue , 1.0f - Math.Abs(xCoord * 2.0f) / 255f)); Lines[i * 3 + 2] = new VertexPositionColor( new Vector3(127, 0, xCoord) , new Color(Color.LightBlue, 0.0f)); xCoord--; } GridDeclaration = new VertexDeclaration(MyGame.graphics.GraphicsDevice, VertexPositionColor.VertexElements); BackgroundDeclaration = new VertexDeclaration(MyGame.graphics.GraphicsDevice, VertexPositionColorTexture.VertexElements); StarMap = MyGame.content.Load <Texture2D>("Textures\\Stars"); //Initialize the Stars RefreshBackground(10000); //Initialize the Skybox int width = 32; int height = 32; SkyTexture1 = Manager.GeneratePerlinNoise(MyGame.random.Next(width / 2, (width + height) / 2)); SkyTexture1 = Manager.SphericalWrap(SkyTexture1); SkyTexture2 = Manager.GeneratePerlinNoise(MyGame.random.Next(width / 2, (width + height) / 2)); SkyTexture2 = Manager.SphericalWrap(SkyTexture2); TransparencyThreshold = 0.3f + 0.1f * (float)MyGame.random.NextDouble(); SkyBox = new VertexPositionColorTexture[width * height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { SkyBox[x + y * width] = new VertexPositionColorTexture( new Vector3((float)Math.Cos((double)x / (width - 1.0) * 2.0 * Math.PI) * (float)Math.Sin((double)y / (height - 1.0) * Math.PI) , -(float)Math.Cos((double)y / (height - 1.0) * Math.PI) , (float)(Math.Sin((double)x / (width - 1.0) * 2.0 * Math.PI)) * (float)Math.Sin((double)y / (height - 1.0) * Math.PI)) , Color.White , new Vector2((float)x / (width - 1.0f), (float)y / (height - 1.0f))); } } int counter = 0; SkyBoxIndexBuffer = new int[6 * (width - 1) * (height - 1)]; for (int x = 0; x < width - 1; x++) { for (int y = 0; y < height - 1; y++) { SkyBoxIndexBuffer[counter++] = x + y * width; SkyBoxIndexBuffer[counter++] = x + 1 + (y + 1) * width; SkyBoxIndexBuffer[counter++] = x + 1 + y * width; SkyBoxIndexBuffer[counter++] = x + y * width; SkyBoxIndexBuffer[counter++] = x + (y + 1) * width; SkyBoxIndexBuffer[counter++] = x + 1 + (y + 1) * width; } } //Set the colors ColorScheme1 = Manager.GenerateStaticNoise(5, 5); ColorScheme2 = Manager.GenerateStaticNoise(5, 5); }