Package javax.media.j3d

Examples of javax.media.j3d.TransformGroup


    }

    private BranchGroup createBranch(TreeBranch3D branch3D) {
        Vector3d translationVector = new Vector3d(branch3D.getState().getTranslationVector().toPointValue());
        BranchGroup branchBG = new BranchGroup();
        TransformGroup transformGroup = TransformerHelper.getTranslationTransformGroup(translationVector);
        branchBG.addChild(transformGroup);

        transformGroup.addChild(branch3D.getGroup());
        return branchBG;
    }
View Full Code Here


    public void addLeaf(TreeLeaf3D leaf) {
        BranchGroup leafBranchGroup = new BranchGroup();
        leafBranchGroup.setCapability(BranchGroup.ALLOW_DETACH);
        leafBranchGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
        TransformGroup transformGroup = new TransformGroup();
        transformGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);
        transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        TreeLeaf3DState leaf3DState = leaf.getState();
        Transform3D translation = TransformerHelper.getTranslationTransform3D(new Vector3d(leaf3DState
                .getLeafAttachPoint().toPointValue()));
        Transform3D rotation = TransformerHelper.getRotationTransform3D(leaf3DState.getRotation(), Axis.Y);
        translation.mul(rotation);
        transformGroup.setTransform(translation);
        transformGroup.addChild(leaf.getBranchGroup());
        leafBranchGroup.addChild(transformGroup);
        group.addChild(leafBranchGroup);
    }
View Full Code Here

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

        addElement3D(treeBranchGroup);
    }
View Full Code Here

        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();
        treeLeafBranchGroup.addChild(transformGroup);
        transformGroup.addChild(treeLeaf3D.getBranchGroup());

        addElement3D(treeLeafBranchGroup);
    }
View Full Code Here

    public BasicGravity(Universe3D universe3D) {
        this.universe3D = universe3D;
    }

    public void fall(BranchGroup groupToFall) {
        TransformGroup tg = (TransformGroup) groupToFall.getChild(0);
        Node node = tg.getChild(0);
        // get the global transform before detaching to get all the transforms along the way
        // the group will not be attached locally anymore, but at the root,
        // so we need to get the global transform.
        Transform3D transform3D = getGlobalTransform3D(node);
        // we need to detach before changing the global transform, or it will move the group too far
        groupToFall.detach();
        tg.setTransform(transform3D);
        Interpolator gravity = createGravityInterpolator(tg);
        addToUniverse(groupToFall, gravity);
    }
View Full Code Here

        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

    }

    private BranchGroup createParts() {
        BranchGroup branchGroup = new BranchGroup();
        Point3d currentPartStartPoint = new Point3d(0, 0, 0);
        TransformGroup previousTransformGroup = new TransformGroup();
        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
            currentPartStartPoint = branchPart3D.getEndPoint();
            previousTransformGroup = currentTransformGroup;
        }
View Full Code Here

    private TransformerHelper() {
        // private constructor to enforce static access
    }

    public static TransformGroup getTranslationTransformGroup(Vector3d translationVector) {
        return new TransformGroup(getTranslationTransform3D(translationVector));
    }
View Full Code Here

        translation.setTranslation(translationVector);
        return translation;
    }

    public static TransformGroup getRotationTransformGroup(double rotationAngle, Axis axis) {
        return new TransformGroup(getRotationTransform3D(rotationAngle, axis));
    }
View Full Code Here

    private TransformerHelper() {
        // private constructor to enforce static access
    }

    public static TransformGroup getTranslationTransformGroup(Vector3d translationVector) {
        return new TransformGroup(getTranslationTransform3D(translationVector));
    }
View Full Code Here

TOP

Related Classes of javax.media.j3d.TransformGroup

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.