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

The following examples show how to use com.jme3.scene.Node#addLight() . 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: BaseMaterialEditor3DPart.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Update the light in the scene in the {@link EditorThread}.
 *
 * @param enabled true if light should be enabled.
 */
@JmeThread
protected void updateLightEnabledImpl(final boolean enabled) {
    if (enabled == isLightEnabled()) return;

    final DirectionalLight light = getLightForCamera();
    final Node stateNode = getStateNode();

    if (enabled) {
        stateNode.addLight(light);
    } else {
        stateNode.removeLight(light);
    }

    setLightEnabled(enabled);
}
 
Example 2
Source File: AdvancedAbstractEditor3DPart.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
public AdvancedAbstractEditor3DPart(@NotNull final T fileEditor) {
    super(fileEditor);
    this.cameraMoving = new AtomicInteger();
    this.editorCamera = needEditorCamera() ? createEditorCamera() : null;
    this.lightForCamera = needLightForCamera() ? createLightForCamera() : null;
    this.prevCameraLocation = new Vector3f();
    this.cameraKeysState = new boolean[4];
    this.cameraSpeed = 1F;

    if (lightForCamera != null) {
        final Node stateNode = getStateNode();
        stateNode.addLight(lightForCamera);
    }

    this.analogListener = this::onAnalogImpl;
    this.actionListener = this::onActionImpl;
    this.actionHandlers = DictionaryFactory.newObjectDictionary();
    this.analogHandlers = DictionaryFactory.newObjectDictionary();

    registerActionHandlers(actionHandlers);
    registerAnalogHandlers(analogHandlers);
}
 
Example 3
Source File: ModelEditor3DPart.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * The process of updating the light.
 */
@JmeThread
private void updateLightEnabledImpl(boolean enabled) {

    if (enabled == isLightEnabled()) {
        return;
    }

    final DirectionalLight light = getLightForCamera();
    final Node stateNode = getStateNode();

    if (enabled) {
        stateNode.addLight(light);
    } else {
        stateNode.removeLight(light);
    }

    setLightEnabled(enabled);
}
 
Example 4
Source File: TestFog.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    this.flyCam.setMoveSpeed(50);
    Node mainScene=new Node();
    cam.setLocation(new Vector3f(-34.74095f, 95.21318f, -287.4945f));
    cam.setRotation(new Quaternion(0.023536969f, 0.9361278f, -0.016098259f, -0.35050195f));

    // load sky
    mainScene.attachChild(SkyFactory.createSky(assetManager, 
            "Textures/Sky/Bright/BrightSky.dds", 
            SkyFactory.EnvMapType.CubeMap));
    createTerrain(mainScene);



    DirectionalLight sun = new DirectionalLight();
    Vector3f lightDir=new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    mainScene.addLight(sun);

    rootNode.attachChild(mainScene);

    fpp=new FilterPostProcessor(assetManager);
    //fpp.setNumSamples(4);
    int numSamples = getContext().getSettings().getSamples();
    if( numSamples > 0 ) {
        fpp.setNumSamples(numSamples); 
    }
    fog=new FogFilter();
    fog.setFogColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f));
    fog.setFogDistance(155);
    fog.setFogDensity(1.0f);
    fpp.addFilter(fog);
    viewPort.addProcessor(fpp);
    initInputs();
}
 
Example 5
Source File: AbstractBlenderLoader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * This method converts the given structure to a scene node.
 * @param structure
 *            structure of a scene
 * @return scene's node
 */
