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); }
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); }
public SolarSystem(Vector3 Position) : base() { Body.CreateUVSphere(64, 64, 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(starColors[MyGame.random.Next(starColors.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, 1.0f); this.Transforms = new ScalePositionRotation( (float)(0.04 + 0.06 * MyGame.random.NextDouble()) , Position , Matrix.CreateFromAxisAngle(RotationAxis, RotationTime)); Mass = 100.0f * (float)(4.0 / 3.0 * Math.PI * Math.Pow(Transforms.Scale, 3.0)); //Initialize the glow int glowSpikes = MyGame.random.Next(25, 50); Glow = new VertexPositionColor[1 + glowSpikes * 2]; GlowIndex = new int[glowSpikes * 9]; Glow[0] = new VertexPositionColor(Vector3.Zero, new Color(Color.White, 0.0f)); for (int i = 0; i < glowSpikes; i++) { Glow[1 + i] = new VertexPositionColor( new Vector3((float)Math.Sin(i * MathHelper.TwoPi / glowSpikes) , (float)Math.Cos(i * MathHelper.TwoPi / glowSpikes) , (float)MyGame.random.NextDouble() * MathHelper.TwoPi) , new Color(StaticNoise[MyGame.random.Next(StaticNoise.Length)] , 0.1f + 0.15f * (float)MyGame.random.NextDouble())); GlowIndex[i * 9] = 0; GlowIndex[i * 9 + 1] = 1 + i; GlowIndex[i * 9 + 2] = 2 + i; Glow[1 + glowSpikes + i] = new VertexPositionColor( Glow[1 + i].Position * (2.0f + 3.0f * (float)MyGame.random.NextDouble()) , new Color(Glow[1 + i].Color, 0.0f)); Glow[1 + glowSpikes + i].Position.Z = Glow[1 + i].Position.Z; GlowIndex[i * 9 + 3] = 1 + i; GlowIndex[i * 9 + 4] = 1 + glowSpikes + i; GlowIndex[i * 9 + 5] = 2 + glowSpikes + i; GlowIndex[i * 9 + 6] = 1 + i; GlowIndex[i * 9 + 7] = 2 + glowSpikes + i; GlowIndex[i * 9 + 8] = 2 + i; } GlowIndex[(glowSpikes - 1) * 9 + 2] = 1; GlowIndex[(glowSpikes - 1) * 9 + 5] = 1 + glowSpikes; GlowIndex[(glowSpikes - 1) * 9 + 7] = 1 + glowSpikes; GlowIndex[(glowSpikes - 1) * 9 + 8] = 1; GlowDeclaration = new VertexDeclaration(MyGame.graphics.GraphicsDevice, VertexPositionColor.VertexElements); }
public Nebula(Vector3 Position) : 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); ColorMap = new Texture2D(MyGame.graphics.GraphicsDevice, 5, 5); ColorMap.SetData <Color>(StaticNoise); RotationAxis = Manager.GetRandomNormal(); RotationTime = (float)MyGame.random.NextDouble(); Bounds = new BoundingSphere(Position, 100.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 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); }