Position updates of sphere instances

42 views
Skip to first unread message

Rainer Gericke

unread,
Jun 30, 2022, 3:43:58 AM6/30/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Hi Robert,

for the physics simulation I am working on I need a particle representation. With the Builder class it is an easy job to generate a couple of spheres with position data (just a vector of 3d points) from the simulation classes. During the simulation process all positions must be updated for each time step. I wonder how to do it. Can you give me a hint?

You can see the white initial spheres in the image.
image.png

Robert Osfield

unread,
Jun 30, 2022, 4:42:06 AM6/30/22
to vsg-...@googlegroups.com
HI Rainer,

The instance positions are an vec3Array that is passed as GeomeytrInfo.positions, these are assigned to the VertexIndexDraw that vsg::Builder sets up, and the vertex shader then reads that per instance array and offsets the objects positions.

To update the positions after vsg::Builder has set things up will require you to traverse the subgraph to find the VertexIndexDraw node then travers it's arrays to find the vsg::BufferInfo object that has data equal to the GeoetryInfio.positions vec3array.  This BufferInfo is the one you'll need to use when updating the array using vsg::CopyAndReleaseBuffer.

The vsgclip example provides an illustration of how the CopyAndRealeaeBuffer is used to pass data to the GPU.

When I was writing vsg::Builder instancing support I actually wrote a test path that illustrated how to update instance position, alas while it proved the code was working it was too complex for an already large example so I didn't merge it.  This type of functionality really requires it's own example.

Cheers,
Robert.



Reply all
Reply to author
Forward
0 new messages