public Node toScene(Structure structure) {
    if ((blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.SCENES) == 0) {
        return null;
    }
    Node result = new Node(structure.getName());
    try {
        List<Structure> base = ((Structure) structure.getFieldValue("base")).evaluateListBase(blenderContext);
        for (Structure b : base) {
            Pointer pObject = (Pointer) b.getFieldValue("object");
            if (pObject.isNotNull()) {
                Structure objectStructure = pObject.fetchData(blenderContext.getInputStream()).get(0);
                Object object = this.toObject(objectStructure);
                if (object instanceof LightNode && (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.LIGHTS) != 0) {
                    result.addLight(((LightNode) object).getLight());
                    result.attachChild((LightNode) object);
                } else if (object instanceof Node && (blenderContext.getBlenderKey().getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0) {
                    LOGGER.log(Level.FINE, "{0}: {1}--> {2}", new Object[] { ((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName() });
                    if (((Node) object).getParent() == null) {
                        result.attachChild((Spatial) object);
                    }
                }
            }
        }
    } catch (BlenderFileException e) {
        LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    return result;
}
 
Example 6
Source File: BlenderModelLoader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public Spatial load(AssetInfo assetInfo) throws IOException {
    try {
        this.setup(assetInfo);

        BlenderKey blenderKey = blenderContext.getBlenderKey();
        Node modelRoot = new Node(blenderKey.getName());

        for (FileBlockHeader block : blocks) {
            if (block.getCode() == FileBlockHeader.BLOCK_OB00) {
                Object object = this.toObject(block.getStructure(blenderContext));

                if (object instanceof LightNode && (blenderKey.getFeaturesToLoad() & FeaturesToLoad.LIGHTS) != 0) {
                    modelRoot.addLight(((LightNode) object).getLight());
                    modelRoot.attachChild((LightNode) object);
                } else if (object instanceof Node && (blenderKey.getFeaturesToLoad() & FeaturesToLoad.OBJECTS) != 0) {
                    LOGGER.log(Level.FINE, "{0}: {1}--> {2}", new Object[] { ((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName() });
                    if (((Node) object).getParent() == null) {
                        modelRoot.attachChild((Node) object);
                    }
                }
            }
        }

        // bake constraints after everything is loaded
        ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class);
        constraintHelper.bakeConstraints(blenderContext);

        blenderContext.dispose();
        return modelRoot;
    } catch (BlenderFileException e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
    }
    return null;
}
 
Example 7
Source File: VehicleEditorController.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public VehicleEditorController(JmeSpatial jmeRootNode, BinaryModelDataObject currentFileObject) {
    this.jmeRootNode = jmeRootNode;
    this.currentFileObject = currentFileObject;
    rootNode = jmeRootNode.getLookup().lookup(Node.class);
    toolsNode = new Node("ToolsNode");
    toolController = new SceneToolController(toolsNode, currentFileObject.getLookup().lookup(ProjectAssetManager.class));
    toolController.setShowSelection(true);
    result = Utilities.actionsGlobalContext().lookupResult(JmeSpatial.class);
    result.addLookupListener(this);
    toolsNode.addLight(new DirectionalLight());
    Node track = (Node) new DesktopAssetManager(true).loadModel("Models/Racetrack/Raceway.j3o");
    track.getChild("Grass").getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(30, -1, 0));
    track.getChild("Grass").getControl(RigidBodyControl.class).setPhysicsRotation(new Quaternion().fromAngleAxis(FastMath.HALF_PI * 0.68f, Vector3f.UNIT_Y).toRotationMatrix());
    track.getChild("Road").getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(30, 0, 0));
    track.getChild("Road").getControl(RigidBodyControl.class).setPhysicsRotation(new Quaternion().fromAngleAxis(FastMath.HALF_PI * 0.68f, Vector3f.UNIT_Y).toRotationMatrix());
    toolsNode.attachChild(track);
    bulletState = new BulletAppState();

    result2 = Utilities.actionsGlobalContext().lookupResult(VehicleWheel.class);
    LookupListener listener = new LookupListener() {

        public void resultChanged(LookupEvent ev) {
            for (Iterator<? extends VehicleWheel> it = result2.allInstances().iterator(); it.hasNext();) {
                VehicleWheel wheel = it.next();
                toolController.updateSelection(wheel.getWheelSpatial());
            }
        }
    };
    result2.addLookupListener(listener);
}
 
Example 8
Source File: HudState.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void initialize( Application app ) 
{
    InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper();
    inputMapper.addDelegate( MainFunctions.F_HUD, this, "toggleHud" );
    
    Camera cam = app.getCamera().clone();
    cam.setParallelProjection(true);
    size = new Vector3f( cam.getWidth(), cam.getHeight(), 0 );
    
    main = new Node( "HUD" ); 
    main.setQueueBucket(Bucket.Gui);
 
    view = app.getRenderManager().createPostView( "Hud ViewPort", cam);
    view.setEnabled(isEnabled());
    view.setClearFlags(false, true, true);
    view.attachScene( main );
 
    // Make sure our viewport is setup properly
    GuiGlobals.getInstance().setupGuiComparators(view);

    // Make sure this viewport gets mouse events
    getState(MouseAppState.class).addCollisionRoot( main, view );
 
    // Setup a basic container for standard layout... for anything
    // that cares to use it.       
    container = new Container( new BorderLayout() );
    container.setPreferredSize( new Vector3f(cam.getWidth(), cam.getHeight(), 0) );
    container.setLocalTranslation( 0, cam.getHeight(), 0 );
    main.attachChild(container);
 
    if( lit )
        {
        // Add some lighting 
        DirectionalLight light = new DirectionalLight();
        light.setDirection( new Vector3f( 1, -0.5f, -1.5f ).normalizeLocal() );
        main.addLight(light);

        AmbientLight ambient = new AmbientLight();
        ambient.setColor( ColorRGBA.Gray );
        main.addLight(ambient);
        }
    
    // Have to add an empty geometry to the HUD because JME has
    // a bug in the online versions and I'd rather not go directly to
    // source.
    Label temp = new Label("");
    getNorth().addChild(temp);        
 
 
    /*
    Just a test container... putting the real stuff somewhere else in a sec.
    Container test = new Container(new ElementId("window.container"), "glass"); 
    System.out.println( "Container layout:" + test.getLayout() );
    test.addChild(new Label("Test Title", new ElementId("window.title.label"), "glass"));
    test.addChild(new Button("Test Button 1", new ElementId("window.button"), "glass"));
    test.addChild(new Button("Test Button 2", new ElementId("window.button"), "glass"));
    test.addChild(new Button("Test Button 3", new ElementId("window.button"), "glass"));
    test.addChild(new Button("Test Button 4", new ElementId("window.button"), "glass"));
    getWest().addChild(test);
    */
    
    main.updateLogicalState(1);
    main.updateGeometricState();
}
 
Example 9
Source File: TestShadowBug.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
  flyCam.setMoveSpeed(100f);
  rootNode.attachChild(makeFloor());

  Node characters = new Node("Characters");
  characters.setShadowMode(ShadowMode.Cast);
  rootNode.attachChild(characters);

  Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
  golem.scale(0.5f);
  golem.setLocalTranslation(200.0f, -6f, 200f);
  golem.setShadowMode(ShadowMode.CastAndReceive);
  characters.attachChild(golem);

  DirectionalLight sun = new DirectionalLight();
  sun.setDirection(new Vector3f(-1f, -1f, 1f));
  sun.setColor(ColorRGBA.White.mult(1.3f));
  rootNode.addLight(sun);
  characters.addLight(sun);

  SpotLight spot = new SpotLight();
  spot.setSpotRange(13f);                           // distance
  spot.setSpotInnerAngle(15f * FastMath.DEG_TO_RAD); // inner light cone (central beam)
  spot.setSpotOuterAngle(20f * FastMath.DEG_TO_RAD); // outer light cone (edge of the light)
  spot.setColor(ColorRGBA.White.mult(1.3f));         // light color
  spot.setPosition(new Vector3f(192.0f, -1f, 192f));
  spot.setDirection(new Vector3f(1, -0.5f, 1));
  rootNode.addLight(spot);

  PointLight lamp_light = new PointLight();
  lamp_light.setColor(ColorRGBA.Yellow);
  lamp_light.setRadius(20f);
  lamp_light.setPosition(new Vector3f(210.0f, 0f, 210f));
  rootNode.addLight(lamp_light);

  SpotLightShadowRenderer slsr = new SpotLightShadowRenderer(assetManager, 512);
  slsr.setLight(spot);
  slsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
  slsr.setShadowIntensity(0.6f);
  viewPort.addProcessor(slsr);

  PointLightShadowRenderer plsr = new PointLightShadowRenderer(assetManager, 512);
  plsr.setLight(lamp_light);
  plsr.setShadowIntensity(0.6f);
  plsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
  viewPort.addProcessor(plsr);

  viewPort.getCamera().setLocation(new Vector3f(192.0f, 10f, 192f));
  float[] angles = new float[]{3.14f/2, 3.14f/2, 0};
  viewPort.getCamera().setRotation(new Quaternion(angles));
}
 
Example 10
Source File: PhysicsTestHelper.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
     * creates a simple physics test world with a floor, an obstacle and some test boxes
     *
     * @param rootNode where lights and geometries should be added
     * @param assetManager for loading assets
     * @param space where collision objects should be added
     */
    public static void createPhysicsTestWorld(Node rootNode, AssetManager assetManager, PhysicsSpace space) {
        AmbientLight light = new AmbientLight();
        light.setColor(ColorRGBA.LightGray);
        rootNode.addLight(light);

        Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));

        Box floorBox = new Box(140, 0.25f, 140);
        Geometry floorGeometry = new Geometry("Floor", floorBox);
        floorGeometry.setMaterial(material);
        floorGeometry.setLocalTranslation(0, -5, 0);
//        Plane plane = new Plane();
//        plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y);
//        floorGeometry.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0));
        floorGeometry.addControl(new RigidBodyControl(0));
        rootNode.attachChild(floorGeometry);
        space.add(floorGeometry);

        //movable boxes
        for (int i = 0; i < 12; i++) {
            Box box = new Box(0.25f, 0.25f, 0.25f);
            Geometry boxGeometry = new Geometry("Box", box);
            boxGeometry.setMaterial(material);
            boxGeometry.setLocalTranslation(i, 5, -3);
            //RigidBodyControl automatically uses box collision shapes when attached to single geometry with box mesh
            boxGeometry.addControl(new RigidBodyControl(2));
            rootNode.attachChild(boxGeometry);
            space.add(boxGeometry);
        }

        //immovable sphere with mesh collision shape
        Sphere sphere = new Sphere(8, 8, 1);
        Geometry sphereGeometry = new Geometry("Sphere", sphere);
        sphereGeometry.setMaterial(material);
        sphereGeometry.setLocalTranslation(4, -4, 2);
        sphereGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(sphere), 0));
        rootNode.attachChild(sphereGeometry);
        space.add(sphereGeometry);

    }
 
