jMonkeyEngine3(jME3)地形的细节级别

时间:2011-11-19 13:21:20

标签: java 3d terrain jmonkeyengine

我正在尝试在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);
        }
    }

1 个答案:

答案 0 :(得分:0)

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

您最好在http://jmonkeyengine.org/forum

向论坛发布任何与jME相关的问题