好的,这是我的代码:
package test;
import java.util.ArrayList;
import java.util.Vector;
import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Node;
public class test extends SimpleApplication {
public static void main(String[] args){
AppSettings settings = new AppSettings(false);
settings.setResolution(640,480);
test app = new test();
app.setSettings(settings);
app.start();
}
@Override
public void simpleInitApp() {
ArrayList<Geometry> geos = new ArrayList<Geometry>();
for ( int count = 0; count <= 5; count++ ) {
double x = 10;
double y = 10;
double z = 10;
Box box = new Box( new Vector3f(count*10,count*10,count*10), (int)x, (int)y, (int)z );
Geometry geo = new Geometry( "Box", box );
Material mat = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor( "Color", ColorRGBA.Blue );
geo.setMaterial(mat);
geos.add( geo );
}
/** Create a pivot node at (0,0,0) and attach it to the root node */
Node pivot = new Node("pivot");
rootNode.attachChild(pivot); // put this node in the scene
/** Attach the two boxes to the *pivot* node. */
for( Geometry g : geos ) {
pivot.attachChild( g );
}
/** Rotate the pivot node: Note that both boxes have rotated! */
pivot.rotate(.4f,.4f,0f);
}
}
它在 app.start() 命令上出错,指出它是一个 NULL 指针异常。当它之前的行没有错误时,app如何成为空指针?我不知道出了什么问题。
历史:我需要能够为我的简单盒子工作创建 3D 渲染。我需要从另一个过程加载模型元素,然后循环浏览它们并绘制它们。我使用 jMonkey 是因为他们最初想要 Xj3D,但我找不到如何让它运行。至少这我可以让教程工作,但是当我修改它以循环并创建几个框时,我得到了空指针问题。
提前致谢!JH
编辑:
这是控制台输出:
Exception in thread "main" java.lang.NullPointerException
at com.jme3.system.JmeDesktopSystem.showSettingsDialog(JmeDesktopSystem.java:73)
at com.jme3.system.JmeSystem.showSettingsDialog(JmeSystem.java:108)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:127)
at test.test.main(test.java:34)