public SolarSystem(int stars, int planets) { const double au = AstronomicalObject.Au; const double me = AstronomicalObject.Me; Bodies = new List <AstronomicalObject> { new AstronomicalObject(new Point3D(0, 0, 0), 10.9 * 2) /* sun */ { BodyName = stars == 1 ? "Gwiazda" : "Gwiazda A", Mass = 333_000 * me * Utils.GetNormalRandom(10, 2), Velocity = new Vector3D(0, 0, 0), Material = new DiffuseMaterial { DiffuseMap = SunTexture } } }; if (stars > 1) { var mass = 333_000 * AstronomicalObject.Me * Utils.GetNormalRandom(1, 0.2); var position = -AstronomicalObject.Au * 0.3; Bodies.Add(new AstronomicalObject(new Point3D(position, 0, 0), 10.9) /* sun */ { BodyName = "Gwiazda B", Mass = mass, Velocity = new Vector3D(0, 0, -GetVelocity(Math.Abs(position), Bodies[0].Mass + mass)) * 1.15, Material = new DiffuseMaterial { DiffuseMap = SunTexture } }); Bodies[0].Velocity = -Bodies[1].Velocity * mass / Bodies[0].Mass; } var centerMass = Bodies.Sum(body => body.Mass); for (var i = 1; i <= planets; i++) { var mass = Utils.GetNormalRandom(me * 2, me * 0.8); var position = new Point3D(Utils.GetNormalRandom(au * i * 0.7, au * 0.1), 0, 0); var velocity = GetVelocity(position.X, centerMass) * Utils.GetNormalRandom(1.1, 0.1); var a = Utils.GetNormalRandom(0, Math.PI * 0.05); Bodies.Add(new AstronomicalObject(position, mass / me * 5) { BodyName = $"Planeta {(char) (64 + i)}", Mass = mass, Velocity = new Vector3D(0, Math.Sin(a) * velocity, -Math.Cos(a) * velocity), Material = new DiffuseMaterial { DiffuseColor = Utils.GetRandomColor4() } }); } OrbitPrevPoints = new List <Point3D>(); OrbitBuilders = new List <LineBuilder>(); OrbitModels = new List <LineGeometryModel3D>(); foreach (var body in Bodies) { OrbitBuilders.Add(new LineBuilder()); OrbitModels.Add(new LineGeometryModel3D { Thickness = 0.5, Color = Colors.Yellow }); OrbitPrevPoints.Add(body.Position); } }