How to create moving spripe via GeomTristrips?

Hi all!

I want to implement something like “moving stripe” with constant number of segments (like in classic ‘Nibbles’ game). Every frame tailing segment should be removed, and new segment should be added to head. How to implement this via GeomTristrips?

Is it possible to modify only GeomVertexData, without touching GeomPrimitive?

Depending on the total number of segments you plan to have, you might be better off just creating and destroying separate nodes for the different segments. That’s certainly easier to do, and Panda’s interface makes that kind of operation simple. But there’s a limit to the number of individual nodes you can render onscreen at once; the rule of thumb is around 300, though you may be able to push it considerably higher depending on your hardware and if you are willing to accept 30fps.

If you really want to go the GeomVertexData route, though, you can certainly do this too. The manual has considerable information on the interfaces to create and modify the vertex information. You can certainly modify a GeomVertexData without modifying the associated GeomPrimitive object, and vice-versa. Let us know if you have any other specific questions to ask on this subject. :slight_smile:


I’m using two stripes with about 500 segments each (each segment is a quad).

Currently I’m trying to implement regeneration of VertexData via shifting (through CopySubdataFrom or get/setSubData) and setting new vertices aftewards.

  handle = MyVertexData.modifyHandle()
  handle.copySubdataFrom(2, 498, handle, 0, 498)
  # data = handle.getSubdata(2, 498)
  # handle.setData(data)
  vWriter.setData3f(x1, y1, z1)
  vWriter.setData3f(x2, y2, z2)

But at this time my code doesn’t work. :\

Is there another way to implement this shifting?

The parameters to copySubdataFrom() and getSubdata() are given in bytes, not rows. So you must multiply all of your numbers by handle.getArrayFormat().getStride().


It works! Thank you!

It works via getSubdata and setSubData, but variant with handle.copySubdataFrom() doesn’t works (it seems that copySubdataFrom() is not safe, when src and dst buffers overlaps).

Actually, there is a bug with copySubdataFrom() in versions 1.7.0 and earlier. It was recently discovered and will be fixed in the next release (and it is already fixed in the buildbot releases).