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);
}
}
}