public void BlockSizesChangesCube() { var cube = CubeFactory.GetCubeWithDefaultFaces(3); AssertCubeBounds(new Vector3(-1.5f, -1.5f, -1.5f), new Vector3(1.5f, 1.5f, 1.5f), cube); }
static async Task Main(string[] args) { //setup DI _serviceProvider = DependencyBuilderClient.Configure(); //Parameters validation if (ArgumentValidationHelper.CheckParameters(args)) { var cube1 = CubeFactory.BuildCube(args[0], args[1], args[2], args[3], args[4]); var cube2 = CubeFactory.BuildCube(args[5], args[6], args[7], args[8], args[9]); //Process execution if ((cube1 != null) && (cube2 != null)) { var service = _serviceProvider.GetService <ICubeService>(); if (service.IsIntersection(cube1, cube2)) { ConsoleLogHelper.ShowInfoMessage($"Cubes intersect.", System.ConsoleColor.Green); var volumeIntersecion = service.VolumeIntersection(cube1, cube2); ConsoleLogHelper.ShowInfoMessage($"Intersected volume: {volumeIntersecion}", System.ConsoleColor.Green); } else { ConsoleLogHelper.ShowInfoMessage($"Cubes DON'T intersect.", System.ConsoleColor.Yellow); } } } Console.WriteLine(string.Empty); Console.WriteLine("Press any key to close the application..."); Console.ReadLine(); }
public void BlockSizesChangesCube() { var cube = CubeFactory.GetCube(3, 0, 0, 0); AssertCubeBounds(new Vector3(-3, -3, -3), new Vector3(3, 3, 3), cube); }
public void CubeAtOffset() { var cube = CubeFactory.GetCube(BlockSize, 1, 2, 0); AssertCubeBounds(new Vector3(1 - BlockSize, 2 - BlockSize, -BlockSize), new Vector3(1 + BlockSize, 2 + BlockSize, BlockSize), cube); }
/// <summary> /// _+ size__ /// | | /// | _ | /// | | /// |__- size_| /// </summary> public void CubeAtOrigin() { var cube = CubeFactory.GetCube(BlockSize, 0, 0, 0); AssertCubeBounds(new Vector3(-BlockSize, -BlockSize, -BlockSize), new Vector3(BlockSize, BlockSize, BlockSize), cube); }
/// <summary> /// _+ size /2__ /// | | /// | _ | /// | | /// |__- size /2_| /// </summary> public void CubeAtOrigin() { var cube = CubeFactory.GetCubeWithDefaultFaces(BlockSize); const float halfSize = BlockSize / 2f; AssertCubeBounds(new Vector3(-halfSize, -halfSize, -halfSize), new Vector3(halfSize, halfSize, halfSize), cube); }
public void CubeHasCorrectNumberOfVertices() { const int verticesInAFace = 6; const int facesInACube = 6; var cube = CubeFactory.GetCubeWithDefaultFaces(BlockSize); cube.Length.ShouldBe(verticesInAFace * facesInACube); }
public void BuildWorldObject(Coord2D mouseIsoFlatCoord, Coord2D mouseIsoCoord) { Coord3D mouseIsoCoord3D = new Coord3D(mouseIsoCoord, Altitude); if (BuildMode == BuildMode.Cube) { // Create cube and add it to the layer map. var cube = CubeFactory.CreateCurrentCube(mouseIsoFlatCoord, mouseIsoCoord3D); if (!LayerMap.ContainsKey(mouseIsoCoord3D)) { LayerMap.Add(mouseIsoCoord3D, cube); } // Deal with the walkable tile table. foreach (var coord in mouseIsoCoord.AdjacentCoords()) { // If there are no solid objects above us, if (!(LayerMap.ContainsKey(new Coord3D(mouseIsoCoord, Altitude + 1)) && LayerMap[new Coord3D(mouseIsoCoord, Altitude + 1)].IsSolid)) // not- contains key and sprite is solid { WalkableTileTable.Add(Altitude + 1, coord, mouseIsoCoord); } // Assuming the added cube is solid, the tile under us is no longer walkable. if (cube.IsSolid) { WalkableTileTable.Remove(Altitude, coord, mouseIsoCoord); } } } else if (BuildMode == BuildMode.Deco) { // Create deco and add it to the layer map. var deco = DecoFactory.CreateCurrentDeco(mouseIsoFlatCoord, mouseIsoCoord, Altitude); if (deco.OccupiedCoords.Any((c) => LayerMap.ContainsKey(c)) == false) { LayerMap.Add(mouseIsoCoord3D, deco); foreach (var coord in deco.OccupiedCoords) { if (coord != mouseIsoCoord3D) { LayerMap.Add(coord, new DecoReference(deco, mouseIsoCoord3D) { Coords = coord.To2D(), Altitude = coord.Z }); } foreach (var _coord in new Coord2D(coord.X, coord.Y).AdjacentCoords()) { // Assuming the added deco is solid, the tiles under us are no longer walkable. if (deco.IsSolid) { WalkableTileTable.Remove(Altitude, _coord, new Coord2D(coord.X, coord.Y)); } } } } } }
public DtoToEntitiesProfile() { CreateMap <CubeCoordinates, Cube>() .ConstructUsing((coord) => CubeFactory.Cube() .WithCenterCoordinates(coord.X, coord.Y, coord.Z) .WithDimension(coord.Dimension) .Build() ); }
public Block(GraphicsDevice graphicsDevice, IntPoint3D position) { this.graphicsDevice = graphicsDevice; Position = position.ToVector() * BlockSize; vertices = CubeFactory.GetCube(BlockSize, IntPoint3D.GetNeighbourPositions()); effect = new BasicEffect(graphicsDevice); }
public Block(GraphicsDevice graphicsDevice, int x, int y, int z) { this.graphicsDevice = graphicsDevice; var vertices = CubeFactory.GetCube(1, x, y, z); buffer = new VertexBuffer(graphicsDevice, typeof(VertexPositionColor), vertices.Length, BufferUsage.WriteOnly); buffer.SetData(vertices); effect = new BasicEffect(graphicsDevice) { World = Matrix.Identity }; }
public void with_collision() { // Arrange var cubeFactory = new CubeFactory(); var operations = CubeOperationsService.Instance; var cubeA = cubeFactory.Create(4, 4, 4, 4); var cubeB = cubeFactory.Create(5, 4, 4, 4); // Act var touch = operations.Collides(cubeA, cubeB); // Assert Assert.True(touch); }
public void If_Cubes_Are_Equal_Then_Intersection_Is_Equal_To_Volume() { var cube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(1) .Build(); //ACT var result = cube.Intersection(cube); //ASSERT Assert.AreEqual(GetCubeVolume(cube), result); }
public void without_collision() { // Arrange var cubeFactory = new CubeFactory(); var operations = CubeOperationsService.Instance; var cubeA = cubeFactory.Create(2, 3, 4, 3); var cubeB = cubeFactory.Create(10, 12, 15, 4); // Act var touch = operations.Collides(cubeA, cubeB); // Assert Assert.False(touch); }
public void no_intersect() { // Arrange var cubeFactory = new CubeFactory(); var operations = CubeOperationsService.Instance; var cubeA = cubeFactory.Create(2, 3, 4, 3); var cubeB = cubeFactory.Create(10, 12, 15, 4); // Act var value = operations.IntersectionVolumeWith(cubeA, cubeB); // Assert Assert.Equal(0, value); }
public void If_Cubes_Have_Same_Center_Then_Collide() { //ARRANGE var cube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(1) .Build(); //ACT var result = cube.Collides(cube); //ASSERT Assert.IsTrue(result); }
internal override void LeftClick() { if (!ViewModel.IsSubLevel) { ViewModel.CurrentMetadata = CubeMetadata; Selection = SelectionMode.Selected; DeselectAllButThis(); } else { Selection = SelectionMode.Active; CubeMetadata.ActiveFrames.Add(GetIndex()); DeactivateAllButThis(); } MapBuilder.GhostMarker.MorphImage(CubeFactory.CreateCurrentCube(Coord2D.Zero, Coord3D.Zero)); }
// Update is called once per frame void Update() { //Press F to make a random cube to randome position if (Input.GetKeyDown(KeyCode.F)) { Debug.Log(transform.position); type = Random.Range(1, 5); x = Random.Range(-47f, 45f); z = Random.Range(-20f, 23f); Vector3 pos = new Vector3(x, 4f, z); CubeFactory.MakeCube(type, pos, Quaternion.identity); cubeCount++; if (cubeCount == 10) { Debug.Log("You've spawned 10 cubes! wow"); } } }
public void If_Cubes_Dont_Touch_Then_Volume_Is_Zero() { var firstCube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(1) .Build(); var secondCube = CubeFactory .Cube() .WithCenterCoordinates(4, 0, 0) .WithDimension(1) .Build(); //ACT var result = firstCube.Intersection(secondCube); //ASSERT Assert.AreEqual(0, result); }
public void If_Cubes_Almost_Touch_Then_Not_Collide() { //ARRANGE var firstCube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(1) .Build(); var secondCube = CubeFactory .Cube() .WithCenterCoordinates(1.001, 0, 0) .WithDimension(1) .Build(); //ACT var result = firstCube.Collides(secondCube); //ASSERT Assert.IsFalse(result); }
// Update is called once per frame void Update() { //Press F to make a random cube to randome position if (Time.time - spawnTime > 1) { Debug.Log(transform.position); type = Random.Range(1, 7); x = Random.Range(-47f, 45f); z = Random.Range(-20f, 23f); Vector3 pos = new Vector3(x, 5f, z); CubeFactory.MakeCube(type, pos, Quaternion.identity); spawnTime = Time.time; cubeCount++; if (cubeCount == 10) { Debug.Log("You've spawned 10 cubes! wow"); } } }
public void Intersection_Is_Mutual() { var firstCube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(1) .Build(); var secondCube = CubeFactory .Cube() .WithCenterCoordinates(1, 0, 0) .WithDimension(2) .Build(); //ACT var firstCubeIntersection = firstCube.Intersection(secondCube); var secondCubeIntersection = secondCube.Intersection(firstCube); //ASSERT Assert.AreEqual(firstCubeIntersection, secondCubeIntersection); }
public void If_Cubes_Are_Near_Then_Collide() { //ARRANGE var firstCube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(2) .Build(); var secondCube = CubeFactory .Cube() .WithCenterCoordinates(2, 0, 0) .WithDimension(3) .Build(); //ACT var result = firstCube.Collides(secondCube); //ASSERT Assert.IsTrue(result); }
public void If_Cubes_Have_Same_Center_Then_Intersection_Equals_Smaller_Cube_Volume() { //ARRANGE var firstCube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(1) .Build(); var secondCube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(2) .Build(); //ACT var result = firstCube.Intersection(secondCube); //ASSERT Assert.AreEqual(GetCubeVolume(firstCube), result); Assert.AreNotEqual(GetCubeVolume(secondCube), result); }
public void Not_Collision_Is_Mutual() { //ARRANGE var firstCube = CubeFactory .Cube() .WithCenterCoordinates(0, 0, 0) .WithDimension(1) .Build(); var secondCube = CubeFactory .Cube() .WithCenterCoordinates(3, 3, 3) .WithDimension(1) .Build(); //ACT var firstCubeCollision = firstCube.Collides(secondCube); var secondCubeCollision = secondCube.Collides(firstCube); //ASSERT Assert.IsFalse(firstCubeCollision); Assert.IsFalse(secondCubeCollision); }
public static void Run() { ShaderProgram prog = null, terrProg = null; Texture tex = null, t2 = null; GraphicsContext context = new GraphicsContext() { Camera = new FirstPersonCamera(new Vector3(4, 3, 3), Vector3.UnitY) }; BitmapTextureSource bmpTex, b2, b3; bmpTex = TextDrawer.CreateWriter("Times New Roman", FontStyle.Regular).Write("Hello!", 200, System.Drawing.Color.White); b2 = new BitmapTextureSource("test.jpg", 0); b3 = new BitmapTextureSource("test.png", 0); Texture fbufTex = null, t3 = null; FramebufferTextureSource fbufTexSrc = new FramebufferTextureSource(256, 256, 0); Framebuffer fbuf = null; Matrix4 World = Matrix4.Identity; EngineObject eObj = null, fsq = null; float timer = 0; CubeMapTextureSource tFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.PositiveY, b3), bFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.PositiveX, b3), lFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.PositiveZ, b3), rFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.NegativeX, b3), fFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.NegativeY, b3), hFace = new CubeMapTextureSource(CubeMapTextureSource.CubeMapFace.NegativeZ, b3); GraphicsDevice.Load += () => { // setup settings, load textures, sounds GraphicsDevice.Wireframe = false; GraphicsDevice.AlphaEnabled = true; GraphicsDevice.DepthTestEnabled = true; GraphicsDevice.CullEnabled = false; GraphicsDevice.CullMode = CullFaceMode.Back; eObj = new EngineObject(); float[] data = { -1, -1, 1, 1, -1, 1, 0, 1, 1 }; uint[] indexData = new uint[] { 0, 1, 2 }; ShaderSource vert = ShaderSource.Load(ShaderType.VertexShader, "Testing/TG_A/vertex.glsl"); ShaderSource frag = ShaderSource.Load(ShaderType.FragmentShader, "Testing/TG_A/fragment.glsl"); ShaderSource tctrl = ShaderSource.Load(ShaderType.TessControlShader, "Testing/TG_A/tesscontrol.glsl"); ShaderSource teval = ShaderSource.Load(ShaderType.TessEvaluationShader, "Testing/TG_A/tessdomain.glsl"); ShaderSource vA = ShaderSource.Load(ShaderType.VertexShader, "Shaders/TerrainGen/vertex.glsl"); ShaderSource fA = ShaderSource.Load(ShaderType.FragmentShader, "Shaders/TerrainGen/fragment.glsl"); terrProg = new ShaderProgram(vA, fA); terrProg.Set("World", Matrix4.Identity); fbuf = new Framebuffer(256, 256); fbufTex = new Texture(); fbufTex.SetData(fbufTexSrc); fbuf[FramebufferAttachment.ColorAttachment0] = fbufTex; fsq = FullScreenQuadFactory.Create(); t3 = new Texture(); t3.SetData(tFace); t3.SetData(bFace); t3.SetData(lFace); t3.SetData(rFace); t3.SetData(fFace); t3.SetData(hFace); t3.SetEnableLinearFilter(true); t3.SetAnisotropicFilter(Texture.MaxAnisotropy); tex = new Texture(); tex.SetData(bmpTex); tex.SetAnisotropicFilter(Texture.MaxAnisotropy); t2 = new Texture(); t2.SetData(b3); t2.SetAnisotropicFilter(Texture.MaxAnisotropy); prog = new ShaderProgram(vert, tctrl, teval, frag); prog.Set("img", 0); prog.Set("heightmap", 1); prog.Set("World", World); vert.Dispose(); frag.Dispose(); tctrl.Dispose(); teval.Dispose(); //eObj = FullScreenQuadFactory.Create(); eObj = CubeFactory.Create(); eObj.SetTexture(0, t2); eObj.SetTexture(1, t3); b3.Dispose(); }; bool eyePosStill = false; GraphicsDevice.Update += (e) => { // add game logic, input handling if (GraphicsDevice.Keyboard[Key.Escape]) { GraphicsDevice.Exit(); } if (GraphicsDevice.Keyboard[Key.Z]) { GraphicsDevice.Wireframe = !GraphicsDevice.Wireframe; //GraphicsDevice.CullEnabled = !GraphicsDevice.Wireframe; } if (GraphicsDevice.Keyboard[Key.F]) { eyePosStill = !eyePosStill; Console.WriteLine("EyePosStill = " + eyePosStill); } context.Update(e); //context.Projection = Matrix4.Identity; //context.View = Matrix4.Identity; prog.Set("View", context.View); prog.Set("Proj", context.Projection); if (!eyePosStill) { prog.Set("eyePos", context.Camera.Position); } prog.Set("Fcoef", (float)(2.0f / Math.Log(1000001) / Math.Log(2))); //timer += 0.001f; //World = Matrix4.RotateY(timer); World = Matrix4.CreateScale(10); prog.Set("World", World); prog.Set("timer", timer); terrProg.Set("timer", timer); }; bool te1 = false; GraphicsDevice.Render += (e) => { GraphicsDevice.SetFramebuffer(fbuf); GraphicsDevice.Clear(); fsq.Bind(); GraphicsDevice.SetShaderProgram(terrProg); GraphicsDevice.SetViewport(0, 0, 256, 256); GraphicsDevice.Draw(PrimitiveType.Triangles, 0, fsq.IndexCount); eObj.Bind(); GraphicsDevice.SetShaderProgram(prog); GraphicsDevice.SetViewport(0, 0, GraphicsDevice.WindowSize.Width, GraphicsDevice.WindowSize.Height); GraphicsDevice.PatchCount = 3; GraphicsDevice.Draw(PrimitiveType.Patches, 0, eObj.IndexCount); GraphicsDevice.SwapBuffers(); if (!te1) { te1 = true; GraphicsDevice.SaveTexture(fbufTex, "test1.png"); } }; GraphicsDevice.Name = "The Julis Faction"; // Run the game at 60 updates per second GraphicsDevice.Run(60.0, 60.0); if (GraphicsDevice.Cleanup != null) { GraphicsDevice.Cleanup(); } }
public void Customize(IFixture fixture) { fixture.Inject(CubeFactory.VertexLists); fixture.Inject(CubeFactory.Build()); }
public CubeFactoryTester(CubeFactory cubeFactory) { _cubeFactory = cubeFactory; }
public CubeNode createNode(CubeDescription cubeDescription) { CubeNode temp = CubeFactory.createCubeNode(textureStore, physicsController, cubeDescription, cubeSize, this); return(temp); }
/// <summary> /// Build the cubic <see cref="Polygon" />. /// </summary> /// <returns>Returns cubic <see cref="Polygon" /> as <see cref="SceneElement" />.</returns> protected override Polygon CreateGeometry() { return(CubeFactory.Create(1)); }