Particle simulation nBody

I am wanting to write some nbody and position hash code in pycuda. Which happens to have opengl interoperability.

I’d like to update the particles position very often with particle numbers up to 300k. I’d like to create a sandbox environment to view these particles sims in real time. Something like this:

The base numerical library would be numpy.

In the api I can’t find things to do stuff like

GeomVertexWrite(stuff).addData(N by 3 array)

Seems like a fairly typical use case.

Also, is there any way to map PBO or VBO onto these VertexData datastructures.


Panda’s GeomVertexWriter isn’t built to handle large data structures, mainly because it’s intended to be a low-level class. You can build a wrapper around it to populate your array one element at a time. However, Python is not a suitable language for writing this kind of wrapper if you wish to maintain good performance.

But, you’re already using numpy, which is, after all, a C++ library with python bindings. If you can use numpy to pack your data array into a string buffer, then you can use GeomVertexArrayData.modifyHandle().setData(data) to load that packed string data into the array.

Panda doesn’t provide access to the underlying OpenGL VBO objects, but you may be able to get access to them with an OpenGL callback. Of course, if you are using an OpenGL callback in the first place, that callback can be entirely responsible for drawing your particles; no need to create a Panda GeomVertexData at all.


Sorry for reviving an old post, but for the sake of keeping all the information in one place I’ll continue the thread.

How would I go ahead and pack my numpy array into a string buffer? I did a couple of searches but the most usefull link I found was … rface.html
I’m still rather confused on how to actually use that information.

thanks for any help.

Try this: … tring.html

Ah ok great, thanks!

However I have another problem, when using GeomVertexArrayData.modifyHandle().setData(Array) I get the following error: [color=red]TypeError: descriptor ‘modifyHandle’ of ‘libpanda.GeomVertexArrayData’ object needs an argument

Call it on the actual GeomVertexArrayData instance instead of the class itself.