Files
mes123456 c2c65d3a09
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Rebuild local Blender WASM environment and recovery evidence
2026-08-27 20:22:15 +08:00

92 lines
3.4 KiB
Python

#!/usr/bin/env python3
import pathlib
import sys
import bpy
def main(output):
bpy.ops.wm.read_factory_settings(use_empty=True)
scene = bpy.context.scene
scene.name = "WBV2P3003RigPoseSkinScene"
scene.frame_start = 1
scene.frame_end = 20
mesh = bpy.data.meshes.new("WBV2P3003SkinnedMesh")
mesh.from_pydata(
[(-1, -1, 0), (1, -1, 0), (1, 1, 0), (-1, 1, 0),
(-1, -1, 2), (1, -1, 2), (1, 1, 2), (-1, 1, 2)],
[],
[(0, 1, 2), (0, 2, 3), (4, 6, 5), (4, 7, 6),
(0, 4, 5), (0, 5, 1), (1, 5, 6), (1, 6, 2),
(2, 6, 7), (2, 7, 3), (4, 0, 3), (4, 3, 7)],
)
mesh.update()
mesh_object = bpy.data.objects.new("WBV2P3003SkinnedMeshObject", mesh)
bpy.context.collection.objects.link(mesh_object)
basis = mesh_object.shape_key_add(name="Basis")
smile = mesh_object.shape_key_add(name="WBV2P3003Smile")
smile.data[2].co.z += 0.35
smile.data[6].co.z += 0.35
smile.value = 0.4
del basis
armature_data = bpy.data.armatures.new("WBV2P3003Armature")
armature_object = bpy.data.objects.new("WBV2P3003ArmatureObject", armature_data)
bpy.context.collection.objects.link(armature_object)
bpy.context.view_layer.objects.active = armature_object
armature_object.select_set(True)
bpy.ops.object.mode_set(mode="EDIT")
root = armature_data.edit_bones.new("WBV2P3003Root")
root.head = (0, 0, 0)
root.tail = (0, 0, 1)
tip = armature_data.edit_bones.new("WBV2P3003Tip")
tip.head = (0, 0, 1)
tip.tail = (0, 0, 2)
tip.parent = root
tip.use_connect = True
bpy.ops.object.mode_set(mode="POSE")
pose_root = armature_object.pose.bones["WBV2P3003Root"]
pose_root.rotation_mode = "XYZ"
for frame, angle in ((1, 0.0), (10, 0.35), (20, -0.2)):
scene.frame_set(frame)
pose_root.rotation_euler[1] = angle
pose_root.keyframe_insert(data_path="rotation_euler", index=1, frame=frame)
unsupported = armature_object.pose.bones["WBV2P3003Tip"].constraints.new("LIMIT_ROTATION")
unsupported.name = "WBV2P3003UnsupportedLimitRotation"
unsupported.use_limit_x = True
unsupported.min_x = -0.25
unsupported.max_x = 0.25
unsupported.influence = 0.65
bpy.ops.object.mode_set(mode="OBJECT")
root_group = mesh_object.vertex_groups.new(name="WBV2P3003Root")
tip_group = mesh_object.vertex_groups.new(name="WBV2P3003Tip")
root_group.add([0, 1, 2, 3], 1.0, "REPLACE")
root_group.add([4, 5, 6, 7], 0.2, "REPLACE")
tip_group.add([4, 5, 6, 7], 0.8, "REPLACE")
tip_group.add([0, 1, 2, 3], 0.0, "REPLACE")
armature_modifier = mesh_object.modifiers.new(name="WBV2P3003ArmatureDeform", type="ARMATURE")
armature_modifier.object = armature_object
bounded = mesh_object.constraints.new("LIMIT_LOCATION")
bounded.name = "WBV2P3003BoundedObjectConstraint"
bounded.use_min_x = True
bounded.use_max_x = True
bounded.min_x = -2.0
bounded.max_x = 2.0
bounded.influence = 0.8
scene.frame_set(1)
scene.world = bpy.data.worlds.new("WBV2P3003RigWorld")
scene.world.color = (0.03, 0.04, 0.05)
bpy.ops.wm.save_as_mainfile(filepath=str(pathlib.Path(output).resolve()), check_existing=False, compress=True)
if __name__ == "__main__":
arguments = sys.argv[sys.argv.index("--") + 1:]
if len(arguments) != 1:
raise SystemExit("usage: blender -b --factory-startup --python WBV2-P3-003.py -- OUTPUT")
main(arguments[0])