feat: add juicer mechanism with continuous pressing animation

Add the Minex-inspired juicer model with synchronized rotary pressing, peel discharge, generation scripts, validation reports, previews, and reference materials.

Status: work in progress. The juicer model is not complete yet and still needs further geometric and motion refinements.
This commit is contained in:
Yanchen
2026-11-16 18:55:11 +08:00
parent e784ef07a8
commit f5d4f6dd41
111 changed files with 10029 additions and 0 deletions
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,158 @@
import argparse
import bpy
import sys
from pathlib import Path
args = sys.argv[sys.argv.index('--')+1:] if '--' in sys.argv else []
parser = argparse.ArgumentParser()
parser.add_argument('--mode', choices=['proof','stills','video'], default='proof')
parser.add_argument('--samples', type=int, default=20)
parser.add_argument('--width', type=int, default=720)
parser.add_argument('--height', type=int, default=840)
parser.add_argument('--start', type=int, default=1)
parser.add_argument('--end', type=int, default=360)
parser.add_argument('--step', type=int, default=2)
opt = parser.parse_args(args)
OUT = Path(__file__).resolve().parent
scene = bpy.context.scene
scene.render.engine = 'CYCLES'
scene.cycles.samples = opt.samples
scene.cycles.use_denoising = True
scene.cycles.adaptive_threshold = 0.04
scene.cycles.max_bounces = 8
scene.cycles.transparent_max_bounces = 12
scene.render.resolution_x = opt.width
scene.render.resolution_y = opt.height
scene.render.resolution_percentage = 100
scene.render.image_settings.file_format = 'PNG'
scene.render.image_settings.color_mode = 'RGB'
scene.render.use_persistent_data = True
def render(frame, camera, path):
scene.frame_set(frame)
inspection = 56 <= frame < 322 and camera not in ['CAM_01_Assembled','CAM_03_Separate_Collectors']
for name in ['Disc_Solid_Front_Cover','Disc_Cover_Centre_Fastener','Disc_Cover_Centre_Knob','Disc_Cover_Knob_Grip']:
bpy.data.objects[name].hide_render = inspection
scene.camera = bpy.data.objects[camera]
scene.render.filepath = str(path)
bpy.ops.render.render(write_still=True)
print(f'RENDERED frame={frame} camera={camera} file={path.name}',flush=True)
if opt.mode == 'proof':
for frame,cam,name in [
(1,'CAM_01_Assembled','proof_assembled.png'),
(129,'CAM_02_Four_Pocket_And_Blade','proof_cutting.png'),
(186,'CAM_02_Four_Pocket_And_Blade','proof_flick.png'),
(184,'CAM_07_Pressing_Contact','proof_pressing_entry.png'),
(192,'CAM_07_Pressing_Contact','proof_pressing.png'),
(202,'CAM_07_Pressing_Contact','proof_pressing_exit.png'),
(150,'CAM_04_Structure_Side','proof_side.png'),
(128,'CAM_05_Front_XOZ_Rotation_Check','proof_front.png'),
(128,'CAM_06_Pocket_Thickness_Midplane','proof_midplane.png'),
(226,'CAM_02_Four_Pocket_And_Blade','proof_residue.png'),
(350,'CAM_03_Separate_Collectors','proof_bins.png'),
]:
render(frame,cam,OUT/name)
elif opt.mode == 'stills':
for frame,cam,name,size in [
(1,'CAM_01_Assembled','preview_assembled.png',(1500,1700)),
(129,'CAM_02_Four_Pocket_And_Blade','preview_cutting.png',(1500,1400)),
(150,'CAM_04_Structure_Side','preview_split_halves.png',(1500,1400)),
(186,'CAM_02_Four_Pocket_And_Blade','preview_blade_transfer.png',(1500,1400)),
(192,'CAM_07_Pressing_Contact','preview_pressing.png',(1500,1400)),
(256,'CAM_08_Continuous_Press_Side','preview_pressing_side.png',(1500,1400)),
(128,'CAM_05_Front_XOZ_Rotation_Check','preview_front.png',(1400,1300)),
(150,'CAM_04_Structure_Side','preview_structure_side.png',(1400,1300)),
(128,'CAM_06_Pocket_Thickness_Midplane','preview_pocket_midplane.png',(1500,1400)),
(226,'CAM_02_Four_Pocket_And_Blade','preview_residue.png',(1500,1400)),
(350,'CAM_03_Separate_Collectors','preview_collectors.png',(1400,1300)),
]:
scene.render.resolution_x,scene.render.resolution_y = size
render(frame,cam,OUT/name)
else:
folder = OUT/'render_frames'
folder.mkdir(exist_ok=True)
for old_frame in folder.glob('*.png'):
old_frame.unlink()
def emission(name,color):
mat = bpy.data.materials.new(name)
mat.use_nodes = True
nodes = mat.node_tree.nodes
nodes.clear()
out = nodes.new('ShaderNodeOutputMaterial')
shader = nodes.new('ShaderNodeEmission')
shader.inputs['Color'].default_value = (*color,1)
mat.node_tree.links.new(shader.outputs[0],out.inputs['Surface'])
return mat
white = emission('Video_Text_White',(0.91,0.95,0.97))
grey = emission('Video_Text_Grey',(0.68,0.77,0.81))
dark = emission('Video_Text_Background',(0.014,0.024,0.030))
labels = {}
for cam_name in ['CAM_01_Assembled','CAM_02_Four_Pocket_And_Blade','CAM_03_Separate_Collectors','CAM_06_Pocket_Thickness_Midplane','CAM_07_Pressing_Contact','CAM_08_Continuous_Press_Side']:
cam = bpy.data.objects[cam_name]
frame = cam.data.view_frame(scene=scene)
left,right = min(v.x for v in frame),max(v.x for v in frame)
bottom,top = min(v.y for v in frame),max(v.y for v in frame)
scale = cam.data.ortho_scale
for kind in ['title','footer','title_bg','footer_bg']:
if kind in ['title','footer']:
data = bpy.data.curves.new(cam_name+kind,'FONT')
data.size = scale*(0.026 if kind=='title' else 0.0125)
data.align_x = 'LEFT'
data.align_y = 'TOP' if kind=='title' else 'BOTTOM'
obj = bpy.data.objects.new('VIDEO_'+cam_name+kind,data)
obj.data.materials.append(white if kind=='title' else grey)
else:
height = scale*(0.052 if kind=='title_bg' else 0.031)
cy = top-scale*0.032 if kind=='title_bg' else bottom+scale*0.022
mesh = bpy.data.meshes.new('Video_Panel')
mesh.from_pydata([(left,cy-height/2,0),(right,cy-height/2,0),(right,cy+height/2,0),(left,cy+height/2,0)],[],[(0,1,2,3)])
obj = bpy.data.objects.new('VIDEO_'+cam_name+kind,mesh)
obj.data.materials.append(dark)
scene.collection.objects.link(obj)
obj.parent = cam
if kind=='title':
obj.location = (left+scale*0.027,top-scale*0.020,-0.20)
elif kind=='footer':
obj.location = (left+scale*0.027,bottom+scale*0.017,-0.20)
else:
obj.location = (0,0,-0.22)
obj.visible_shadow = False
obj.hide_render = True
labels[(cam_name,kind)] = obj
for f in range(opt.start,opt.end+1,opt.step):
cam = 'CAM_01_Assembled' if f<=55 else 'CAM_03_Separate_Collectors' if f>=322 else 'CAM_06_Pocket_Thickness_Midplane' if 120<=f<=141 else 'CAM_07_Pressing_Contact' if 166<=f<=223 else 'CAM_08_Continuous_Press_Side' if 230<=f<=307 else 'CAM_02_Four_Pocket_And_Blade'
if f<64:
title = '01 / FEED WITH BOTH ROTORS TURNING'
elif f<120:
title = '02 / CONTINUOUS INDEX TO EXTERNAL BLADE'
elif f<148:
title = '03 / EXTERNAL TANGENTIAL CUT'
elif f<166:
title = '04 / HALF FOLLOWS ROTATING POCKET'
elif f<178:
title = '05 / BALL ENTERS WITHOUT LIFTING'
elif f<192:
title = '06 / BOTH ROTORS KEEP TURNING'
elif f<214:
title = '07 / ROLLING NIP / DEEPEST AT 08s'
elif f<230:
title = '08 / SQUEEZED PEEL RELEASES'
elif f<256:
title = '09 / SECOND ROLLING NIP / SIDE VIEW'
elif f<278:
title = '10 / CONTINUOUS ROTARY EXTRACTION'
elif f<322:
title = '11 / PEEL DISCHARGE / NO ROTOR STOP'
else:
title = '12 / SEPARATE COLLECTION BOXES'
for (name,kind),obj in labels.items():
obj.hide_render = name != cam
labels[(cam,'title')].data.body = title
labels[(cam,'footer')].data.body = 'CONTINUOUS ROTORS / NO VERTICAL RAM' if cam in ['CAM_01_Assembled','CAM_03_Separate_Collectors'] else 'INSPECTION: COVER OFF / NONSTOP ROTORS / NO RAM'
render(f,cam,folder/f'{f:04d}.png')
@@ -0,0 +1,365 @@
import bpy
import bmesh
import hashlib
import json
import math
from pathlib import Path
from mathutils import Vector
from mathutils.bvhtree import BVHTree
OUT = Path(__file__).resolve().parent
DOC = OUT.parents[1]/'HOW_ZMUEX_juicer_work.md'
scene = bpy.context.scene
report = json.loads((OUT/'mechanism_validation.json').read_text(encoding='utf-8'))
report['revision_notes'] = [
'Reference ZMUEX_working_video.mp4 01:59-02:06 was inspected from both supplied viewpoints before rebuilding the motion',
'Disc and pressing carrier rotate clockwise continuously with a four-pocket/three-head angular speed ratio; neither has a dwell during pressing',
'Each half follows its rotating pocket through the rolling nip; cut flesh becomes a concave layer around the ball instead of translating upward as a flattened orange',
'Squeezed hollow peels leave the moving pocket after engagement, follow a short discharge guide and then fall into the residue box',
'Recursive visibility keys hide every fruit and residue child mesh; blue-gray machinery contrasts with orange ingredients',
'Pressing carrier has a fixed Y axis and no Z translation; balls engage pockets only by coordinated rotation',
'Drum and pressing carrier use parallel Y axes; their circular faces lie in XOZ and face machine front +Y',
'One-piece hemispherical pockets remain centered across the 74 mm drum thickness',
'External tangential blade meets fruit at the projected tangent and never enters the drum or pocket rims; its cutting plane matches fruit separation',
'Incorrect wire filter and all drum blade-clearance slots are removed; a solid juice guide is used',
'Residue and its collection box use synchronized world-space extraction',
]
report['saved_file_reopened'] = Path(bpy.data.filepath).name == 'PerfectCoffee_Minex_Mechanism.blend'
report['source_document_matches'] = hashlib.sha256(DOC.read_bytes()).hexdigest() == report['source_sha256']
report['missing_external_assets'] = [im.filepath for im in bpy.data.images if im.source=='FILE' and not im.packed_file and not Path(bpy.path.abspath(im.filepath)).exists()]
report['linked_library_count'] = len(bpy.data.libraries)
scene.frame_set(1)
bpy.context.view_layer.update()
disc = bpy.data.objects['Four_Pocket_Disc_Y_Axis']
male = bpy.data.objects['Three_Ball_Press_Y_Axis']
blade = bpy.data.objects['Fixed_Tangential_Cutting_Blade']
report['disc_thickness_m'] = disc['thickness_m']
report['thick_disc_passed'] = report['disc_thickness_m'] >= 0.070
report['actual_pocket_count'] = len([o for o in bpy.data.objects if o.name.startswith('Hemispherical_Pocket_')])
report['actual_spherical_head_count'] = len([o for o in bpy.data.objects if o.name.startswith('Spherical_Pressing_Head_')])
report['solid_front_cover_present'] = 'Disc_Solid_Front_Cover' in bpy.data.objects
report['vertical_press_parts_absent'] = not any(o.name.startswith('Press_Z_') or o.name.startswith('Press_Sliding_') for o in bpy.data.objects)
report['rotational_relief_grooves_present'] = disc.get('rotational_relief_track_count',0)>0 and all(bpy.data.objects['Hemispherical_Pocket_'+str(i)].get('rotational_relief_grooves',0)>0 for i in range(1,5))
report['press_axis_positions'] = {}
reference_axis = None
report['press_axis_max_deviation_m'] = 0.0
for frame in range(1,361):
scene.frame_set(frame)
bpy.context.view_layer.update()
position = male.matrix_world.translation.copy()
if reference_axis is None:
reference_axis = position.copy()
report['press_axis_max_deviation_m'] = max(report['press_axis_max_deviation_m'],(position-reference_axis).length)
if frame in [1,64,128,172,192,214,236,256,278,360]:
report['press_axis_positions'][str(frame)] = list(position)
report['press_axis_fixed_throughout_animation'] = report['press_axis_max_deviation_m']<0.000001
report['short_neck_heads_present'] = all('Press_Head_Short_Neck_'+str(i) in bpy.data.objects for i in [1,2,3])
report['fixed_blade_has_no_animation'] = blade.animation_data is None
report['filter_mesh_absent'] = not any(o.name.startswith('Filter_') or o.name == 'Juice_Only_Inclined_Filter' for o in bpy.data.objects)
report['solid_juice_guide_present'] = 'Juice_Guide_Solid_Tray_No_Mesh' in bpy.data.objects
report['drum_blade_slots_absent'] = not any('Blade_Clearance' in o.name for o in bpy.data.objects)
report['front_facing_checks'] = {}
for obj in [disc,male,bpy.data.objects['Press_Equilateral_Triangle_Carrier']]:
normal = obj.matrix_world.to_quaternion() @ Vector((1,0,0))
report['front_facing_checks'][obj.name] = {
'face_normal':list(normal),
'expected':[0,1,0],
'error':(normal-Vector((0,1,0))).length,
}
report['front_faces_xoz_passed'] = all(v['error']<0.0001 for v in report['front_facing_checks'].values())
report['blade_minimum_edge_radius_m'] = abs(blade.location.y-blade.dimensions.y/2-disc.location.y)
report['blade_outside_drum'] = report['blade_minimum_edge_radius_m'] > 0.091
report['blade_outside_pocket_rims'] = report['blade_minimum_edge_radius_m'] > 0.103
report['blade_penetration_disabled_by_geometry'] = not blade['penetrates_drum'] and report['blade_outside_pocket_rims']
report['l_hopper_parts_present'] = all(name in bpy.data.objects for name in ['L_Hopper_Long_Arm_Floor','L_Hopper_Short_Arm_Floor','Fixed_Entrance_Sliding_Ramp','Entrance_Periodic_Gate_Pivot'])
report['long_arm_has_four_fruit_positions'] = all(name in bpy.data.objects for name in ['Process_Whole_Orange','Hopper_Queued_Orange_1','Hopper_Queued_Orange_2','Hopper_Queued_Orange_3'])
report['separate_half_and_residue_meshes'] = all(name in bpy.data.objects for name in ['Process_Retained_Half_Peel','Process_Blade_Half_Peel','Residue_A_Pressed_Half_Peel_Empty_Peel','Residue_B_Pressed_Half_Peel_Empty_Peel'])
report['visibility_checks'] = {}
assembly_names = ['Process_Whole_Orange','Process_Retained_Half','Process_Blade_Half','Residue_A_Pressed_Half_Peel','Residue_B_Pressed_Half_Peel']
visibility_expectations = {
1:{'Process_Whole_Orange'},
127:{'Process_Whole_Orange'},
128:{'Process_Retained_Half','Process_Blade_Half'},
192:{'Process_Retained_Half','Process_Blade_Half'},
213:{'Process_Retained_Half','Process_Blade_Half'},
214:{'Process_Blade_Half','Residue_A_Pressed_Half_Peel'},
256:{'Process_Blade_Half','Residue_A_Pressed_Half_Peel'},
278:{'Residue_A_Pressed_Half_Peel','Residue_B_Pressed_Half_Peel'},
360:{'Residue_A_Pressed_Half_Peel','Residue_B_Pressed_Half_Peel'},
}
for frame,visible in visibility_expectations.items():
scene.frame_set(frame)
bpy.context.view_layer.update()
unexpected = []
for name in assembly_names:
assembly = bpy.data.objects[name]
should_hide = name not in visible
for child in [assembly,*assembly.children_recursive]:
if child.hide_render != should_hide or child.hide_viewport != should_hide:
unexpected.append(child.name)
report['visibility_checks'][str(frame)] = {'unexpected_objects':unexpected,'passed':not unexpected}
report['recursive_visibility_passed'] = all(v['passed'] for v in report['visibility_checks'].values())
mechanism_color = bpy.data.materials['Mechanism_Light_Blue_Gray_Polymer'].diffuse_color
fruit_color = bpy.data.materials['Orange_Peel_Procedural'].diffuse_color
report['mechanism_fruit_color_distance'] = (Vector(mechanism_color[:3])-Vector(fruit_color[:3])).length
report['mechanism_fruit_colors_differ'] = report['mechanism_fruit_color_distance']>0.4
report['collector_flags'] = {
'juice_no_spout':not bpy.data.objects['Juice_Collection_Box_No_Spout_No_Handle']['has_spout'],
'juice_no_handle':not bpy.data.objects['Juice_Collection_Box_No_Spout_No_Handle']['has_handle'],
'residue_no_juice':not bpy.data.objects['Residue_Collection_Box']['contains_juice'],
}
report['pocket_orientation_checks'] = {}
report['pocket_axial_center_errors_m'] = {}
for frame,index,expected in [(64,1,(0,0,1)),(128,1,(-1,0,0)),(192,1,(0,0,-1)),(256,2,(0,0,-1))]:
scene.frame_set(frame)
bpy.context.view_layer.update()
pocket = bpy.data.objects['Hemispherical_Pocket_'+str(index+1)]
normal = disc.matrix_world.to_quaternion() @ Vector(pocket['radial_opening_local'])
pp = pocket.matrix_world.translation
axial_error = abs(pp.y-disc.matrix_world.translation.y)
report['pocket_axial_center_errors_m'][f'{frame}_pocket_{index}'] = axial_error
report['pocket_orientation_checks'][f'{frame}_pocket_{index}'] = {
'normal':list(normal),
'expected':expected,
'error':(normal-Vector(expected)).length,
'opening_plane_contains_y_axis':abs(normal.y)<0.000001,
}
report['pocket_orientation_passed'] = all(v['error']<0.0001 and v['opening_plane_contains_y_axis'] for v in report['pocket_orientation_checks'].values())
report['pockets_centered_across_drum_thickness'] = all(v<0.000001 for v in report['pocket_axial_center_errors_m'].values())
report['pocket_dimensions'] = {name:{key:bpy.data.objects[name][key] for key in ['inner_radius_m','outer_radius_m','depth_m']} for name in ['Hemispherical_Pocket_1','Hemispherical_Pocket_2','Hemispherical_Pocket_3','Hemispherical_Pocket_4']}
report['hemispherical_pockets_passed'] = all(v['inner_radius_m']>0.030 and v['outer_radius_m']>v['inner_radius_m'] and v['depth_m']==v['outer_radius_m'] for v in report['pocket_dimensions'].values())
scene.frame_set(128)
bpy.context.view_layer.update()
report['disc_top_moves_to_negative_x'] = (disc.matrix_world.to_quaternion() @ Vector((0,0,1))-Vector((-1,0,0))).length < 0.0001
report['disc_rotation_is_clockwise_from_positive_y'] = report['disc_top_moves_to_negative_x'] and disc.rotation_euler.x<0 and abs(disc.rotation_euler.y)<1e-6 and abs(disc.rotation_euler.z)<1e-6
male_angle_at_cut = male.rotation_euler.x
scene.frame_set(145)
report['press_rotation_is_clockwise_from_positive_y'] = male.rotation_euler.x<male_angle_at_cut and abs(male.rotation_euler.y)<1e-6 and abs(male.rotation_euler.z)<1e-6
previous_rotations = None
report['both_mechanisms_clockwise_throughout'] = True
report['rotor_step_ranges_degrees'] = {'disc':[float('inf'),float('-inf')],'press':[float('inf'),float('-inf')]}
report['rotor_zero_speed_frames'] = []
report['rotor_frame_deltas'] = {}
for frame in range(1,361):
scene.frame_set(frame)
rotations = (disc.rotation_euler.x,male.rotation_euler.x)
if previous_rotations is not None:
deltas = tuple(math.degrees(rotations[i]-previous_rotations[i]) for i in range(2))
report['rotor_frame_deltas'][str(frame)] = deltas
if deltas[0]>=-0.00001 or deltas[1]>=-0.00001:
report['both_mechanisms_clockwise_throughout'] = False
report['rotor_zero_speed_frames'].append(frame)
for name,delta in zip(['disc','press'],deltas):
bounds = report['rotor_step_ranges_degrees'][name]
bounds[0] = min(bounds[0],delta)
bounds[1] = max(bounds[1],delta)
previous_rotations = rotations
report['both_rotors_continuous_throughout'] = report['both_mechanisms_clockwise_throughout'] and not report['rotor_zero_speed_frames']
report['press_to_disc_angular_speed_ratio'] = report['rotor_step_ranges_degrees']['press'][0]/report['rotor_step_ranges_degrees']['disc'][0]
report['constant_speed_ratio_passed'] = abs(report['press_to_disc_angular_speed_ratio']-4/3)<0.0001
scene.frame_set(128)
bpy.context.view_layer.update()
pocket_normal = disc.matrix_world.to_quaternion() @ Vector(bpy.data.objects['Hemispherical_Pocket_2']['radial_opening_local'])
blade_tangent = blade.matrix_world.to_quaternion() @ Vector((0,0,1))
blade_plane_normal = blade.matrix_world.to_quaternion() @ Vector((0,1,0))
report['blade_tangent_at_cutting_station'] = abs(blade_tangent.dot(pocket_normal))<0.0001
report['blade_cut_plane_matches_fruit_split'] = (blade_plane_normal-pocket_normal).length<0.0001
fruit_center = bpy.data.objects['Process_Whole_Orange'].matrix_world.translation
disc_center = disc.matrix_world.translation
report['cutting_fruit_radius_m'] = math.hypot(fruit_center.x-disc_center.x,fruit_center.z-disc_center.z)
report['fruit_centered_on_external_cutting_edge'] = abs(report['cutting_fruit_radius_m']-blade['cutting_edge_radius_m'])<0.00001
scene.frame_set(182)
ejector = bpy.data.objects['Blade_Discharge_Spring_Pivot']
report['spring_ejector_moves_in_xoz'] = abs(ejector.rotation_euler.x)>0.1 and (ejector.matrix_world.to_quaternion() @ Vector((1,0,0))-Vector((0,1,0))).length<0.0001
report['fruit_rolling_nip_checks'] = {}
for half_name,pocket_index,frames in [('Process_Retained_Half',2,[176,184,192,200,208]),('Process_Blade_Half',3,[240,248,256,264,270])]:
positions = []
errors = []
orientation_errors = []
scales = []
for frame in frames:
scene.frame_set(frame)
bpy.context.view_layer.update()
half = bpy.data.objects[half_name]
pocket = bpy.data.objects['Hemispherical_Pocket_'+str(pocket_index)]
expected = pocket.matrix_world.translation
positions.append(half.matrix_world.translation.copy())
errors.append((expected-half.matrix_world.translation).length)
inward = disc.matrix_world.to_quaternion() @ -Vector(pocket['radial_opening_local'])
dome = half.matrix_world.to_quaternion() @ Vector((0,0,1))
orientation_errors.append((inward-dome).length)
scales.append(list(half.scale))
report['fruit_rolling_nip_checks'][half_name] = {
'frames':frames,
'pocket_tracking_errors_m':errors,
'dome_orientation_errors':orientation_errors,
'arc_travel_m':(positions[-1]-positions[0]).length,
'root_scales':scales,
}
report['fruit_follows_pocket_through_press'] = all(max(v['pocket_tracking_errors_m'])<0.00001 and max(v['dome_orientation_errors'])<0.0001 and v['arc_travel_m']>0.040 for v in report['fruit_rolling_nip_checks'].values())
report['no_fake_z_squash_or_ram'] = all(abs(scale[2]-1)<0.000001 for v in report['fruit_rolling_nip_checks'].values() for scale in v['root_scales'])
report['pressing_alignment'] = {}
for frame,half_name,pocket_index,ball_index in [(192,'Process_Retained_Half',1,1),(256,'Process_Blade_Half',2,2)]:
scene.frame_set(frame)
bpy.context.view_layer.update()
pocket = bpy.data.objects['Hemispherical_Pocket_'+str(pocket_index+1)]
ball = bpy.data.objects['Spherical_Pressing_Head_'+str(ball_index+1)]
pp = pocket.matrix_world.translation
bp = ball.matrix_world.translation
pocket_normal = disc.matrix_world.to_quaternion() @ Vector(pocket['radial_opening_local'])
ball_normal = (male.matrix_world.to_quaternion() @ Vector((0,ball.location.y,ball.location.z))).normalized()
half = bpy.data.objects[half_name]
dome_normal = half.matrix_world.to_quaternion() @ Vector((0,0,1))
cup = bpy.data.objects[half_name+'_Cut_Flesh'].data.shape_keys.key_blocks['Pressed_Around_Spherical_Head']
report['pressing_alignment'][str(frame)] = {
'pocket_center_m':list(pp),
'ball_center_m':list(bp),
'ball_pocket_center_error_m':(pp-bp).length,
'half_cut_plane_origin_m':list(half.matrix_world.translation),
'ball_half_origin_error_m':(bp-half.matrix_world.translation).length,
'ball_inward_apex_m':list(bp+ball_normal*0.028),
'flesh_cup_apex_m':list(half.matrix_world @ Vector((0,0,0.0289))),
'half_dome_matches_inward_normal':dome_normal.dot(-pocket_normal)>0.999,
'flesh_conforms_to_ball':cup.value>0.999,
'root_scale':list(half.scale),
'disc_step_degrees':report['rotor_frame_deltas'][str(frame)][0],
'press_step_degrees':report['rotor_frame_deltas'][str(frame)][1],
}
report['pressing_alignment_passed'] = all(v['ball_pocket_center_error_m']<0.00001 and v['ball_half_origin_error_m']<0.00001 and v['half_dome_matches_inward_normal'] and v['flesh_conforms_to_ball'] and v['disc_step_degrees']<-0.01 and v['press_step_degrees']<-0.01 for v in report['pressing_alignment'].values())
report['residue_contact_and_motion'] = {}
for name,half_name,ball_name,pocket_name,show_frame,end in [('Residue_A_Pressed_Half_Peel','Process_Retained_Half','Spherical_Pressing_Head_2','Hemispherical_Pocket_2',214,242),('Residue_B_Pressed_Half_Peel','Process_Blade_Half','Spherical_Pressing_Head_3','Hemispherical_Pocket_3',278,306)]:
obj = bpy.data.objects[name]
scene.frame_set(show_frame)
bpy.context.view_layer.update()
actual_at_show = obj.matrix_world.translation.copy()
scene.frame_set(show_frame)
bpy.context.view_layer.update()
expected = bpy.data.objects[pocket_name].matrix_world.translation.copy()
contact_error = (actual_at_show-expected).length
scene.frame_set(show_frame)
bpy.context.view_layer.update()
start_position = obj.matrix_world.translation.copy()
start_rotation = obj.matrix_world.to_quaternion()
scene.frame_set(end)
bpy.context.view_layer.update()
position = obj.matrix_world.translation.copy()
end_rotation = obj.matrix_world.to_quaternion()
ball_position = bpy.data.objects[ball_name].matrix_world.translation
center = bpy.data.objects['Residue_Collection_Box_Slide'].matrix_world @ Vector((0.045,0.003,0))
report['residue_contact_and_motion'][name] = {
'initial_pressed_half_position_error_m':contact_error,
'actual_at_show':list(actual_at_show),
'expected_at_show':list(expected),
'guided_lateral_travel_m':math.hypot(position.x-start_position.x,position.y-start_position.y),
'release_rotation_change_radians':start_rotation.rotation_difference(end_rotation).angle,
'z_at_release_m':start_position.z,
'z_in_bin_m':position.z,
'falls_downward':position.z<start_position.z,
'distance_from_rotating_ball_at_rest_m':(position-ball_position).length,
'inside_residue_box_world_coordinates':abs(position.x-center.x)<0.065 and abs(position.y-center.y)<0.063 and 0.058<position.z<0.233,
}
report['residue_motion_passed'] = all(v['initial_pressed_half_position_error_m']<0.00001 and abs(v['release_rotation_change_radians'])<0.0001 and v['falls_downward'] and v['distance_from_rotating_ball_at_rest_m']>0.12 and v['inside_residue_box_world_coordinates'] for v in report['residue_contact_and_motion'].values())
scene.frame_set(350)
report['residue_and_box_slide_error_m'] = (bpy.data.objects['Residue_Animation_Slide'].matrix_world.translation-bpy.data.objects['Residue_Collection_Box_Slide'].matrix_world.translation).length
report['collector_slide_synchronized'] = report['residue_and_box_slide_error_m']<0.000001
report['non_manifold_edges'] = {}
report['positive_part_volumes_m3'] = {}
for name in ['Four_Pocket_Disc_Thick_Body','Fixed_Tangential_Cutting_Blade','Spherical_Pressing_Head_1','Press_Equilateral_Triangle_Carrier','Process_Retained_Half_Peel','Residue_A_Pressed_Half_Peel_Empty_Peel','Juice_Collection_Box_No_Spout_No_Handle','Residue_Collection_Box','Juice_Guide_Solid_Tray_No_Mesh','Transparent_Hood_With_Curved_Sides']+['Hemispherical_Pocket_'+str(i) for i in range(1,5)]+['Pocket_Rim_'+str(i) for i in range(1,5)]:
scene.frame_set(1)
obj = bpy.data.objects[name]
ev = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
mesh = ev.to_mesh()
bm = bmesh.new()
bm.from_mesh(mesh)
report['non_manifold_edges'][name] = sum(not e.is_manifold for e in bm.edges)
report['positive_part_volumes_m3'][name] = bm.calc_volume(signed=True)
bm.free()
ev.to_mesh_clear()
def tree(obj):
ev = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
mesh = ev.to_mesh()
result = BVHTree.FromPolygons([ev.matrix_world@v.co for v in mesh.vertices],[list(p.vertices) for p in mesh.polygons])
ev.to_mesh_clear()
return result
report['ball_disc_surface_intersection_frames'] = []
report['ball_disc_collision_details'] = []
report['seated_fruit_pocket_intersection_frames'] = []
report['blade_pocket_intersection_frames'] = []
report['blade_disc_surface_intersection_frames'] = []
report['ejector_pocket_intersection_frames'] = []
report['ejector_disc_surface_intersection_frames'] = []
blade_names = ['Fixed_Tangential_Cutting_Blade','Blade_Holder_Crossbar','Blade_Fixed_Mount','Blade_External_Cross_Bracket'] + [o.name for o in bpy.data.objects if o.name.startswith('Blade_Holder_Side_Cheek') or o.name.startswith('Blade_Mounting_Tang')]
ejector_names = ['Blade_Spring_Discharge_Plate']
for frame in sorted(set(range(1,361,2)) | {64,128,148,172,178,184,192,202,214,236,248,256,266,278,322}):
scene.frame_set(frame)
bpy.context.view_layer.update()
part_names = ['Four_Pocket_Disc_Thick_Body','Disc_Solid_Front_Cover']+['Pocket_Rim_'+str(i) for i in range(1,5)]
drum_parts = [tree(bpy.data.objects[name]) for name in part_names]
pockets = [tree(bpy.data.objects['Hemispherical_Pocket_'+str(i)]) for i in range(1,5)]
ball_names = ['Spherical_Pressing_Head_'+str(i) for i in range(1,4)]
moving_press_names = ball_names+['Press_Head_Short_Neck_'+str(i) for i in range(1,4)]+['Press_Equilateral_Triangle_Carrier']
balls = [tree(bpy.data.objects[name]) for name in moving_press_names]
details = [{'frame':frame,'ball':ball_name,'part':part_name} for ball_name,ball in zip(moving_press_names,balls) for part_name,part in zip(part_names,drum_parts) if part.overlap(ball)]
details += [{'frame':frame,'ball':ball_name,'part':'Hemispherical_Pocket_'+str(i)} for ball_name,ball in zip(moving_press_names,balls) for i,pocket in enumerate(pockets,1) if pocket.overlap(ball)]
report['ball_disc_collision_details'].extend(details)
if details:
report['ball_disc_surface_intersection_frames'].append(frame)
blades = [tree(bpy.data.objects[name]) for name in blade_names]
if any(blade.overlap(pocket) for blade in blades for pocket in pockets):
report['blade_pocket_intersection_frames'].append(frame)
if any(blade.overlap(part) for blade in blades for part in drum_parts):
report['blade_disc_surface_intersection_frames'].append(frame)
ejectors = [tree(bpy.data.objects[name]) for name in ejector_names]
if any(ejector.overlap(pocket) for ejector in ejectors for pocket in pockets):
report['ejector_pocket_intersection_frames'].append(frame)
if any(ejector.overlap(part) for ejector in ejectors for part in drum_parts):
report['ejector_disc_surface_intersection_frames'].append(frame)
if 64<=frame<=92:
fruit = tree(bpy.data.objects['Process_Whole_Orange_Peel'])
if any(fruit.overlap(pocket) for pocket in pockets):
report['seated_fruit_pocket_intersection_frames'].append({'frame':frame,'fruit':'whole'})
if 148<=frame<214:
fruit = tree(bpy.data.objects['Process_Retained_Half_Peel'])
if any(fruit.overlap(pocket) for pocket in pockets):
report['seated_fruit_pocket_intersection_frames'].append({'frame':frame,'fruit':'retained_half'})
if 192<=frame<278:
fruit = tree(bpy.data.objects['Process_Blade_Half_Peel'])
if any(fruit.overlap(pocket) for pocket in pockets):
report['seated_fruit_pocket_intersection_frames'].append({'frame':frame,'fruit':'blade_half'})
report['geometry_checks_passed'] = all(v==0 for v in report['non_manifold_edges'].values()) and all(v>0 for v in report['positive_part_volumes_m3'].values())
report['structure_checks_passed'] = (
report['source_document_matches'] and report['thick_disc_passed'] and report['actual_pocket_count']==4
and report['actual_spherical_head_count']==3 and report['solid_front_cover_present'] and report['short_neck_heads_present']
and report['vertical_press_parts_absent'] and report['press_axis_fixed_throughout_animation'] and report['rotational_relief_grooves_present']
and report['fixed_blade_has_no_animation'] and report['filter_mesh_absent'] and report['solid_juice_guide_present'] and report['drum_blade_slots_absent']
and report['front_faces_xoz_passed'] and report['blade_outside_drum'] and report['blade_outside_pocket_rims'] and report['blade_penetration_disabled_by_geometry']
and report['pockets_centered_across_drum_thickness'] and report['pocket_orientation_passed'] and report['hemispherical_pockets_passed']
and report['disc_rotation_is_clockwise_from_positive_y'] and report['press_rotation_is_clockwise_from_positive_y'] and report['both_mechanisms_clockwise_throughout'] and report['both_rotors_continuous_throughout'] and report['constant_speed_ratio_passed']
and report['fruit_follows_pocket_through_press'] and report['no_fake_z_squash_or_ram']
and report['blade_tangent_at_cutting_station'] and report['blade_cut_plane_matches_fruit_split'] and report['fruit_centered_on_external_cutting_edge'] and report['spring_ejector_moves_in_xoz']
and report['l_hopper_parts_present'] and report['long_arm_has_four_fruit_positions']
and report['separate_half_and_residue_meshes'] and report['recursive_visibility_passed'] and report['mechanism_fruit_colors_differ'] and all(report['collector_flags'].values())
and report['pressing_alignment_passed'] and report['residue_motion_passed'] and report['collector_slide_synchronized']
)
report['contact_checks_passed'] = all(not report[key] for key in ['ball_disc_surface_intersection_frames','seated_fruit_pocket_intersection_frames','blade_pocket_intersection_frames','blade_disc_surface_intersection_frames','ejector_pocket_intersection_frames','ejector_disc_surface_intersection_frames'])
report['contact_check_scope'] = 'Every frame: both rotor angle increments and fixed press axis. Every second frame plus exact process keyframes: balls, short necks and carrier versus drum, cover and one-piece pockets; seated fruit versus pockets; external blade, holder, supports and moving ejector versus rotating geometry. Intentional fruit cutting and pressing contact are excluded; this is sampled geometric validation, not a manufacturing physics simulation.'
report['data_checks_passed'] = report['saved_file_reopened'] and not report['missing_external_assets'] and report['linked_library_count']==0
report['passed'] = report['geometry_checks_passed'] and report['structure_checks_passed'] and report['contact_checks_passed'] and report['data_checks_passed']
report['visual_review'] = 'Final stills and rendered video are reviewed separately.'
(OUT/'mechanism_validation.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
keys = ['passed','structure_checks_passed','geometry_checks_passed','contact_checks_passed','data_checks_passed','front_faces_xoz_passed','filter_mesh_absent','blade_minimum_edge_radius_m','cutting_fruit_radius_m','ball_disc_surface_intersection_frames','ball_disc_collision_details','seated_fruit_pocket_intersection_frames','blade_pocket_intersection_frames','blade_disc_surface_intersection_frames','ejector_pocket_intersection_frames','ejector_disc_surface_intersection_frames','pocket_axial_center_errors_m','pocket_orientation_checks','pressing_alignment','residue_contact_and_motion','collector_slide_synchronized','recursive_visibility_passed','visibility_checks','both_mechanisms_clockwise_throughout','both_rotors_continuous_throughout','rotor_step_ranges_degrees','rotor_zero_speed_frames','press_to_disc_angular_speed_ratio','fruit_follows_pocket_through_press','no_fake_z_squash_or_ram','fruit_rolling_nip_checks','non_manifold_edges']
print(json.dumps({k:report[k] for k in keys},ensure_ascii=False,indent=2),flush=True)
if not report['passed']:
raise RuntimeError('Front-facing external-blade mechanism validation failed')
@@ -0,0 +1,60 @@
import hashlib
import json
import shutil
import subprocess
from pathlib import Path
OUT = Path(__file__).resolve().parent
VIDEO = OUT/'preview_operation.mp4'
BLEND = OUT/'PerfectCoffee_Minex_Mechanism.blend'
ffmpeg = shutil.which('ffmpeg')
ffprobe = shutil.which('ffprobe')
if not ffmpeg or not ffprobe:
raise RuntimeError('FFmpeg and ffprobe are required')
probe = json.loads(subprocess.check_output([ffprobe,'-v','error','-count_frames','-show_streams','-show_format','-of','json',str(VIDEO)],text=True))
stream = next(s for s in probe['streams'] if s['codec_type']=='video')
result = subprocess.run([ffmpeg,'-v','error','-xerror','-i',str(VIDEO),'-f','null','-'],capture_output=True,text=True)
if result.returncode:
raise RuntimeError(result.stderr)
expected = [f'{f:04d}.png' for f in range(1,361,2)]
frames_dir = OUT/'render_frames'
frames_present = frames_dir.is_dir()
missing = [name for name in expected if not (frames_dir/name).is_file()] if frames_present else []
selection = 'eq(n,0)+eq(n,63)+eq(n,64)+eq(n,83)+eq(n,92)+eq(n,96)+eq(n,100)+eq(n,106)+eq(n,127)+eq(n,139)+eq(n,160)+eq(n,179)'
subprocess.run([ffmpeg,'-v','error','-y','-i',str(VIDEO),'-vf',f"select='{selection}',scale=360:450,tile=4x3",'-frames:v','1',str(OUT/'preview_contact_sheet.png')],check=True)
report = {
'file':VIDEO.name,
'source_blend':BLEND.name,
'source_blend_sha256':hashlib.sha256(BLEND.read_bytes()).hexdigest(),
'build_script_sha256':hashlib.sha256((OUT/'build_minex_mechanism.py').read_bytes()).hexdigest(),
'render_script_sha256':hashlib.sha256((OUT/'render_minex_mechanism.py').read_bytes()).hexdigest(),
'motion_reference':{'file':'model_assets/reference/juicer/ZMUEX_working_video.mp4','segment_seconds':[119,126],'inspected_views':['front mechanism','side close-up']},
'inspection_view':'Front cover and centre knob are hidden only in internal mechanism renders; assembled Blender geometry remains complete',
'video_sha256':hashlib.sha256(VIDEO.read_bytes()).hexdigest(),
'codec':stream['codec_name'],
'pixel_format':stream['pix_fmt'],
'width':int(stream['width']),
'height':int(stream['height']),
'frame_rate':stream['avg_frame_rate'],
'decoded_frames':int(stream.get('nb_read_frames',stream['nb_frames'])),
'duration_seconds':float(probe['format']['duration']),
'bytes':VIDEO.stat().st_size,
'source_blender_timeline':{'start':1,'end':360,'fps':24,'seconds':15},
'preview_sampling':'Every second Blender frame, encoded at 12 fps for the same 15-second duration',
'expected_source_images':len(expected),
'source_frames_present_at_validation':frames_present,
'missing_source_images':missing,
'decoded_without_errors':True,
'contact_sheet':'preview_contact_sheet.png',
'visual_review':'Pending final video and contact-sheet review',
}
report['technical_checks_passed'] = (
stream['codec_name']=='h264' and (report['width'],report['height'])==(720,900)
and report['frame_rate']=='12/1' and report['decoded_frames']==180
and abs(report['duration_seconds']-15.0)<0.01 and not missing
)
report['passed'] = report['technical_checks_passed']
(OUT/'video_validation.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
print(json.dumps(report,ensure_ascii=False,indent=2))
if not report['passed']:
raise RuntimeError('Video technical validation failed')
+44
View File
@@ -0,0 +1,44 @@
{
"file": "preview_operation.mp4",
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
"source_blend_sha256": "046841038e0d0cb9af03d7b2e5a63208609caeae568c2c5a8a3cbfcd1c4cfd66",
"build_script_sha256": "8544cdacc6bfcae0d994318d48f6860724927daca6581cf00bffab750b122bf7",
"render_script_sha256": "8d7a597c9698fc8b7db4a1fe746b7f13f5a66ed6624e9786507018ad89ec9816",
"motion_reference": {
"file": "model_assets/reference/juicer/ZMUEX_working_video.mp4",
"segment_seconds": [
119,
126
],
"inspected_views": [
"front mechanism",
"side close-up"
]
},
"inspection_view": "Front cover and centre knob are hidden only in internal mechanism renders; assembled Blender geometry remains complete",
"video_sha256": "9571041aa9338d0b0c457461030599f5a2e643b6a3f7c70127167037d9061273",
"codec": "h264",
"pixel_format": "yuv420p",
"width": 720,
"height": 900,
"frame_rate": "12/1",
"decoded_frames": 180,
"duration_seconds": 15.0,
"bytes": 1755352,
"source_blender_timeline": {
"start": 1,
"end": 360,
"fps": 24,
"seconds": 15
},
"preview_sampling": "Every second Blender frame, encoded at 12 fps for the same 15-second duration",
"expected_source_images": 180,
"source_frames_present_at_validation": true,
"missing_source_images": [],
"decoded_without_errors": true,
"contact_sheet": "preview_contact_sheet.png",
"visual_review": "Reviewed the complete 15-second video, formal high-resolution stills, contact sheet and individual entry/peak/release frames. Both rotors move continuously, each orange half follows its pocket through the rolling nip, and squeezed peels discharge after contact.",
"technical_checks_passed": true,
"passed": true,
"visual_review_passed": true
}