Example 11
Source File: TestMultiPostWater.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
    public void simpleInitApp() {

//      setDisplayFps(false);
//      setDisplayStatView(false);

        Node mainScene = new Node("Main Scene");
        rootNode.attachChild(mainScene);

        createTerrain(mainScene);
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection(lightDir);
        sun.setColor(ColorRGBA.White.clone().multLocal(1.7f));
        mainScene.addLight(sun);

        flyCam.setMoveSpeed(100);

        //cam.setLocation(new Vector3f(-700, 100, 300));
        //cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
        cam.setLocation(new Vector3f(-327.21957f, 251.6459f, 126.884346f));
        cam.setRotation(new Quaternion().fromAngles(new float[]{FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0}));


        Spatial sky = SkyFactory.createSky(assetManager, 
                "Scenes/Beach/FullskiesSunset0068.dds", EnvMapType.CubeMap);
        sky.setLocalScale(350);

        mainScene.attachChild(sky);
        cam.setFrustumFar(4000);



        FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

        water = new WaterFilter(rootNode, lightDir);
        water.setCenter(new Vector3f(9.628218f, -15.830074f, 199.23595f));
        water.setRadius(260);
        water.setWaveScale(0.003f);
        water.setMaxAmplitude(2f);
        water.setFoamExistence(new Vector3f(1f, 4, 0.5f));
        water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
        water.setRefractionStrength(0.2f);
        water.setWaterHeight(WATER_HEIGHT);
        fpp.addFilter(water);

        WaterFilter water2 = new WaterFilter(rootNode, lightDir);
        water2.setCenter(new Vector3f(-280.46027f, -24.971727f, -271.71976f));
        water2.setRadius(260);
        water2.setWaterHeight(WATER_HEIGHT);
        water2.setUseFoam(false);
        water2.setUseRipples(false);
        water2.setDeepWaterColor(ColorRGBA.Brown);
        water2.setWaterColor(ColorRGBA.Brown.mult(2.0f));
        water2.setWaterTransparency(0.2f);
        water2.setMaxAmplitude(0.3f);
        water2.setWaveScale(0.008f);
        water2.setSpeed(0.7f);
        water2.setShoreHardness(1.0f);
        water2.setRefractionConstant(0.2f);
        water2.setShininess(0.3f);
        water2.setSunScale(1.0f);
        water2.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
        fpp.addFilter(water2);


        WaterFilter water3 = new WaterFilter(rootNode, lightDir);
        water3.setCenter(new Vector3f(319.6663f, -18.367947f, -236.67674f));
        water3.setRadius(260);
        water3.setWaterHeight(WATER_HEIGHT);
        water3.setWaveScale(0.003f);
        water3.setMaxAmplitude(2f);
        water3.setFoamExistence(new Vector3f(1f, 4, 0.5f));
        water3.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
        water3.setRefractionStrength(0.2f);
        water3.setDeepWaterColor(ColorRGBA.Red);
        water3.setWaterColor(ColorRGBA.Red.mult(2.0f));
        water3.setLightColor(ColorRGBA.Red);
        fpp.addFilter(water3);

        viewPort.addProcessor(fpp);

        //fpp.setNumSamples(4);
    }
 
