Example usage for javax.media.j3d BranchGroup BranchGroup

List of usage examples for javax.media.j3d BranchGroup BranchGroup

Introduction

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

Prototype

public BranchGroup() 

Source Link

Document

Constructs and initializes a new BranchGroup node object.

Usage

From source file:HelloWorld.java

private static BranchGroup createSceneGraph() {
    // Make a scene graph branch
    BranchGroup branch = new BranchGroup();

    // Make a changeable 3D transform
    TransformGroup trans = new TransformGroup();
    trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    branch.addChild(trans);// www  .  j a v  a 2s.c o m

    // Make a shape
    ColorCube demo = new ColorCube(0.4);
    trans.addChild(demo);

    // Make a behavor to spin the shape
    Alpha spinAlpha = new Alpha(-1, 4000);
    RotationInterpolator spinner = new RotationInterpolator(spinAlpha, trans);
    spinner.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0));
    trans.addChild(spinner);

    return branch;
}

From source file:Hello3d.java

public Hello3d() {
    SimpleUniverse universe = new SimpleUniverse();
    BranchGroup group = new BranchGroup();
    group.addChild(new ColorCube(0.3));
    universe.getViewingPlatform().setNominalViewingTransform();
    universe.addBranchGraph(group);//  w w w. j ava  2s  . co  m
}

From source file:Rotation.java

/**
 * Erstellt den Szenegraphen/*from  ww w .  ja va  2  s .  c o  m*/
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    TransformGroup objDreh = new TransformGroup(drehung);
    TransformGroup spin = new TransformGroup();
    spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    spin.addChild(new ColorCube(0.4));
    objDreh.addChild(spin);
    objWurzel.addChild(objDreh);

    // Drehung
    Alpha spinAlpha = new Alpha(-1, 5000);
    RotationInterpolator dreher = new RotationInterpolator(spinAlpha, spin);
    BoundingSphere zone = new BoundingSphere();
    dreher.setSchedulingBounds(zone);
    spin.addChild(dreher);

    return objWurzel;
}

From source file:Erscheinungsbild.java

/**
 * Erstellt den Szenegraphen//from ww  w .j  a va  2 s.c o m
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    TransformGroup objDreh = new TransformGroup(drehung);
    objDreh.addChild(new Box(0.5f, 0.5f, 0.5f, makeAppearance()));
    objWurzel.addChild(objDreh);

    return objWurzel;
}

From source file:FarbWurfelAsQuads.java

/**
 * Erstellt den Szenegraphen//from  www  .  j a va 2  s.  co  m
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    drehung.setScale(0.5d);
    TransformGroup objDreh = new TransformGroup(drehung);
    Shape3D shape = new Shape3D(makeCube(), makeAppearance());
    objDreh.addChild(shape);

    objWurzel.addChild(objDreh);
    return objWurzel;
}

From source file:Licht.java

/**
 * Erstellt den Szenegraphen/*from  w  w  w .  j  a va 2  s.  c  o  m*/
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    TransformGroup objDreh = new TransformGroup(drehung);

    Sphere kugel = new Sphere(0.5f, Sphere.GENERATE_NORMALS, 50, makeAppearance());
    objWurzel.addChild(kugel);
    objWurzel.addChild(objDreh);

    //directes Licht
    DirectionalLight d_Licht = new DirectionalLight();
    d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), Double.MAX_VALUE));
    d_Licht.setColor(new Color3f(1.0f, 0.0f, 0.0f));
    Vector3f dir = new Vector3f(1.0f, 2.0f, -1.0f);
    dir.normalize();
    d_Licht.setDirection(dir);
    objWurzel.addChild(d_Licht);

    // ambient Licht
    AmbientLight a_licht = new AmbientLight();
    a_licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f), Double.MAX_VALUE));
    a_licht.setColor(new Color3f(1.0f, 0.0f, 0.0f));
    objWurzel.addChild(a_licht);

    return objWurzel;
}

From source file:Ball.java

public Ball() {
    // Create the universe
    SimpleUniverse universe = new SimpleUniverse();

    // Create a structure to contain objects
    BranchGroup group = new BranchGroup();

    // Create a ball and add it to the group of objects
    Sphere sphere = new Sphere(0.5f);
    group.addChild(sphere);//  w w w .j a v a 2  s  .  c  o m

    // Create a red light that shines for 100m from the origin
    Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
    Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    group.addChild(light1);

    // look towards the ball
    universe.getViewingPlatform().setNominalViewingTransform();

    // add the group of objects to the Universe
    universe.addBranchGraph(group);
}

From source file:TextureMapping.java

/**
 * Erstellt den Szenegraphen/*from   w  ww .j a  va  2 s .c o m*/
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    TransformGroup objDreh = new TransformGroup(drehung);

    objDreh.addChild(new Box(0.5f, 0.5f, 0.5f, Box.GENERATE_TEXTURE_COORDS, makeAppearance()));

    objWurzel.addChild(objDreh);

    return objWurzel;
}

From source file:Phong.java

/**
 * Erstellt den Szenegraphen/*ww w.  j  a  v a2  s. co m*/
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    TransformGroup objDreh = new TransformGroup(drehung);
    //Loader
    ObjectFile file = new ObjectFile(ObjectFile.RESIZE);
    Scene scene = null;
    try {
        scene = file.load(ClassLoader.getSystemResource("teapot.obj"));

    } catch (Exception e) {
        System.err.println(e);
        System.exit(1);
    }
    objDreh.addChild(scene.getSceneGroup());

    DirectionalLight d_Licht = new DirectionalLight(new Color3f(1.0f, 1.0f, 1.0f),
            new Vector3f(-1.0f, -1.0f, -1.0f));
    d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), 100.0d));
    objDreh.addChild(d_Licht);
    objWurzel.addChild(objDreh);
    return objWurzel;
}

From source file:ObjectLoader.java

/**
 * Erstellt den Szenegraphen/*from  ww  w .j av  a  2 s .  c  om*/
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    TransformGroup objDreh = new TransformGroup(drehung);
    //Loader
    ObjectFile file = new ObjectFile(ObjectFile.RESIZE);
    Scene scene = null;
    try {
        scene = file.load(ClassLoader.getSystemResource("teapot.obj"));

    } catch (Exception e) {
    }
    objDreh.addChild(scene.getSceneGroup());

    DirectionalLight d_Licht = new DirectionalLight(new Color3f(1.0f, 0.5f, 0.3f),
            new Vector3f(-1.0f, -1.0f, -1.0f));
    d_Licht.setInfluencingBounds(new BoundingSphere(new Point3d(0.0d, 0.0d, 0.0d), 100.0d));
    //      d_Licht.setColor(new Color3f(1.0f,0.5f,0.3f));
    objDreh.addChild(d_Licht);

    objWurzel.addChild(objDreh);
    return objWurzel;
}