Package javax.vecmath

Examples of javax.vecmath.Vector3d


    }

    private void addTree(Tree tree) {
        Tree3D tree3D = tree.getTree3D();
        Point3d treeOriginPoint = tree3D.getState().getTranslationVector().toPointValue();
        Transform3D translation = TransformerHelper.getTranslationTransform3D(new Vector3d(treeOriginPoint));
        TransformGroup transformGroup = new TransformGroup(translation);

        BranchGroup treeBranchGroup = new BranchGroup();
        treeBranchGroup.addChild(transformGroup);
        transformGroup.addChild(tree3D.getBranchGroup());
View Full Code Here


    private void addFallenLeaf(TreeLeaf treeLeaf) {
        TreeLeaf3D treeLeaf3D = treeLeaf.getTreeLeaf3D();
        Point3d treeLeafOriginPoint = treeLeaf3D.getState().getLeafAttachPoint().toPointValue();
        double treeLeafRotation = treeLeaf3D.getState().getRotation();
        Transform3D translation = TransformerHelper.getTranslationTransform3D(new Vector3d(treeLeafOriginPoint));
        Transform3D rotation = TransformerHelper.getRotationTransform3D(treeLeafRotation, Axis.Y);
        translation.mul(rotation);
        TransformGroup transformGroup = new TransformGroup(translation);

        BranchGroup treeLeafBranchGroup = new BranchGroup();
View Full Code Here

        }
        Appearance trunkAppearance = new Appearance();
        AppearanceFactory.setColorWithMaterial(trunkAppearance, ColorConstants.brown, new Color3f(0.15f, 0.15f, 0.15f),
                new Color3f(0.05f, 0.05f, 0.05f));
        trunkCylinder = new Cylinder(trunk.getRadius(), trunk.getHeight(), trunkAppearance);
        Vector3d translationVector = new Vector3d();
        translationVector.setY(trunk.getHeight() / 2);
        TransformGroup transformGroup = TransformerHelper.getTranslationTransformGroup(translationVector);
        transformGroup.addChild(trunkCylinder);
        this.group = new Group();
        group.addChild(transformGroup);
    }
View Full Code Here

        branchGroup.addChild(previousTransformGroup);
        for (TreeBranchPart branchPart : treeBranch.getParts()) {
            TreeBranchPart3D branchPart3D = branchPart.getBranchPart3D();
            Group branchPartGroup = branchPart3D.getGroup();
            BranchGroup currentBranchGroup = new BranchGroup();
            Vector3d translationVector = new Vector3d(currentPartStartPoint);
            TransformGroup currentTransformGroup = TransformerHelper.getTranslationTransformGroup(translationVector);
            currentBranchGroup.addChild(currentTransformGroup);
            currentTransformGroup.addChild(branchPartGroup);
            previousTransformGroup.addChild(currentBranchGroup);
            // set pointer for next round
View Full Code Here

     * @param p1 first point
     * @param p2 second point
     * @param p3 third point
     */
    public static Vector3f computeNormal(Point3d p1, Point3d p2, Point3d p3) {
        Vector3d normal = new Vector3d();
        Vector3d vector1 = new Vector3d();
        Vector3d vector2 = new Vector3d();

        vector1.sub(p2, p1);
        vector2.sub(p3, p1);

        normal.cross(vector1, vector2);
        normal.normalize();
        return new Vector3f(normal);
    }
View Full Code Here

    }

    private void fall() {
        Transform3D globalTransform = new Transform3D();
        branchGroup.getLocalToVworld(globalTransform);
        Vector3d translationVector = new Vector3d();
        globalTransform.get(translationVector);
        Point3d projectionPoint = ProjectionHelper.getProjectionPoint(new Point3d(translationVector));
        state.setLeafAttachPoint(new Point3dState(projectionPoint));
        double angle = TransformerHelper.getRotationFromTransform(globalTransform, Axis.Y);
        state.setRotation(angle);
View Full Code Here

    private TreeBranchStateFactory factory;

    protected void setUp() throws Exception {
        super.setUp();
        translationVector = new Vector3d(1.5, 3.6, 8.9);
        branchEndPoint = new Point3d(1, 2.7, 3);
        factory = new TreeBranchStateFactory();
        branchState = factory.createRandomBranchState(translationVector, branchEndPoint);
    }
View Full Code Here

    }

    public void testComputeBranchTranslationVector() {
        float treeRadius = 6;
        float treeHeight = 8;
        Vector3d translationVector = factory.computeBranchTranslationVector(treeRadius, treeHeight);
        PointTestHelper.assertPointIsWithinBounds(new Point3d(translationVector), new Point3d(-6, 8, -6), new Point3d(
                6, 8, 6));
        treeRadius = 0.2f;
        treeHeight = 15;
        translationVector = factory.computeBranchTranslationVector(treeRadius, treeHeight);
View Full Code Here


    public void testComputeAttachPointForNewleafState1() {
        // create object states
        TreeLeaf3DState leaf3DState1 = new TreeLeaf3DState();
        setLeafStateTransform(leaf3DState1, new Vector3d(2, 0, 0));
        TreeLeaf3DState leaf3DState2 = new TreeLeaf3DState();
        setLeafStateTransform(leaf3DState2, new Vector3d(3, 0, 0));
        TreeLeafState leafState1 = new TreeLeafState();
        leafState1.setLeaf3DState(leaf3DState1);
        TreeLeafState leafState2 = new TreeLeafState();
        leafState2.setLeaf3DState(leaf3DState2);
        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>(2);
View Full Code Here

    }

    public void testComputeAttachPointForNewleafState2() {
        // create object states
        TreeLeaf3DState leaf3DState1 = new TreeLeaf3DState();
        setLeafStateTransform(leaf3DState1, new Vector3d(1, 0, 0));
        TreeLeaf3DState leaf3DState2 = new TreeLeaf3DState();
        setLeafStateTransform(leaf3DState2, new Vector3d(5, 0, 0));
        TreeLeafState leafState1 = new TreeLeafState();
        leafState1.setLeaf3DState(leaf3DState1);
        TreeLeafState leafState2 = new TreeLeafState();
        leafState2.setLeaf3DState(leaf3DState2);
        List<TreeLeafState> leaveStates = new ArrayList<TreeLeafState>(2);
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector3d

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.