Example 12
Source File: PhysicsTestHelper.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
     * creates a simple physics test world with a floor, an obstacle and some test boxes
     * @param rootNode
     * @param assetManager
     * @param space
     */
    public static void createPhysicsTestWorld(Node rootNode, AssetManager assetManager, PhysicsSpace space) {
        AmbientLight light = new AmbientLight();
        light.setColor(ColorRGBA.LightGray);
        rootNode.addLight(light);

        Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));

        Box floorBox = new Box(140, 0.25f, 140);
        Geometry floorGeometry = new Geometry("Floor", floorBox);
        floorGeometry.setMaterial(material);
        floorGeometry.setLocalTranslation(0, -5, 0);
//        Plane plane = new Plane();
//        plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y);
//        floorGeometry.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0));
        floorGeometry.addControl(new RigidBodyControl(0));
        rootNode.attachChild(floorGeometry);
        space.add(floorGeometry);

        //movable boxes
        for (int i = 0; i < 12; i++) {
            Box box = new Box(0.25f, 0.25f, 0.25f);
            Geometry boxGeometry = new Geometry("Box", box);
            boxGeometry.setMaterial(material);
            boxGeometry.setLocalTranslation(i, 5, -3);
            //RigidBodyControl automatically uses box collision shapes when attached to single geometry with box mesh
            boxGeometry.addControl(new RigidBodyControl(2));
            rootNode.attachChild(boxGeometry);
            space.add(boxGeometry);
        }

        //immovable sphere with mesh collision shape
        Sphere sphere = new Sphere(8, 8, 1);
        Geometry sphereGeometry = new Geometry("Sphere", sphere);
        sphereGeometry.setMaterial(material);
        sphereGeometry.setLocalTranslation(4, -4, 2);
        sphereGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(sphere), 0));
        rootNode.attachChild(sphereGeometry);
        space.add(sphereGeometry);

    }
 
