我正在使用j Monkey Engine 3来构建一个自定义体素引擎。在Block.java类中,我创建了一个几何对象数组,我想为其分配四元网格。此代码返回空指针异常:
faces = new Geometry[6];
Mesh q = new Quad(0.2f, 0.2f);
if(q == null)
{
System.out.println("q is null"); ----> this doesn't occure
}
for(int i = 0; i < 6; i++)
{
faces[i].setMesh(q.clone()); -------> this still gives null pointer
}
也许这只是一个愚蠢的错误。如果你需要更多的代码,我可以发布整个java类。
我认为faces
是一个空数组。因此faces[i]
为空
先试试这样的东西:
for(int i = 0; i < 6; i++)
{
faces[i] = new Geometry();
}