public void testPicking(){
runTest(new TestRunnable() {
@Override
public void runMTTestCode() {
//Create 3 rectangles
MTRectangle rect1 = new MTRectangle(100,100,getMTApplication());
rect1.setFillColor(new MTColor(255,0,0));
MTRectangle rect2 = new MTRectangle(100,100,getMTApplication());
rect2.setFillColor(new MTColor(0,255,0));
MTRectangle rect3 = new MTRectangle(100,100,getMTApplication());
rect3.setFillColor(new MTColor(0,0,255));
parent.addChild(rect1);
parent.addChild(rect2);
parent.addChild(rect3);
assertEquals(3, parent.getChildCount());
//Test if all 3 rects in pick list
assertEquals(getCanvas().pick(50, 50).getPickList().size(), 3);
//Check order of picks, should be 3,2,1
assertEquals(getCanvas().pick(50, 50).getPickList().get(0).hitObj, rect3);
assertEquals(getCanvas().pick(50, 50).getPickList().get(1).hitObj, rect2);
assertEquals(getCanvas().pick(50, 50).getPickList().get(2).hitObj, rect1);
//Check if intersectionpoint is 50,50,0
assertTrue(getCanvas().pick(50, 50).getInterSectionPointNearestPickedObj().equalsVectorWithTolerance(new Vector3D(50,50,0), 0.05f));
//Should pick rect3
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect3);
//Test sendToFront()
rect1.sendToFront();
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect1);
rect2.sendToFront();
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect2);
rect3.sendToFront();
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect3);
//Test when translated Z
rect3.translate(new Vector3D(0,0,-0.5f));
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect2);
rect3.translate(new Vector3D(0,0, 0.5f));
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect3);
rect1.translate(new Vector3D(0,0, 0.5f));
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect1);
rect1.translate(new Vector3D(0,0, -0.5f));
assertEquals(getCanvas().pick(50, 50).getNearestPickResult(), rect3);