Metaballs
Metaball methods provide support for creating and rendering smooth organic shapes made from multiple interacting points.
A metaball system contains multiple metaballs that can be moved, colored, and simulated with optional physics.
Methods
Section titled “Methods”createMetaballSystem
Section titled “createMetaballSystem”Creates a new metaball system attached to a display.
Returns: systemId : number
Example
Section titled “Example”local systemId = gpu.createMetaballSystem(displayId)addMetaball
Section titled “addMetaball”Adds a metaball to an existing system.
Returns: ballId : number
Example
Section titled “Example”local ballId = gpu.addMetaball( systemId, 50, 50, 20, 1.0)clearMetaballs
Section titled “clearMetaballs”Removes all metaballs from a system.
Example
Section titled “Example”gpu.clearMetaballs(systemId)getMetaballCount
Section titled “getMetaballCount”Returns the number of metaballs currently in a system.
Example
Section titled “Example”print(gpu.getMetaballCount(systemId))getMetaballInfo
Section titled “getMetaballInfo”Returns information about a specific metaball.
Requires: systemId : number, ballId : number
Returns: Metaball information table.
Example
Section titled “Example”local info = gpu.getMetaballInfo( systemId, ballId)
print(info)removeMetaballSystem
Section titled “removeMetaballSystem”Deletes an entire metaball system.
Use this when the system is no longer needed.
Example
Section titled “Example”gpu.removeMetaballSystem(systemId)renderMetaballs
Section titled “renderMetaballs”Renders a metaball system.
threshold controls the surface cutoff value.
renderMode controls the rendering mode.
Example
Section titled “Example”gpu.renderMetaballs( systemId, 1.0, 0)setMetaballColor
Section titled “setMetaballColor”Changes the color of a metaball.
Example
Section titled “Example”gpu.setMetaballColor( systemId, ballId, 0, 255, 255)setMetaballPhysics
Section titled “setMetaballPhysics”Enables or disables metaball physics.
Parameters:
enabled- whether physics simulation is activegravity- gravity strengthdrag- movement resistance
Example
Section titled “Example”gpu.setMetaballPhysics( systemId, true, 0.1, 0.01)setMetaballVelocity
Section titled “setMetaballVelocity”Sets the velocity of a metaball.
Example
Section titled “Example”gpu.setMetaballVelocity( systemId, ballId, 2, -1)updateMetaballs
Section titled “updateMetaballs”Advances the metaball simulation.
Call this every frame when using physics.
Example
Section titled “Example”gpu.updateMetaballs( systemId, 0.05)