user2466076
user2466076

Reputation: 95

Null pointer exception when adding quad to geometry in jME 3

i'm using the j Monkey Engine 3 to build a custom voxel engine. In the Block.java class i create an array of geometry objects to wich i want to assign quad meshes. This code returns null pointer exception:

    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
    }

Maybe it's just a stupid mistake. If you need more code I can post the whole java class.

Upvotes: 1

Views: 75

Answers (1)

Krayo
Krayo

Reputation: 2510

I think faces is an empty array. So faces[i] is null.
Try something like this first:

for(int i = 0; i < 6; i++)
{
    faces[i] = new Geometry();
}

Upvotes: 1

Related Questions