feat: track remaining production assets, playtest scenes and references
Close the gaps left open after the LFS migration: 177 files that were sitting untracked now enter version control, with every binary going through Git LFS. - labels: milk and orange-juice wrap artwork (SVG/PNG), Seedream sources, prompts and Dreamina job records - orange juice 2L: bottle, cap, empty state and three label variants (blend + glb each) - cup contents: desktop and mobile-optimised variants plus 3 textures - milk 2L: empty and packaged variants with their glb exports - milk frother: low-poly assembly and split base/jug parts - tamper: model, glb and fit test - juicer: seven assembly-part review scenes and their export scripts - playtests: extraction animation scene and grinding/tamping whitebox - reference: Minex page candidates, user review screenshots, sequence analysis frames and tamper STLs - docs: item design draft, bean research notes, region reference and the model-asset audit report Re-renderable preview/check frames stay untracked on purpose.
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
import bpy
|
||||
import bmesh
|
||||
import json
|
||||
from pathlib import Path
|
||||
from mathutils import Vector
|
||||
|
||||
OUT = Path('/Users/yanchenyu/Documents/WebApps/PerfetCoffee/model_assets/reference/tamper')
|
||||
SOURCES = [
|
||||
('01_matism09_58mm_cc-by/58mm.stl', 'Reference_01_Matism09', -0.050, (0.16, 0.32, 0.38, 1.0)),
|
||||
('02_tswaehn_58mm_cc-by-sa/Coffee_Tamper_v5.stl', 'Reference_02_Tswaehn', 0.050, (0.52, 0.31, 0.12, 1.0)),
|
||||
]
|
||||
|
||||
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
bpy.context.preferences.filepaths.save_version = 0
|
||||
scene = bpy.context.scene
|
||||
scene.unit_settings.system = 'METRIC'
|
||||
scene.unit_settings.length_unit = 'MILLIMETERS'
|
||||
scene.unit_settings.scale_length = 1.0
|
||||
model_collection = bpy.data.collections.new('Tamper_References')
|
||||
studio_collection = bpy.data.collections.new('Studio_Exclude_From_Export')
|
||||
scene.collection.children.link(model_collection)
|
||||
scene.collection.children.link(studio_collection)
|
||||
report = []
|
||||
objects = []
|
||||
|
||||
for index, (relative_path, name, x, color) in enumerate(SOURCES):
|
||||
bpy.ops.wm.stl_import(filepath=str(OUT / relative_path), global_scale=0.001)
|
||||
obj = bpy.context.object
|
||||
obj.name = name
|
||||
obj.data.name = name + '_Mesh'
|
||||
for collection in list(obj.users_collection):
|
||||
collection.objects.unlink(obj)
|
||||
model_collection.objects.link(obj)
|
||||
obj.location = (x, 0.0, 0.0)
|
||||
obj['source_file'] = relative_path
|
||||
obj['source_units'] = 'millimeters; imported with global_scale=0.001'
|
||||
material = bpy.data.materials.new(name + '_PreviewMaterial')
|
||||
material.use_nodes = True
|
||||
material.diffuse_color = color
|
||||
bsdf = material.node_tree.nodes.get('Principled BSDF')
|
||||
bsdf.inputs['Base Color'].default_value = color
|
||||
bsdf.inputs['Metallic'].default_value = 0.30
|
||||
bsdf.inputs['Roughness'].default_value = 0.32
|
||||
obj.data.materials.clear()
|
||||
obj.data.materials.append(material)
|
||||
for polygon in obj.data.polygons:
|
||||
polygon.use_smooth = True
|
||||
bm = bmesh.new()
|
||||
bm.from_mesh(obj.data)
|
||||
bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))
|
||||
non_manifold = sum(1 for edge in bm.edges if not edge.is_manifold)
|
||||
bm.to_mesh(obj.data)
|
||||
bm.free()
|
||||
bpy.context.view_layer.update()
|
||||
report.append({
|
||||
'file': relative_path,
|
||||
'triangles': len(obj.data.polygons),
|
||||
'vertices': len(obj.data.vertices),
|
||||
'dimensions_mm': [round(value * 1000.0, 5) for value in obj.dimensions],
|
||||
'non_manifold_edges': non_manifold,
|
||||
})
|
||||
objects.append(obj)
|
||||
|
||||
|
||||
def point_at(obj, target):
|
||||
obj.rotation_euler = (Vector(target) - obj.location).to_track_quat('-Z', 'Y').to_euler()
|
||||
|
||||
|
||||
def area_light(name, location, energy, size, color):
|
||||
data = bpy.data.lights.new(name, 'AREA')
|
||||
data.energy = energy
|
||||
data.shape = 'DISK'
|
||||
data.size = size
|
||||
data.color = color
|
||||
obj = bpy.data.objects.new(name, data)
|
||||
studio_collection.objects.link(obj)
|
||||
obj.location = location
|
||||
point_at(obj, (0.0, 0.0, 0.045))
|
||||
|
||||
|
||||
ground_material = bpy.data.materials.new('Studio_WarmGray')
|
||||
ground_material.use_nodes = True
|
||||
ground_bsdf = ground_material.node_tree.nodes.get('Principled BSDF')
|
||||
ground_bsdf.inputs['Base Color'].default_value = (0.20, 0.22, 0.24, 1.0)
|
||||
ground_bsdf.inputs['Roughness'].default_value = 0.80
|
||||
bpy.ops.mesh.primitive_plane_add(size=2.0, location=(0.0, 0.0, -0.00005))
|
||||
ground = bpy.context.object
|
||||
ground.name = 'Studio_Ground'
|
||||
for collection in list(ground.users_collection):
|
||||
collection.objects.unlink(ground)
|
||||
studio_collection.objects.link(ground)
|
||||
ground.data.materials.append(ground_material)
|
||||
|
||||
world = bpy.data.worlds.new('Tamper_Studio_World')
|
||||
world.use_nodes = True
|
||||
world.node_tree.nodes['Background'].inputs['Color'].default_value = (0.28, 0.32, 0.38, 1.0)
|
||||
world.node_tree.nodes['Background'].inputs['Strength'].default_value = 0.25
|
||||
scene.world = world
|
||||
area_light('Studio_Key', (0.10, 0.08, 0.24), 1.1, 0.17, (1.0, 0.89, 0.75))
|
||||
area_light('Studio_Fill', (-0.17, 0.02, 0.13), 0.45, 0.14, (0.80, 0.89, 1.0))
|
||||
area_light('Studio_Rim', (0.0, -0.14, 0.20), 1.3, 0.12, (1.0, 0.96, 0.88))
|
||||
|
||||
camera_data = bpy.data.cameras.new('Reference_Comparison_Camera')
|
||||
camera_data.type = 'ORTHO'
|
||||
camera_data.ortho_scale = 0.220
|
||||
camera_data.clip_start = 0.001
|
||||
camera_data.clip_end = 100.0
|
||||
camera = bpy.data.objects.new('Reference_Comparison_Camera', camera_data)
|
||||
studio_collection.objects.link(camera)
|
||||
camera.location = (0.14, 0.27, 0.155)
|
||||
point_at(camera, (0.0, 0.0, 0.040))
|
||||
scene.camera = camera
|
||||
|
||||
for obj, label, x in zip(objects, ('01 | 87.0 mm | CC BY', '02 | 73.2 mm | CC BY-SA'), (-0.050, 0.050)):
|
||||
curve = bpy.data.curves.new(label, 'FONT')
|
||||
curve.body = label
|
||||
curve.align_x = 'CENTER'
|
||||
curve.size = 0.0060
|
||||
text = bpy.data.objects.new(label, curve)
|
||||
studio_collection.objects.link(text)
|
||||
text.location = (x, -0.040, 0.001)
|
||||
text.rotation_euler = (camera.location - text.location).to_track_quat('Z', 'Y').to_euler()
|
||||
text.data.materials.append(ground_material)
|
||||
|
||||
scene.render.engine = 'CYCLES'
|
||||
scene.cycles.samples = 64
|
||||
scene.cycles.use_denoising = True
|
||||
scene.render.resolution_x = 1500
|
||||
scene.render.resolution_y = 1050
|
||||
scene.render.resolution_percentage = 100
|
||||
scene.render.image_settings.file_format = 'PNG'
|
||||
scene.render.image_settings.color_mode = 'RGB'
|
||||
scene.render.film_transparent = False
|
||||
scene.view_settings.view_transform = 'AgX'
|
||||
scene.view_settings.look = 'AgX - Medium High Contrast'
|
||||
scene.view_settings.exposure = -0.2
|
||||
scene.render.filepath = str(OUT / 'preview_comparison.png')
|
||||
(OUT / 'validation.json').write_text(json.dumps({'models': report, 'units': 'millimeters', 'preview_engine': 'CYCLES'}, indent=2), encoding='utf-8')
|
||||
assert all(item['non_manifold_edges'] == 0 for item in report), 'Inspect non-manifold reference meshes before using them'
|
||||
bpy.ops.render.render(write_still=True)
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
objects[0].select_set(True)
|
||||
bpy.context.view_layer.objects.active = objects[0]
|
||||
for screen in bpy.data.screens:
|
||||
for area in screen.areas:
|
||||
if area.type == 'VIEW_3D':
|
||||
area.spaces.active.region_3d.view_perspective = 'CAMERA'
|
||||
area.spaces.active.shading.type = 'MATERIAL'
|
||||
bpy.ops.wm.save_as_mainfile(filepath=str(OUT / 'Tamper_References.blend'))
|
||||
print('TAMPER_REFERENCE_VALIDATION=' + json.dumps(report), flush=True)
|
||||
print('TAMPER_REFERENCE_PREVIEW_COMPLETE', flush=True)
|
||||
Reference in New Issue
Block a user