Example usage for javax.media.j3d Transform3D set

List of usage examples for javax.media.j3d Transform3D set

Introduction

In this page you can find the example usage for javax.media.j3d Transform3D set.

Prototype

public final void set(double scale) 

Source Link

Document

Sets the value of this transform to a uniform scale; all of the matrix values are modified.

Usage

From source file:AvatarTest.java

public static void main(String[] args) {
    AvatarTest avatarTest = new AvatarTest();

    // Create a simple scene and attach it to the virtual universe
    SimpleUniverse u = new SimpleUniverse();

    PhysicalEnvironment physicalEnv = u.getViewer().getPhysicalEnvironment();

    TransformGroup tg = u.getViewer().getViewingPlatform().getViewPlatformTransform();

    Transform3D t3d = new Transform3D();
    t3d.set(new Vector3f(0, 0.5f, 0));
    tg.setTransform(t3d);/*w w w  . ja v a 2s  .c om*/

    CarSteering keys = new CarSteering(tg);
    keys.setSchedulingBounds(avatarTest.getBoundingSphere());

    u.getViewer().setAvatar(avatarTest.createAvatar());

    if (physicalEnv != null) {
        JavaSoundMixer javaSoundMixer = new JavaSoundMixer(physicalEnv);

        if (javaSoundMixer == null)
            System.out.println("Unable to create AudioDevice.");

        javaSoundMixer.initialize();
    }

    // Add everthing to the scene graph - it will now be displayed.
    BranchGroup scene = avatarTest.createSceneGraph();
    scene.addChild(keys);
    //      Java3dTree j3dTree = new Java3dTree();

    //   j3dTree.recursiveApplyCapability(scene);

    u.addBranchGraph(scene);

    //j3dTree.updateNodes(u);

    u.getViewingPlatform().getViewPlatform().setActivationRadius(2);
}

From source file:SimpleCylinder.java

/**
 * This builds the content branch of our scene graph. It uses the Cylinder
 * utility class to create the actual shape, adding to to the transform
 * group so that the shape is slightly tilted to reveal its 3D shape.
 * /*from  w  w w .jav  a2  s  .  c om*/
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    //Create the shape and add it to the branch
    rotationGroup.addChild(new Cylinder(1.0f, 1.0f, new Appearance()));
    return contentBranch;
}

From source file:SimpleCone.java

/**
 * This builds the content branch of our scene graph. It uses the buildShape
 * function to create the actual shape, adding to to the transform group so
 * that the shape is slightly tilted to reveal its 3D shape.
 * /*from ww w  .  ja v a2s .com*/
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    rotationGroup.addChild(new Cone(1.0f, 2.0f, 0, new Appearance()));
    return contentBranch;
}

From source file:SimpleWire.java

/**
 * This builds the content branch of our scene graph. It uses the buildCube
 * function to create the actual shape, adding to to the transform group so
 * that the shape is slightly tilted to reveal its 3D shape.
 * /* w  w w . j a v  a 2 s  .c  om*/
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch(Node shape) {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    rotationGroup.addChild(shape);
    return contentBranch;
}

From source file:SimpleSphere.java

protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    //                rotateCube.set(new AxisAngle4d(1.0,0.0,0.0,Math.PI/2.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    Appearance app = new Appearance();
    Color3f ambientColour = new Color3f(1.0f, 0.0f, 0.0f);
    Color3f diffuseColour = new Color3f(1.0f, 0.0f, 0.0f);
    Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f);
    float shininess = 20.0f;
    app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess));
    rotationGroup.addChild(new Sphere(2.0f, Sphere.GENERATE_NORMALS, 120, app));
    addLights(contentBranch);/* w  w w .  j  ava  2  s  . c o m*/
    return contentBranch;
}

From source file:SimpleDirLight.java

