Package libshapedraw

Examples of libshapedraw.MockMinecraftAccess


public class TestShape extends SetupTestEnvironment.TestCase {
    @Test
    public void testVisible() {
        MockShape shape = new MockShape();
        MockMinecraftAccess mc = new MockMinecraftAccess();

        assertTrue(shape.isVisible());
        shape.render(mc);
        assertEquals(1, shape.getCountRender());
View Full Code Here


    @Test
    public void testTransforms() {
        MockShape shape = new MockShape();
        assertEquals(0, shape.getTransforms().size());

        MockMinecraftAccess mc = new MockMinecraftAccess();
        shape.render(mc);
        assertEquals(1, shape.getCountRender());

        shape.addTransform(new ShapeRotate(45.0, 0.0, 1.0, 0.0));
        assertEquals(1, shape.getTransforms().size());
View Full Code Here

        // rendering auto-normalizes
        shape = new WireframeCuboid(1.0,2.0,3.0, 4.0,5.0,6.0);
        shape.getLowerCorner().setX(55.5);
        shape.getUpperCorner().setZ(-99.0);
        assertEquals("(55.5,2.0,3.0)(4.0,5.0,-99.0)", shape.getLowerCorner().toString() + shape.getUpperCorner().toString());
        shape.render(new MockMinecraftAccess());
        assertEquals("(4.0,2.0,-99.0)(55.5,5.0,3.0)", shape.getLowerCorner().toString() + shape.getUpperCorner().toString());
    }
View Full Code Here

        assertEquals("(2.5,3.5,4.5)", new WireframeCuboid(1.0,2.0,3.0, 4.0,5.0,6.0).getOriginReadonly().toString());
    }

    @Test
    public void testRender() {
        MockMinecraftAccess mc = new MockMinecraftAccess();
        for (boolean twice : new boolean[] {true, false}) {
            WireframeCuboid shape = new WireframeCuboid(1.0,2.0,3.0, 4.0,5.0,6.0);
            shape.setLineStyle(Color.WHITE.copy(), 1.0F, twice);
            assertEquals(twice, shape.isVisibleThroughTerrain());

            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(3, 16, twice);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(12, 64, twice);
        }
    }
View Full Code Here

        assertEquals("(1.0,2.0,3.0)", new WireframeLine(1.0,2.0,3.0, 4.0,5.0,6.0).getOriginReadonly().toString());
    }

    @Test
    public void testRender() {
        MockMinecraftAccess mc = new MockMinecraftAccess();           
        for (boolean twice : new boolean[] {true, false}) {
            WireframeLine shape = new WireframeLine(1.0,2.0,3.0, 4.0,5.0,6.0);
            shape.setLineStyle(Color.WHITE.copy(), 1.0F, false);
            shape.setLineStyle(Color.RED.copy(), 2.0F, twice);
            assertEquals(twice, shape.isVisibleThroughTerrain());

            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 2, twice);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 8, twice);

            // revert to the default line style
            shape.setLineStyle(null);
            assertSame(LineStyle.DEFAULT, shape.getEffectiveLineStyle());
            assertTrue(shape.isVisibleThroughTerrain());
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 2, true);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 8, true);
        }
    }
View Full Code Here

    }

    @Test(expected=IllegalStateException.class)
    public void testInitializeTwice() {
        // first initialization done by SetupTestEnvironment
        ct.initialize(new MockMinecraftAccess());
    }
