Java Code Examples for com.jme3.scene.Node#setLocalTranslation()

The following examples show how to use com.jme3.scene.Node#setLocalTranslation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestParallax.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
            
    Node floorGeom = new Node("floorGeom");
    Quad q = new Quad(100, 100);
    q.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry g = new Geometry("geom", q);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    floorGeom.attachChild(g);
    
    
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(-50, 22, 60);
    //floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
Example 2
Source File: TestParallax.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall2.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 0);

    Node floorGeom = (Node) assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml");
    Geometry g = ((Geometry) floorGeom.getChild(0));
    g.getMesh().scaleTextureCoordinates(new Vector2f(10, 10));
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(0, 22, 0);
    floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
Example 3
Source File: AbstractTransformControl.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
@Override
@JmeThread
public void setCollisionPlane(@NotNull final CollisionResult collisionResult) {

    final EditorTransformSupport editorControl = getEditorControl();
    final Transform transform = editorControl.getTransformCenter();

    if (transform == null) {
        LOGGER.warning(this, "not found transform center for the " + editorControl);
        return;
    }

    detectPickedAxis(editorControl, collisionResult);

    // set the collision Plane location and rotation
    final Node collisionPlane = getCollisionPlane();
    collisionPlane.setLocalTranslation(transform.getTranslation());
    collisionPlane.setLocalRotation(Quaternion.IDENTITY);
}
 
Example 4
Source File: EditorLightNode.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Update position and rotation of a model.
 */
@JmeThread
public void updateModel() {

    final Node model = getModel();
    if (model == null) return;

    final LocalObjects local = LocalObjects.get();
    final Vector3f positionOnCamera = local.nextVector();
    positionOnCamera.set(getLocalTranslation())
            .subtractLocal(camera.getLocation())
            .normalizeLocal()
            .multLocal(camera.getFrustumNear() + 0.4f)
            .addLocal(camera.getLocation());

    model.setLocalTranslation(positionOnCamera);
    model.setLocalRotation(getLocalRotation());
}
 
Example 5
Source File: EditorTransformSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@JmeThread
public void prepareToMove(@NotNull final Node parent, @NotNull final Node child,
                          @NotNull final Transform transform, @NotNull final Camera camera) {
    parent.setLocalRotation(camera.getRotation());
    parent.setLocalTranslation(transform.getTranslation());
    child.setLocalTranslation(Vector3f.ZERO);
    child.setLocalRotation(Quaternion.IDENTITY);
}
 
Example 6
Source File: LightProbeFactory.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * For debuging porpose only
 * Will return a Node meant to be added to a GUI presenting the 2 cube maps in a cross pattern with all the mip maps.
 *
 * @param manager the asset manager
 * @return a debug node
 */
public static Node getDebugGui(AssetManager manager, LightProbe probe) {
    if (!probe.isReady()) {
        throw new UnsupportedOperationException("This EnvProbe is not ready yet, try to test isReady()");
    }

    Node debugNode = new Node("debug gui probe");
    Node debugPfemCm = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(probe.getPrefilteredEnvMap(), manager);
    debugNode.attachChild(debugPfemCm);
    debugPfemCm.setLocalTranslation(520, 0, 0);

    return debugNode;
}
 
Example 7
Source File: AdvancedAbstractEditor3DPart.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Move a camera to direction.
 *
 * @param value the value to move.
 */
@JmeThread
private void moveDirectionCamera(final float value, final boolean isAction, final boolean isPressed, final int key) {

    if (!canCameraMove()) {
        return;
    } else if (isAction && isPressed) {
        startCameraMoving(key);
    } else if (isAction) {
        finishCameraMoving(key, false);
    }

    if (!isCameraMoving() || isAction) {
        return;
    }

    final EditorCamera editorCamera = getEditorCamera();
    if (editorCamera == null) {
        return;
    }

    final Camera camera = EditorUtil.getGlobalCamera();
    final Node nodeForCamera = getNodeForCamera();

    final LocalObjects local = LocalObjects.get();
    final Vector3f direction = camera.getDirection(local.nextVector());
    direction.multLocal(value * cameraSpeed);
    direction.addLocal(nodeForCamera.getLocalTranslation());

    nodeForCamera.setLocalTranslation(direction);
}
 
