Package barsuift.simLife.j3d

Examples of barsuift.simLife.j3d.Point3dState


    public void testCreateRandom() {
        Point3d leafAttachPoint = new Point3d(Math.random(), Math.random(), Math.random());
        TreeLeaf leaf = factory.createRandom(leafAttachPoint);
        TreeLeaf3DState leaf3dState = leaf.getTreeLeaf3D().getState();
        // test the leaf created is a random one (by testing the 3d leaf)
        Point3dState initialEndPoint1 = leaf3dState.getInitialEndPoint1();
        Point3dState initialEndPoint2 = leaf3dState.getInitialEndPoint2();
        Point3dState expectedEndPoint1 = new Point3dState(initialEndPoint1.getX() * 10, initialEndPoint1.getY() * 10,
                initialEndPoint1.getZ() * 10);
        Point3dState expectedEndPoint2 = new Point3dState(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10,
                initialEndPoint2.getZ() * 10);
        assertEquals(expectedEndPoint1, leaf3dState.getEndPoint1());
        assertEquals(expectedEndPoint2, leaf3dState.getEndPoint2());
    }
View Full Code Here


    }

    public void testComputeAttachPointForNewLeaf1() {
        // create object states
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setLeafAttachPoint(new Point3dState(2, 0, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setLeafAttachPoint(new Point3dState(3, 0, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setLeaf3DState(leaf3D2);
        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>(2);
        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        TreeBranchPart3DState part3D = new TreeBranchPart3DState(new Point3dState(3.5, 0, 0));
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        partState.setBranchPart3DState(part3D);
        // the branch part is along the X axis
        // it starts at 0
View Full Code Here

    }

    public void testComputeAttachPointForNewLeaf2() {
        // create object states
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setLeafAttachPoint(new Point3dState(1, 0, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setLeafAttachPoint(new Point3dState(5, 0, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setLeaf3DState(leaf3D2);
        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>(2);
        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        TreeBranchPart3DState part3D = new TreeBranchPart3DState(new Point3dState(7, 0, 0));
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        partState.setBranchPart3DState(part3D);
        // the branch part is along the X axis
        // it starts at 0
View Full Code Here

    }

    public void testComputeAttachPointForNewLeaf3() {
        // create object states
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setLeafAttachPoint(new Point3dState(2, 0, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setLeafAttachPoint(new Point3dState(3, 0, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setLeaf3DState(leaf3D2);
        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>(2);
        leaveStates.add(leaf1);
        leaveStates.add(leaf2);
        TreeBranchPart3DState part3D = new TreeBranchPart3DState(new Point3dState(6, 0, 0));
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        partState.setBranchPart3DState(part3D);
        // the branch part is along the X axis
        // it starts at 0
View Full Code Here

     * Test if the leaves are not created in the order based on the distance to the branch part start.
     */
    public void testComputeAttachPointForNewLeaf4() {
        // create object states
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setLeafAttachPoint(new Point3dState(2, 0, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setLeafAttachPoint(new Point3dState(3, 0, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setLeaf3DState(leaf3D2);
        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>(2);
        // add the leaves in the "wrong" order
        leaveStates.add(leaf2);
        leaveStates.add(leaf1);
        TreeBranchPart3DState part3D = new TreeBranchPart3DState(new Point3dState(3.5, 0, 0));
        TreeBranchPartState partState = new TreeBranchPartState();
        partState.setLeaveStates(leaveStates);
        partState.setBranchPart3DState(part3D);
        // the branch part is along the X axis
        // it starts at 0
View Full Code Here

        assertTrue(part.canIncreaseOneLeafSize());

        // set all the leaves at their maximum size, so that they can not be increased anymore
        for (TreeLeafState leafState : partState.getLeaveStates()) {
            TreeLeaf3DState leaf3dState = leafState.getLeaf3DState();
            Point3dState initialEndPoint1 = leaf3dState.getInitialEndPoint1();
            leaf3dState.setEndPoint1(new Point3dState(initialEndPoint1.getX() * 10, initialEndPoint1.getY() * 10,
                    initialEndPoint1.getZ() * 10));
            Point3dState initialEndPoint2 = leaf3dState.getInitialEndPoint2();
            leaf3dState.setEndPoint2(new Point3dState(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10,
                    initialEndPoint2.getZ() * 10));
        }
        part = new BasicTreeBranchPart(new MockUniverse(), partState);
        assertFalse(part.canIncreaseOneLeafSize());

        // reset the end point 1 of leaf 1, so that it can be increased again
View Full Code Here

        Point3d firstInitialEndPoint1 = firstLeafState.getLeaf3DState().getInitialEndPoint1().toPointValue();
        branchPartState.setEnergy(new BigDecimal(150));
        // set all the leaves at their maximum size, so that they can not be increased anymore
        for (TreeLeafState leafState : branchPartState.getLeaveStates()) {
            TreeLeaf3DState leaf3dState = leafState.getLeaf3DState();
            Point3dState initialEndPoint1 = leaf3dState.getInitialEndPoint1();
            leaf3dState.setEndPoint1(new Point3dState(initialEndPoint1.getX() * 10, initialEndPoint1.getY() * 10,
                    initialEndPoint1.getZ() * 10));
            Point3dState initialEndPoint2 = leaf3dState.getInitialEndPoint2();
            leaf3dState.setEndPoint2(new Point3dState(initialEndPoint2.getX() * 10, initialEndPoint2.getY() * 10,
                    initialEndPoint2.getZ() * 10));
        }
        // set the first leaf end point to (0,0,0) so that it can be increased
        firstLeafState.getLeaf3DState().setEndPoint1(new Point3dState());
        BasicTreeBranchPart part = new BasicTreeBranchPart(new MockUniverse(), branchPartState);

        part.increaseOneLeafSize();


View Full Code Here

        assertEquals(new BigDecimal(110), part.getEnergy());
    }

    public void testGetRandomLeafToIncrease1() {
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D1.setEndPoint2(new Point3dState(0, 2, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D2.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeaf3DState leaf3D3 = new TreeLeaf3DState();
        leaf3D3.setEndPoint1(new Point3dState(3, 0, 0));
        leaf3D3.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setId(new Long(1));
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setId(new Long(2));
View Full Code Here

    /**
     * Test with one leaf at its maximum size
     */
    public void testGetRandomLeafToIncrease2() {
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D1.setEndPoint2(new Point3dState(0, 2, 0));
        leaf3D1.setInitialEndPoint1(new Point3dState(0.2, 0, 0));
        leaf3D1.setInitialEndPoint2(new Point3dState(0, 0.2, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D2.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeaf3DState leaf3D3 = new TreeLeaf3DState();
        leaf3D3.setEndPoint1(new Point3dState(3, 0, 0));
        leaf3D3.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setId(new Long(1));
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setId(new Long(2));
View Full Code Here

    /**
     * Test with all but one leaves at their maximum sizes
     */
    public void testGetRandomLeafToIncrease3() {
        TreeLeaf3DState leaf3D1 = new TreeLeaf3DState();
        leaf3D1.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D1.setEndPoint2(new Point3dState(0, 2, 0));
        leaf3D1.setInitialEndPoint1(new Point3dState(0.2, 0, 0));
        leaf3D1.setInitialEndPoint2(new Point3dState(0, 0.2, 0));
        TreeLeaf3DState leaf3D2 = new TreeLeaf3DState();
        leaf3D2.setEndPoint1(new Point3dState(2, 0, 0));
        leaf3D2.setEndPoint2(new Point3dState(0, 4, 0));
        leaf3D2.setInitialEndPoint1(new Point3dState(0.2, 0, 0));
        leaf3D2.setInitialEndPoint2(new Point3dState(0, 0.4, 0));
        TreeLeaf3DState leaf3D3 = new TreeLeaf3DState();
        leaf3D3.setEndPoint1(new Point3dState(3, 0, 0));
        leaf3D3.setEndPoint2(new Point3dState(0, 4, 0));
        TreeLeafState leaf1 = new TreeLeafState();
        leaf1.setId(new Long(1));
        leaf1.setLeaf3DState(leaf3D1);
        TreeLeafState leaf2 = new TreeLeafState();
        leaf2.setId(new Long(2));
View Full Code Here

TOP

Related Classes of barsuift.simLife.j3d.Point3dState

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.