JMonkeyEngine渲染。框不渲染

时间:2014-11-10 10:43:04

标签: jmonkeyengine

我的代码

 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();
}

并没有显示:( 没有错误 没有控制台崩溃 没有退出游戏 有谁知道如何修复它? 所有工作,但这个敌人不是:(

我需要这个与jmonkeyengine 3的3D游戏

获取任何帮助

2 个答案:

答案 0 :(得分:0)

哟可能需要添加一个Light才能看到你的Box并将其附在盒子上。

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

答案 1 :(得分:0)

另一个解决方案是将Common / MatDefs / Light / Lighting.j3md更改为Common / MatDefs / Misc / Unshaded.j3md并删除漫反射和环境颜色定义,并使用它们代替颜色颜色定义。之所以发生这种情况,是因为闪电材料需要场景中的光,如Jman2所述。无阴影的材料不需要光线。试试吧 - 应该有帮助。

相关问题