Example 8
Source File: TestEverything.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupRobotGuy(){
        Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
        Material mat = assetManager.loadMaterial("Models/Oto/Oto.j3m");
        model.getChild(0).setMaterial(mat);
//        model.setAnimation("Walk");
        model.setLocalTranslation(30, 10.5f, 30);
        model.setLocalScale(2);
        model.setShadowMode(ShadowMode.CastAndReceive);
        rootNode.attachChild(model);
    }
 
Example 9
Source File: TestEverything.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupRobotGuy(){
        Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
        Material mat = assetManager.loadMaterial("Models/Oto/Oto.j3m");
        model.getChild(0).setMaterial(mat);
//        model.setAnimation("Walk");
        model.setLocalTranslation(30, 10.5f, 30);
        model.setLocalScale(2);
        model.setShadowMode(ShadowMode.CastAndReceive);
        rootNode.attachChild(model);
    }
 
Example 10
Source File: TestRagdollCharacter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void simpleInitApp() {
        setupKeys();

        bulletAppState = new BulletAppState();
        bulletAppState.setEnabled(true);
        stateManager.attach(bulletAppState);


//        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
        PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
        initWall(2,1,1);
        setupLight();

        cam.setLocation(new Vector3f(-8,0,-4));
        cam.lookAt(new Vector3f(4,0,-7), Vector3f.UNIT_Y);

        model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
        model.lookAt(new Vector3f(0,0,-1), Vector3f.UNIT_Y);
        model.setLocalTranslation(4, 0, -7f);

        ragdoll = new KinematicRagdollControl(0.5f);
        model.addControl(ragdoll);

        getPhysicsSpace().add(ragdoll);
        speed = 1.3f;

        rootNode.attachChild(model);


        AnimControl control = model.getControl(AnimControl.class);
        animChannel = control.createChannel();
        animChannel.setAnim("IdleTop");
        control.addListener(this);

    }
 
Example 11
Source File: TestRagDoll.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Node createLimb(float width, float height, Vector3f location, boolean rotate) {
    int axis = rotate ? PhysicsSpace.AXIS_X : PhysicsSpace.AXIS_Y;
    CapsuleCollisionShape shape = new CapsuleCollisionShape(width, height, axis);
    Node node = new Node("Limb");
    RigidBodyControl rigidBodyControl = new RigidBodyControl(shape, 1);
    node.setLocalTranslation(location);
    node.addControl(rigidBodyControl);
    return node;
}
 
Example 12
Source File: EditorTransformSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Prepare nodes to move.
 *
 * @param parent    the parent node.
 * @param child     the child node.
 * @param transform the base transform.
 * @param camera    the camera.
 */
@JmeThread
public void prepareToMove(@NotNull final Node parent, @NotNull final Node child,
                          @NotNull final Transform transform, @NotNull final Camera camera) {
    parent.setLocalTranslation(transform.getTranslation());
    parent.setLocalRotation(transform.getRotation());
    child.setLocalTranslation(Vector3f.ZERO);
    child.setLocalRotation(Quaternion.IDENTITY);
}
 
Example 13
Source File: EditorTransformSupport.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@JmeThread
public void prepareToMove(@NotNull final Node parent, @NotNull final Node child,
                          @NotNull final Transform transform, @NotNull final Camera camera) {
    parent.setLocalTranslation(Vector3f.ZERO);
    parent.setLocalRotation(Quaternion.IDENTITY);
    child.setLocalTranslation(transform.getTranslation());
    child.setLocalRotation(transform.getRotation());
}
 
