private void SetUpGameWorld() { //AtmosphericScatteringGround float radius = 6000; earth = new Planet("earth", new Vector3(0, 0, 0), NoiseGenerator.FastPlanet(radius), EffectLoader.LoadSM5Effect("flatshaded").Clone(), radius, Color.DarkSeaGreen.ChangeTone(-100), Color.SaddleBrown, Color.SaddleBrown.ChangeTone(-10), 0); //earth.AddAtmosphere(); SystemCore.GameObjectManager.AddAndInitialiseGameObject(earth); mouseCamera.SetPositionAndLook(new Vector3(0, radius + 200, 0), (float)Math.PI, (float)-Math.PI / 5); duneBuggyOne = new DuneBuggy(PlayerIndex.One, Color.Red, new Vector3(0, radius + 100, 0)); spaceShipOne = new SpaceShip(PlayerIndex.One, Color.Red, new Vector3(0, radius + 200, 0)); field = new GravitationalField(new InfiniteForceFieldShape(), Vector3.Zero.ToBepuVector(), 100000 * radius, 100); SystemCore.PhysicsSimulation.Add(field); spaceShipOne.Activate(); duneBuggyCamera = new DuneBuggyPlanetCamera(duneBuggyOne); spaceShipCamera = new SpaceShipCamera(spaceShipOne); }
int BuildPlanetSimulation(Space space) { space.ForceUpdater.Gravity = Vector3.Zero; var planet = new Sphere(new Vector3(0, 0, 0), 30); space.Add(planet); var field = new GravitationalField(new InfiniteForceFieldShape(), planet.Position, 66730 / 2f, 100); space.Add(field); //Drop the "meteorites" on the planet. Entity toAdd; #if WINDOWS //By pre-allocating a bunch of box-box pair handlers, the simulation will avoid having to allocate new ones at runtime. NarrowPhaseHelper.Factories.BoxBox.EnsureCount(30000); int numColumns = 25; int numRows = 25; int numHigh = 25; #else NarrowPhaseHelper.Factories.BoxBox.EnsureCount(2000); int numColumns = 10; int numRows = 10; int numHigh = 10; #endif float separation = 5; for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { for (int k = 0; k < numHigh; k++) { toAdd = new Box(new Vector3(separation * i - numRows * separation / 2, 40 + k * separation, separation * j - numColumns * separation / 2), 1f, 1f, 1f, 5); toAdd.LinearVelocity = new Vector3(30, 0, 0); toAdd.LinearDamping = 0; toAdd.AngularDamping = 0; space.Add(toAdd); } } } #if WINDOWS return(3000); #else return(1000); #endif }
/// <summary> /// Constructs a new demo. /// </summary> /// <param name="game">Game owning this demo.</param> public PlanetDemo(DemosGame game) : base(game) { Space.ForceUpdater.Gravity = Vector3.Zero; //By pre-allocating a bunch of box-box pair handlers, the simulation will avoid having to allocate new ones at runtime. NarrowPhaseHelper.Factories.BoxBox.EnsureCount(1000); planetPosition = new Vector3(0, 0, 0); var planet = new Sphere(planetPosition, 30); Space.Add(planet); var field = new GravitationalField(new InfiniteForceFieldShape(), planet.Position, 66730 / 2, 100); Space.Add(field); //Drop the "meteorites" on the planet. Entity toAdd; int numColumns = 10; int numRows = 10; int numHigh = 10; Fix64 separation = 5; for (int i = 0; i < numRows; i++) { for (int j = 0; j < numColumns; j++) { for (int k = 0; k < numHigh; k++) { toAdd = new Box(new Vector3(separation * i - numRows * separation / 2, 40 + k * separation, separation * j - numColumns * separation / 2), 1, 1, 1, 5); toAdd.LinearVelocity = new Vector3(30, 0, 0); toAdd.LinearDamping = 0; toAdd.AngularDamping = 0; Space.Add(toAdd); } } } game.Camera.Position = new Vector3(0, 0, 150); }