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 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(); }
private void bootstrap() { config = TWConfig.Load(); config.Save(); if (config.RunTestUI) { runWinformsTestrunner(); return; } if (config.TestMode) { var obj = createTestClass(config.TestClass); runTestMethod(obj, config.TestMethod); return; } // Run engine! var engine = new TWEngine(); engine.Run(); }