37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import sys
|
|
|
|
import bpy
|
|
|
|
|
|
def main(output: pathlib.Path) -> None:
|
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
lattice = bpy.data.lattices.new("WebGapLattice")
|
|
lattice.points_u = 3
|
|
lattice.points_v = 2
|
|
lattice.points_w = 2
|
|
lattice.interpolation_type_u = "KEY_LINEAR"
|
|
lattice.interpolation_type_v = "KEY_CARDINAL"
|
|
lattice.interpolation_type_w = "KEY_BSPLINE"
|
|
lattice.use_outside = True
|
|
lattice.vertex_group = "WebGapInfluence"
|
|
lattice_object = bpy.data.objects.new("WebGapLatticeObject", lattice)
|
|
bpy.context.collection.objects.link(lattice_object)
|
|
for index, point in enumerate(lattice.points):
|
|
point.co_deform = (
|
|
point.co.x + 0.125 * (index % 3),
|
|
point.co.y - 0.0625 * (index % 2),
|
|
point.co.z + 0.25 * (index // 6),
|
|
)
|
|
point.weight_softbody = 0.5 + index * 0.125
|
|
point.select = index in {0, len(lattice.points) - 1}
|
|
bpy.ops.wm.save_as_mainfile(filepath=str(output), compress=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
|
if len(arguments) != 1:
|
|
raise SystemExit("usage: blender -b --python M16-GAP-00010.py -- OUTPUT")
|
|
main(pathlib.Path(arguments[0]).resolve())
|