Simple metaball (2021)

Author's sample script, wroks, hints.
Post Reply
User avatar
3DfromNULL
Site Admin
Posts: 43
Joined: 2018-Jul-13 9:35

Simple metaball (2021)

Post by 3DfromNULL » 2021-May-25 4:41

This script generates a metaball that includes several primitives in it. Each primitive has am animation dropping short distance, and the metaball behaves like paint squeezed from a tube as a result.

Image

First, the script create a metaball, a sphere primitive, and an animation of the primitive. In the first key frame (i.e. time=0), it puts the ball at a enough high position out of rendering area.

Image

Then the script copies the primitive to several ones (in the single metaball object), shifts time line and x-coordinate of them, and adds wave to y-coordinate.

Image

When you look at the time sequences using the Scene Editor (Key Frame Editor for tS5 or lower) after the script ended, it shows cascaded time lines for a metaball object;

Image

The script ends after made only an animation of a metaball (with several sphere primitives). I copied the metaball to several ones by hand and added color to each of them.

Image



Tips for acceleration

The algorism in the script is not an optimized one to shorten the execution time, and it takes time wastefully by backing to the same active time frame and forcing tS to calculate influences between primitives repeatedly. You might be able to rewrite it into something like a time-oriented using list object of Python so that it uses each time frame only once, but you will lose readability of the code.

ts5 has lower performance for metaball editing than tS6 (and Model side of tS7), and what a worse, the script must skip CheckAbort() of checking Esc key in a loop because during the metaball edit mode the function pauses the execution for tS5.

The simplest solution to speed-up is to change the "Conversion" parameter in the metaball options panel into "On Demand" before executing the script. You need to set it to "On Move" before playing the animation. You can access the panel by right clicking a green button of metaball primitive (e.g. meta muscle). There seems not to be any API function to manipulate the option.


Image Image
Image Image Image
Note: tS4 has most of API functions for metaball but does not have MetaballEditMode(). It's necessary to change code so that it make each of all primitives instead of doing CurrobjCopy().
Attachments
metaball1a.py
script file
(3.74 KiB) Downloaded 85 times

Post Reply