View Full Code Here

        assertEquals("(4.0,5.5,-3.0)", shape.getOriginReadonly().toString());
    }

    @Test
    public void testRender() {
        MockMinecraftAccess mc = new MockMinecraftAccess();
        ArrayList<ReadonlyVector3> arr = new ArrayList<ReadonlyVector3>();
        for (boolean seeThru : new boolean[] {true, false}) {
            arr.clear();
            WireframeLinesBlend shape = new WireframeLinesBlend(arr);
            shape.setLineStyle(Color.WHITE.copy(), 1.0F, seeThru);
            shape.setBlendToLineStyle(Color.RED.copy().setAlpha(0.5), 5.0F, seeThru);
            assertEquals(seeThru, shape.isVisibleThroughTerrain());

            // No points == nothing to render
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(0, 0, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(0, 0, seeThru);
   
            // Only one point makes no lines
            arr.add(new Vector3(0.0, 5.5, -12.5));
            mc.reset();
            shape.render(mc); // deferred to WireframeLines
            mc.assertCountsEqual(1, 1, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 4, seeThru);
   
            // Two points make one line
            arr.add(new Vector3(7.0, 5.5, -12.5));
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 2, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 8, seeThru);
   
            // Three points make two lines
            arr.add(new Vector3(7.0, 15.5, -12.5));
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(2, 4, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(8, 16, seeThru);
   
            // Eleven points make ten lines
            arr.add(new Vector3(7.0, 15.5, -6.5));
            arr.add(new Vector3(7.0, 12.5, -3.5));
            arr.add(new Vector3(17.0, 12.5, -3.5));
            arr.add(new Vector3(17.0, 6.5, -3.5));
            arr.add(new Vector3(12.0, 7.5, -3.5));
            arr.add(new Vector3(10.0, 7.5, 3.5));
            arr.add(new Vector3(10.0, 7.5, 6.0));
            arr.add(new Vector3(20.0, 17.5, 6.0));
            assertEquals(11, arr.size());
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(10, 20, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(40, 80, seeThru);

            // Add a render cap, we only render that many lines
            shape.setRenderCap(5);
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(5, 10, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(20, 40, seeThru);

            // Remove the render cap, we render everything again
            shape.setRenderCap(-1);
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(10, 20, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(40, 80, seeThru);

            // A render cap that's larger than the number of line segments defined is fine too
            shape.setRenderCap(9001);
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(10, 20, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(40, 80, seeThru);

            shape.setBlendToLineStyle(Color.YELLOW.copy().setAlpha(0.5), 5.0F, false);
            shape.setRenderCap(-1);
            mc.reset();
            shape.render(mc); // secondary deferred to WireframeLines
            if (seeThru) {
                mc.assertCountsEqual(11, 31, false);
            } else {
                mc.assertCountsEqual(10, 20, false);
            }
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            if (seeThru) {
                mc.assertCountsEqual(44, 124, false);
            } else {
                mc.assertCountsEqual(40, 80, false);
            }
        }
    }
View Full Code Here

        arr.add(new Vector3(4.0, 5.0, 6.0));
        arr.add("how did i get here");
        arr.add(new Vector3(7.0, 8.0, 9.0));
        WireframeLinesBlend shape = new WireframeLinesBlend(arr);
        shape.setLineStyle(Color.WHITE.copy(), 1.0F, true);
        shape.render(new MockMinecraftAccess());
    }
View Full Code Here

        arr.add(new Vector3(4.0, 5.0, 6.0));
        arr.add(null);
        arr.add(new Vector3(7.0, 8.0, 9.0));
        WireframeLinesBlend shape = new WireframeLinesBlend(arr);
        shape.setLineStyle(Color.WHITE.copy(), 1.0F, true);
        shape.render(new MockMinecraftAccess());
    }
View Full Code Here

        assertEquals("(4.0,5.5,-3.0)", shape.getOriginReadonly().toString());
    }

    @Test
    public void testRender() {
        MockMinecraftAccess mc = new MockMinecraftAccess();
        ArrayList<ReadonlyVector3> arr = new ArrayList<ReadonlyVector3>();
        for (boolean seeThru : new boolean[] {true, false}) {
            arr.clear();
            WireframeLines shape = new WireframeLines(arr);
            shape.setLineStyle(Color.WHITE.copy(), 1.0F, seeThru);
            assertEquals(seeThru, shape.isVisibleThroughTerrain());

            // No points == nothing to render
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(0, 0, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(0, 0, seeThru);
   
            // Only one point makes no lines
            arr.add(new Vector3(0.0, 5.5, -12.5));
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 1, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 4, seeThru);
   
            // Two points make one line
            arr.add(new Vector3(7.0, 5.5, -12.5));
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 2, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 8, seeThru);
   
            // Three points make two lines
            arr.add(new Vector3(7.0, 15.5, -12.5));
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 3, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 12, seeThru);
   
            // Eleven points make ten lines
            arr.add(new Vector3(7.0, 15.5, -6.5));
            arr.add(new Vector3(7.0, 12.5, -3.5));
            arr.add(new Vector3(17.0, 12.5, -3.5));
            arr.add(new Vector3(17.0, 6.5, -3.5));
            arr.add(new Vector3(12.0, 7.5, -3.5));
            arr.add(new Vector3(10.0, 7.5, 3.5));
            arr.add(new Vector3(10.0, 7.5, 6.0));
            arr.add(new Vector3(20.0, 17.5, 6.0));
            assertEquals(11, arr.size());
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 11, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 44, seeThru);

            // Add a render cap, we only render that many lines
            shape.setRenderCap(5);
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 6, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 24, seeThru);

            // Remove the render cap, we render everything again
            shape.setRenderCap(-1);
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 11, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 44, seeThru);

            // A render cap that's larger than the number of line segments defined is fine too
            shape.setRenderCap(9001);
            mc.reset();
            shape.render(mc);
            mc.assertCountsEqual(1, 11, seeThru);
            shape.render(mc);
            shape.render(mc);
            shape.render(mc);
            mc.assertCountsEqual(4, 44, seeThru);
        }
    }
View Full Code Here

TOP

Related Classes of libshapedraw.MockMinecraftAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.