Examples or ideas for procedural morphing?

Rather than processing the geometry every frame, it may be more efficient to use morph targets (also known as shape keys) if all you want is to morph a piece of geometry between different shapes. The way this works is that you would generate the geometry as you would normally, probably in their final configuration. But you’d add another column to the vertex table containing deltas that move the vertices from their final configuration to the initial, wrong configuration. Then by setting the morph slider value between 0.0 and 1.0, Panda will morph between the two geometry configurations.

When creating the GeomVertexFormat, you’d create an additional vertex column called “vertex.morph.yourSlider” (set to GeomEnums.C_morph_delta contents mode) that contains the difference between the vertex position in the right configuration and in the wrong configuration. You’d also need to tell Panda that it is animated. Your format set-up would look something like this:

aformat1 = GeomVertexArrayFormat()
aformat1.addColumn(...regular vertex column...)
... other columns...

# Create a second array for the morphs
aformat2 = GeomVertexArrayFormat()
aformat2.addColumn("vertex.morph.yourSlider", 3, GeomEnums.NT_float32, GeomEnums.C_morph_delta)
# You can also morph other columns as needed, just change "vertex"

format = GeomVertexFormat()
format.addArray(aformat1)
format.addArray(aformat2)

# Indicate that this format should be animated by Panda.
aspec = GeomVertexAnimationSpec()
aspec.setPanda()
format.setAnimation(aspec)

format = GeomVertexFormat.registerFormat(format)

You would furthermore need to attach a SliderTable to the geometry with GeomVertexData.setSliderTable. The easiest way to create a slider you can control is to create a UserVertexSlider, with the name matching the one you chose in the vertex column:

# Create a SliderTable holding a slider, affecting all vertex rows.
slider = UserVertexSlider("yourSlider")
table = SliderTable()
table.addSlider(slider, SparseArray.allOn())

# vdata is the GeomVertexData you created and filled in
vdata.setSliderTable(SliderTable.registerTable(table))

Now, you will be able to call slider.setSlider(v), where v is between 0.0 and 1.0 to morph between the two shapes, or even outside that range to exaggerate the effect.