Get all vertices from node


I need an efficient way to get all vertices from a specified node.
Thanks in advance!

1 Like

Efficient is questionable, the only way to get this info would be to iterate through all the nodes children using node.descendantmatches(geometry). Then you’ll have to get the vertex buffer for each geometry and read the buffer to pull the xyz components into whatever format you’re trying to accumulate your verts in. There are some methods in BufferUtils to make this easier to write.

What exactly are you trying to do with all this vertex info?


That is the question. You may not even need to do what you’re doing, so as for efficient - it needs context.

You don’t want to use MyMesh.listVertexLocations()?

And if this is still for your “fit the scene in view” problem… why do you need to be 100% accurate? For 99% of the cases that a user will care about, fitting the scene’s bounding box in view will be enough.

I know, i’m just curious…

In any case, you’ll have to use the approach @QSDragon described - pulling the data straight from the vertex buffers. jME keeps the vertices efficiently packed in the format the GPU needs for rendering. If you want to get at the vertex data you have to unpack it.


Which I believe is what sgold’s method is doing for you.

It’s going to be pretty expensive no matter how you do it.

1 Like