Example 13
Source File: PhysicsTestHelper.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void createPhysicsTestWorldSoccer(Node rootNode, AssetManager assetManager, PhysicsSpace space) {
        AmbientLight light = new AmbientLight();
        light.setColor(ColorRGBA.LightGray);
        rootNode.addLight(light);

        Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));

        Box floorBox = new Box(140, 0.25f, 140);
        Geometry floorGeometry = new Geometry("Floor", floorBox);
        floorGeometry.setMaterial(material);
        floorGeometry.setLocalTranslation(0, -0.25f, 0);
//        Plane plane = new Plane();
//        plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y);
//        floorGeometry.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0));
        floorGeometry.addControl(new RigidBodyControl(0));
        rootNode.attachChild(floorGeometry);
        space.add(floorGeometry);

        //movable spheres
        for (int i = 0; i < 5; i++) {
            Sphere sphere = new Sphere(16, 16, .5f);
            Geometry ballGeometry = new Geometry("Soccer ball", sphere);
            ballGeometry.setMaterial(material);
            ballGeometry.setLocalTranslation(i, 2, -3);
            //RigidBodyControl automatically uses Sphere collision shapes when attached to single geometry with sphere mesh
            ballGeometry.addControl(new RigidBodyControl(.001f));
            ballGeometry.getControl(RigidBodyControl.class).setRestitution(1);
            rootNode.attachChild(ballGeometry);
            space.add(ballGeometry);
        }

        //immovable Box with mesh collision shape
        Box box = new Box(1, 1, 1);
        Geometry boxGeometry = new Geometry("Box", box);
        boxGeometry.setMaterial(material);
        boxGeometry.setLocalTranslation(4, 1, 2);
        boxGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(box), 0));
        rootNode.attachChild(boxGeometry);
        space.add(boxGeometry);

    }