create Java 3D Transform - Java javax.media.j3d

Java examples for javax.media.j3d:Transform3D

Description

create Java 3D Transform

Demo Code

/**/*from   w w  w . j a  v a2  s .c  o m*/
 * Copyright (c) 2014 Sa?l Pi?a <sauljabin@gmail.com>.
 * 
 * This file is part of WaspsNestBuilding.
 * 
 * WaspsNestBuilding is licensed under The MIT License.
 * For full copyright and license information please see the LICENSE file.
 */
import java.awt.Color;
import javax.media.j3d.Appearance;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.Material;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.media.j3d.TransparencyAttributes;
import javax.vecmath.Color3f;
import javax.vecmath.Vector3d;

public class Main{
    public static Transform3D createTransform3D(Vector3d displace,
            Vector3d scale, double rotationX, double rotationY,
            double rotationZ) {
        Transform3D t = new Transform3D();
        Transform3D taux = new Transform3D();

        if (scale != null) {
            taux.setScale(scale);
            t.mul(taux);
        }

        if (displace != null) {
            taux.setTranslation(displace);
            t.mul(taux);
        }

        taux.rotX(rotationX);
        t.mul(taux);

        taux.rotY(rotationY);
        t.mul(taux);

        taux.rotZ(rotationZ);
        t.mul(taux);

        return t;
    }
}

Related Tutorials