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 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 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 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)); }