/**
 * This build the content branch of our scene graph. It creates a transform
 * group so that the shape is slightly tilted to reveal its 3D shape.
 * /* w  ww  .j a  va2 s.  co  m*/
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    //Create a new appearance
    Appearance app = new Appearance();
    //Create the colours for the material
    Color3f ambientColour = new Color3f(1.0f, 0.0f, 0.0f);
    Color3f diffuseColour = new Color3f(1.0f, 0.0f, 0.0f);
    Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f);
    //Define the shininess
    float shininess = 20.0f;
    //Set the material of the appearance
    app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess));
    //Create and add a new sphere using the appearance
    rotationGroup.addChild(new Sphere(2.0f, Sphere.GENERATE_NORMALS, 120, app));
    //Use the addLights function to add the lights to the branch
    addLights(contentBranch);
    //Return the root of the content branch
    return contentBranch;
}

From source file:SimpleWorld.java

/**
 * This builds the content branch of our scene graph. It uses the buildCube
 * function to create the actual shape, adding to to the transform group so
 * that the shape is slightly tilted to reveal its 3D shape.
 * //from   ww  w  .ja va  2  s  . c  o m
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch(Node shape) {
    //Create the branch group that will be the root of the content branch
    BranchGroup contentBranch = new BranchGroup();

    //Create the transform that will cause the shape to appear tilted
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);

    //Put the branch together
    contentBranch.addChild(rotationGroup);
    rotationGroup.addChild(shape);

    return contentBranch;
}

From source file:LocalEyeApp.java

TransformGroup createTG(float x, float y, float z) {
    Vector3f position = new Vector3f(x, y, z);
    Transform3D translate = new Transform3D();
    translate.set(position);
    TransformGroup trans1 = new TransformGroup(translate);
    return trans1;
}

From source file:SimpleMouse.java

/**
 * Build the view branch of the scene graph
 * //from   w  ww.  ja v a2 s  .com
 * @return BranchGroup that is the root of the view branch
 */
protected BranchGroup buildViewBranch(Canvas3D c) {
    BranchGroup viewBranch = new BranchGroup();
    Transform3D viewXfm = new Transform3D();
    viewXfm.set(new Vector3f(0.0f, 0.0f, 10.0f));
    TransformGroup viewXfmGroup = new TransformGroup(viewXfm);
    ViewPlatform myViewPlatform = new ViewPlatform();
    PhysicalBody myBody = new PhysicalBody();
    PhysicalEnvironment myEnvironment = new PhysicalEnvironment();
    viewXfmGroup.addChild(myViewPlatform);
    viewBranch.addChild(viewXfmGroup);
    View myView = new View();
    myView.addCanvas3D(c);
    myView.attachViewPlatform(myViewPlatform);
    myView.setPhysicalBody(myBody);
    myView.setPhysicalEnvironment(myEnvironment);
    return viewBranch;
}

From source file:SimpleSpotLights.java

/**
 * This build the content branch of our scene graph. It creates a transform
 * group so that the shape is slightly tilted to reveal its 3D shape.
 * /* ww  w.j a  v a  2s.c  o m*/
 * @param shape
 *            Node that represents the geometry for the content
 * @return BranchGroup that is the root of the content branch
 */
protected BranchGroup buildContentBranch() {
    BranchGroup contentBranch = new BranchGroup();
    Transform3D rotateCube = new Transform3D();
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));
    TransformGroup rotationGroup = new TransformGroup(rotateCube);
    contentBranch.addChild(rotationGroup);
    //Create a new appearance
    Appearance app = new Appearance();
    //Create the colours for the material
    Color3f ambientColour = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f diffuseColour = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f);
    //Define the shininess
    float shininess = 20.0f;
    //Set the material of the appearance
    app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess));
    //Create and add a new sphere using the appearance
    rotationGroup.addChild(new Sphere(2.0f, Sphere.GENERATE_NORMALS, 120, app));
    //Use the addLights function to add the lights to the branch
    addLights(contentBranch);
    //Return the root of the content branch
    return contentBranch;
}