Example 14
Source File: TestJoystick.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    getFlyByCamera().setEnabled(false);

    Joystick[] joysticks = inputManager.getJoysticks();
    if (joysticks == null)
        throw new IllegalStateException("Cannot find any joysticks!");

    try {
        PrintWriter out = new PrintWriter( new FileWriter( "joysticks-" + System.currentTimeMillis() + ".txt" ) );
        dumpJoysticks( joysticks, out );
        out.close();
    } catch( IOException e ) {
        throw new RuntimeException( "Error writing joystick dump", e );
    }   


    int gamepadSize = cam.getHeight() / 2;
    float scale = gamepadSize / 512.0f;        
    gamepad = new GamepadView();       
    gamepad.setLocalTranslation( cam.getWidth() - gamepadSize - (scale * 20), 0, 0 );
    gamepad.setLocalScale( scale, scale, scale ); 
    guiNode.attachChild(gamepad); 

    joystickInfo = new Node( "joystickInfo" );
    joystickInfo.setLocalTranslation( 0, cam.getHeight(), 0 );
    guiNode.attachChild( joystickInfo );

    // Add a raw listener because it's easier to get all joystick events
    // this way.
    inputManager.addRawInputListener( new JoystickEventListener() );
    
    // add action listener for mouse click 
    // to all easier custom mapping
    inputManager.addMapping("mouseClick", new MouseButtonTrigger(mouseInput.BUTTON_LEFT));
    inputManager.addListener(new ActionListener() {
        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if(isPressed){
                pickGamePad(getInputManager().getCursorPosition());
            }
        }
    }, "mouseClick");
}
 
Example 15
Source File: BorderLayout.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void reshape(Vector3f pos, Vector3f size) {
    // Note: we use the pos and size for scratch because we
    // are a layout and we should therefore always be last.

    // Make sure the preferred size book-keeping is up to date.
    // Some children don't like being asked to resize without
    // having been asked to calculate their preferred size first.
    calculatePreferredSize(new Vector3f());

    Vector3f pref;
    Node child;

    // First the north component takes up the entire upper
    // border.
    child = children.get(Position.North);
    if( child != null ) {
        pref = getPreferredSize(Position.North);
        child.setLocalTranslation(pos);
        pos.y -= pref.y;
        size.y -= pref.y;
        child.getControl(GuiControl.class).setSize(new Vector3f(size.x, pref.y, size.z));
    }

    // And the south component takes up the entire lower border
    child = children.get(Position.South);
    if( child != null ) {
        pref = getPreferredSize(Position.South);
        child.setLocalTranslation(pos.x, pos.y - size.y + pref.y, pos.z);
        size.y -= pref.y;
        child.getControl(GuiControl.class).setSize(new Vector3f(size.x, pref.y, size.z));
    }

    // Now the east and west to hem in the left/right borders
    child = children.get(Position.West);
    if( child != null ) {
        pref = getPreferredSize(Position.West);
        child.setLocalTranslation(pos);
        pos.x += pref.x;
        size.x -= pref.x;
        child.getControl(GuiControl.class).setSize(new Vector3f(pref.x, size.y, size.z));
    }
    child = children.get(Position.East);
    if( child != null ) {
        pref = getPreferredSize(Position.East);
        child.setLocalTranslation(pos.x + size.x - pref.x, pos.y, pos.z);
        size.x -= pref.x;
        child.getControl(GuiControl.class).setSize(new Vector3f(pref.x, size.y, size.z));
    }

    // And what's left goes to the center component and it needs to
    // be resized appropriately.
    child = children.get(Position.Center);
    if( child != null ) {
        child.setLocalTranslation( pos );
        child.getControl(GuiControl.class).setSize(size);
    }
}
 
