public void TestGetChunksInRange_FindChunksDown() { var radius = new Vector3(200, 200, 200); var tree = new SimpleWorldOctree(radius); // Using dummy octree TW.Graphics.SpectaterCamera.FarClip = 1000; engine.AddSimulator(new WorldRenderingSimulator()); engine.AddSimulator(new BasicSimulator(delegate { Vector3 campos = TW.Graphics.Camera.ViewInverse.xna().Translation.dx(); var chunks = WorldOctreeExtensions.GetChunksInRange(tree, campos, 100, 200, 2); foreach (var c in chunks) { TW.Graphics.LineManager3D.AddCenteredBox(tree.GetChunkCenter(c), tree.GetChunkRadius(c).MaxComponent() * 2, new Color4(1, 1, 0)); } var inChunk = WorldOctreeExtensions.FindChunksDown(tree, 2, delegate(ChunkCoordinate c) { BoundingBox chunkBoundingBox = tree.GetChunkBoundingBox(c); Microsoft.Xna.Framework.ContainmentType containmentType = chunkBoundingBox.xna().Contains(campos.xna()); return(containmentType == ContainmentType.Contains); }); if (inChunk.Any()) { var bb = tree.GetChunkBoundingBox(inChunk.First()); bb.Minimum += MathHelper.One * 0.01f; bb.Maximum -= MathHelper.One * 0.01f; TW.Graphics.LineManager3D.AddBox(bb, new Color4(1, 0.5f, 0)); } TW.Graphics.LineManager3D.AddCenteredBox(new Vector3(), radius.MaxComponent() * 2, new Color4(0, 0, 0)); })); }
public void Initialize(TWEngine game) { game.AddSimulator(new BarrelShooterSimulator()); game.AddSimulator(new PhysXSimulator()); game.AddSimulator(new WorldRenderingSimulator()); game.AddSimulator(new PhysXDebugRendererSimulator()); }
private Level setupRendering() { var level = createLevel(); var cam = TW.Data.Get <CameraInfo>(); cam.Mode = CameraInfo.CameraMode.ThirdPerson; var camEntity = new Entity(); cam.ThirdPersonCameraTarget = camEntity; var phys = new ClusterPhysicsService(level); var controller = new ClusterFlightController(TW.Graphics.Keyboard); engine.AddSimulator(new BasicSimulator(() => { controller.SimulateFlightStep(cameraIsland, cameraIsland.GetForward(), cameraIsland.Position); camEntity.WorldMatrix = Matrix.Translation( cameraIsland.GetIslandsInCluster().Aggregate(new Vector3(), (acc, el) => acc + el.Position) / cameraIsland.GetIslandsInCluster().Count()); phys.UpdateClusterMovement(); })); engine.AddSimulator(new ThirdPersonCameraSimulator()); //engine.AddSimulator(new LoadLevelSimulator(level)); engine.AddSimulator(new WorldRenderingSimulator()); return(level); }
public void Initialize(TWEngine game) { game.AddSimulator(new PhysXSimulator()); game.AddSimulator(new WorldRenderingSimulator()); game.AddSimulator(new PhysXDebugRendererSimulator()); var e = new Engine.WorldRendering.Entity { Mesh = MeshFactory.Load("Core\\TileSet\\ts001sg001"), Visible = true, Solid = true, WorldMatrix = Matrix.Translation(0, 5, 0) }; e = new Engine.WorldRendering.Entity { Mesh = MeshFactory.Load("Core\\TileSet\\ts001sg001"), Visible = true, Solid = false, WorldMatrix = Matrix.Translation(0, 10, 0) }; e = new Engine.WorldRendering.Entity { Mesh = MeshFactory.Load("Core\\Barrel01"), Visible = true, Solid = true, Static = false, WorldMatrix = Matrix.Translation(0, 20, 0) }; }
public void AddSimulatorsToEngine(TWEngine engine) { engine.AddSimulator(updateConnectedClients, "Server-UpdateConnectedClientsSim"); engine.AddSimulator(processClientInputs, "Server-PlayerInputProcessingSim"); engine.AddSimulator(WorldSimulationService, "Server-WorldSimulationSim"); engine.AddSimulator(sendGameStateUpdates, "Server-SendStateSim"); engine.AddSimulator(clearStateChangesSimulator, "Server-ClearChangesSim"); }
public void TestWriteDebugText() { engine.AddSimulator(new BasicSimulator(delegate { //TW.Debug.WriteText("Some text"); // This text is added to a text output box, and reset after each frame (like the linemanager) throw new NotImplementedException(); })); }
public void Setup() { engine.Initialize(); engine.AddSimulator(new WorldRenderingSimulator()); var l = TW.Graphics.AcquireRenderer().CreateDirectionalLight(); l.LightDirection = SlimDX.Vector3.Normalize(new SlimDX.Vector3(-1, -5, -1)); }
public void TestInput() { var button = TW.Data.Get<InputFactory>().GetButton("moveForward"); engine.AddSimulator(new InputSimulator()); engine.AddSimulator(new BasicSimulator(delegate { if (button.Down) TW.Graphics.LineManager3D.AddLine(new Vector3(), new Vector3(1, 1, 1), new Color4(1, 0, 0)); })); }
public IRenderingTester(TWEngine engine, IActionScheduler scheduler, ParticlesBoxRenderer particleBoxRenderer) { this.engine = engine; this.scheduler = scheduler; this.particleBoxRenderer = particleBoxRenderer; scheduler.SetCurrentTime(TW.Graphics.TotalRunTime); engine.AddSimulator(new BasicSimulator(update)); engine.AddSimulator(new WorldRenderingSimulator()); }
public void LoadIntoEngine(TWEngine engine) { engine.AddSimulator(PlayerMovementSimulator); engine.AddSimulator(gameSimulationService); engine.AddSimulator(PlayerCameraSimulator); engine.AddSimulator(ScatteredRenderingSimulator); //engine.AddSimulator(new AudioSimulator()); TW.Graphics.SpectaterCamera.FarClip = 2000; }
public void TestEngineUI() { var engine = new TWEngine(); engine.DontLoadPlugin = true; engine.Initialize(); engine.AddSimulator(new EngineUISimulator()); engine.AddSimulator(new WorldRenderingSimulator()); engine.Run(); }
public void TestProfiler() { var game = new TWEngine(); game.DontLoadPlugin = true; game.Initialize(); game.AddSimulator(new ProfilerSimulator()); game.AddSimulator(new WorldRenderingSimulator()); game.Run(); }
public void TestSimpleScript() { var ph = new Physical(); ph.Mesh = TW.Assets.LoadMesh("Core\\Crate01"); throw new NotImplementedException(); //var obj = new WorldObject(ph); //obj.Scripts.Add(new RotateOnTheSpotScript(new SimpleSimulationEngine())); engine.AddSimulator(new ScriptsSimulator()); engine.AddSimulator(new SkyMerchantRenderingSimulator()); engine.AddSimulator(new PhysicalSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); }
public void Setup() { engine = EngineFactory.CreateEngine(); consoleUi = new DeveloperConsoleUI(createCommandProvider()); var visible = true; consoleUi.Show(); engine.AddSimulator(new BasicSimulator(() => { if (TW.Graphics.Keyboard.IsKeyPressed(Key.Grave)) { visible = !visible; if (visible) { consoleUi.Show(); } else { consoleUi.Hide(); } } consoleUi.Update(); })); TW.Graphics.SpectaterCamera.EnableUserInput = false; }
public void RunExample() { thread = new Thread(simulationThread); thread.Start(); engine.AddSimulator(new BasicSimulator(simulateWrapper)); }
public ScenarioGame(GodGameOffline offline, TWEngine engine, Internal.Model.World world, TownCenterType townCenterType, TownCenterService townCenterService, MinerType minerType) { this.world = world; this.townCenterType = townCenterType; this.townCenterService = townCenterService; this.minerType = minerType; offline.AddSimulatorsToEngine(engine); int skipFrames = 0; var scenarioTasks = Run().GetEnumerator(); bool complete = false; engine.AddSimulator(() => { skipFrames--; if (skipFrames > 0) { return; } if (!scenarioTasks.MoveNext()) { complete = true; } if (complete) { return; } skipFrames = scenarioTasks.Current; }, "ScenarioSimulator"); }
public static void addCameraLightSimulator(TWEngine engine) { engine.AddSimulator(new BasicSimulator(() => { })); }
public void AddSimulatorsToEngine(TWEngine engine) { engine.AddSimulator(userInputProcessingService, "Client-UserInputProcessingSim"); engine.AddSimulator(sendPlayerInputs, "Client-PlayerInputsSendingSim"); engine.AddSimulator(applyServerStateChanges, "Client-applyServerStateChangesSim"); engine.AddSimulator(uiRenderingService, "Client-UIRenderingSim"); engine.AddSimulator(developerConsoleService, "Client-DevConsoleSim"); engine.AddSimulator(simpleWorldRenderer, "Client-WorldRenderingSim"); engine.AddSimulator(clearStateChangesSimulator, "Client-ClearChangesSim"); engine.AddSimulator(worldRenderingSimulator, "Client-EngineWorldRenderingSimulator"); }
public void TestRaycastEntity() { var game = new TWEngine(); game.DontLoadPlugin = true; game.Initialize(); var world = TW.Data.GetSingleton <Engine.WorldRendering.World>(); game.AddSimulator(new BasicSimulator(delegate { var rayPos = TW.Graphics.Camera.ViewInverse.xna().Translation.dx(); var rayDir = TW.Graphics.Camera.ViewInverse.xna().Forward.dx(); var ray = new Ray(rayPos, rayDir); var result = world.Raycast(ray); if (result.IsHit) { TW.Graphics.LineManager3D.AddTriangle(result.V1, result.V2, result.V3, new Color4(Color.Yellow)); } })); game.AddSimulator(new WorldRenderingSimulator()); new Engine.WorldRendering.Entity { Mesh = MeshFactory.Load("Core\\Barrel01"), Visible = true, Solid = true, Static = false, WorldMatrix = Matrix.Translation(0, 0.5f, 0) }; new Engine.WorldRendering.Entity { Mesh = MeshFactory.Load("Core\\Barrel01"), Visible = true, Solid = true, Static = false, WorldMatrix = Matrix.Translation(0, 0.5f, 1) }; game.Run(); }
public void InitializeEngine() { engine = EngineFactory.CreateEngine(); engine.DontLoadPlugin = true; engine.Initialize(); EngineFactory.Instance = new EngineContext(engine); engine.AddSimulator(new EngineUISimulator()); }
public void Setup() { engine = EngineFactory.CreateEngine(); toolSelectionMenu = new ToolSelectionMenu(); engine.AddSimulator(new BasicSimulator(() => { toolSelectionMenu.ProcessUserInput(); })); TW.Graphics.SpectaterCamera.EnableUserInput = false; }
public void TestAstarTerrain() { setup(); var terrain = TW.Data.GetSingleton <VoxelTerrain>(); var start = new Vector3(1, 40, 1); var end = new Vector3(5, 40, 5); List <VoxelBlock> path = null; VoxelTerrainTest.generateTerrain(1, 1); engine.AddSimulator(new BasicSimulator(delegate { if (TW.Graphics.Keyboard.IsKeyPressed(Key.T)) { VoxelBlock last; terrain.Raycast(TW.Data.GetSingleton <CameraInfo>().GetCenterScreenRay(), out last); start = terrain.GetPositionOf(last); } if (TW.Graphics.Keyboard.IsKeyPressed(Key.Y)) { VoxelBlock last; terrain.Raycast(TW.Data.GetSingleton <CameraInfo>().GetCenterScreenRay(), out last); end = terrain.GetPositionOf(last); } var star = new TerrainAStar(); path = star.findPath(terrain.GetVoxelAt(start), terrain.GetVoxelAt(end)); if (path != null) { drawPath(path.Select(voxel => terrain.GetPositionOf(voxel) + new Vector3(0.5f)).ToArray()); } })); engine.AddSimulator(new TerrainEditorSimulator()); engine.AddSimulator(new VoxelTerrainSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); engine.Run(); }
public void AddToEngine(TWEngine engine) { TW.Graphics.SpectaterCamera.MovementSpeed = 0.5f; TW.Graphics.AcquireRenderer().Wireframe = false; TW.Graphics.AcquireRenderer().CullMode = CullMode.Front; //foreach (var v in vertices) lines.AddCenteredBox(v * cellSize, cellSize * 0.2f, Color.OrangeRed.dx()); statsArea = new Textarea() { Position = new Vector2(10, 10), Size = new Vector2(300, 200) }; textarea = new Textarea() { Position = new Vector2(10, statsArea.Position.Y + statsArea.Size.Y), Size = new Vector2(200, 200) }; engine.AddSimulator(() => { updateRaycastInfo(); tryPlaceObject(); tryRemoveObject(); UpdateDirty(); drawRaycastInfo(); drawHermiteInfoForCube((RaycastedPoint / cellSize).ToFloored(), textarea); updateStatsArea(); }, "UserInput"); engine.AddSimulator(new WorldRenderingSimulator()); addLinesSimulator(engine, this.lines); engine.AddSimulator(CameraLightSimulator); }
public void TestIslandTool() { var tool = new IslandToolItem(createObjectsFactory(), new Random()); tool.OnSelected(); engine.AddSimulator(new BasicSimulator(tool.Update)); engine.AddSimulator(new BasicSimulator(() => TW.Data.Objects.OfType <IslandPart>().ForEach(i => i.FixPhysical()))); engine.AddSimulator(new PhysicalSimulator()); engine.AddSimulator(new WorldRenderingSimulator()); }
public void TestIslandGenerator() { initializeTW(); var generator = new IslandGenerator(); int seed = 1; var startShapes = generator.GetIslandBase(seed); var islandMesh = generator.GetIslandMesh(startShapes, seed); deferredRenderer.CreateMeshElement(islandMesh); engine.AddSimulator(new WorldRenderingSimulator()); }
public void TestPausingWrapper() { PausingWrapper wrapper = null; wrapper = new PausingWrapper(delegate { Console.WriteLine("Hello"); while (!TW.Graphics.Keyboard.IsKeyPressed(Key.Return)) { wrapper.Pause(); } }, new SimpleThreadFactory()); engine.AddSimulator(new BasicSimulator(wrapper.Execute)); }
public void Setup() { engine = EngineFactory.CreateEngine(); textBox = new DirectInputTextBox(); textarea = new Textarea(); textarea.Position = new Vector2(100, 100); engine.AddSimulator(new BasicSimulator(() => { textBox.ProcessUserInput(TW.Graphics.Keyboard); textarea.Text = textBox.Text; })); TW.Graphics.SpectaterCamera.EnableUserInput = false; }
public void TestPressKeys() { string txt = ""; engine.AddSimulator(new BasicSimulator(() => { var keys = TW.Graphics.Keyboard.PressedKeys; if (keys.Any()) { string directInputName = Enum.GetName(typeof(Key), keys.First()); txt = "RawKey: " + directInputName + " ----- Code: " + (uint)keys.First(); } textarea.Text = txt + "\nTextbox: " + textarea.Text; })); }
public void TestWalkAround() { var pos = new Vector3(); var island = createIsland(); var playerOnIslandMover = new PlayerSurfaceMover(ray => island.RaycastDetail(ProcUtilities.RaycastFace, ray).DistanceOrNull); // gameloop engine.AddSimulator(new BasicSimulator(() => { pos = playerOnIslandMover.ProcessUserMovement(pos); TW.Graphics.SpectaterCamera.CameraPosition = pos; drawFaces(island); })); engine.Run(); }
public void AddSimulatorsToEngine(TWEngine engine) { //engine.AddSimulator(updateConnectedClients, "Server-UpdateConnectedClientsSim"); //engine.AddSimulator(processClientInputs, "Server-PlayerInputProcessingSim"); //engine.AddSimulator(sendGameStateUpdates, "Server-SendStateSim"); //engine.AddSimulator(clearStateChangesSimulator, "Server-ClearChangesSim"); engine.AddSimulator(userInputProcessingService, "Client-UserInputProcessingSim"); engine.AddSimulator(WorldSimulationService, "Server-WorldSimulationSim"); //engine.AddSimulator(sendPlayerInputs, "Client-PlayerInputsSendingSim"); //engine.AddSimulator(applyServerStateChanges, "Client-applyServerStateChangesSim"); engine.AddSimulator(uiRenderingService, "Client-UIRenderingSim"); engine.AddSimulator(developerConsoleService, "Client-DevConsoleSim"); engine.AddSimulator(simpleWorldRenderer, "Client-WorldRenderingSim"); engine.AddSimulator(clearStateChangesSimulator, "Client-ClearChangesSim"); engine.AddSimulator(worldRenderingSimulator, "Client-EngineWorldRenderingSimulator"); }