0

我正在尝试在 jMonkeyEnging 中进行地形生成,并按照教程(http://jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_terrain)进行操作,但遇到了一个小问题。最后,simpleInitApp 方法(细节级别)中的代码块,我得到了错误:

1. Cannot Find Symbol: class list
2. Cannot Find Symbol: class camera
3. Cannot Find Symbol: class arrayList

当我删除详细级别编码时,运行时出现错误:

1. SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
    at mygame.Main.simpleInitApp(Main.java:35)
        at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:231)
    at         com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)
    at java.lang.Thread.run(Thread.java:722)

我做错了什么,这不在教程中(或我的代码,如下)

    package mygame;

    import com.jme3.app.SimpleApplication;
    import com.jme3.material.Material;
    import com.jme3.terrain.geomipmap.TerrainLodControl;
    import com.jme3.terrain.heightmap.AbstractHeightMap;
    import com.jme3.terrain.geomipmap.TerrainQuad;
    import com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator;
    import com.jme3.terrain.heightmap.HillHeightMap; // for exercise 2
    import com.jme3.terrain.heightmap.ImageBasedHeightMap;
    import com.jme3.texture.Texture;
    import com.jme3.texture.Texture.WrapMode;
    import jme3tools.converters.ImageToAwt;

    /**
     * test
     * @author Me
     */
    public class Main extends SimpleApplication {

        public static void main(String[] args) {
            Main app = new Main();
            app.start();
        }

        private TerrainQuad terrain;
        Material mat_terrain;

        @Override
        public void simpleInitApp() {
            flyCam.setMoveSpeed(50);

            //add grass to the mat_terrain
            Texture grass = assetManager.loadTexture("Textures/grass.jpg");
            mat_terrain.setTexture("tex1", grass);
            mat_terrain.setFloat("tex1Scale", 64f);

            //add dirt to the mat_terrain
            Texture dirt = assetManager.loadTexture("Textures/dirt.jpg");
            mat_terrain.setTexture("tex2", dirt);
            mat_terrain.setFloat("tex2Scale", 32f);

            //add roads to the mat_terrain
            Texture road = assetManager.loadTexture("Textures/road.jpg");
            mat_terrain.setTexture("tex2", road);
            mat_terrain.setFloat("tex3Scale", 128f);

            //deal with the generation
            AbstractHeightMap heightMap = null;
            HillHeightMap heightmap = null;
            try {
                heightmap = new HillHeightMap(513, 1000, 50, 100, (byte) 3);
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            //create the world
            int patchSize = 65;
            terrain = new TerrainQuad("my terrain", patchSize, 513,                    heightmap.getHeightMap());

            //material, position, scale

            terrain.setMaterial(mat_terrain);
            terrain.setLocalTranslation(0, -100, 0);
            terrain.setLocalScale(2f, 1f, 2f);
            rootNode.attachChild(terrain);

            //LOD
            List<Camera> cameras = new ArrayList<Camera>();
            cameras.add(getCamera());
            TerrainLodControl control = new TerrainLodControl(terrain, cameras);
            terrain.addControl(control);
        }
    }
4

1 回答 1

0

您需要导入 Camera(来自 jME3 渲染包)以及 List 和 ArrayList(来自 java.util)。

您最好在http://jmonkeyengine.org/forum的论坛上发布任何与 jME 相关的问题

于 2012-05-01T04:39:16.287 回答