Example 16
Source File: TestAnimBlendBug.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {
        inputManager.addMapping("One", new KeyTrigger(KeyInput.KEY_1));
        inputManager.addListener(this, "One");

        flyCam.setMoveSpeed(100f);
        cam.setLocation( new Vector3f( 0f, 150f, -325f ) );
        cam.lookAt( new Vector3f( 0f, 100f, 0f ), Vector3f.UNIT_Y );

        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
        dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
        rootNode.addLight(dl);

        Node model1 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
        Node model2 = (Node) assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
//        Node model2 = model1.clone();

        model1.setLocalTranslation(-60, 0, 0);
        model2.setLocalTranslation(60, 0, 0);

        AnimControl control1 = model1.getControl(AnimControl.class);
        animNames = control1.getAnimationNames().toArray(new String[0]);
        channel1 = control1.createChannel();
        
        AnimControl control2 = model2.getControl(AnimControl.class);
        channel2 = control2.createChannel();

        SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton1", control1.getSkeleton());
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.getAdditionalRenderState().setWireframe(true);
        mat.setColor("Color", ColorRGBA.Green);
        mat.getAdditionalRenderState().setDepthTest(false);
        skeletonDebug.setMaterial(mat);
        model1.attachChild(skeletonDebug);

        skeletonDebug = new SkeletonDebugger("skeleton2", control2.getSkeleton());
        skeletonDebug.setMaterial(mat);
        model2.attachChild(skeletonDebug);

        rootNode.attachChild(model1);
        rootNode.attachChild(model2);
    }
 
Example 17
Source File: TestBillboard.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {
        flyCam.setMoveSpeed(10);

        Quad q = new Quad(2, 2);
        Geometry g = new Geometry("Quad", q);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        g.setMaterial(mat);

        Quad q2 = new Quad(1, 1);
        Geometry g3 = new Geometry("Quad2", q2);
        Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat2.setColor("Color", ColorRGBA.Yellow);
        g3.setMaterial(mat2);
        g3.setLocalTranslation(.5f, .5f, .01f);

        Box b = new Box(.25f, .5f, .25f);
        Geometry g2 = new Geometry("Box", b);
        g2.setLocalTranslation(0, 0, 3);
        g2.setMaterial(mat);

        Node bb = new Node("billboard");

        BillboardControl control=new BillboardControl();
        
        bb.addControl(control);
        bb.attachChild(g);
        bb.attachChild(g3);       
        

        n=new Node("parent");
        n.attachChild(g2);
        n.attachChild(bb);
        rootNode.attachChild(n);

        n2=new Node("parentParent");
        n2.setLocalTranslation(Vector3f.UNIT_X.mult(5));
        n2.attachChild(n);

        rootNode.attachChild(n2);


//        rootNode.attachChild(bb);
//        rootNode.attachChild(g2);
    }
 
Example 18
Source File: TestSpatialAnim.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {

    AmbientLight al = new AmbientLight();
    rootNode.addLight(al);

    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(Vector3f.UNIT_XYZ.negate());
    rootNode.addLight(dl);

    // Create model
    Box box = new Box(1, 1, 1);
    Geometry geom = new Geometry("box", box);
    geom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
    Node model = new Node("model");
    model.attachChild(geom);

    Box child = new Box(0.5f, 0.5f, 0.5f);
    Geometry childGeom = new Geometry("box", child);
    childGeom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
    Node childModel = new Node("childmodel");
    childModel.setLocalTranslation(2, 2, 2);
    childModel.attachChild(childGeom);
    model.attachChild(childModel);
    
    //animation parameters
    float animTime = 5;
    int fps = 25;
    float totalXLength = 10;
    
    //calculating frames
    int totalFrames = (int) (fps * animTime);
    float dT = animTime / totalFrames, t = 0;
    float dX = totalXLength / totalFrames, x = 0;
    float[] times = new float[totalFrames];
    Vector3f[] translations = new Vector3f[totalFrames];
    Quaternion[] rotations = new Quaternion[totalFrames];
    Vector3f[] scales = new Vector3f[totalFrames];
    for (int i = 0; i < totalFrames; ++i) {
            times[i] = t;
            t += dT;
            translations[i] = new Vector3f(x, 0, 0);
            x += dX;
            rotations[i] = Quaternion.IDENTITY;
            scales[i] = Vector3f.UNIT_XYZ;
    }
    TransformTrack transformTrack = new TransformTrack(geom, times, translations, rotations, scales);
    TransformTrack transformTrackChild = new TransformTrack(childGeom, times, translations, rotations, scales);
    // creating the animation
    AnimClip animClip = new AnimClip("anim");
    animClip.setTracks(new AnimTrack[] { transformTrack, transformTrackChild });

    // create spatial animation control
    AnimComposer animComposer = new AnimComposer();
    animComposer.addAnimClip(animClip);

    model.addControl(animComposer);
    rootNode.attachChild(model);

    // run animation
    model.getControl(AnimComposer.class).setCurrentAction("anim");
}
 
