1

My code

 private Node enemies;


 private void initEnemies(){
    enemies = new Node();

    Box boxMesh = new Box(1f, 1f, 1f);
    Geometry boxGeo = new Geometry("Colored Box", boxMesh);
    Material boxMat = new Material(getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
    boxMat.setBoolean("UseMaterialColors", true);
    boxMat.setColor("Ambient", ColorRGBA.Blue);
    boxMat.setColor("Diffuse", ColorRGBA.Blue);
    boxGeo.setMaterial(boxMat);
    boxGeo.setLocalTranslation(playerNode.getLocalTranslation());
    boxGeo.setUserData("Health", 100);

    enemies.attachChild(boxGeo);
    rootNode.attachChild(enemies);
}


@Override
public void simpleInitApp() {
    initAsset();
    initState();
    initThis();

    flyCam.setEnabled(false);
    stateManager.detach(stateManager.getState(FlyCamAppState.class));

    MyCamera myCam = new MyCamera(cam);
    myCam.registerWithInput(inputManager);

    stateManager.attach(new GunState());

    bulletAppState = new BulletAppState();

    stateManager.attach(bulletAppState);

    initTerrain();
    initLight();
    initHUD();
    initPlayer();
    initEnemies();
}

And not showing :( No errors No console crash No exit game Anybody know how to repair it? All working but this enemies not :(

I need this to my 3d game with jmonkeyengine 3

Thx for any help

FajosDev
  • 11
  • 1
  • 1
    Can you show the initLight() method please? Maybe the box is just black. Try changing the background color: viewPort.setBackgroundColor(ColorRGBA.DarkGray); – 1000ml Nov 10 '14 at 14:53

2 Answers2

0

Yo may need to add a Light to see your Box and attach that to the box.

DirectionalLight sun = new DirectionalLight();
sun.setDirection((new Vector3f(1f, 1f, 1f)).normalizeLocal());
sun.setColor(ColorRGBA.White);
rootNode.attachChild(Box);
rootNode.addLight(sun);
Jman2
  • 11
  • 2
0

Another one solution is to change Common/MatDefs/Light/Lighting.j3md to Common/MatDefs/Misc/Unshaded.j3md and remove Diffuse and Ambient color definitions and use instead of them Color color definition. It happening because Lightning material requires light in the scene as Jman2 stated. Unshaded material requires no light. Try it - should helps.

Serj.by
  • 534
  • 5
  • 17