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:
@@ -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')
|
||||
Reference in New Issue
Block a user