Example 19
Source File: TestAnimationFactory.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {

    AmbientLight al = new AmbientLight();
    rootNode.addLight(al);

    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(Vector3f.UNIT_XYZ.negate());
    rootNode.addLight(dl);

    // Create model
    Box box = new Box(1, 1, 1);
    Geometry geom = new Geometry("box", box);
    geom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
    Node model = new Node("model");
    model.attachChild(geom);

    Box child = new Box(0.5f, 0.5f, 0.5f);
    Geometry childGeom = new Geometry("box", child);
    childGeom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
    Node childModel = new Node("childmodel");
    childModel.setLocalTranslation(2, 2, 2);
    childModel.attachChild(childGeom);
    model.attachChild(childModel);
    TangentBinormalGenerator.generate(model);

    //creating quite complex animation with the AnimationHelper
    // animation of 6 seconds named "anim" and with 25 frames per second
    AnimationFactory animationFactory = new AnimationFactory(6, "anim", 25);
    
    //creating a translation keyFrame at time = 3 with a translation on the x axis of 5 WU        
    animationFactory.addTimeTranslation(3, new Vector3f(5, 0, 0));
    //resetting the translation to the start position at time = 6
    animationFactory.addTimeTranslation(6, new Vector3f(0, 0, 0));

    //Creating a scale keyFrame at time = 2 with the unit scale.
    animationFactory.addTimeScale(2, new Vector3f(1, 1, 1));
    //Creating a scale keyFrame at time = 4 scaling to 1.5
    animationFactory.addTimeScale(4, new Vector3f(1.5f, 1.5f, 1.5f));
    //resetting the scale to the start value at time = 5
    animationFactory.addTimeScale(5, new Vector3f(1, 1, 1));

    
    //Creating a rotation keyFrame at time = 0.5 of quarter PI around the Z axis
    animationFactory.addTimeRotation(0.5f,new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Z));
    //rotating back to initial rotation value at time = 1
    animationFactory.addTimeRotation(1,Quaternion.IDENTITY);
    //Creating a rotation keyFrame at time = 2. Note that i used the Euler angle version because the angle is higher than PI
    //this should result in a complete revolution of the spatial around the x axis in 1 second (from 1 to 2)
    animationFactory.addTimeRotationAngles(2, FastMath.TWO_PI,0, 0);


    AnimControl control = new AnimControl();
    control.addAnim(animationFactory.buildAnimation());

    model.addControl(control);

    rootNode.attachChild(model);

    //run animation
    control.createChannel().setAnim("anim");
}
 
Example 20
Source File: TestBillboard.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void simpleInitApp() {
        flyCam.setMoveSpeed(10);

        Quad q = new Quad(2, 2);
        Geometry g = new Geometry("Quad", q);
        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);
        g.setMaterial(mat);

        Quad q2 = new Quad(1, 1);
        Geometry g3 = new Geometry("Quad2", q2);
        Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat2.setColor("Color", ColorRGBA.Yellow);
        g3.setMaterial(mat2);
        g3.setLocalTranslation(.5f, .5f, .01f);

        Box b = new Box(new Vector3f(0, 0, 3), .25f, .5f, .25f);
        Geometry g2 = new Geometry("Box", b);
        g2.setMaterial(mat);

        Node bb = new Node("billboard");

        BillboardControl control=new BillboardControl();
        
        bb.addControl(control);
        bb.attachChild(g);
        bb.attachChild(g3);       
        

        n=new Node("parent");
        n.attachChild(g2);
        n.attachChild(bb);
        rootNode.attachChild(n);

        n2=new Node("parentParent");
        n2.setLocalTranslation(Vector3f.UNIT_X.mult(5));
        n2.attachChild(n);

        rootNode.attachChild(n2);


//        rootNode.attachChild(bb);
//        rootNode.attachChild(g2);
    }