[Solved] Box not showing up when moving vertices

I am currently trying to fix a bug with a “selectionBox” (a custom shape of a box without bottom quad) to move and resize according to the start and current mouse position (just like when selecting stuff in a normal RTS but with a cube, think Dungeon Keeper style).

Although I stumble upon a problem when trying to “use” the selectionBox while the camera is not seeing the center of the world (0, 0, 0). At least I think that’s when it stops to show up.

Is there anyone that knows what the problem might be, I’ve checked with a lot of System.out.println();'s and the problem seems to be somewhere inside the code where I move the vertices as no data is lost on the way as far as I’ve seen.

The code for moving the vertices reads:


private void updateSelectionBoxVertices(SelectionArea selectionArea)


VertexBuffer buffer = selectionBoxGeo.getMesh().getBuffer(Type.Position);

float[] vertexArray = BufferUtils.getFloatArray((FloatBuffer) buffer.getData());

vertexArray[0] = selectionArea.start.x;

vertexArray[2] = selectionArea.start.y;


vertexArray[24] = selectionArea.end.x;

vertexArray[26] = selectionArea.end.y;




The selectionArea is just a simple class containing two Vector2f and dots are just all the other vertices in the array based on the same idea as the four shown, no need to show them.

Don’t forget to call updateBound()

…that’s just the first thing that jumps out at me.

1 Like

Where do I find that method?

It’s on Mesh.

1 Like

I guess you ment .updateModelBound(); and thanks it worked! :smiley: although, I get the warning in the editor that “Updating is not needed in jME3, check your update order if you need to call this.” But I think I’ll just ignore it :slight_smile:

Thanks again, you made my day (well night actually)! :wink:

No. I meant Mesh.updateBound().


If you move the vertexes around in the mesh then it needs its bounds updated. At least, I’ve always done it.

Well, that one didn’t work so I think I’ll stick to Geometry.updateModelBound(); since that works :stuck_out_tongue: