Compare commits
10
Commits
d190c496d0
...
330a7fc19c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
330a7fc19c | ||
|
|
0f9e127162 | ||
|
|
e8f6f34e15 | ||
|
|
142a24d656 | ||
|
|
98954cc571 | ||
|
|
45293742e1 | ||
|
|
7eeff1cca2 | ||
|
|
f5d4f6dd41 | ||
|
|
e784ef07a8 | ||
|
|
036ee25a2a |
@@ -1,3 +1,29 @@
|
|||||||
|
# Git LFS: large binary assets are stored out-of-band, not as pack blobs.
|
||||||
|
# Text formats (svg, json, py, md) stay in normal git so they diff normally.
|
||||||
|
#
|
||||||
|
# Everything below applies to both new additions and future modifications.
|
||||||
|
# Reference material under model_assets/reference/ is kept in full and is the
|
||||||
|
# main beneficiary of this (models, videos, product photos, PDFs).
|
||||||
|
|
||||||
|
*.blend filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.blend1 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.glb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gltf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.fbx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.obj filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.stl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.usdz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mov filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.webp filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tif filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tiff filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.exr filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.hdr filter=lfs diff=lfs merge=lfs -text
|
||||||
*.blend filter=lfs diff=lfs merge=lfs -text
|
*.blend filter=lfs diff=lfs merge=lfs -text
|
||||||
*.blend1 filter=lfs diff=lfs merge=lfs -text
|
*.blend1 filter=lfs diff=lfs merge=lfs -text
|
||||||
*.glb filter=lfs diff=lfs merge=lfs -text
|
*.glb filter=lfs diff=lfs merge=lfs -text
|
||||||
@@ -17,6 +43,10 @@
|
|||||||
*.tiff filter=lfs diff=lfs merge=lfs -text
|
*.tiff filter=lfs diff=lfs merge=lfs -text
|
||||||
*.exr filter=lfs diff=lfs merge=lfs -text
|
*.exr filter=lfs diff=lfs merge=lfs -text
|
||||||
*.hdr filter=lfs diff=lfs merge=lfs -text
|
*.hdr filter=lfs diff=lfs merge=lfs -text
|
||||||
|
# Phone/camera photo formats (reference shots)
|
||||||
|
*.heic filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.heif filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.dng filter=lfs diff=lfs merge=lfs -text
|
||||||
*.heic filter=lfs diff=lfs merge=lfs -text
|
*.heic filter=lfs diff=lfs merge=lfs -text
|
||||||
*.heif filter=lfs diff=lfs merge=lfs -text
|
*.heif filter=lfs diff=lfs merge=lfs -text
|
||||||
*.dng filter=lfs diff=lfs merge=lfs -text
|
*.dng filter=lfs diff=lfs merge=lfs -text
|
||||||
|
|||||||
+49
@@ -12,6 +12,55 @@ wheels/
|
|||||||
# macOS
|
# macOS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Agent tooling state (local MCP config, caches)
|
||||||
|
.kimi-code/
|
||||||
|
|
||||||
# Blender backups and local modeling work
|
# Blender backups and local modeling work
|
||||||
*.blend1
|
*.blend1
|
||||||
**/_work/
|
**/_work/
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Render output: review/preview images are regenerated by the build scripts
|
||||||
|
# (build_*.py, render_*.py, export_*.py, capture_*.py). They are evidence of a
|
||||||
|
# review, not assets, so they stay out of the repository.
|
||||||
|
#
|
||||||
|
# Deliberately narrow patterns. NOT ignored on purpose:
|
||||||
|
# - model_assets/**/textures/** -> material sources read by the build scripts
|
||||||
|
# - model_assets/labels/** -> label artwork (wrap SVG/PNG, AI sources)
|
||||||
|
# - every *.blend and *.glb -> both high-poly and low-poly are kept
|
||||||
|
# - *_validation.json / *.json -> acceptance records
|
||||||
|
# If a new render is worth keeping, give it a non-preview name in textures/ or
|
||||||
|
# labels/ instead of widening these rules.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
model_assets/**/preview*.png
|
||||||
|
model_assets/**/comparison_*.png
|
||||||
|
model_assets/**/review_*.png
|
||||||
|
model_assets/**/assembly_*.png
|
||||||
|
model_assets/**/contact_sheet*.png
|
||||||
|
|
||||||
|
# One-off sheets that do not follow the preview_* convention
|
||||||
|
model_assets/coffee_machine/portafilter_*.png
|
||||||
|
model_assets/coffee_machine/cup_fit_test/*.png
|
||||||
|
model_assets/coffee_cup/optimization/*.png
|
||||||
|
model_assets/milk_2l/assembly_test/*.png
|
||||||
|
model_assets/tamper/fit_test/*.png
|
||||||
|
|
||||||
|
# Reference material keeps its own previews (third-party download thumbnails,
|
||||||
|
# attribution screenshots); never let the rules above swallow it.
|
||||||
|
!model_assets/reference/**
|
||||||
|
|
||||||
|
# ...but the re-include above must not resurrect OS/tool junk or backups.
|
||||||
|
model_assets/reference/**/.DS_Store
|
||||||
|
model_assets/reference/**/*.blend1
|
||||||
|
model_assets/reference/**/__pycache__/
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Playtest render output: frame checks, preview stills and demo videos are
|
||||||
|
# produced by build_animation.py / render_whitebox.py and can be regenerated.
|
||||||
|
# The .blend scenes, scripts and validation.json stay tracked.
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
playtests/**/previews/
|
||||||
|
playtests/**/checks/
|
||||||
|
playtests/**/*contact_sheet*.png
|
||||||
|
playtests/**/*.mp4
|
||||||
|
model_assets/**/preview_controls*.mp4
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# ZUMEX 榨汁机内部构造以及运行原理
|
||||||
|
## 榨汁机上层结构
|
||||||
|
### 橙子排列槽
|
||||||
|
- 描述:一个 L 型的槽位,长边可以排列4个橙子,短边稍微下沉直接对接入口。
|
||||||
|
- 功能:用于存放待压榨的橙子。
|
||||||
|
### 入口
|
||||||
|
- 描述:一个周期性开合的闸门和一个斜坡组成。斜坡的靠上的口对接排列槽的短边,靠下的入口对准榨汁机的旋转机构。
|
||||||
|
- 功能:确保橙子可以准确无误地滑入到旋转机构的凹槽中被稳稳卡住。
|
||||||
|
|
||||||
|
## 榨汁机内部结构
|
||||||
|
### 旋转机构
|
||||||
|
- 描述:一个圆盘,其上有4个略大于橙子的凹槽,且凹槽是半球。
|
||||||
|
- 功能:用于卡住橙子,使得橙子可以正常走到被切割的流程。
|
||||||
|
### 切割刀片
|
||||||
|
- 描述:一个方形的刀片结构,但是侧面由塑料片固定在机器上,其位于旋转机构的右侧。
|
||||||
|
- 功能:且刀片可以将卡在旋转机构内的橙子切成两半。当旋转机构将橙子带到了刀片上的时候,由旋转机构带来的推力可以结合刀片将橙子切成两半。留在旋转机构的那一半会跟随旋转机构进入压榨阶段,留在刀片上的那一半则由刀片弹起,使得那一半橘子因为惯性进入刚好旋转到刀片上的一个空的凹槽中。
|
||||||
|
### 球形挤压器
|
||||||
|
- 描述:中央的等边三角形和三个角上的球形挤压器。
|
||||||
|
- 功能:旋转中球形挤压器和旋转机构中的凹槽贴合,从而挤压位于旋转机构中的半个橙子,挤压出橙子汁。
|
||||||
|
## 榨汁机的收储结构
|
||||||
|
### 残渣收集器
|
||||||
|
- 描述:一个贴合底部形状的盒子。
|
||||||
|
- 功能:收集橙子残渣。
|
||||||
|
### 橙汁收集器
|
||||||
|
- 描述:一个贴合底部形状的盒子,没有壶嘴之类的结构,没有握把。
|
||||||
|
- 功能:收集压榨出来的橙汁。
|
||||||
|
## 额外补充
|
||||||
|
- 旋转机构中被挤压的橙子残渣会先粘在球形挤压器的球上面,然后在重力的影响下掉到残渣收集器中。
|
||||||
|
- 假设所有的橙子汁都可以被收集到橙汁存储盒中。残渣收集器中没有任何橙汁漏出来。
|
||||||
|
- 需要单独建模橙子和橙子残渣,橙子残渣就是被压榨完的半边橙子。但是可以不用很高的建模精度,差不多就好了。
|
||||||
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,744 @@
|
|||||||
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from mathutils import Matrix, Vector
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parent
|
||||||
|
REFERENCE = ROOT / "reference" / "consumables"
|
||||||
|
MAX_TRIANGLES = 1000
|
||||||
|
TAU = math.tau
|
||||||
|
MANIFEST = []
|
||||||
|
|
||||||
|
|
||||||
|
def material(name, color, roughness=0.6, alpha=1.0):
|
||||||
|
mat = bpy.data.materials.new(name)
|
||||||
|
mat.diffuse_color = (*color, alpha)
|
||||||
|
mat.use_nodes = True
|
||||||
|
bsdf = mat.node_tree.nodes.get("Principled BSDF")
|
||||||
|
bsdf.inputs["Base Color"].default_value = (*color, alpha)
|
||||||
|
bsdf.inputs["Roughness"].default_value = roughness
|
||||||
|
bsdf.inputs["Alpha"].default_value = alpha
|
||||||
|
if alpha < 1.0:
|
||||||
|
bsdf.inputs["IOR"].default_value = 1.45
|
||||||
|
mat.surface_render_method = "DITHERED"
|
||||||
|
mat.use_backface_culling = False
|
||||||
|
return mat
|
||||||
|
|
||||||
|
|
||||||
|
def reset():
|
||||||
|
bpy.ops.object.select_all(action="SELECT")
|
||||||
|
bpy.ops.object.delete(use_global=False)
|
||||||
|
for collection in list(bpy.data.collections):
|
||||||
|
bpy.data.collections.remove(collection)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.unit_settings.system = "METRIC"
|
||||||
|
scene.unit_settings.length_unit = "METERS"
|
||||||
|
scene.unit_settings.scale_length = 1.0
|
||||||
|
scene.render.engine = "BLENDER_EEVEE"
|
||||||
|
scene.render.resolution_x = 720
|
||||||
|
scene.render.resolution_y = 720
|
||||||
|
scene.render.resolution_percentage = 100
|
||||||
|
scene.render.image_settings.file_format = "PNG"
|
||||||
|
scene.render.film_transparent = False
|
||||||
|
scene.world.color = (0.3, 0.3, 0.3)
|
||||||
|
scene.world.use_nodes = True
|
||||||
|
scene.world.node_tree.nodes["Background"].inputs[0].default_value = (0.72, 0.78, 0.82, 1)
|
||||||
|
scene.world.node_tree.nodes["Background"].inputs[1].default_value = 0.30
|
||||||
|
scene.view_settings.view_transform = "AgX"
|
||||||
|
scene.view_settings.look = "AgX - Medium High Contrast"
|
||||||
|
scene.view_settings.exposure = -0.4
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
collection = bpy.data.collections.new("Model")
|
||||||
|
scene.collection.children.link(collection)
|
||||||
|
root = bpy.data.objects.new("Asset_Root", None)
|
||||||
|
root.empty_display_type = "PLAIN_AXES"
|
||||||
|
root.empty_display_size = 0.03
|
||||||
|
collection.objects.link(root)
|
||||||
|
return collection, root
|
||||||
|
|
||||||
|
|
||||||
|
def link_mesh(collection, root, name, vertices, faces, mats, indices=None, smooth=False):
|
||||||
|
mesh = bpy.data.meshes.new(name + "_Mesh")
|
||||||
|
mesh.from_pydata(vertices, [], faces)
|
||||||
|
mesh.update()
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(mesh)
|
||||||
|
bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))
|
||||||
|
bm.to_mesh(mesh)
|
||||||
|
bm.free()
|
||||||
|
obj = bpy.data.objects.new(name, mesh)
|
||||||
|
collection.objects.link(obj)
|
||||||
|
obj.parent = root
|
||||||
|
for mat in mats:
|
||||||
|
mesh.materials.append(mat)
|
||||||
|
for index, polygon in enumerate(mesh.polygons):
|
||||||
|
polygon.use_smooth = smooth
|
||||||
|
if indices:
|
||||||
|
polygon.material_index = indices[index]
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def merge_geometry(objects, name, collection, root):
|
||||||
|
vertices = []
|
||||||
|
faces = []
|
||||||
|
mats = []
|
||||||
|
indices = []
|
||||||
|
for obj in objects:
|
||||||
|
offset = len(vertices)
|
||||||
|
matrix = obj.matrix_world
|
||||||
|
vertices.extend(tuple(matrix @ v.co) for v in obj.data.vertices)
|
||||||
|
object_mats = list(obj.data.materials)
|
||||||
|
mat_map = {}
|
||||||
|
for index, mat in enumerate(object_mats):
|
||||||
|
if mat.name not in [m.name for m in mats]:
|
||||||
|
mats.append(mat)
|
||||||
|
mat_map[index] = [m.name for m in mats].index(mat.name)
|
||||||
|
for polygon in obj.data.polygons:
|
||||||
|
faces.append(tuple(offset + i for i in polygon.vertices))
|
||||||
|
indices.append(mat_map[polygon.material_index])
|
||||||
|
merged = link_mesh(collection, root, name, vertices, faces, mats, indices, True)
|
||||||
|
for obj in objects:
|
||||||
|
mesh = obj.data
|
||||||
|
bpy.data.objects.remove(obj, do_unlink=True)
|
||||||
|
if mesh.users == 0:
|
||||||
|
bpy.data.meshes.remove(mesh)
|
||||||
|
return merged
|
||||||
|
|
||||||
|
|
||||||
|
def loft(name, profile, segments, mat, collection, root, smooth=True, cap_ribs=False):
|
||||||
|
vertices = []
|
||||||
|
rings = []
|
||||||
|
for entry in profile:
|
||||||
|
radius, z = entry[0], entry[1]
|
||||||
|
cx = entry[2] if len(entry) > 2 else 0.0
|
||||||
|
cy = entry[3] if len(entry) > 3 else 0.0
|
||||||
|
aspect = entry[4] if len(entry) > 4 else 1.0
|
||||||
|
power = entry[5] if len(entry) > 5 else 2.0
|
||||||
|
if radius == 0:
|
||||||
|
rings.append([len(vertices)])
|
||||||
|
vertices.append((cx, cy, z))
|
||||||
|
continue
|
||||||
|
ring = []
|
||||||
|
for i in range(segments):
|
||||||
|
angle = TAU * i / segments
|
||||||
|
c, s = math.cos(angle), math.sin(angle)
|
||||||
|
x = math.copysign(abs(c) ** (2.0 / power), c) * radius
|
||||||
|
y = math.copysign(abs(s) ** (2.0 / power), s) * radius * aspect
|
||||||
|
if cap_ribs:
|
||||||
|
rib = 1.0 + 0.035 * math.cos(angle * segments / 2)
|
||||||
|
x *= rib
|
||||||
|
y *= rib
|
||||||
|
ring.append(len(vertices))
|
||||||
|
vertices.append((cx + x, cy + y, z))
|
||||||
|
rings.append(ring)
|
||||||
|
faces = []
|
||||||
|
for first, second in zip(rings[:-1], rings[1:]):
|
||||||
|
for i in range(segments):
|
||||||
|
j = (i + 1) % segments
|
||||||
|
if len(first) == 1 and len(second) == 1:
|
||||||
|
continue
|
||||||
|
if len(first) == 1:
|
||||||
|
faces.append((first[0], second[j], second[i]))
|
||||||
|
elif len(second) == 1:
|
||||||
|
faces.append((first[i], first[j], second[0]))
|
||||||
|
else:
|
||||||
|
faces.append((first[i], first[j], second[j], second[i]))
|
||||||
|
return link_mesh(collection, root, name, vertices, faces, [mat], smooth=smooth)
|
||||||
|
|
||||||
|
|
||||||
|
def prism(name, outline, bottom, top, mat, collection, root, slope=0.0):
|
||||||
|
count = len(outline)
|
||||||
|
vertices = [(x, y, bottom) for x, y in outline]
|
||||||
|
vertices += [(x, y, top + slope * y) for x, y in outline]
|
||||||
|
faces = [tuple(reversed(range(count))), tuple(range(count, 2 * count))]
|
||||||
|
for i in range(count):
|
||||||
|
j = (i + 1) % count
|
||||||
|
faces.append((i, j, count + j, count + i))
|
||||||
|
return link_mesh(collection, root, name, vertices, faces, [mat])
|
||||||
|
|
||||||
|
|
||||||
|
def box(name, location, scale, mat, collection, root, angle=0.0):
|
||||||
|
verts = []
|
||||||
|
for z in (-0.5, 0.5):
|
||||||
|
for x, y in ((-0.5, -0.5), (0.5, -0.5), (0.5, 0.5), (-0.5, 0.5)):
|
||||||
|
xx, yy = x * scale[0], y * scale[1]
|
||||||
|
verts.append((location[0] + xx * math.cos(angle) - yy * math.sin(angle),
|
||||||
|
location[1] + xx * math.sin(angle) + yy * math.cos(angle),
|
||||||
|
location[2] + z * scale[2]))
|
||||||
|
faces = [(3, 2, 1, 0), (4, 5, 6, 7), (0, 1, 5, 4), (1, 2, 6, 5), (2, 3, 7, 6), (3, 0, 4, 7)]
|
||||||
|
return link_mesh(collection, root, name, verts, faces, [mat])
|
||||||
|
|
||||||
|
|
||||||
|
def ellipsoid(name, center, radii, mat, collection, root, segments=8):
|
||||||
|
profile = [(0, -1.0)]
|
||||||
|
for j in range(1, 4):
|
||||||
|
theta = -math.pi / 2 + math.pi * j / 4
|
||||||
|
profile.append((math.cos(theta), math.sin(theta)))
|
||||||
|
profile.append((0, 1.0))
|
||||||
|
obj = loft(name, [(r, z) for r, z in profile], segments, mat, collection, root)
|
||||||
|
for vertex in obj.data.vertices:
|
||||||
|
vertex.co.x = center[0] + vertex.co.x * radii[0]
|
||||||
|
vertex.co.y = center[1] + vertex.co.y * radii[1]
|
||||||
|
vertex.co.z = center[2] + vertex.co.z * radii[2]
|
||||||
|
obj.data.update()
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def tube(name, points, radius, sides, mat, collection, root):
|
||||||
|
vertices = []
|
||||||
|
for i, point in enumerate(points):
|
||||||
|
p = Vector(point)
|
||||||
|
if i == 0:
|
||||||
|
tangent = Vector(points[1]) - p
|
||||||
|
elif i == len(points) - 1:
|
||||||
|
tangent = p - Vector(points[i - 1])
|
||||||
|
else:
|
||||||
|
tangent = Vector(points[i + 1]) - Vector(points[i - 1])
|
||||||
|
tangent.normalize()
|
||||||
|
normal = tangent.cross(Vector((0, 1, 0))).normalized()
|
||||||
|
if normal.length < 0.1:
|
||||||
|
normal = tangent.cross(Vector((1, 0, 0))).normalized()
|
||||||
|
other = tangent.cross(normal).normalized()
|
||||||
|
for j in range(sides):
|
||||||
|
a = TAU * j / sides
|
||||||
|
q = p + radius * (math.cos(a) * normal + math.sin(a) * other)
|
||||||
|
vertices.append(tuple(q))
|
||||||
|
faces = [tuple(reversed(range(sides)))]
|
||||||
|
for i in range(len(points) - 1):
|
||||||
|
for j in range(sides):
|
||||||
|
k = (j + 1) % sides
|
||||||
|
faces.append((i * sides + j, i * sides + k, (i + 1) * sides + k, (i + 1) * sides + j))
|
||||||
|
faces.append(tuple(range((len(points) - 1) * sides, len(points) * sides)))
|
||||||
|
return link_mesh(collection, root, name, vertices, faces, [mat], smooth=True)
|
||||||
|
|
||||||
|
|
||||||
|
def add_reference(root, filename):
|
||||||
|
image = bpy.data.images.load(str(REFERENCE / filename), check_existing=True)
|
||||||
|
image.name = "REFERENCE_" + Path(filename).stem
|
||||||
|
image.use_fake_user = True
|
||||||
|
image.pack()
|
||||||
|
root["reference_photo"] = filename
|
||||||
|
root["reference_usage"] = "Shape and proportion only; no label or photographic texture"
|
||||||
|
|
||||||
|
|
||||||
|
def volume_ml(obj):
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(obj.data)
|
||||||
|
value = abs(bm.calc_volume(signed=True)) * 1000000
|
||||||
|
bm.free()
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def section_solid(name, sections, segments, mat, collection, root):
|
||||||
|
vertices = []
|
||||||
|
for z, half_x, half_y, corner, cx, cy, circular in sections:
|
||||||
|
for i in range(segments):
|
||||||
|
angle = TAU * i / segments
|
||||||
|
c, s = math.cos(angle), math.sin(angle)
|
||||||
|
if circular:
|
||||||
|
x, y = half_x * c, half_y * s
|
||||||
|
else:
|
||||||
|
tx = half_x / max(abs(c), 1e-10)
|
||||||
|
ty = half_y / max(abs(s), 1e-10)
|
||||||
|
diagonal = (half_x + half_y - corner) / max(abs(c) + abs(s), 1e-10)
|
||||||
|
distance = min(tx, ty, diagonal)
|
||||||
|
x, y = distance * c, distance * s
|
||||||
|
vertices.append((cx + x, cy + y, z))
|
||||||
|
faces = [tuple(reversed(range(segments))), tuple(range((len(sections) - 1) * segments, len(sections) * segments))]
|
||||||
|
for ring in range(len(sections) - 1):
|
||||||
|
for i in range(segments):
|
||||||
|
j = (i + 1) % segments
|
||||||
|
faces.append((ring * segments + i, ring * segments + j,
|
||||||
|
(ring + 1) * segments + j, (ring + 1) * segments + i))
|
||||||
|
return link_mesh(collection, root, name, vertices, faces, [mat])
|
||||||
|
|
||||||
|
|
||||||
|
def apply_difference(body, cutter):
|
||||||
|
bpy.context.view_layer.objects.active = body
|
||||||
|
modifier = body.modifiers.new("Integral_Construction", "BOOLEAN")
|
||||||
|
modifier.operation = "DIFFERENCE"
|
||||||
|
modifier.solver = "EXACT"
|
||||||
|
modifier.object = cutter
|
||||||
|
bpy.ops.object.modifier_apply(modifier=modifier.name)
|
||||||
|
mesh = cutter.data
|
||||||
|
bpy.data.objects.remove(cutter, do_unlink=True)
|
||||||
|
if mesh.users == 0:
|
||||||
|
bpy.data.meshes.remove(mesh)
|
||||||
|
|
||||||
|
|
||||||
|
def make_rectangular_milk_body(collection, root, mat):
|
||||||
|
outer_sections = [
|
||||||
|
(0.002, 0.052, 0.052, 0.006, 0, 0, False),
|
||||||
|
(0.006, 0.058, 0.058, 0.006, 0, 0, False),
|
||||||
|
(0.018, 0.060, 0.060, 0.005, 0, 0, False),
|
||||||
|
(0.210, 0.060, 0.060, 0.005, 0, 0, False),
|
||||||
|
(0.222, 0.060, 0.060, 0.005, 0, 0, False),
|
||||||
|
(0.230, 0.055, 0.055, 0.006, 0, 0, False),
|
||||||
|
(0.242, 0.040, 0.040, 0.007, 0, 0, False),
|
||||||
|
(0.252, 0.026, 0.026, 0.007, 0, 0, False),
|
||||||
|
(0.260, 0.021, 0.021, 0, 0, 0, True),
|
||||||
|
(0.266, 0.018, 0.018, 0, 0, 0, True),
|
||||||
|
(0.278, 0.018, 0.018, 0, 0, 0, True),
|
||||||
|
]
|
||||||
|
cavity_sections = [
|
||||||
|
(0.006, 0.053, 0.053, 0.004, 0, 0, False),
|
||||||
|
(0.018, 0.055, 0.055, 0.004, 0, 0, False),
|
||||||
|
(0.112, 0.055, 0.055, 0.004, 0, 0, False),
|
||||||
|
(0.122, 0.055, 0.055, 0.062, 0, 0, False),
|
||||||
|
(0.214, 0.055, 0.055, 0.062, 0, 0, False),
|
||||||
|
(0.218, 0.055, 0.055, 0.004, 0, 0, False),
|
||||||
|
(0.230, 0.050, 0.050, 0.004, 0, 0, False),
|
||||||
|
(0.242, 0.035, 0.035, 0.004, 0, 0, False),
|
||||||
|
(0.252, 0.021, 0.021, 0.004, 0, 0, False),
|
||||||
|
(0.260, 0.015, 0.015, 0, 0, 0, True),
|
||||||
|
(0.279, 0.015, 0.015, 0, 0, 0, True),
|
||||||
|
]
|
||||||
|
body = section_solid("Milk_Bottle_Body", outer_sections, 12, mat, collection, root)
|
||||||
|
cavity = section_solid("Milk_Interior_Cavity", cavity_sections, 12, mat, collection, root)
|
||||||
|
cavity_volume = volume_ml(cavity)
|
||||||
|
control = [Vector(point) for point in [(0.080, -0.024), (0.068, -0.006), (0.044, 0.023), (0.032, 0.044), (0.006, 0.068)]]
|
||||||
|
curve = []
|
||||||
|
for segment in range(len(control) - 1):
|
||||||
|
p0 = control[max(0, segment - 1)]
|
||||||
|
p1, p2 = control[segment], control[segment + 1]
|
||||||
|
p3 = control[min(len(control) - 1, segment + 2)]
|
||||||
|
for step in range(3):
|
||||||
|
t = step / 3
|
||||||
|
point = 0.5 * ((2 * p1) + (-p0 + p2) * t
|
||||||
|
+ (2 * p0 - 5 * p1 + 4 * p2 - p3) * t * t
|
||||||
|
+ (-p0 + 3 * p1 - 3 * p2 + p3) * t * t * t)
|
||||||
|
curve.append(point)
|
||||||
|
curve.append(control[-1])
|
||||||
|
left, right = [], []
|
||||||
|
for i, point in enumerate(curve):
|
||||||
|
tangent = curve[min(i + 1, len(curve) - 1)] - curve[max(0, i - 1)]
|
||||||
|
tangent.normalize()
|
||||||
|
normal = Vector((-tangent.y, tangent.x))
|
||||||
|
left.append(point + normal * 0.0085)
|
||||||
|
right.append(point - normal * 0.0085)
|
||||||
|
tangent = (curve[-1] - curve[-2]).normalized()
|
||||||
|
normal = Vector((-tangent.y, tangent.x))
|
||||||
|
for i in range(1, 7):
|
||||||
|
angle = math.pi * i / 6
|
||||||
|
left.append(curve[-1] + tangent * (0.0085 * math.sin(angle)) + normal * (0.0085 * math.cos(angle)))
|
||||||
|
outline = [tuple(point) for point in left + list(reversed(right[:-1]))]
|
||||||
|
count = len(outline)
|
||||||
|
vertices, faces = [], []
|
||||||
|
for z, scale in [(0.122, 0.96), (0.128, 1.0), (0.208, 1.0), (0.214, 0.96)]:
|
||||||
|
for x, y in outline:
|
||||||
|
vertices.append((0.040 + (x - 0.040) * scale, 0.030 + (y - 0.030) * scale, z))
|
||||||
|
faces = [tuple(reversed(range(count))), tuple(range(3 * count, 4 * count))]
|
||||||
|
for ring in range(3):
|
||||||
|
for i in range(count):
|
||||||
|
j = (i + 1) % count
|
||||||
|
faces.append((ring * count + i, ring * count + j, (ring + 1) * count + j, (ring + 1) * count + i))
|
||||||
|
cutter = link_mesh(collection, root, "Milk_Corner_Handle_Pocket", vertices, faces, [mat])
|
||||||
|
probe = cutter.copy()
|
||||||
|
probe.data = cutter.data.copy()
|
||||||
|
collection.objects.link(probe)
|
||||||
|
bpy.context.view_layer.objects.active = probe
|
||||||
|
modifier = probe.modifiers.new("Cavity_Clearance", "BOOLEAN")
|
||||||
|
modifier.operation = "INTERSECT"
|
||||||
|
modifier.solver = "EXACT"
|
||||||
|
modifier.object = cavity
|
||||||
|
bpy.ops.object.modifier_apply(modifier=modifier.name)
|
||||||
|
overlap = volume_ml(probe)
|
||||||
|
bpy.data.objects.remove(probe, do_unlink=True)
|
||||||
|
if overlap > 0.001:
|
||||||
|
raise RuntimeError(f"Handle pocket intersects liquid cavity: {overlap} mL")
|
||||||
|
apply_difference(body, cavity)
|
||||||
|
apply_difference(body, cutter)
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(body.data)
|
||||||
|
bmesh.ops.dissolve_limit(bm, angle_limit=math.radians(0.5), use_dissolve_boundaries=False)
|
||||||
|
bmesh.ops.triangulate(bm, faces=list(bm.faces))
|
||||||
|
bmesh.ops.dissolve_degenerate(bm, dist=0.00000001, edges=list(bm.edges))
|
||||||
|
bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))
|
||||||
|
non_manifold = sum(not edge.is_manifold for edge in bm.edges)
|
||||||
|
bm.to_mesh(body.data)
|
||||||
|
bm.free()
|
||||||
|
for polygon in body.data.polygons:
|
||||||
|
polygon.use_smooth = polygon.center.z > 0.243 or polygon.normal.z > 0.1
|
||||||
|
body.data.update()
|
||||||
|
if non_manifold:
|
||||||
|
raise RuntimeError(f"Milk bottle has {non_manifold} non-manifold edges")
|
||||||
|
factor = math.sqrt(2150 / cavity_volume)
|
||||||
|
root["interior_capacity_ml"] = cavity_volume * factor * factor
|
||||||
|
root["body_profile"] = "Chamfered square lower cuboid; centered shrinking upper segment; circular centered mouth"
|
||||||
|
root["lower_segment_square"] = True
|
||||||
|
root["lower_segment_top_z_m"] = 0.222
|
||||||
|
root["shoulder_start_height_ratio"] = 0.222 / 0.278
|
||||||
|
root["mouth_center_xy"] = [0.0, 0.0]
|
||||||
|
root["shoulder_to_mouth_ratio"] = 0.021 / 0.018
|
||||||
|
root["handle_construction"] = "Large arched corner opening from +X toward +Y around an integral vertical grip; central body is not cut through"
|
||||||
|
root["handle_path_xy"] = [list(point) for point in curve]
|
||||||
|
root["handle_aperture_width_m"] = 0.017
|
||||||
|
root["handle_aperture_height_m"] = 0.092
|
||||||
|
root["handle_bottom_z_m"] = 0.122
|
||||||
|
root["handle_top_z_m"] = 0.214
|
||||||
|
root["handle_cavity_overlap_ml"] = overlap
|
||||||
|
root["body_non_manifold_edges"] = non_manifold
|
||||||
|
root["mouth_z_m"] = 0.278
|
||||||
|
root["cap_base_z_m"] = 0.264
|
||||||
|
root["neck_outer_radius_m"] = 0.018 * factor
|
||||||
|
root["cap_inner_radius_m"] = 0.0196 * factor
|
||||||
|
root["cap_radial_clearance_m"] = (0.0196 * 0.965 - 0.018) * factor
|
||||||
|
root["cap_top_clearance_m"] = 0.0005
|
||||||
|
return body, 0.0, 0.264, factor
|
||||||
|
|
||||||
|
|
||||||
|
def make_bottle(collection, root, kind):
|
||||||
|
milk = kind == "milk"
|
||||||
|
prefix = "Milk" if milk else "OrangeJuice"
|
||||||
|
body_mat = material(prefix + "_HDPE" if milk else prefix + "_ClearPET",
|
||||||
|
(0.88, 0.875, 0.78) if milk else (0.93, 0.98, 1.0),
|
||||||
|
0.4 if milk else 0.18,
|
||||||
|
1.0 if milk else 0.055)
|
||||||
|
cap_mat = material(prefix + "_Cap", (0.035, 0.19, 0.48) if milk else (0.025, 0.20, 0.065), 0.46)
|
||||||
|
root["design_id"] = "premade_milk" if milk else "bottled_orange_juice"
|
||||||
|
root["nominal_capacity_ml"] = 2000
|
||||||
|
root["label_packaging"] = "None: unbranded container only"
|
||||||
|
root["cap_independent"] = True
|
||||||
|
if milk:
|
||||||
|
body, neck_y, neck_z, factor = make_rectangular_milk_body(collection, root, body_mat)
|
||||||
|
else:
|
||||||
|
profile = [
|
||||||
|
(0, 0.003), (0.050, 0.003, 0, 0, 0.87, 2.7),
|
||||||
|
(0.058, 0.010, 0, 0, 0.87, 2.7), (0.060, 0.023, 0, 0, 0.87, 2.7),
|
||||||
|
(0.060, 0.068, 0, 0, 0.87, 2.7), (0.056, 0.073, 0, 0, 0.87, 2.7),
|
||||||
|
(0.059, 0.079, 0, 0, 0.87, 2.7), (0.060, 0.113, 0, 0, 0.87, 2.7),
|
||||||
|
(0.057, 0.155, 0, 0, 0.87, 2.7), (0.057, 0.180, 0, 0, 0.87, 2.7),
|
||||||
|
(0.052, 0.211, 0, 0, 0.87, 2.7), (0.040, 0.240, 0, 0, 0.87, 2.7),
|
||||||
|
(0.028, 0.254, 0, 0, 0.90, 2.3), (0.019, 0.263),
|
||||||
|
(0.018, 0.267), (0.018, 0.283), (0.014, 0.283),
|
||||||
|
(0.014, 0.261), (0, 0.261),
|
||||||
|
]
|
||||||
|
body = loft(prefix + "_Bottle_Body", profile, 16, body_mat, collection, root)
|
||||||
|
juice_mat = material("OrangeJuice_Liquid", (0.95, 0.29, 0.012), 0.36)
|
||||||
|
fill = [
|
||||||
|
(0, 0.010), (0.049, 0.010, 0, 0, 0.87, 2.7),
|
||||||
|
(0.056, 0.020, 0, 0, 0.87, 2.7), (0.0565, 0.150, 0, 0, 0.87, 2.7),
|
||||||
|
(0.0545, 0.180, 0, 0, 0.87, 2.7), (0.050, 0.211, 0, 0, 0.87, 2.7),
|
||||||
|
(0.039, 0.236, 0, 0, 0.87, 2.7), (0.034, 0.245, 0, 0, 0.87, 2.7),
|
||||||
|
(0, 0.245),
|
||||||
|
]
|
||||||
|
fill_obj = loft(prefix + "_Juice_Fill", fill, 16, juice_mat, collection, root)
|
||||||
|
neck_y, neck_z = 0.0, 0.283
|
||||||
|
if milk:
|
||||||
|
cap_profile = [
|
||||||
|
(0, 0.017), (0.019, 0.017), (0.021, 0.014), (0.0215, 0.004),
|
||||||
|
(0.0215, 0.002), (0.0208, 0), (0.0196, 0), (0.0196, 0.0145),
|
||||||
|
(0, 0.0145),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
cap_profile = [
|
||||||
|
(0, 0), (0.0208, 0), (0.0215, 0.002), (0.0215, 0.004),
|
||||||
|
(0.021, 0.005), (0.021, 0.014), (0.019, 0.017), (0, 0.017),
|
||||||
|
]
|
||||||
|
cap_pivot = bpy.data.objects.new(prefix + "_Cap_Pivot", None)
|
||||||
|
collection.objects.link(cap_pivot)
|
||||||
|
cap_pivot.parent = root
|
||||||
|
cap_pivot.location = (0, neck_y, neck_z)
|
||||||
|
cap_pivot.empty_display_size = 0.024
|
||||||
|
cap = loft(prefix + "_Cap", cap_profile, 16, cap_mat, collection, cap_pivot, cap_ribs=True)
|
||||||
|
cap["detach_axis"] = "Z"
|
||||||
|
cap["thread_detail"] = "Omitted for low-poly budget"
|
||||||
|
if milk:
|
||||||
|
root["volume_calibration"] = "Inner cavity calibrated to nominal 2L with headroom"
|
||||||
|
else:
|
||||||
|
factor = math.sqrt(2000 / volume_ml(fill_obj))
|
||||||
|
root["modeled_liquid_ml"] = 2000.0
|
||||||
|
for obj in collection.all_objects:
|
||||||
|
if obj.type == "MESH":
|
||||||
|
for vertex in obj.data.vertices:
|
||||||
|
vertex.co.x *= factor
|
||||||
|
vertex.co.y *= factor
|
||||||
|
cap_pivot.location.y *= factor
|
||||||
|
root["volume_calibration"] = "Geometric volume, not a manufacturing specification"
|
||||||
|
return body, cap, cap_pivot
|
||||||
|
|
||||||
|
|
||||||
|
def make_croissant(collection, root):
|
||||||
|
mats = [
|
||||||
|
material("Croissant_Golden", (0.62, 0.265, 0.060), 0.72),
|
||||||
|
material("Croissant_LightLayers", (0.82, 0.435, 0.13), 0.75),
|
||||||
|
material("Croissant_Toast", (0.40, 0.135, 0.026), 0.78),
|
||||||
|
]
|
||||||
|
count, sides = 23, 10
|
||||||
|
vertices, faces, indices = [], [], []
|
||||||
|
for i in range(count):
|
||||||
|
t = -1 + 2 * i / (count - 1)
|
||||||
|
x, y = 0.09 * t, 0.052 * abs(t) ** 1.85 - 0.009
|
||||||
|
z = 0.026 + 0.004 * (1 - t * t)
|
||||||
|
derivative = Vector((0.09, 0.052 * 1.85 * math.copysign(abs(t) ** 0.85, t), 0))
|
||||||
|
tangent = derivative.normalized()
|
||||||
|
normal = Vector((-tangent.y, tangent.x, 0))
|
||||||
|
radius = 0.003 + 0.026 * max(0, 1 - t * t) ** 0.72
|
||||||
|
for j in range(sides):
|
||||||
|
angle = TAU * j / sides
|
||||||
|
layer = 1 + 0.055 * math.cos(t * math.pi * 9 + 0.7 * math.sin(angle))
|
||||||
|
p = Vector((x, y, z))
|
||||||
|
p += normal * (radius * 0.92 * math.cos(angle) * layer)
|
||||||
|
p.z += radius * math.sin(angle) * layer
|
||||||
|
vertices.append(tuple(p))
|
||||||
|
for i in range(count - 1):
|
||||||
|
for j in range(sides):
|
||||||
|
k = (j + 1) % sides
|
||||||
|
faces.append((i * sides + j, i * sides + k, (i + 1) * sides + k, (i + 1) * sides + j))
|
||||||
|
indices.append(1 if i % 5 in (0, 1) else (2 if i % 5 == 3 else 0))
|
||||||
|
faces += [tuple(reversed(range(sides))), tuple(range((count - 1) * sides, count * sides))]
|
||||||
|
indices += [0, 0]
|
||||||
|
obj = link_mesh(collection, root, "Croissant_Rolled_Pastry", vertices, faces, mats, indices, True)
|
||||||
|
obj["recognition_features"] = "Crescent, tapered tips, laminated rolled bands"
|
||||||
|
root["design_id"] = "croissant"
|
||||||
|
|
||||||
|
|
||||||
|
def make_cake(collection, root):
|
||||||
|
chocolate = material("Cake_ChocolateSponge", (0.12, 0.040, 0.019), 0.88)
|
||||||
|
cream = material("Cake_VanillaCream", (0.88, 0.78, 0.57), 0.67)
|
||||||
|
frosting = material("Cake_Frosting", (0.91, 0.84, 0.70), 0.56)
|
||||||
|
red = material("Cake_Strawberry", (0.58, 0.027, 0.020), 0.4)
|
||||||
|
green = material("Cake_StrawberryLeaves", (0.095, 0.25, 0.025), 0.72)
|
||||||
|
outline = [(0, -0.060), (-0.054, 0.031), (-0.046, 0.044), (-0.027, 0.052),
|
||||||
|
(0, 0.055), (0.027, 0.052), (0.046, 0.044), (0.054, 0.031)]
|
||||||
|
prism("Cake_Sponge_Lower", outline, 0.001, 0.021, chocolate, collection, root)
|
||||||
|
prism("Cake_Cream_Lower", outline, 0.021, 0.027, cream, collection, root)
|
||||||
|
prism("Cake_Sponge_Upper", outline, 0.027, 0.046, chocolate, collection, root)
|
||||||
|
prism("Cake_Cream_Upper", outline, 0.046, 0.052, cream, collection, root)
|
||||||
|
prism("Cake_Frosting_Top", outline, 0.052, 0.059, frosting, collection, root, 0.08)
|
||||||
|
ellipsoid("Cake_Strawberry", (0, 0.036, 0.076), (0.014, 0.012, 0.019), red, collection, root)
|
||||||
|
for i in range(3):
|
||||||
|
a = i * TAU / 3
|
||||||
|
link_mesh(collection, root, f"Cake_Leaf_{i + 1}", [
|
||||||
|
(0, 0.036, 0.091), (0.014 * math.cos(a - 0.3), 0.036 + 0.014 * math.sin(a - 0.3), 0.092),
|
||||||
|
(0.019 * math.cos(a), 0.036 + 0.019 * math.sin(a), 0.090),
|
||||||
|
(0.014 * math.cos(a + 0.3), 0.036 + 0.014 * math.sin(a + 0.3), 0.092),
|
||||||
|
], [(0, 1, 2), (0, 2, 3)], [green])
|
||||||
|
root["design_id"] = "cake_slice"
|
||||||
|
|
||||||
|
|
||||||
|
def make_cream_toast(collection, root):
|
||||||
|
crust = material("Toast_Crust", (0.43, 0.18, 0.052), 0.82)
|
||||||
|
crumb = material("Toast_Crumb", (0.82, 0.65, 0.38), 0.88)
|
||||||
|
cream = material("Toast_PaleYellowCream", (0.94, 0.77, 0.30), 0.48)
|
||||||
|
outline = [
|
||||||
|
(-0.046, -0.059), (0.046, -0.059), (0.053, -0.055),
|
||||||
|
(0.057, -0.048), (0.057, -0.030), (0.055, 0.022),
|
||||||
|
(0.054, 0.038), (0.047, 0.050), (0.035, 0.059),
|
||||||
|
(0.020, 0.064), (0, 0.061), (-0.020, 0.064),
|
||||||
|
(-0.035, 0.059), (-0.047, 0.050), (-0.054, 0.038),
|
||||||
|
(-0.055, 0.022), (-0.057, -0.030), (-0.057, -0.048),
|
||||||
|
(-0.053, -0.055),
|
||||||
|
]
|
||||||
|
|
||||||
|
def layer(name, rings, mat):
|
||||||
|
count = len(outline)
|
||||||
|
vertices = [(x * scale, y * scale, z) for scale, z in rings for x, y in outline]
|
||||||
|
faces = [tuple(reversed(range(count)))]
|
||||||
|
for ring in range(len(rings) - 1):
|
||||||
|
for i in range(count):
|
||||||
|
j = (i + 1) % count
|
||||||
|
a = ring * count
|
||||||
|
b = (ring + 1) * count
|
||||||
|
faces.append((a + i, a + j, b + j, b + i))
|
||||||
|
faces.append(tuple(range((len(rings) - 1) * count, len(rings) * count)))
|
||||||
|
obj = link_mesh(collection, root, name, vertices, faces, [mat], smooth=True)
|
||||||
|
for polygon in obj.data.polygons:
|
||||||
|
polygon.use_smooth = len(polygon.vertices) == 4
|
||||||
|
return obj
|
||||||
|
|
||||||
|
layer("Toast_Bread_Crust", [(0.94, 0.001), (1.0, 0.003), (1.0, 0.0145), (0.965, 0.017)], crust)
|
||||||
|
layer("Toast_Inner_Crumb", [(0.90, 0.017), (0.90, 0.01735)], crumb)
|
||||||
|
layer("Toast_PaleYellowCream_Layer", [(0.827, 0.01735), (0.845, 0.01775), (0.827, 0.0194)], cream)
|
||||||
|
root["design_id"] = "avocado_toast"
|
||||||
|
root["presentation"] = "Plain toast with one pale-yellow cream layer; no avocado, chili or other toppings"
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_count(obj, depsgraph=None):
|
||||||
|
if depsgraph is None:
|
||||||
|
obj.data.calc_loop_triangles()
|
||||||
|
return len(obj.data.loop_triangles)
|
||||||
|
evaluated = obj.evaluated_get(depsgraph)
|
||||||
|
mesh = evaluated.to_mesh()
|
||||||
|
mesh.calc_loop_triangles()
|
||||||
|
count = len(mesh.loop_triangles)
|
||||||
|
evaluated.to_mesh_clear()
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
def bounds(objects):
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
points = [obj.matrix_world @ vertex.co for obj in objects for vertex in obj.data.vertices]
|
||||||
|
return [min(v[i] for v in points) for i in range(3)], [max(v[i] for v in points) for i in range(3)]
|
||||||
|
|
||||||
|
|
||||||
|
def studio(collection, objects, path, positive_y=False):
|
||||||
|
scene = bpy.context.scene
|
||||||
|
minimum, maximum = bounds(objects)
|
||||||
|
center = Vector([(a + b) / 2 for a, b in zip(minimum, maximum)])
|
||||||
|
size = max(maximum[i] - minimum[i] for i in range(3))
|
||||||
|
floor_mat = material("Studio_Background", (0.68, 0.70, 0.66), 0.86)
|
||||||
|
bpy.ops.mesh.primitive_plane_add(size=200, location=(0, 0, min(-0.0002, minimum[2] - 0.0002)))
|
||||||
|
floor = bpy.context.object
|
||||||
|
floor.name = "Studio_Ground"
|
||||||
|
floor.data.materials.append(floor_mat)
|
||||||
|
for c in list(floor.users_collection):
|
||||||
|
c.objects.unlink(floor)
|
||||||
|
collection.objects.link(floor)
|
||||||
|
camera_data = bpy.data.cameras.new("Studio_Camera")
|
||||||
|
camera = bpy.data.objects.new("Studio_Camera", camera_data)
|
||||||
|
collection.objects.link(camera)
|
||||||
|
camera.location = center + Vector((size * 1.6, size * 2.3 if positive_y else -size * 2.3, size * 1.65))
|
||||||
|
camera.rotation_euler = (center - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera_data.type = "ORTHO"
|
||||||
|
camera_data.ortho_scale = size * 1.30
|
||||||
|
scene.camera = camera
|
||||||
|
for i, (offset, power, light_size) in enumerate([
|
||||||
|
((-1.5, -1.8, 3.0), 35, 1.6), ((2.0, -0.3, 1.6), 20, 1.3), ((0.3, 2.0, 2.4), 30, 1.4),
|
||||||
|
]):
|
||||||
|
data = bpy.data.lights.new(f"Studio_Light_{i + 1}", "AREA")
|
||||||
|
data.energy = power * max(0.2, size * 3) * 0.25
|
||||||
|
data.shape = "DISK"
|
||||||
|
data.size = light_size * size
|
||||||
|
obj = bpy.data.objects.new(data.name, data)
|
||||||
|
collection.objects.link(obj)
|
||||||
|
obj.location = center + Vector(offset) * size
|
||||||
|
obj.rotation_euler = (center - obj.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
scene.render.filepath = str(path)
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
|
||||||
|
|
||||||
|
def export_model(collection, path):
|
||||||
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
for obj in collection.all_objects:
|
||||||
|
obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = next(obj for obj in collection.all_objects if obj.type == "MESH")
|
||||||
|
bpy.ops.export_scene.gltf(filepath=str(path), export_format="GLB", use_selection=True,
|
||||||
|
export_yup=True, export_apply=True, export_cameras=False, export_lights=False)
|
||||||
|
|
||||||
|
|
||||||
|
def report_for(root, collection, out, blend, glb, cap=None):
|
||||||
|
objects = [obj for obj in collection.all_objects if obj.type == "MESH"]
|
||||||
|
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
|
components = {obj.name: triangle_count(obj, depsgraph) for obj in objects}
|
||||||
|
total = sum(components.values())
|
||||||
|
minimum, maximum = bounds(objects)
|
||||||
|
report = {
|
||||||
|
"asset": root.name,
|
||||||
|
"design_id": root.get("design_id"),
|
||||||
|
"presentation": root.get("presentation"),
|
||||||
|
"blender_version": bpy.app.version_string,
|
||||||
|
"units": "meters",
|
||||||
|
"axis_convention": "Blender Z up; GLB Y up",
|
||||||
|
"triangle_limit": MAX_TRIANGLES,
|
||||||
|
"triangles": total,
|
||||||
|
"passed_triangle_budget": total <= MAX_TRIANGLES,
|
||||||
|
"mesh_components": components,
|
||||||
|
"bounds_min_m": minimum,
|
||||||
|
"bounds_max_m": maximum,
|
||||||
|
"dimensions_m": [maximum[i] - minimum[i] for i in range(3)],
|
||||||
|
"reference_photo": root.get("reference_photo"),
|
||||||
|
"reference_images_packed": True,
|
||||||
|
"labels_or_brand_graphics": False,
|
||||||
|
"blend": blend.name,
|
||||||
|
"glb": glb.name,
|
||||||
|
"preview": "preview.png",
|
||||||
|
"native_reopen_passed": None,
|
||||||
|
"glb_reimport_passed": None,
|
||||||
|
}
|
||||||
|
for key in ("nominal_capacity_ml", "cap_independent", "interior_capacity_ml", "modeled_liquid_ml",
|
||||||
|
"body_profile", "handle_construction", "body_non_manifold_edges",
|
||||||
|
"mouth_z_m", "cap_base_z_m", "neck_outer_radius_m", "cap_inner_radius_m",
|
||||||
|
"cap_radial_clearance_m", "cap_top_clearance_m", "lower_segment_square",
|
||||||
|
"lower_segment_top_z_m", "shoulder_start_height_ratio", "mouth_center_xy", "shoulder_to_mouth_ratio",
|
||||||
|
"handle_bottom_z_m", "handle_top_z_m", "handle_cavity_overlap_ml",
|
||||||
|
"handle_aperture_width_m", "handle_aperture_height_m"):
|
||||||
|
if key in root:
|
||||||
|
report[key] = list(root[key]) if key == "mouth_center_xy" else root[key]
|
||||||
|
if cap:
|
||||||
|
report["cap_mesh"] = cap.name
|
||||||
|
report["cap_triangles"] = components[cap.name]
|
||||||
|
report["cap_files"] = [blend.with_name(blend.stem + "_Cap.blend").name,
|
||||||
|
glb.with_name(glb.stem + "_Cap.glb").name]
|
||||||
|
report["preview_cap_removed"] = "preview_cap_removed.png"
|
||||||
|
report["passed"] = report["passed_triangle_budget"]
|
||||||
|
(out / "validation.json").write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
assert total <= MAX_TRIANGLES, (root.name, total)
|
||||||
|
return report
|
||||||
|
|
||||||
|
|
||||||
|
def finalize(root, collection, directory, cap=None, cap_pivot=None):
|
||||||
|
out = ROOT / directory
|
||||||
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
blend = out / ("PerfectCoffee_" + out.name + ".blend")
|
||||||
|
glb = blend.with_suffix(".glb")
|
||||||
|
report = report_for(root, collection, out, blend, glb, cap)
|
||||||
|
export_model(collection, glb)
|
||||||
|
studio_collection = bpy.data.collections.new("Studio")
|
||||||
|
bpy.context.scene.collection.children.link(studio_collection)
|
||||||
|
studio(studio_collection, [obj for obj in collection.all_objects if obj.type == "MESH"], out / "preview.png",
|
||||||
|
positive_y=root.name == "Milk2L_Root")
|
||||||
|
if cap_pivot:
|
||||||
|
saved_location = cap_pivot.location.copy()
|
||||||
|
cap_pivot.location += Vector((0.045, 0, 0.055))
|
||||||
|
bpy.context.scene.render.filepath = str(out / "preview_cap_removed.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
cap_pivot.location = saved_location
|
||||||
|
bpy.context.scene.render.filepath = str(out / "preview.png")
|
||||||
|
for area in bpy.context.screen.areas if bpy.context.screen else []:
|
||||||
|
if area.type == "VIEW_3D":
|
||||||
|
area.spaces.active.region_3d.view_distance = 0.5
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(blend), compress=True)
|
||||||
|
if cap:
|
||||||
|
cap_mesh = cap.data.copy()
|
||||||
|
cap_name = cap.name
|
||||||
|
cap_only_name = root.name + "_CapOnly"
|
||||||
|
reset()
|
||||||
|
cap_collection = bpy.data.collections.get("Model")
|
||||||
|
cap_root = bpy.data.objects.get("Asset_Root")
|
||||||
|
cap_root.name = cap_only_name
|
||||||
|
obj = bpy.data.objects.new(cap_name, cap_mesh)
|
||||||
|
cap_collection.objects.link(obj)
|
||||||
|
obj.parent = cap_root
|
||||||
|
cap_root["pivot"] = "Bottom center; local Z is removal axis"
|
||||||
|
export_model(cap_collection, glb.with_name(glb.stem + "_Cap.glb"))
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(blend.with_name(blend.stem + "_Cap.blend")), compress=True)
|
||||||
|
MANIFEST.append({"directory": directory, "blend": blend.name, "glb": glb.name, "triangles": report["triangles"]})
|
||||||
|
print("ASSET_COMPLETE", directory, report["triangles"], flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
ASSETS = [
|
||||||
|
("milk_2l", "milk", "milk_2l_woolworths.png", "Milk2L_Root"),
|
||||||
|
("orange_juice_2l", "orange_juice", "orange_juice_2l_product.webp", "OrangeJuice2L_Root"),
|
||||||
|
("food/bakery_and_cake/Croissant", "croissant", "croissant.jpg", "Croissant_Root"),
|
||||||
|
("food/bakery_and_cake/CakeSlice", "cake", "cake_slice.jpg", "CakeSlice_Root"),
|
||||||
|
("food/toast_and_wrap/AvocadoToast", "avocado_toast", "cream_toast.jpg", "AvocadoToast_Root"),
|
||||||
|
]
|
||||||
|
|
||||||
|
requested_assets = set(sys.argv[sys.argv.index("--") + 1:]) if "--" in sys.argv else set()
|
||||||
|
for directory, kind, reference, root_name in ASSETS:
|
||||||
|
if requested_assets and directory not in requested_assets:
|
||||||
|
continue
|
||||||
|
collection, root = reset()
|
||||||
|
root.name = root_name
|
||||||
|
add_reference(root, reference)
|
||||||
|
cap, cap_pivot = None, None
|
||||||
|
if kind in ("milk", "orange_juice"):
|
||||||
|
_, cap, cap_pivot = make_bottle(collection, root, kind)
|
||||||
|
elif kind == "croissant":
|
||||||
|
make_croissant(collection, root)
|
||||||
|
elif kind == "cake":
|
||||||
|
make_cake(collection, root)
|
||||||
|
elif kind == "avocado_toast":
|
||||||
|
make_cream_toast(collection, root)
|
||||||
|
finalize(root, collection, directory, cap, cap_pivot)
|
||||||
|
|
||||||
|
if not requested_assets:
|
||||||
|
(ROOT / "low_poly_consumables_manifest.json").write_text(json.dumps({
|
||||||
|
"triangle_limit_per_asset": MAX_TRIANGLES,
|
||||||
|
"assets": MANIFEST,
|
||||||
|
}, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
print("ALL_ASSETS_COMPLETE", len(MANIFEST), flush=True)
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,515 @@
|
|||||||
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
from mathutils import Vector
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
|
||||||
|
OUT = Path('/Users/yanchenyu/Documents/WebApps/PerfetCoffee/model_assets/coffee_cup')
|
||||||
|
SOURCE = OUT / 'PerfectCoffee_CoffeeCup.blend'
|
||||||
|
TEXTURES = OUT / 'textures'
|
||||||
|
TEXTURES.mkdir(exist_ok=True)
|
||||||
|
SOURCE_SHA256 = hashlib.sha256(SOURCE.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
SEGMENTS = 96
|
||||||
|
CUP_SEGMENTS = 24
|
||||||
|
CUP_HEIGHT = 0.110
|
||||||
|
CUP_INNER_BOTTOM_RADIUS = 0.028
|
||||||
|
CUP_INNER_TOP_RADIUS = 0.0405
|
||||||
|
CUP_INNER_FLOOR = 0.002
|
||||||
|
LIQUID_BOTTOM = CUP_INNER_FLOOR + 0.00020
|
||||||
|
LIQUID_TOP = 0.10380
|
||||||
|
FOAM_BOTTOM = LIQUID_TOP + 0.00002
|
||||||
|
FOAM_EDGE_TOP = 0.10570
|
||||||
|
FOAM_DOME = 0.00035
|
||||||
|
FIT_CLEARANCE = 0.00012
|
||||||
|
LIQUID_UV_RADIUS = (CUP_INNER_BOTTOM_RADIUS + (CUP_INNER_TOP_RADIUS - CUP_INNER_BOTTOM_RADIUS) * LIQUID_TOP / CUP_HEIGHT) * math.cos(math.pi / CUP_SEGMENTS) - FIT_CLEARANCE
|
||||||
|
FOAM_UV_RADIUS = (CUP_INNER_BOTTOM_RADIUS + (CUP_INNER_TOP_RADIUS - CUP_INNER_BOTTOM_RADIUS) * FOAM_EDGE_TOP / CUP_HEIGHT) * math.cos(math.pi / CUP_SEGMENTS) - FIT_CLEARANCE
|
||||||
|
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(SOURCE))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.unit_settings.system = 'METRIC'
|
||||||
|
scene.unit_settings.length_unit = 'METERS'
|
||||||
|
scene.unit_settings.scale_length = 1.0
|
||||||
|
|
||||||
|
lid = bpy.data.objects.get('CC_Lid')
|
||||||
|
if lid is not None:
|
||||||
|
bpy.data.objects.remove(lid, do_unlink=True)
|
||||||
|
for obj in list(bpy.data.collections['Studio_Exclude_From_Export'].objects):
|
||||||
|
bpy.data.objects.remove(obj, do_unlink=True)
|
||||||
|
source_root = bpy.data.objects.get('CC_CoffeeCup_Assembly')
|
||||||
|
if source_root is not None:
|
||||||
|
bpy.data.objects.remove(source_root, do_unlink=True)
|
||||||
|
|
||||||
|
cup = bpy.data.objects['CC_Cup_Body']
|
||||||
|
cup.parent = None
|
||||||
|
cup.location = (0.0, 0.0, 0.0)
|
||||||
|
cup.rotation_euler = (0.0, 0.0, 0.0)
|
||||||
|
model_collection = bpy.data.collections.get('CC_CoffeeCup_Model')
|
||||||
|
model_collection.name = 'CC_CupContents_Preview'
|
||||||
|
studio = bpy.data.collections['Studio_Exclude_From_Export']
|
||||||
|
|
||||||
|
root = bpy.data.objects.new('CC_CupContents_Assembly', None)
|
||||||
|
model_collection.objects.link(root)
|
||||||
|
root.empty_display_type = 'PLAIN_AXES'
|
||||||
|
root.empty_display_size = 0.02
|
||||||
|
root['units'] = 'meters; Z up; liquid +Y corresponds to UV +V'
|
||||||
|
root['source_cup'] = SOURCE.name
|
||||||
|
root['source_cup_sha256'] = SOURCE_SHA256
|
||||||
|
root['liquid_top_m'] = LIQUID_TOP
|
||||||
|
root['foam_edge_top_m'] = FOAM_EDGE_TOP
|
||||||
|
root['foam_dome_m'] = FOAM_DOME
|
||||||
|
root['foam_thickness_mm'] = (FOAM_EDGE_TOP - FOAM_BOTTOM) * 1000.0
|
||||||
|
root['rim_clearance_mm'] = (CUP_HEIGHT - FOAM_EDGE_TOP - FOAM_DOME) * 1000.0
|
||||||
|
root['liquid_material_slot'] = 'CC_Coffee_Liquid'
|
||||||
|
root['foam_material_slot'] = 'CC_Milk_Foam'
|
||||||
|
root['uv_usage'] = 'LiquidSurfaceUV: planar X/Y top projection, center=(0.5,0.5), full top bounds=(0,0)-(1,1)'
|
||||||
|
root['runtime_hint'] = 'Hide CC_Milk_Foam for Americano; override CC_Coffee_Liquid and CC_Milk_Foam materials independently in Godot'
|
||||||
|
|
||||||
|
|
||||||
|
def inner_radius(z):
|
||||||
|
if z <= 0.022:
|
||||||
|
return 0.028 + (z - CUP_INNER_FLOOR) * (0.0305 - 0.028) / (0.022 - CUP_INNER_FLOOR)
|
||||||
|
return 0.0305 + (z - 0.022) * (0.038 - 0.0305) / (0.088 - 0.022)
|
||||||
|
|
||||||
|
|
||||||
|
def fitted_radius(z):
|
||||||
|
return inner_radius(z) * math.cos(math.pi / CUP_SEGMENTS) - FIT_CLEARANCE
|
||||||
|
|
||||||
|
|
||||||
|
def linear_channel(value):
|
||||||
|
return value / 12.92 if value <= 0.04045 else ((value + 0.055) / 1.055) ** 2.4
|
||||||
|
|
||||||
|
|
||||||
|
def rgba_from_hex(value):
|
||||||
|
return tuple(linear_channel(int(value[index:index + 2], 16) / 255.0) for index in (1, 3, 5)) + (1.0,)
|
||||||
|
|
||||||
|
|
||||||
|
def set_input(node, name, value):
|
||||||
|
socket = node.inputs.get(name)
|
||||||
|
if socket is not None:
|
||||||
|
socket.default_value = value
|
||||||
|
|
||||||
|
|
||||||
|
def new_material(name, hex_color, roughness):
|
||||||
|
mat = bpy.data.materials.new(name)
|
||||||
|
mat.use_nodes = True
|
||||||
|
mat.diffuse_color = rgba_from_hex(hex_color)
|
||||||
|
bsdf = mat.node_tree.nodes.get('Principled BSDF')
|
||||||
|
bsdf.inputs['Base Color'].default_value = rgba_from_hex(hex_color)
|
||||||
|
bsdf.inputs['Roughness'].default_value = roughness
|
||||||
|
return mat, bsdf
|
||||||
|
|
||||||
|
|
||||||
|
def micro_bump(mat, bsdf, scale, distance, strength):
|
||||||
|
nodes = mat.node_tree.nodes
|
||||||
|
links = mat.node_tree.links
|
||||||
|
noise = nodes.new('ShaderNodeTexNoise')
|
||||||
|
noise.name = 'Micro_Surface_Only_In_Blender'
|
||||||
|
noise.label = 'Cycles micro detail; use a Godot shader for equivalent detail'
|
||||||
|
noise.inputs['Scale'].default_value = scale
|
||||||
|
noise.inputs['Detail'].default_value = 2.0
|
||||||
|
noise.inputs['Roughness'].default_value = 0.65
|
||||||
|
bump = nodes.new('ShaderNodeBump')
|
||||||
|
bump.inputs['Strength'].default_value = strength
|
||||||
|
bump.inputs['Distance'].default_value = distance
|
||||||
|
links.new(noise.outputs['Fac'], bump.inputs['Height'])
|
||||||
|
links.new(bump.outputs['Normal'], bsdf.inputs['Normal'])
|
||||||
|
noise.location = (-480, -150)
|
||||||
|
bump.location = (-220, -100)
|
||||||
|
|
||||||
|
|
||||||
|
def make_texture(name, pixels):
|
||||||
|
size = pixels.shape[0]
|
||||||
|
image = bpy.data.images.new(name, width=size, height=size, alpha=True)
|
||||||
|
image.colorspace_settings.name = 'sRGB'
|
||||||
|
rgba = np.ones((size, size, 4), dtype=np.float32)
|
||||||
|
rgba[:, :, :3] = np.clip(pixels, 0.0, 1.0)
|
||||||
|
image.pixels.foreach_set(rgba.ravel())
|
||||||
|
image.filepath_raw = str(TEXTURES / (name + '.png'))
|
||||||
|
image.file_format = 'PNG'
|
||||||
|
image.save()
|
||||||
|
image.pack()
|
||||||
|
return image
|
||||||
|
|
||||||
|
|
||||||
|
def attach_albedo(mat, bsdf, image):
|
||||||
|
nodes = mat.node_tree.nodes
|
||||||
|
links = mat.node_tree.links
|
||||||
|
uv = nodes.new('ShaderNodeUVMap')
|
||||||
|
uv.uv_map = 'LiquidSurfaceUV'
|
||||||
|
uv.location = (-680, 220)
|
||||||
|
texture = nodes.new('ShaderNodeTexImage')
|
||||||
|
texture.image = image
|
||||||
|
texture.interpolation = 'Linear'
|
||||||
|
texture.extension = 'EXTEND'
|
||||||
|
texture.location = (-420, 220)
|
||||||
|
links.new(uv.outputs['UV'], texture.inputs['Vector'])
|
||||||
|
links.new(texture.outputs['Color'], bsdf.inputs['Base Color'])
|
||||||
|
bsdf.location = (0, 160)
|
||||||
|
mat.node_tree.nodes.get('Material Output').location = (310, 160)
|
||||||
|
|
||||||
|
|
||||||
|
SIZE = 1024
|
||||||
|
axis = np.linspace(-1.0, 1.0, SIZE, dtype=np.float32)
|
||||||
|
x, y = np.meshgrid(axis, axis)
|
||||||
|
radius = np.sqrt(x * x + y * y)
|
||||||
|
angle = np.arctan2(y, x)
|
||||||
|
rng = np.random.default_rng(4061)
|
||||||
|
noise = (
|
||||||
|
np.sin(x * 21.0 + y * 13.0) * 0.35
|
||||||
|
+ np.sin(x * 57.0 - y * 43.0) * 0.17
|
||||||
|
+ np.cos(x * 109.0 + y * 83.0) * 0.08
|
||||||
|
+ rng.normal(0.0, 0.10, (SIZE, SIZE))
|
||||||
|
)
|
||||||
|
|
||||||
|
coffee_dark = np.array([39.0, 20.0, 9.0]) / 255.0
|
||||||
|
coffee_edge = np.array([87.0, 45.0, 16.0]) / 255.0
|
||||||
|
edge = np.clip((radius - 0.82) / 0.18, 0.0, 1.0) ** 3
|
||||||
|
swirl = (0.5 + 0.5 * np.sin(angle * 3.0 + radius * 38.0)) * np.exp(-((radius - 0.91) / 0.055) ** 2)
|
||||||
|
coffee_pixels = coffee_dark[None, None, :] * (1.0 - edge[:, :, None] * 0.64) + coffee_edge[None, None, :] * edge[:, :, None] * 0.64
|
||||||
|
coffee_pixels += swirl[:, :, None] * np.array([0.020, 0.010, 0.002])[None, None, :]
|
||||||
|
coffee_pixels += noise[:, :, None] * 0.007
|
||||||
|
coffee_image = make_texture('CC_Coffee_Surface', coffee_pixels)
|
||||||
|
|
||||||
|
latte_base = np.array([163.0, 101.0, 51.0]) / 255.0
|
||||||
|
latte_edge = np.array([119.0, 70.0, 31.0]) / 255.0
|
||||||
|
milk = np.array([255.0, 241.0, 214.0]) / 255.0
|
||||||
|
foam_edge = np.clip((radius - 0.80) / 0.20, 0.0, 1.0) ** 2
|
||||||
|
latte_pixels = latte_base[None, None, :] * (1.0 - foam_edge[:, :, None] * 0.52) + latte_edge[None, None, :] * foam_edge[:, :, None] * 0.52
|
||||||
|
latte_pixels += noise[:, :, None] * 0.010
|
||||||
|
|
||||||
|
curve_size = 2048
|
||||||
|
curve_axis = np.linspace(-1.0, 1.0, curve_size, dtype=np.float32)
|
||||||
|
t = np.linspace(0.0, math.tau, 512, endpoint=False)
|
||||||
|
heart_x = 16.0 * np.sin(t) ** 3 / 17.0 * 0.65
|
||||||
|
heart_y = (13.0 * np.cos(t) - 5.0 * np.cos(2.0 * t) - 2.0 * np.cos(3.0 * t) - np.cos(4.0 * t)) / 17.0 * 0.68 + 0.065
|
||||||
|
next_x = np.roll(heart_x, -1)
|
||||||
|
next_y = np.roll(heart_y, -1)
|
||||||
|
heart_large = np.zeros((curve_size, curve_size), dtype=np.float32)
|
||||||
|
for row, y_value in enumerate(curve_axis):
|
||||||
|
crossing = (heart_y > y_value) != (next_y > y_value)
|
||||||
|
x_crossings = heart_x[crossing] + (y_value - heart_y[crossing]) * (next_x[crossing] - heart_x[crossing]) / (next_y[crossing] - heart_y[crossing])
|
||||||
|
x_crossings.sort()
|
||||||
|
for pair in range(0, len(x_crossings), 2):
|
||||||
|
left = np.searchsorted(curve_axis, x_crossings[pair])
|
||||||
|
right = np.searchsorted(curve_axis, x_crossings[pair + 1])
|
||||||
|
heart_large[row, left:right] = 1.0
|
||||||
|
heart = heart_large.reshape(SIZE, 2, SIZE, 2).mean(axis=(1, 3))
|
||||||
|
latte_pixels = latte_pixels * (1.0 - heart[:, :, None]) + milk[None, None, :] * heart[:, :, None]
|
||||||
|
|
||||||
|
for _ in range(100):
|
||||||
|
bubble_angle = rng.uniform(0.0, math.tau)
|
||||||
|
bubble_radius = rng.uniform(0.82, 0.975)
|
||||||
|
bx = math.cos(bubble_angle) * bubble_radius
|
||||||
|
by = math.sin(bubble_angle) * bubble_radius
|
||||||
|
br = rng.uniform(0.0020, 0.0065)
|
||||||
|
distance = np.sqrt((x - bx) ** 2 + (y - by) ** 2)
|
||||||
|
ring = np.exp(-((distance - br) / 0.0016) ** 2) * 0.26
|
||||||
|
latte_pixels = latte_pixels * (1.0 - ring[:, :, None]) + milk[None, None, :] * ring[:, :, None]
|
||||||
|
latte_image = make_texture('CC_Latte_Surface', latte_pixels)
|
||||||
|
|
||||||
|
coffee_mat, coffee_bsdf = new_material('CC_Coffee_Liquid', '#271409', 0.20)
|
||||||
|
set_input(coffee_bsdf, 'IOR', 1.333)
|
||||||
|
set_input(coffee_bsdf, 'Specular IOR Level', 0.32)
|
||||||
|
set_input(coffee_bsdf, 'Coat Weight', 0.18)
|
||||||
|
set_input(coffee_bsdf, 'Coat Roughness', 0.16)
|
||||||
|
attach_albedo(coffee_mat, coffee_bsdf, coffee_image)
|
||||||
|
micro_bump(coffee_mat, coffee_bsdf, 95.0, 0.000015, 0.08)
|
||||||
|
|
||||||
|
foam_mat, foam_bsdf = new_material('CC_Milk_Foam', '#A36533', 0.62)
|
||||||
|
set_input(foam_bsdf, 'IOR', 1.35)
|
||||||
|
set_input(foam_bsdf, 'Specular IOR Level', 0.20)
|
||||||
|
set_input(foam_bsdf, 'Subsurface Weight', 0.035)
|
||||||
|
set_input(foam_bsdf, 'Subsurface Radius', (0.001, 0.0006, 0.0003))
|
||||||
|
set_input(foam_bsdf, 'Subsurface Scale', 0.001)
|
||||||
|
attach_albedo(foam_mat, foam_bsdf, latte_image)
|
||||||
|
micro_bump(foam_mat, foam_bsdf, 145.0, 0.000055, 0.13)
|
||||||
|
|
||||||
|
|
||||||
|
def recalculate_normals(mesh):
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(mesh)
|
||||||
|
bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))
|
||||||
|
bm.to_mesh(mesh)
|
||||||
|
bm.free()
|
||||||
|
mesh.update()
|
||||||
|
|
||||||
|
|
||||||
|
def apply_planar_uv(obj, uv_radius):
|
||||||
|
uv = obj.data.uv_layers['LiquidSurfaceUV']
|
||||||
|
for polygon in obj.data.polygons:
|
||||||
|
polygon.use_smooth = abs(polygon.normal.z) < 0.995
|
||||||
|
for loop_index in polygon.loop_indices:
|
||||||
|
vertex = obj.data.vertices[obj.data.loops[loop_index].vertex_index].co
|
||||||
|
uv.data[loop_index].uv = (0.5 + vertex.x / (2.0 * uv_radius), 0.5 + vertex.y / (2.0 * uv_radius))
|
||||||
|
obj['uv_radius_m'] = uv_radius
|
||||||
|
|
||||||
|
|
||||||
|
def make_object(name, vertices, faces, top_face_start, material, uv_radius):
|
||||||
|
mesh = bpy.data.meshes.new(name + '_Mesh')
|
||||||
|
mesh.from_pydata(vertices, [], faces)
|
||||||
|
recalculate_normals(mesh)
|
||||||
|
obj = bpy.data.objects.new(name, mesh)
|
||||||
|
model_collection.objects.link(obj)
|
||||||
|
obj.parent = root
|
||||||
|
obj.data.materials.append(material)
|
||||||
|
mesh.uv_layers.new(name='LiquidSurfaceUV')
|
||||||
|
mesh.uv_layers.active = mesh.uv_layers['LiquidSurfaceUV']
|
||||||
|
apply_planar_uv(obj, uv_radius)
|
||||||
|
obj['uv_map'] = 'LiquidSurfaceUV'
|
||||||
|
obj['top_uv_faces'] = len(mesh.polygons) - top_face_start
|
||||||
|
obj['material_slot'] = material.name
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
liquid_rings = [
|
||||||
|
(fitted_radius(LIQUID_BOTTOM), LIQUID_BOTTOM),
|
||||||
|
(fitted_radius(LIQUID_TOP), LIQUID_TOP),
|
||||||
|
]
|
||||||
|
vertices = []
|
||||||
|
for ring_radius, z in liquid_rings:
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
angle = math.tau * index / SEGMENTS
|
||||||
|
vertices.append((ring_radius * math.cos(angle), ring_radius * math.sin(angle), z))
|
||||||
|
faces = [tuple(reversed(range(SEGMENTS)))]
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
following = (index + 1) % SEGMENTS
|
||||||
|
faces.append((index, following, SEGMENTS + following, SEGMENTS + index))
|
||||||
|
liquid = make_object('CC_Coffee_Liquid', vertices, faces, len(faces), coffee_mat, LIQUID_UV_RADIUS)
|
||||||
|
liquid_top_start = len(liquid.data.polygons)
|
||||||
|
cap = bmesh.new()
|
||||||
|
cap.from_mesh(liquid.data)
|
||||||
|
outer = [vertex for vertex in cap.verts if abs(vertex.co.z - LIQUID_TOP) < 0.0000001]
|
||||||
|
bmesh.ops.triangle_fill(cap, edges=[edge for edge in cap.edges if all(vertex in outer for vertex in edge.verts)], use_beauty=True)
|
||||||
|
bmesh.ops.recalc_face_normals(cap, faces=list(cap.faces))
|
||||||
|
cap.to_mesh(liquid.data)
|
||||||
|
cap.free()
|
||||||
|
liquid.data.update()
|
||||||
|
apply_planar_uv(liquid, LIQUID_UV_RADIUS)
|
||||||
|
liquid['top_uv_faces'] = len(liquid.data.polygons) - liquid_top_start
|
||||||
|
liquid['fill_height_mm'] = (LIQUID_TOP - LIQUID_BOTTOM) * 1000.0
|
||||||
|
liquid['top_clearance_to_rim_mm'] = (CUP_HEIGHT - LIQUID_TOP) * 1000.0
|
||||||
|
|
||||||
|
foam_rings = [
|
||||||
|
(fitted_radius(FOAM_BOTTOM) - 0.00008, FOAM_BOTTOM),
|
||||||
|
(fitted_radius(FOAM_BOTTOM), FOAM_BOTTOM + 0.00012),
|
||||||
|
(fitted_radius(FOAM_EDGE_TOP) - 0.00008, FOAM_EDGE_TOP - 0.00012),
|
||||||
|
]
|
||||||
|
for fraction in (1.0, 0.975, 0.92, 0.78, 0.55, 0.30, 0.12):
|
||||||
|
z = FOAM_EDGE_TOP + FOAM_DOME * (1.0 - fraction * fraction)
|
||||||
|
foam_rings.append((fitted_radius(FOAM_EDGE_TOP) * fraction, z))
|
||||||
|
vertices = []
|
||||||
|
for ring_radius, z in foam_rings:
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
angle = math.tau * index / SEGMENTS
|
||||||
|
vertices.append((ring_radius * math.cos(angle), ring_radius * math.sin(angle), z))
|
||||||
|
faces = [tuple(reversed(range(SEGMENTS)))]
|
||||||
|
for ring_index in range(len(foam_rings) - 1):
|
||||||
|
first = ring_index * SEGMENTS
|
||||||
|
second = first + SEGMENTS
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
following = (index + 1) % SEGMENTS
|
||||||
|
faces.append((first + index, first + following, second + following, second + index))
|
||||||
|
foam_top_start = len(faces) - 7 * SEGMENTS
|
||||||
|
center_index = len(vertices)
|
||||||
|
vertices.append((0.0, 0.0, FOAM_EDGE_TOP + FOAM_DOME))
|
||||||
|
last = (len(foam_rings) - 1) * SEGMENTS
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
following = (index + 1) % SEGMENTS
|
||||||
|
faces.append((last + index, last + following, center_index))
|
||||||
|
foam = make_object('CC_Milk_Foam', vertices, faces, foam_top_start, foam_mat, FOAM_UV_RADIUS)
|
||||||
|
foam['thickness_at_edge_mm'] = (FOAM_EDGE_TOP - FOAM_BOTTOM) * 1000.0
|
||||||
|
foam['dome_rise_mm'] = FOAM_DOME * 1000.0
|
||||||
|
foam['surface_texture'] = 'CC_Latte_Surface.png'
|
||||||
|
foam['surface_texture_uv'] = 'LiquidSurfaceUV; replace this image for other latte art'
|
||||||
|
|
||||||
|
|
||||||
|
def point_at(obj, target):
|
||||||
|
obj.rotation_euler = (Vector(target) - obj.location).to_track_quat('-Z', 'Y').to_euler()
|
||||||
|
|
||||||
|
|
||||||
|
def camera(name, location, target, ortho_scale):
|
||||||
|
data = bpy.data.cameras.new(name)
|
||||||
|
data.type = 'ORTHO'
|
||||||
|
data.ortho_scale = ortho_scale
|
||||||
|
data.clip_start = 0.001
|
||||||
|
data.clip_end = 100.0
|
||||||
|
obj = bpy.data.objects.new(name, data)
|
||||||
|
studio.objects.link(obj)
|
||||||
|
obj.location = location
|
||||||
|
point_at(obj, target)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def area_light(name, location, energy, size, color, target):
|
||||||
|
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.objects.link(obj)
|
||||||
|
obj.location = location
|
||||||
|
point_at(obj, target)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
ground_mat, ground_bsdf = new_material('Studio_Warm_Stone', '#A89D8D', 0.78)
|
||||||
|
bpy.ops.mesh.primitive_plane_add(size=2.0, location=(0.0, 0.0, -0.00008))
|
||||||
|
ground = bpy.context.object
|
||||||
|
ground.name = 'Studio_Ground'
|
||||||
|
for collection in list(ground.users_collection):
|
||||||
|
collection.objects.unlink(ground)
|
||||||
|
studio.objects.link(ground)
|
||||||
|
ground.data.materials.append(ground_mat)
|
||||||
|
|
||||||
|
world = bpy.data.worlds.new('CupContents_Studio_World')
|
||||||
|
world.use_nodes = True
|
||||||
|
world.node_tree.nodes['Background'].inputs['Color'].default_value = (0.32, 0.36, 0.42, 1.0)
|
||||||
|
world.node_tree.nodes['Background'].inputs['Strength'].default_value = 0.20
|
||||||
|
scene.world = world
|
||||||
|
area_light('Studio_Key', (0.10, 0.08, 0.25), 0.75, 0.17, (1.0, 0.89, 0.75), (0.0, 0.0, 0.07))
|
||||||
|
area_light('Studio_Fill', (-0.16, 0.04, 0.16), 0.30, 0.14, (0.80, 0.89, 1.0), (0.0, 0.0, 0.065))
|
||||||
|
area_light('Studio_Rim', (0.02, -0.15, 0.23), 0.90, 0.13, (1.0, 0.96, 0.87), (0.0, 0.0, 0.08))
|
||||||
|
hero_camera = camera('Acceptance_Latte_Cycles', (0.145, 0.205, 0.285), (0.0, 0.0, 0.061), 0.165)
|
||||||
|
top_camera = camera('Acceptance_Latte_Top_UV', (0.0, 0.0, 0.31), (0.0, 0.0, 0.0), 0.103)
|
||||||
|
detail_camera = camera('Acceptance_Foam_Detail', (0.095, 0.135, 0.255), (0.0, 0.0, 0.098), 0.107)
|
||||||
|
|
||||||
|
scene.render.engine = 'CYCLES'
|
||||||
|
scene.cycles.samples = 96
|
||||||
|
scene.cycles.use_denoising = True
|
||||||
|
scene.cycles.max_bounces = 8
|
||||||
|
scene.render.resolution_x = 1400
|
||||||
|
scene.render.resolution_y = 1400
|
||||||
|
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.5
|
||||||
|
|
||||||
|
|
||||||
|
def non_manifold_count(obj):
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(obj.data)
|
||||||
|
result = sum(1 for edge in bm.edges if not edge.is_manifold)
|
||||||
|
bm.free()
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def uv_report(obj, top_z):
|
||||||
|
uv = obj.data.uv_layers['LiquidSurfaceUV']
|
||||||
|
top_loops = [loop_index for polygon in obj.data.polygons if abs(polygon.normal.z) > 0.5 for loop_index in polygon.loop_indices if obj.data.vertices[obj.data.loops[loop_index].vertex_index].co.z >= top_z - 0.000001]
|
||||||
|
center_uv = None
|
||||||
|
if obj == foam:
|
||||||
|
center = obj.data.vertices[center_index]
|
||||||
|
for loop in obj.data.loops:
|
||||||
|
if loop.vertex_index == center_index:
|
||||||
|
center_uv = list(uv.data[loop.index].uv)
|
||||||
|
break
|
||||||
|
return {
|
||||||
|
'uv_map': uv.name,
|
||||||
|
'uv_bounds': [min(uv.data[index].uv[axis] for axis in (0, 1) for index in top_loops), max(uv.data[index].uv[axis] for axis in (0, 1) for index in top_loops)],
|
||||||
|
'center_uv': center_uv,
|
||||||
|
'top_faces': obj['top_uv_faces'],
|
||||||
|
'material_slots': [slot.material.name for slot in obj.material_slots],
|
||||||
|
'non_manifold_edges': non_manifold_count(obj),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
cup_bvh = BVHTree.FromObject(cup, bpy.context.evaluated_depsgraph_get())
|
||||||
|
liquid_bvh = BVHTree.FromObject(liquid, bpy.context.evaluated_depsgraph_get())
|
||||||
|
foam_bvh = BVHTree.FromObject(foam, bpy.context.evaluated_depsgraph_get())
|
||||||
|
liquid_cup_intersections = len(cup_bvh.overlap(liquid_bvh))
|
||||||
|
foam_cup_intersections = len(cup_bvh.overlap(foam_bvh))
|
||||||
|
foam_liquid_intersections = len(liquid_bvh.overlap(foam_bvh))
|
||||||
|
liquid_uv = uv_report(liquid, LIQUID_TOP)
|
||||||
|
foam_uv = uv_report(foam, FOAM_EDGE_TOP)
|
||||||
|
report = {
|
||||||
|
'source_cup': SOURCE.name,
|
||||||
|
'source_cup_sha256_before_build': SOURCE_SHA256,
|
||||||
|
'source_cup_sha256_after_build': hashlib.sha256(SOURCE.read_bytes()).hexdigest(),
|
||||||
|
'lid_included': False,
|
||||||
|
'liquid_top_mm': LIQUID_TOP * 1000.0,
|
||||||
|
'foam_edge_thickness_mm': (FOAM_EDGE_TOP - FOAM_BOTTOM) * 1000.0,
|
||||||
|
'foam_center_rise_mm': FOAM_DOME * 1000.0,
|
||||||
|
'rim_clearance_mm': (CUP_HEIGHT - FOAM_EDGE_TOP - FOAM_DOME) * 1000.0,
|
||||||
|
'radial_fit_clearance_min_mm': FIT_CLEARANCE * 1000.0,
|
||||||
|
'liquid_cup_triangle_intersections': liquid_cup_intersections,
|
||||||
|
'foam_cup_triangle_intersections': foam_cup_intersections,
|
||||||
|
'foam_liquid_triangle_intersections': foam_liquid_intersections,
|
||||||
|
'coffee': liquid_uv,
|
||||||
|
'foam': foam_uv,
|
||||||
|
'textures_packed': {image.name: bool(image.packed_file) for image in (coffee_image, latte_image)},
|
||||||
|
'render_engine': scene.render.engine,
|
||||||
|
}
|
||||||
|
report['passed'] = (
|
||||||
|
report['source_cup_sha256_before_build'] == report['source_cup_sha256_after_build']
|
||||||
|
and liquid_cup_intersections == 0
|
||||||
|
and foam_cup_intersections == 0
|
||||||
|
and foam_liquid_intersections == 0
|
||||||
|
and liquid.data.uv_layers.active.name == 'LiquidSurfaceUV'
|
||||||
|
and foam.data.uv_layers.active.name == 'LiquidSurfaceUV'
|
||||||
|
and liquid_uv['non_manifold_edges'] == 0
|
||||||
|
and foam_uv['non_manifold_edges'] == 0
|
||||||
|
and len(liquid.material_slots) == 1
|
||||||
|
and len(foam.material_slots) == 1
|
||||||
|
and liquid.material_slots[0].material != foam.material_slots[0].material
|
||||||
|
and all(0.0 <= value <= 1.0 for value in liquid_uv['uv_bounds'] + foam_uv['uv_bounds'])
|
||||||
|
and all(abs(value - 0.5) < 0.000001 for value in foam_uv['center_uv'])
|
||||||
|
and all(report['textures_packed'].values())
|
||||||
|
)
|
||||||
|
(OUT / 'validation_contents.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||||
|
print('CUP_CONTENTS_VALIDATION=' + json.dumps(report, ensure_ascii=False), flush=True)
|
||||||
|
assert report['passed'], 'Cup contents validation failed; inspect validation_contents.json'
|
||||||
|
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
root.select_set(True)
|
||||||
|
liquid.select_set(True)
|
||||||
|
foam.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = root
|
||||||
|
bpy.ops.export_scene.gltf(
|
||||||
|
filepath=str(OUT / 'PerfectCoffee_CupContents.glb'),
|
||||||
|
export_format='GLB',
|
||||||
|
use_selection=True,
|
||||||
|
export_apply=True,
|
||||||
|
export_animations=False,
|
||||||
|
export_extras=True,
|
||||||
|
export_cameras=False,
|
||||||
|
export_lights=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
scene.camera = hero_camera
|
||||||
|
scene.render.filepath = str(OUT / 'preview_contents_latte.png')
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
|
||||||
|
scene.camera = top_camera
|
||||||
|
scene.render.filepath = str(OUT / 'preview_contents_latte_top.png')
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
|
||||||
|
foam.hide_render = True
|
||||||
|
scene.camera = detail_camera
|
||||||
|
scene.render.filepath = str(OUT / 'preview_contents_americano.png')
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
foam.hide_render = False
|
||||||
|
scene.camera = hero_camera
|
||||||
|
scene.render.filepath = str(OUT / 'preview_contents_latte.png')
|
||||||
|
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
root.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = root
|
||||||
|
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 / 'PerfectCoffee_CupContents.blend'))
|
||||||
|
print('CUP_CONTENTS_BUILD_COMPLETE', flush=True)
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
{
|
||||||
|
"baseline_blend": "PerfectCoffee_CupContents.blend",
|
||||||
|
"baseline_sha256_before_optimization": "62ce59ff695fcfe3d19129fc8735b3a969ab25607b6c9d1ff1b4694b6b725330",
|
||||||
|
"baseline_sha256_after_optimization": "62ce59ff695fcfe3d19129fc8735b3a969ab25607b6c9d1ff1b4694b6b725330",
|
||||||
|
"mobile_blend": "PerfectCoffee_CupContents_Mobile.blend",
|
||||||
|
"mobile_glb": "PerfectCoffee_CupContents_Mobile.glb",
|
||||||
|
"texture": {
|
||||||
|
"before": {
|
||||||
|
"count": 2,
|
||||||
|
"dimensions_each": [
|
||||||
|
1024,
|
||||||
|
1024
|
||||||
|
],
|
||||||
|
"png_bytes_total": 1262110,
|
||||||
|
"rgba8_with_mipmaps_mib": 10.6666666667
|
||||||
|
},
|
||||||
|
"after": {
|
||||||
|
"count": 1,
|
||||||
|
"dimensions": [
|
||||||
|
1024,
|
||||||
|
512
|
||||||
|
],
|
||||||
|
"tile_dimensions_each": [
|
||||||
|
512,
|
||||||
|
512
|
||||||
|
],
|
||||||
|
"format": "RGB PNG, lossless",
|
||||||
|
"png_bytes": 181671,
|
||||||
|
"rgba8_with_mipmaps_mib": 2.6666666667
|
||||||
|
},
|
||||||
|
"file_size_reduction_percent": 85.60577128776414,
|
||||||
|
"gpu_memory_reduction_percent": 75.0
|
||||||
|
},
|
||||||
|
"foam": {
|
||||||
|
"vertices_before": 961,
|
||||||
|
"vertices_after": 145,
|
||||||
|
"triangles_before": 1918,
|
||||||
|
"triangles_after": 286,
|
||||||
|
"triangle_reduction_percent": 85.08863399374349,
|
||||||
|
"segments_before": 96,
|
||||||
|
"segments_after": 48,
|
||||||
|
"thickness_edge_mm": 1.8800000000000066,
|
||||||
|
"dome_rise_mm": 0.35,
|
||||||
|
"outer_envelope_preserved": true,
|
||||||
|
"non_manifold_edges": 0
|
||||||
|
},
|
||||||
|
"complete_contents_triangles_before": 2298,
|
||||||
|
"complete_contents_triangles_after": 666,
|
||||||
|
"intersections": {
|
||||||
|
"liquid_cup": 0,
|
||||||
|
"foam_cup": 0,
|
||||||
|
"foam_liquid": 0
|
||||||
|
},
|
||||||
|
"atlas_uv": {
|
||||||
|
"coffee": {
|
||||||
|
"u": [
|
||||||
|
8.773192838873456e-09,
|
||||||
|
0.5
|
||||||
|
],
|
||||||
|
"v": [
|
||||||
|
1.7546385677746912e-08,
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"foam": {
|
||||||
|
"u": [
|
||||||
|
0.5,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"v": [
|
||||||
|
8.95026985858749e-09,
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"foam_center": [
|
||||||
|
0.75,
|
||||||
|
0.5
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"glb": {
|
||||||
|
"bytes": 218520,
|
||||||
|
"meshes": 2,
|
||||||
|
"vertices_after_export_split": 874,
|
||||||
|
"triangles": 666,
|
||||||
|
"images": 1,
|
||||||
|
"materials": 2,
|
||||||
|
"cameras": 0
|
||||||
|
},
|
||||||
|
"image_metrics_before_vs_after": {
|
||||||
|
"latte": {
|
||||||
|
"ssim_all": 0.999625,
|
||||||
|
"psnr_db": "52.745750"
|
||||||
|
},
|
||||||
|
"latte_top": {
|
||||||
|
"ssim_all": 0.996863,
|
||||||
|
"psnr_db": "40.374979"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"comparison_convention": "Left=original, right=Mobile; identical camera, lighting, Cycles samples, resolution and color management",
|
||||||
|
"geometry_and_export_passed": true,
|
||||||
|
"visual_review": "passed",
|
||||||
|
"visual_review_notes": "同一 Cycles 机位对比已人工查看;拉花轮廓、奶泡颜色与杯口边缘保持一致,无明显异常暗环、贴图偏移或显著锯齿。",
|
||||||
|
"glb_reimport_validation": {
|
||||||
|
"passed": true,
|
||||||
|
"meshes": 2,
|
||||||
|
"triangles": 666,
|
||||||
|
"embedded_images": 1,
|
||||||
|
"cycles_render_review": "passed"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,340 @@
|
|||||||
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import struct
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
|
||||||
|
OUT = Path('/Users/yanchenyu/Documents/WebApps/PerfetCoffee/model_assets/coffee_cup')
|
||||||
|
BASE = OUT / 'PerfectCoffee_CupContents.blend'
|
||||||
|
MOBILE_BLEND = OUT / 'PerfectCoffee_CupContents_Mobile.blend'
|
||||||
|
MOBILE_GLB = OUT / 'PerfectCoffee_CupContents_Mobile.glb'
|
||||||
|
ATLAS = OUT / 'textures' / 'CC_CupContents_Atlas.png'
|
||||||
|
COMPARISONS = OUT / 'optimization'
|
||||||
|
COMPARISONS.mkdir(exist_ok=True)
|
||||||
|
FFMPEG = shutil.which('ffmpeg')
|
||||||
|
assert FFMPEG, 'ffmpeg is required for the existing lossless texture and comparison pipeline'
|
||||||
|
|
||||||
|
BASE_SHA256 = hashlib.sha256(BASE.read_bytes()).hexdigest()
|
||||||
|
ORIGINAL_TEXTURE_BYTES = sum((OUT / 'textures' / name).stat().st_size for name in ('CC_Coffee_Surface.png', 'CC_Latte_Surface.png'))
|
||||||
|
SEGMENTS = 48
|
||||||
|
CUP_SEGMENTS = 24
|
||||||
|
FOAM_BOTTOM = 0.10382
|
||||||
|
FOAM_EDGE_TOP = 0.10570
|
||||||
|
FOAM_DOME = 0.00035
|
||||||
|
FIT_CLEARANCE = 0.00012
|
||||||
|
|
||||||
|
|
||||||
|
def run(command):
|
||||||
|
result = subprocess.run(command, check=True, text=True, capture_output=True)
|
||||||
|
return result.stdout + result.stderr
|
||||||
|
|
||||||
|
|
||||||
|
run([
|
||||||
|
FFMPEG, '-y', '-hide_banner', '-loglevel', 'warning',
|
||||||
|
'-i', str(OUT / 'textures' / 'CC_Coffee_Surface.png'),
|
||||||
|
'-i', str(OUT / 'textures' / 'CC_Latte_Surface.png'),
|
||||||
|
'-filter_complex',
|
||||||
|
'[0:v]scale=512:512:flags=lanczos[a];[1:v]scale=512:512:flags=lanczos[b];[a][b]hstack=inputs=2,format=rgb24[out]',
|
||||||
|
'-map', '[out]', '-frames:v', '1', '-pred', 'mixed', '-compression_level', '9', '-update', '1', str(ATLAS),
|
||||||
|
])
|
||||||
|
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(BASE))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
scene = bpy.context.scene
|
||||||
|
root = bpy.data.objects['CC_CupContents_Assembly']
|
||||||
|
cup = bpy.data.objects['CC_Cup_Body']
|
||||||
|
liquid = bpy.data.objects['CC_Coffee_Liquid']
|
||||||
|
foam = bpy.data.objects['CC_Milk_Foam']
|
||||||
|
coffee_mat = bpy.data.materials['CC_Coffee_Liquid']
|
||||||
|
foam_mat = bpy.data.materials['CC_Milk_Foam']
|
||||||
|
|
||||||
|
original_foam_vertices = len(foam.data.vertices)
|
||||||
|
foam.data.calc_loop_triangles()
|
||||||
|
original_foam_triangles = len(foam.data.loop_triangles)
|
||||||
|
liquid.data.calc_loop_triangles()
|
||||||
|
liquid_triangles = len(liquid.data.loop_triangles)
|
||||||
|
original_foam_bounds = {
|
||||||
|
'min_z': min(vertex.co.z for vertex in foam.data.vertices),
|
||||||
|
'max_z': max(vertex.co.z for vertex in foam.data.vertices),
|
||||||
|
'max_radius': max(math.hypot(vertex.co.x, vertex.co.y) for vertex in foam.data.vertices),
|
||||||
|
}
|
||||||
|
|
||||||
|
scene.cycles.samples = 96
|
||||||
|
scene.cycles.use_denoising = True
|
||||||
|
scene.render.resolution_x = 1400
|
||||||
|
scene.render.resolution_y = 1400
|
||||||
|
scene.render.resolution_percentage = 100
|
||||||
|
for camera_name, filename in [
|
||||||
|
('Acceptance_Latte_Cycles', 'before_latte.png'),
|
||||||
|
('Acceptance_Latte_Top_UV', 'before_latte_top.png'),
|
||||||
|
]:
|
||||||
|
scene.camera = bpy.data.objects[camera_name]
|
||||||
|
scene.render.filepath = str(COMPARISONS / filename)
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
|
||||||
|
atlas_image = bpy.data.images.load(str(ATLAS), check_existing=False)
|
||||||
|
atlas_image.name = 'CC_CupContents_Atlas'
|
||||||
|
atlas_image.colorspace_settings.name = 'sRGB'
|
||||||
|
atlas_image.pack()
|
||||||
|
for material in (coffee_mat, foam_mat):
|
||||||
|
for node in material.node_tree.nodes:
|
||||||
|
if node.type == 'TEX_IMAGE':
|
||||||
|
node.image = atlas_image
|
||||||
|
for image_name in ('CC_Coffee_Surface', 'CC_Latte_Surface'):
|
||||||
|
image = bpy.data.images.get(image_name)
|
||||||
|
if image is not None and image.users == 0:
|
||||||
|
bpy.data.images.remove(image)
|
||||||
|
|
||||||
|
for obj, offset in ((liquid, 0.0), (foam, 0.5)):
|
||||||
|
uv = obj.data.uv_layers['LiquidSurfaceUV']
|
||||||
|
for loop_uv in uv.data:
|
||||||
|
loop_uv.uv.x = offset + loop_uv.uv.x * 0.5
|
||||||
|
obj['uv_map'] = 'LiquidSurfaceUV'
|
||||||
|
obj['atlas_rect'] = [offset, 0.0, 0.5, 1.0]
|
||||||
|
|
||||||
|
|
||||||
|
def fitted_radius(z):
|
||||||
|
if z <= 0.022:
|
||||||
|
radius = 0.028 + (z - 0.002) * (0.0305 - 0.028) / 0.020
|
||||||
|
else:
|
||||||
|
radius = 0.0305 + (z - 0.022) * (0.038 - 0.0305) / 0.066
|
||||||
|
return radius * math.cos(math.pi / CUP_SEGMENTS) - FIT_CLEARANCE
|
||||||
|
|
||||||
|
|
||||||
|
outer_radius = fitted_radius(FOAM_EDGE_TOP)
|
||||||
|
rings = [
|
||||||
|
(fitted_radius(FOAM_BOTTOM), FOAM_BOTTOM),
|
||||||
|
(outer_radius, FOAM_EDGE_TOP),
|
||||||
|
(outer_radius * 0.55, FOAM_EDGE_TOP + FOAM_DOME * (1.0 - 0.55 * 0.55)),
|
||||||
|
]
|
||||||
|
vertices = []
|
||||||
|
for radius, z in rings:
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
angle = math.tau * index / SEGMENTS
|
||||||
|
vertices.append((radius * math.cos(angle), radius * math.sin(angle), z))
|
||||||
|
faces = [tuple(reversed(range(SEGMENTS)))]
|
||||||
|
for ring_index in range(len(rings) - 1):
|
||||||
|
first = ring_index * SEGMENTS
|
||||||
|
second = first + SEGMENTS
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
following = (index + 1) % SEGMENTS
|
||||||
|
faces.append((first + index, first + following, second + following, second + index))
|
||||||
|
center_index = len(vertices)
|
||||||
|
vertices.append((0.0, 0.0, FOAM_EDGE_TOP + FOAM_DOME))
|
||||||
|
last = (len(rings) - 1) * SEGMENTS
|
||||||
|
for index in range(SEGMENTS):
|
||||||
|
following = (index + 1) % SEGMENTS
|
||||||
|
faces.append((last + index, last + following, center_index))
|
||||||
|
|
||||||
|
mesh = bpy.data.meshes.new('CC_Milk_Foam_Mobile_Mesh')
|
||||||
|
mesh.from_pydata(vertices, [], faces)
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(mesh)
|
||||||
|
bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))
|
||||||
|
bm.to_mesh(mesh)
|
||||||
|
bm.free()
|
||||||
|
mesh.update()
|
||||||
|
mesh.materials.append(foam_mat)
|
||||||
|
uv = mesh.uv_layers.new(name='LiquidSurfaceUV')
|
||||||
|
for polygon in mesh.polygons:
|
||||||
|
polygon.use_smooth = abs(polygon.normal.z) < 0.995
|
||||||
|
for loop_index in polygon.loop_indices:
|
||||||
|
vertex = mesh.vertices[mesh.loops[loop_index].vertex_index].co
|
||||||
|
u = 0.5 + vertex.x / (2.0 * outer_radius)
|
||||||
|
v = 0.5 + vertex.y / (2.0 * outer_radius)
|
||||||
|
uv.data[loop_index].uv = (0.5 + u * 0.5, v)
|
||||||
|
mesh.uv_layers.active = uv
|
||||||
|
old_mesh = foam.data
|
||||||
|
foam.data = mesh
|
||||||
|
if old_mesh.users == 0:
|
||||||
|
bpy.data.meshes.remove(old_mesh)
|
||||||
|
foam['radial_segments'] = SEGMENTS
|
||||||
|
foam['radial_surface_rings'] = 2
|
||||||
|
foam['top_uv_faces'] = SEGMENTS * 2
|
||||||
|
foam['atlas_rect'] = [0.5, 0.0, 0.5, 1.0]
|
||||||
|
foam['surface_texture'] = ATLAS.name
|
||||||
|
foam['surface_texture_uv'] = 'LiquidSurfaceUV; right half of atlas; original 0-1 liquid UV is remapped to U=0.5-1.0'
|
||||||
|
foam['optimization'] = '96 to 48 segments; seven concentric surface rings to one intermediate ring; thickness and dome preserved'
|
||||||
|
liquid['surface_texture'] = ATLAS.name
|
||||||
|
liquid['surface_texture_uv'] = 'LiquidSurfaceUV; left half of atlas; original 0-1 liquid UV is remapped to U=0-0.5'
|
||||||
|
root['uv_usage'] = 'LiquidSurfaceUV atlas: coffee U=0-0.5; foam U=0.5-1; shared V=0-1; each tile center U=0.25 or 0.75, V=0.5'
|
||||||
|
root['texture_atlas'] = 'CC_CupContents_Atlas.png; left coffee 512x512, right latte 512x512; RGB PNG lossless'
|
||||||
|
root['mobile_baseline_blend'] = BASE.name
|
||||||
|
root['mobile_baseline_sha256'] = BASE_SHA256
|
||||||
|
root['foam_original_segments'] = 96
|
||||||
|
root['foam_mobile_segments'] = SEGMENTS
|
||||||
|
|
||||||
|
|
||||||
|
def non_manifold_count(obj):
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(obj.data)
|
||||||
|
count = sum(1 for edge in bm.edges if not edge.is_manifold)
|
||||||
|
bm.free()
|
||||||
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
def uv_bounds(obj):
|
||||||
|
uv = obj.data.uv_layers.active
|
||||||
|
return {
|
||||||
|
'u': [min(loop_uv.uv.x for loop_uv in uv.data), max(loop_uv.uv.x for loop_uv in uv.data)],
|
||||||
|
'v': [min(loop_uv.uv.y for loop_uv in uv.data), max(loop_uv.uv.y for loop_uv in uv.data)],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def glb_statistics(path):
|
||||||
|
raw = path.read_bytes()
|
||||||
|
json_length, chunk_type = struct.unpack_from('<II', raw, 12)
|
||||||
|
assert chunk_type == 0x4E4F534A
|
||||||
|
asset = json.loads(raw[20:20 + json_length])
|
||||||
|
vertices = 0
|
||||||
|
triangles = 0
|
||||||
|
for mesh in asset['meshes']:
|
||||||
|
for primitive in mesh['primitives']:
|
||||||
|
vertices += asset['accessors'][primitive['attributes']['POSITION']]['count']
|
||||||
|
triangles += asset['accessors'][primitive['indices']]['count'] // 3
|
||||||
|
return {
|
||||||
|
'bytes': len(raw),
|
||||||
|
'meshes': len(asset['meshes']),
|
||||||
|
'vertices_after_export_split': vertices,
|
||||||
|
'triangles': triangles,
|
||||||
|
'images': len(asset.get('images', [])),
|
||||||
|
'materials': len(asset.get('materials', [])),
|
||||||
|
'cameras': len(asset.get('cameras', [])),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
foam.data.calc_loop_triangles()
|
||||||
|
mobile_foam_triangles = len(foam.data.loop_triangles)
|
||||||
|
cup_bvh = BVHTree.FromObject(cup, bpy.context.evaluated_depsgraph_get())
|
||||||
|
liquid_bvh = BVHTree.FromObject(liquid, bpy.context.evaluated_depsgraph_get())
|
||||||
|
foam_bvh = BVHTree.FromObject(foam, bpy.context.evaluated_depsgraph_get())
|
||||||
|
liquid_uv = uv_bounds(liquid)
|
||||||
|
foam_uv = uv_bounds(foam)
|
||||||
|
center_uv = next(uv.data[loop.index].uv[:] for loop in foam.data.loops if loop.vertex_index == center_index)
|
||||||
|
mobile_foam_bounds = {
|
||||||
|
'min_z': min(vertex.co.z for vertex in foam.data.vertices),
|
||||||
|
'max_z': max(vertex.co.z for vertex in foam.data.vertices),
|
||||||
|
'max_radius': max(math.hypot(vertex.co.x, vertex.co.y) for vertex in foam.data.vertices),
|
||||||
|
}
|
||||||
|
outer_envelope_preserved = all(
|
||||||
|
math.isclose(original_foam_bounds[key], mobile_foam_bounds[key], rel_tol=0.0, abs_tol=0.000000001)
|
||||||
|
for key in original_foam_bounds
|
||||||
|
)
|
||||||
|
geometry_and_export_passed = (
|
||||||
|
non_manifold_count(foam) == 0
|
||||||
|
and len(cup_bvh.overlap(liquid_bvh)) == 0
|
||||||
|
and len(cup_bvh.overlap(foam_bvh)) == 0
|
||||||
|
and len(liquid_bvh.overlap(foam_bvh)) == 0
|
||||||
|
and mobile_foam_triangles == 286
|
||||||
|
and len(foam.data.vertices) == 145
|
||||||
|
and outer_envelope_preserved
|
||||||
|
and abs(liquid_uv['u'][0]) < 0.000001
|
||||||
|
and abs(liquid_uv['u'][1] - 0.5) < 0.000001
|
||||||
|
and abs(foam_uv['u'][0] - 0.5) < 0.000001
|
||||||
|
and abs(foam_uv['u'][1] - 1.0) < 0.000001
|
||||||
|
and all(abs(value - 0.5) < 0.000001 for value in center_uv[1:])
|
||||||
|
and abs(center_uv[0] - 0.75) < 0.000001
|
||||||
|
and atlas_image.packed_file is not None
|
||||||
|
and hashlib.sha256(BASE.read_bytes()).hexdigest() == BASE_SHA256
|
||||||
|
)
|
||||||
|
assert geometry_and_export_passed, 'Mobile geometry, atlas UV or source preservation validation failed'
|
||||||
|
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
root.select_set(True)
|
||||||
|
liquid.select_set(True)
|
||||||
|
foam.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = root
|
||||||
|
bpy.ops.export_scene.gltf(
|
||||||
|
filepath=str(MOBILE_GLB),
|
||||||
|
export_format='GLB',
|
||||||
|
use_selection=True,
|
||||||
|
export_apply=True,
|
||||||
|
export_animations=False,
|
||||||
|
export_extras=True,
|
||||||
|
export_cameras=False,
|
||||||
|
export_lights=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
for camera_name, filename in [
|
||||||
|
('Acceptance_Latte_Cycles', 'after_latte.png'),
|
||||||
|
('Acceptance_Latte_Top_UV', 'after_latte_top.png'),
|
||||||
|
]:
|
||||||
|
scene.camera = bpy.data.objects[camera_name]
|
||||||
|
scene.render.filepath = str(COMPARISONS / filename)
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
|
||||||
|
metrics = {}
|
||||||
|
for view in ('latte', 'latte_top'):
|
||||||
|
before = COMPARISONS / f'before_{view}.png'
|
||||||
|
after = COMPARISONS / f'after_{view}.png'
|
||||||
|
ssim_log = run([FFMPEG, '-hide_banner', '-nostats', '-i', str(before), '-i', str(after), '-filter_complex', '[0:v][1:v]ssim', '-f', 'null', '-'])
|
||||||
|
psnr_log = run([FFMPEG, '-hide_banner', '-nostats', '-i', str(before), '-i', str(after), '-filter_complex', '[0:v][1:v]psnr', '-f', 'null', '-'])
|
||||||
|
ssim_match = re.search(r'All:([0-9.]+)', ssim_log)
|
||||||
|
psnr_match = re.search(r'average:([0-9.]+|inf)', psnr_log)
|
||||||
|
assert ssim_match and psnr_match, f'Unable to read image metrics for {view}'
|
||||||
|
metrics[view] = {'ssim_all': float(ssim_match.group(1)), 'psnr_db': psnr_match.group(1)}
|
||||||
|
run([
|
||||||
|
FFMPEG, '-y', '-hide_banner', '-loglevel', 'warning', '-i', str(before), '-i', str(after),
|
||||||
|
'-filter_complex',
|
||||||
|
'[0:v]scale=900:900:flags=lanczos[a];[1:v]scale=900:900:flags=lanczos[b];[a]pad=912:900:0:0:color=0x202124[ap];[ap][b]hstack=inputs=2[out]',
|
||||||
|
'-map', '[out]', '-frames:v', '1', '-pred', 'mixed', '-compression_level', '9', '-update', '1',
|
||||||
|
str(COMPARISONS / f'compare_{view}.png'),
|
||||||
|
])
|
||||||
|
|
||||||
|
report = {
|
||||||
|
'baseline_blend': BASE.name,
|
||||||
|
'baseline_sha256_before_optimization': BASE_SHA256,
|
||||||
|
'baseline_sha256_after_optimization': hashlib.sha256(BASE.read_bytes()).hexdigest(),
|
||||||
|
'mobile_blend': MOBILE_BLEND.name,
|
||||||
|
'mobile_glb': MOBILE_GLB.name,
|
||||||
|
'texture': {
|
||||||
|
'before': {'count': 2, 'dimensions_each': [1024, 1024], 'png_bytes_total': ORIGINAL_TEXTURE_BYTES, 'rgba8_with_mipmaps_mib': 10.6666666667},
|
||||||
|
'after': {'count': 1, 'dimensions': [1024, 512], 'tile_dimensions_each': [512, 512], 'format': 'RGB PNG, lossless', 'png_bytes': ATLAS.stat().st_size, 'rgba8_with_mipmaps_mib': 2.6666666667},
|
||||||
|
'file_size_reduction_percent': (1.0 - ATLAS.stat().st_size / ORIGINAL_TEXTURE_BYTES) * 100.0,
|
||||||
|
'gpu_memory_reduction_percent': 75.0,
|
||||||
|
},
|
||||||
|
'foam': {
|
||||||
|
'vertices_before': original_foam_vertices,
|
||||||
|
'vertices_after': len(foam.data.vertices),
|
||||||
|
'triangles_before': original_foam_triangles,
|
||||||
|
'triangles_after': mobile_foam_triangles,
|
||||||
|
'triangle_reduction_percent': (1.0 - mobile_foam_triangles / original_foam_triangles) * 100.0,
|
||||||
|
'segments_before': 96,
|
||||||
|
'segments_after': SEGMENTS,
|
||||||
|
'thickness_edge_mm': (FOAM_EDGE_TOP - FOAM_BOTTOM) * 1000.0,
|
||||||
|
'dome_rise_mm': FOAM_DOME * 1000.0,
|
||||||
|
'outer_envelope_preserved': outer_envelope_preserved,
|
||||||
|
'non_manifold_edges': non_manifold_count(foam),
|
||||||
|
},
|
||||||
|
'complete_contents_triangles_before': liquid_triangles + original_foam_triangles,
|
||||||
|
'complete_contents_triangles_after': liquid_triangles + mobile_foam_triangles,
|
||||||
|
'intersections': {
|
||||||
|
'liquid_cup': len(cup_bvh.overlap(liquid_bvh)),
|
||||||
|
'foam_cup': len(cup_bvh.overlap(foam_bvh)),
|
||||||
|
'foam_liquid': len(liquid_bvh.overlap(foam_bvh)),
|
||||||
|
},
|
||||||
|
'atlas_uv': {'coffee': liquid_uv, 'foam': foam_uv, 'foam_center': list(center_uv)},
|
||||||
|
'glb': glb_statistics(MOBILE_GLB),
|
||||||
|
'image_metrics_before_vs_after': metrics,
|
||||||
|
'comparison_convention': 'Left=original, right=Mobile; identical camera, lighting, Cycles samples, resolution and color management',
|
||||||
|
'geometry_and_export_passed': geometry_and_export_passed,
|
||||||
|
'visual_review': 'pending_manual_comparison',
|
||||||
|
}
|
||||||
|
(COMPARISONS / 'validation_mobile.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||||
|
|
||||||
|
scene.camera = bpy.data.objects['Acceptance_Latte_Cycles']
|
||||||
|
scene.render.filepath = str(COMPARISONS / 'after_latte.png')
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
root.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = root
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(MOBILE_BLEND))
|
||||||
|
print('MOBILE_OPTIMIZATION_VALIDATION=' + json.dumps(report, ensure_ascii=False), flush=True)
|
||||||
|
print('MOBILE_OPTIMIZATION_BUILD_COMPLETE', flush=True)
|
||||||
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,49 @@
|
|||||||
|
{
|
||||||
|
"source_cup": "PerfectCoffee_CoffeeCup.blend",
|
||||||
|
"source_cup_sha256_before_build": "c0557c2f335e2bf178ff3190f8071e4b74e0b8503937e4d499e349fc304607f5",
|
||||||
|
"source_cup_sha256_after_build": "c0557c2f335e2bf178ff3190f8071e4b74e0b8503937e4d499e349fc304607f5",
|
||||||
|
"lid_included": false,
|
||||||
|
"liquid_top_mm": 103.8,
|
||||||
|
"foam_edge_thickness_mm": 1.8799999999999928,
|
||||||
|
"foam_center_rise_mm": 0.35,
|
||||||
|
"rim_clearance_mm": 3.949999999999999,
|
||||||
|
"radial_fit_clearance_min_mm": 0.12000000000000001,
|
||||||
|
"liquid_cup_triangle_intersections": 0,
|
||||||
|
"foam_cup_triangle_intersections": 0,
|
||||||
|
"foam_liquid_triangle_intersections": 0,
|
||||||
|
"coffee": {
|
||||||
|
"uv_map": "LiquidSurfaceUV",
|
||||||
|
"uv_bounds": [
|
||||||
|
1.7546385677746912e-08,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"center_uv": null,
|
||||||
|
"top_faces": 94,
|
||||||
|
"material_slots": [
|
||||||
|
"CC_Coffee_Liquid"
|
||||||
|
],
|
||||||
|
"non_manifold_edges": 0
|
||||||
|
},
|
||||||
|
"foam": {
|
||||||
|
"uv_map": "LiquidSurfaceUV",
|
||||||
|
"uv_bounds": [
|
||||||
|
8.95026985858749e-09,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"center_uv": [
|
||||||
|
0.5,
|
||||||
|
0.5
|
||||||
|
],
|
||||||
|
"top_faces": 768,
|
||||||
|
"material_slots": [
|
||||||
|
"CC_Milk_Foam"
|
||||||
|
],
|
||||||
|
"non_manifold_edges": 0
|
||||||
|
},
|
||||||
|
"textures_packed": {
|
||||||
|
"CC_Coffee_Surface": true,
|
||||||
|
"CC_Latte_Surface": true
|
||||||
|
},
|
||||||
|
"render_engine": "CYCLES",
|
||||||
|
"passed": true
|
||||||
|
}
|
||||||
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.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,440 @@
|
|||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from mathutils import Vector
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parent
|
||||||
|
MILK_DIR = ROOT / "milk_2l"
|
||||||
|
ORANGE_DIR = ROOT / "orange_juice_2l"
|
||||||
|
MILK_SOURCE = MILK_DIR / "PerfectCoffee_milk_2l.blend"
|
||||||
|
ORANGE_SOURCE = ORANGE_DIR / "PerfectCoffee_orange_juice_2l_MilkJug.blend"
|
||||||
|
MILK_BLEND = MILK_DIR / "PerfectCoffee_milk_2l_Empty.blend"
|
||||||
|
MILK_GLB = MILK_BLEND.with_suffix(".glb")
|
||||||
|
ORANGE_BLEND = ORANGE_DIR / "PerfectCoffee_orange_juice_2l_MilkJug_LabelTest.blend"
|
||||||
|
ORANGE_GLB = ORANGE_BLEND.with_suffix(".glb")
|
||||||
|
TEXTURE = ROOT / "labels" / "orange_juice" / "orange_juice_wrap_wide.png"
|
||||||
|
ALPHA = 0.15
|
||||||
|
LABEL_Z_MIN = 0.025
|
||||||
|
LABEL_Z_MAX = 0.115
|
||||||
|
LABEL_OFFSET = 0.00006
|
||||||
|
HANDLE_BOTTOM = 0.122
|
||||||
|
|
||||||
|
|
||||||
|
def sha256(path):
|
||||||
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def mesh_objects():
|
||||||
|
return [obj for obj in bpy.context.scene.objects if obj.type == "MESH" and not obj.name.startswith("Studio_")]
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_count(objects):
|
||||||
|
total = 0
|
||||||
|
for obj in objects:
|
||||||
|
obj.data.calc_loop_triangles()
|
||||||
|
total += len(obj.data.loop_triangles)
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
def export_collection(path):
|
||||||
|
collection = bpy.data.collections["Model"]
|
||||||
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
for obj in collection.all_objects:
|
||||||
|
obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = next(obj for obj in collection.all_objects if obj.type == "MESH")
|
||||||
|
bpy.ops.export_scene.gltf(
|
||||||
|
filepath=str(path), export_format="GLB", use_selection=True,
|
||||||
|
export_yup=True, export_apply=True, export_texcoords=True,
|
||||||
|
export_cameras=False, export_lights=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def remove_liquid():
|
||||||
|
removed = []
|
||||||
|
for obj in mesh_objects():
|
||||||
|
if any(token in obj.name.lower() for token in ("liquid", "_fill", "contents")):
|
||||||
|
removed.append(obj.name)
|
||||||
|
bpy.data.objects.remove(obj, do_unlink=True)
|
||||||
|
return removed
|
||||||
|
|
||||||
|
|
||||||
|
def set_opacity(body, name):
|
||||||
|
material = body.data.materials[0].copy()
|
||||||
|
material.name = name
|
||||||
|
material.diffuse_color = (*material.diffuse_color[:3], ALPHA)
|
||||||
|
material.use_nodes = True
|
||||||
|
material.surface_render_method = "DITHERED"
|
||||||
|
material.use_backface_culling = False
|
||||||
|
material.node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value = ALPHA
|
||||||
|
body.data.materials.clear()
|
||||||
|
body.data.materials.append(material)
|
||||||
|
for polygon in body.data.polygons:
|
||||||
|
polygon.material_index = 0
|
||||||
|
|
||||||
|
|
||||||
|
def render_views(views, cap_pivot=None):
|
||||||
|
scene = bpy.context.scene
|
||||||
|
camera = scene.camera
|
||||||
|
camera_matrix = camera.matrix_world.copy()
|
||||||
|
camera_scale = camera.data.ortho_scale
|
||||||
|
resolution = scene.render.resolution_x, scene.render.resolution_y
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
if cap_pivot:
|
||||||
|
location = cap_pivot.location.copy()
|
||||||
|
cap_pivot.location += Vector((0.045, 0, 0.055))
|
||||||
|
scene.render.filepath = views["cap_removed"]
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
cap_pivot.location = location
|
||||||
|
for name, position, target, scale in views["details"]:
|
||||||
|
camera.location = position
|
||||||
|
target = Vector(target)
|
||||||
|
camera.rotation_euler = (target - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = scale
|
||||||
|
scene.render.resolution_x = 900
|
||||||
|
scene.render.resolution_y = 900
|
||||||
|
scene.render.filepath = name
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
camera.matrix_world = camera_matrix
|
||||||
|
camera.data.ortho_scale = camera_scale
|
||||||
|
scene.render.resolution_x, scene.render.resolution_y = resolution
|
||||||
|
scene.render.filepath = views["main"]
|
||||||
|
|
||||||
|
|
||||||
|
def clip_polygon(points, threshold, keep_above):
|
||||||
|
result = []
|
||||||
|
for first, second in zip(points, points[1:] + points[:1]):
|
||||||
|
first_inside = first.z >= threshold if keep_above else first.z <= threshold
|
||||||
|
second_inside = second.z >= threshold if keep_above else second.z <= threshold
|
||||||
|
if first_inside:
|
||||||
|
result.append(first.copy())
|
||||||
|
if first_inside != second_inside:
|
||||||
|
amount = (threshold - first.z) / (second.z - first.z)
|
||||||
|
result.append(first.lerp(second, amount))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def cross_2d(origin, first, second):
|
||||||
|
return (first[0] - origin[0]) * (second[1] - origin[1]) - (first[1] - origin[1]) * (second[0] - origin[0])
|
||||||
|
|
||||||
|
|
||||||
|
def convex_hull(points):
|
||||||
|
points = sorted(set((round(point[0], 7), round(point[1], 7)) for point in points))
|
||||||
|
lower = []
|
||||||
|
for point in points:
|
||||||
|
while len(lower) >= 2 and cross_2d(lower[-2], lower[-1], point) <= 0:
|
||||||
|
lower.pop()
|
||||||
|
lower.append(point)
|
||||||
|
upper = []
|
||||||
|
for point in reversed(points):
|
||||||
|
while len(upper) >= 2 and cross_2d(upper[-2], upper[-1], point) <= 0:
|
||||||
|
upper.pop()
|
||||||
|
upper.append(point)
|
||||||
|
return lower[:-1] + upper[:-1]
|
||||||
|
|
||||||
|
|
||||||
|
def perimeter_mapping(points):
|
||||||
|
hull = convex_hull(points)
|
||||||
|
back_index = max(range(len(hull)), key=lambda i: (hull[i][1] + hull[(i + 1) % len(hull)][1]) / 2)
|
||||||
|
first = Vector(hull[back_index])
|
||||||
|
second = Vector(hull[(back_index + 1) % len(hull)])
|
||||||
|
start = (first + second) / 2
|
||||||
|
outline = [start] + [Vector(hull[i]) for i in range(back_index + 1, len(hull))]
|
||||||
|
outline += [Vector(hull[i]) for i in range(back_index + 1)] + [start]
|
||||||
|
lengths = [(second - first).length for first, second in zip(outline[:-1], outline[1:])]
|
||||||
|
total = sum(lengths)
|
||||||
|
|
||||||
|
def map_point(point):
|
||||||
|
point = Vector(point)
|
||||||
|
best_distance = None
|
||||||
|
best_length = 0.0
|
||||||
|
accumulated = 0.0
|
||||||
|
for first, second, length in zip(outline[:-1], outline[1:], lengths):
|
||||||
|
edge = second - first
|
||||||
|
amount = max(0.0, min(1.0, (point - first).dot(edge) / edge.length_squared))
|
||||||
|
nearest = first + amount * edge
|
||||||
|
distance = (point - nearest).length_squared
|
||||||
|
if best_distance is None or distance < best_distance:
|
||||||
|
best_distance = distance
|
||||||
|
best_length = accumulated + amount * length
|
||||||
|
accumulated += length
|
||||||
|
return best_length / total
|
||||||
|
|
||||||
|
return map_point, total
|
||||||
|
|
||||||
|
|
||||||
|
def create_label(body, root):
|
||||||
|
polygons = []
|
||||||
|
for polygon in body.data.polygons:
|
||||||
|
if abs(polygon.normal.z) > 0.1:
|
||||||
|
continue
|
||||||
|
if polygon.center.x * polygon.normal.x + polygon.center.y * polygon.normal.y <= 0:
|
||||||
|
continue
|
||||||
|
points = [body.data.vertices[index].co.copy() for index in polygon.vertices]
|
||||||
|
if max(point.z for point in points) < LABEL_Z_MIN or min(point.z for point in points) > LABEL_Z_MAX:
|
||||||
|
continue
|
||||||
|
clipped = clip_polygon(clip_polygon(points, LABEL_Z_MIN, True), LABEL_Z_MAX, False)
|
||||||
|
if len(clipped) >= 3:
|
||||||
|
polygons.append(clipped)
|
||||||
|
vertices = []
|
||||||
|
faces = []
|
||||||
|
vertex_map = {}
|
||||||
|
for polygon in polygons:
|
||||||
|
face = []
|
||||||
|
for point in polygon:
|
||||||
|
key = tuple(round(value, 7) for value in point)
|
||||||
|
if key not in vertex_map:
|
||||||
|
vertex_map[key] = len(vertices)
|
||||||
|
vertices.append(tuple(point))
|
||||||
|
face.append(vertex_map[key])
|
||||||
|
faces.append(tuple(face))
|
||||||
|
assert len(faces) >= 8, f"Unexpected label surface face count: {len(faces)}"
|
||||||
|
mesh = bpy.data.meshes.new("OrangeJuice_Label_Surface_Mesh")
|
||||||
|
mesh.from_pydata(vertices, [], faces)
|
||||||
|
mesh.update()
|
||||||
|
label = bpy.data.objects.new("OrangeJuice_Label_Surface", mesh)
|
||||||
|
bpy.data.collections["Model"].objects.link(label)
|
||||||
|
label.parent = root
|
||||||
|
map_point, perimeter = perimeter_mapping(vertices)
|
||||||
|
uv = mesh.uv_layers.new(name="UVMap_TightLabel")
|
||||||
|
for polygon in mesh.polygons:
|
||||||
|
values = []
|
||||||
|
for loop_index in polygon.loop_indices:
|
||||||
|
vertex = mesh.vertices[mesh.loops[loop_index].vertex_index].co
|
||||||
|
u = map_point((vertex.x, vertex.y))
|
||||||
|
v = (vertex.z - LABEL_Z_MIN) / (LABEL_Z_MAX - LABEL_Z_MIN)
|
||||||
|
values.append((loop_index, u, v))
|
||||||
|
if max(value[1] for value in values) - min(value[1] for value in values) > 0.5:
|
||||||
|
values = [(index, u + 1 if u < 0.5 else u, v) for index, u, v in values]
|
||||||
|
for loop_index, u, v in values:
|
||||||
|
uv.data[loop_index].uv = (u, v)
|
||||||
|
image = bpy.data.images.load(str(TEXTURE), check_existing=True)
|
||||||
|
image.name = "OrangeJuice_Wrap_Tight"
|
||||||
|
image.use_fake_user = True
|
||||||
|
image.pack()
|
||||||
|
material = bpy.data.materials.new("OrangeJuice_Label_Tight")
|
||||||
|
material.use_nodes = True
|
||||||
|
material.use_backface_culling = False
|
||||||
|
output = material.node_tree.nodes.get("Material Output")
|
||||||
|
shader = material.node_tree.nodes.get("Principled BSDF")
|
||||||
|
texture = material.node_tree.nodes.new("ShaderNodeTexImage")
|
||||||
|
texture.image = image
|
||||||
|
texture.extension = "REPEAT"
|
||||||
|
texture.interpolation = "Linear"
|
||||||
|
shader.inputs["Roughness"].default_value = 0.62
|
||||||
|
material.node_tree.links.new(texture.outputs["Color"], shader.inputs["Base Color"])
|
||||||
|
material.node_tree.links.new(shader.outputs["BSDF"], output.inputs["Surface"])
|
||||||
|
mesh.materials.append(material)
|
||||||
|
modifier = label.modifiers.new("Tight_To_Bottle", "SHRINKWRAP")
|
||||||
|
modifier.target = body
|
||||||
|
modifier.wrap_method = "NEAREST_SURFACEPOINT"
|
||||||
|
modifier.wrap_mode = "OUTSIDE_SURFACE"
|
||||||
|
modifier.offset = LABEL_OFFSET
|
||||||
|
label["label_surface_offset_m"] = LABEL_OFFSET
|
||||||
|
label["label_z_range_m"] = [LABEL_Z_MIN, LABEL_Z_MAX]
|
||||||
|
label["below_handle"] = True
|
||||||
|
label["texture_contains_percentage_claim"] = False
|
||||||
|
root["label_fit_method"] = "Surface-cut geometry with shrinkwrap to the actual bottle exterior"
|
||||||
|
return label, perimeter, len(polygons)
|
||||||
|
|
||||||
|
|
||||||
|
def surface_gaps(body, label):
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
|
tree = BVHTree.FromObject(body, depsgraph)
|
||||||
|
evaluated = label.evaluated_get(depsgraph)
|
||||||
|
mesh = evaluated.to_mesh()
|
||||||
|
inverse = body.matrix_world.inverted()
|
||||||
|
gaps = []
|
||||||
|
for vertex in mesh.vertices:
|
||||||
|
point = inverse @ (label.matrix_world @ vertex.co)
|
||||||
|
nearest, normal, _, distance = tree.find_nearest(point)
|
||||||
|
signed = (point - nearest).dot(normal)
|
||||||
|
gaps.append(signed)
|
||||||
|
evaluated.to_mesh_clear()
|
||||||
|
return [min(gaps) * 1000, max(gaps) * 1000]
|
||||||
|
|
||||||
|
|
||||||
|
def make_milk():
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(MILK_SOURCE))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
removed = remove_liquid()
|
||||||
|
assert {obj.name for obj in mesh_objects()} == {"Milk_Bottle_Body", "Milk_Cap"}
|
||||||
|
body = bpy.data.objects["Milk_Bottle_Body"]
|
||||||
|
set_opacity(body, "Milk_HDPE_Observe15")
|
||||||
|
root = bpy.data.objects["Milk2L_Root"]
|
||||||
|
root.name = "Milk2L_Empty_Root"
|
||||||
|
root["interior_empty"] = True
|
||||||
|
root["modeled_liquid_ml"] = 0.0
|
||||||
|
root["body_opacity"] = ALPHA
|
||||||
|
export_collection(MILK_GLB)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.render.filepath = str(MILK_DIR / "preview_empty15.png")
|
||||||
|
render_views({
|
||||||
|
"main": str(MILK_DIR / "preview_empty15.png"),
|
||||||
|
"cap_removed": str(MILK_DIR / "preview_empty15_cap_removed.png"),
|
||||||
|
"details": [],
|
||||||
|
}, bpy.data.objects["Milk_Cap_Pivot"])
|
||||||
|
assert sha256(MILK_SOURCE) == SOURCE_HASHES[MILK_SOURCE]
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(MILK_BLEND), compress=True)
|
||||||
|
return removed
|
||||||
|
|
||||||
|
|
||||||
|
def make_orange():
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(ORANGE_SOURCE))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
removed = remove_liquid()
|
||||||
|
assert {obj.name for obj in mesh_objects()} == {"OrangeJuice_Bottle_Body", "OrangeJuice_Cap"}
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
set_opacity(body, "OrangeJuice_PET_Observe15")
|
||||||
|
root = bpy.data.objects["OrangeJuice2L_MilkJug_Root"]
|
||||||
|
root.name = "OrangeJuice2L_MilkJug_LabelTest_Root"
|
||||||
|
root["interior_empty"] = True
|
||||||
|
root["modeled_liquid_ml"] = 0.0
|
||||||
|
root["body_opacity"] = ALPHA
|
||||||
|
label, perimeter, source_face_count = create_label(body, root)
|
||||||
|
export_collection(ORANGE_GLB)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.render.filepath = str(ORANGE_DIR / "preview_label_test.png")
|
||||||
|
render_views({
|
||||||
|
"main": str(ORANGE_DIR / "preview_label_test.png"),
|
||||||
|
"cap_removed": None,
|
||||||
|
"details": [
|
||||||
|
(str(ORANGE_DIR / "preview_label_test_front.png"), (0, -0.55, 0.18), (0, 0, 0.14), 0.325),
|
||||||
|
(str(ORANGE_DIR / "preview_label_test_back.png"), (0, 0.55, 0.18), (0, 0, 0.14), 0.325),
|
||||||
|
(str(ORANGE_DIR / "preview_label_fit.png"), (0.20, -0.28, 0.16), (0, 0, 0.075), 0.205),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
assert sha256(ORANGE_SOURCE) == SOURCE_HASHES[ORANGE_SOURCE]
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(ORANGE_BLEND), compress=True)
|
||||||
|
return {
|
||||||
|
"removed_liquid_objects": removed,
|
||||||
|
"label_source_face_count": source_face_count,
|
||||||
|
"label_perimeter_m": perimeter,
|
||||||
|
"label_surface_gap_mm": surface_gaps(body, label),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def validate_milk(removed):
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(MILK_BLEND))
|
||||||
|
native_triangles = triangle_count(mesh_objects())
|
||||||
|
native_alpha = bpy.data.materials["Milk_HDPE_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
native_ok = (
|
||||||
|
native_triangles == 906 and abs(native_alpha - ALPHA) < 0.00001
|
||||||
|
and bpy.data.objects.get("OrangeJuice_Juice_Fill") is None
|
||||||
|
and len(mesh_objects()) == 2
|
||||||
|
)
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
bpy.ops.import_scene.gltf(filepath=str(MILK_GLB))
|
||||||
|
glb_triangles = triangle_count(mesh_objects())
|
||||||
|
glb_alpha = bpy.data.materials["Milk_HDPE_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
glb_ok = glb_triangles == 906 and abs(glb_alpha - ALPHA) < 0.00001 and len(mesh_objects()) == 2
|
||||||
|
assert native_ok and glb_ok
|
||||||
|
report = {
|
||||||
|
"asset": "Milk2L_Empty_Root",
|
||||||
|
"source_model": "model_assets/milk_2l/PerfectCoffee_milk_2l.blend",
|
||||||
|
"source_unchanged": True,
|
||||||
|
"body_opacity": ALPHA,
|
||||||
|
"interior_empty": True,
|
||||||
|
"removed_liquid_objects": removed,
|
||||||
|
"native_triangles": native_triangles,
|
||||||
|
"glb_triangles": glb_triangles,
|
||||||
|
"native_reopen_passed": native_ok,
|
||||||
|
"glb_reimport_passed": glb_ok,
|
||||||
|
"technical_validation_passed": True,
|
||||||
|
"visual_review_passed": False,
|
||||||
|
"passed": False,
|
||||||
|
"blend": MILK_BLEND.name,
|
||||||
|
"glb": MILK_GLB.name,
|
||||||
|
"preview": "preview_empty15.png",
|
||||||
|
"preview_cap_removed": "preview_empty15_cap_removed.png",
|
||||||
|
}
|
||||||
|
(MILK_DIR / "validation_empty15.json").write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
return report
|
||||||
|
|
||||||
|
|
||||||
|
def validate_orange(fit_data):
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(ORANGE_BLEND))
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
native_triangles = triangle_count(mesh_objects())
|
||||||
|
native_alpha = bpy.data.materials["OrangeJuice_PET_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
native_gaps = surface_gaps(body, label)
|
||||||
|
texture = bpy.data.materials["OrangeJuice_Label_Tight"].node_tree.nodes.get("Image Texture")
|
||||||
|
native_ok = (
|
||||||
|
native_triangles <= 1000 and len(mesh_objects()) == 3
|
||||||
|
and abs(native_alpha - ALPHA) < 0.00001
|
||||||
|
and label.modifiers["Tight_To_Bottle"].target == body
|
||||||
|
and bool(label.data.uv_layers)
|
||||||
|
and texture is not None and list(texture.image.size) == [3584, 768]
|
||||||
|
and texture.image.packed_file is not None
|
||||||
|
and max(native_gaps) <= 0.061 and min(native_gaps) > 0
|
||||||
|
and LABEL_Z_MAX < HANDLE_BOTTOM
|
||||||
|
)
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
bpy.ops.import_scene.gltf(filepath=str(ORANGE_GLB))
|
||||||
|
imported_objects = mesh_objects()
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
glb_triangles = triangle_count(imported_objects)
|
||||||
|
glb_alpha = bpy.data.materials["OrangeJuice_PET_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
glb_gaps = surface_gaps(body, label)
|
||||||
|
glb_texture = bpy.data.materials["OrangeJuice_Label_Tight"].node_tree.nodes.get("Image Texture")
|
||||||
|
glb_ok = (
|
||||||
|
glb_triangles == native_triangles and len(imported_objects) == 3
|
||||||
|
and abs(glb_alpha - ALPHA) < 0.00001
|
||||||
|
and bool(label.data.uv_layers)
|
||||||
|
and glb_texture is not None and list(glb_texture.image.size) == [3584, 768]
|
||||||
|
and max(glb_gaps) <= 0.061 and min(glb_gaps) > 0
|
||||||
|
)
|
||||||
|
assert native_ok and glb_ok, "Tight label or empty bottle validation failed"
|
||||||
|
report = {
|
||||||
|
"asset": "OrangeJuice2L_MilkJug_LabelTest_Root",
|
||||||
|
"source_model": "model_assets/orange_juice_2l/PerfectCoffee_orange_juice_2l_MilkJug.blend",
|
||||||
|
"source_unchanged": True,
|
||||||
|
"body_opacity": ALPHA,
|
||||||
|
"interior_empty": True,
|
||||||
|
"removed_liquid_objects": fit_data["removed_liquid_objects"],
|
||||||
|
"native_triangles": native_triangles,
|
||||||
|
"glb_triangles": glb_triangles,
|
||||||
|
"triangle_limit": 1000,
|
||||||
|
"cap_color": "orange",
|
||||||
|
"cap_independent": True,
|
||||||
|
"label_method": "Clipped bottle-surface mesh with shrinkwrap",
|
||||||
|
"label_z_range_m": [LABEL_Z_MIN, LABEL_Z_MAX],
|
||||||
|
"handle_bottom_z_m": HANDLE_BOTTOM,
|
||||||
|
"label_below_handle": True,
|
||||||
|
"label_nominal_offset_mm": LABEL_OFFSET * 1000,
|
||||||
|
"native_surface_gap_mm": native_gaps,
|
||||||
|
"glb_surface_gap_mm": glb_gaps,
|
||||||
|
"label_source_face_count": fit_data["label_source_face_count"],
|
||||||
|
"label_perimeter_m": fit_data["label_perimeter_m"],
|
||||||
|
"texture_dimensions": [3584, 768],
|
||||||
|
"percentage_purity_claims_present": False,
|
||||||
|
"native_reopen_passed": native_ok,
|
||||||
|
"glb_reimport_passed": glb_ok,
|
||||||
|
"technical_validation_passed": True,
|
||||||
|
"visual_review_passed": False,
|
||||||
|
"passed": False,
|
||||||
|
"blend": ORANGE_BLEND.name,
|
||||||
|
"glb": ORANGE_GLB.name,
|
||||||
|
"preview": "preview_label_test.png",
|
||||||
|
"preview_front": "preview_label_test_front.png",
|
||||||
|
"preview_back": "preview_label_test_back.png",
|
||||||
|
"preview_fit": "preview_label_fit.png",
|
||||||
|
}
|
||||||
|
(ORANGE_DIR / "validation_milk_jug_label_test.json").write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
return report
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE_HASHES = {path: sha256(path) for path in (MILK_SOURCE, ORANGE_SOURCE)}
|
||||||
|
removed_milk = make_milk()
|
||||||
|
orange_fit = make_orange()
|
||||||
|
milk_report = validate_milk(removed_milk)
|
||||||
|
orange_report = validate_orange(orange_fit)
|
||||||
|
for path, expected_hash in SOURCE_HASHES.items():
|
||||||
|
assert sha256(path) == expected_hash
|
||||||
|
print("MILK", json.dumps(milk_report, ensure_ascii=False))
|
||||||
|
print("ORANGE", json.dumps(orange_report, ensure_ascii=False))
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"asset": "CakeSlice_Root",
|
||||||
|
"design_id": "cake_slice",
|
||||||
|
"blender_version": "5.2.0 LTS",
|
||||||
|
"units": "meters",
|
||||||
|
"axis_convention": "Blender Z up; GLB Y up",
|
||||||
|
"triangle_limit": 1000,
|
||||||
|
"triangles": 194,
|
||||||
|
"passed_triangle_budget": true,
|
||||||
|
"mesh_components": {
|
||||||
|
"Cake_Sponge_Lower": 28,
|
||||||
|
"Cake_Cream_Lower": 28,
|
||||||
|
"Cake_Sponge_Upper": 28,
|
||||||
|
"Cake_Cream_Upper": 28,
|
||||||
|
"Cake_Frosting_Top": 28,
|
||||||
|
"Cake_Strawberry": 48,
|
||||||
|
"Cake_Leaf_1": 2,
|
||||||
|
"Cake_Leaf_2": 2,
|
||||||
|
"Cake_Leaf_3": 2
|
||||||
|
},
|
||||||
|
"bounds_min_m": [
|
||||||
|
-0.05400000140070915,
|
||||||
|
-0.05999999865889549,
|
||||||
|
0.0010000000474974513
|
||||||
|
],
|
||||||
|
"bounds_max_m": [
|
||||||
|
0.05400000140070915,
|
||||||
|
0.054999999701976776,
|
||||||
|
0.0949999988079071
|
||||||
|
],
|
||||||
|
"dimensions_m": [
|
||||||
|
0.1080000028014183,
|
||||||
|
0.11499999836087227,
|
||||||
|
0.09399999876040965
|
||||||
|
],
|
||||||
|
"reference_photo": "cake_slice.jpg",
|
||||||
|
"reference_images_packed": true,
|
||||||
|
"labels_or_brand_graphics": false,
|
||||||
|
"blend": "PerfectCoffee_CakeSlice.blend",
|
||||||
|
"glb": "PerfectCoffee_CakeSlice.glb",
|
||||||
|
"preview": "preview.png",
|
||||||
|
"native_reopen_passed": true,
|
||||||
|
"glb_reimport_passed": true,
|
||||||
|
"passed": true,
|
||||||
|
"native_triangles": 194,
|
||||||
|
"native_dimensions_m": [
|
||||||
|
0.1080000028014183,
|
||||||
|
0.11499999836087227,
|
||||||
|
0.09399999876040965
|
||||||
|
],
|
||||||
|
"no_image_textures_or_labels": true,
|
||||||
|
"cap_detach_parenting_passed": null,
|
||||||
|
"cap_blend_and_glb_passed": null,
|
||||||
|
"liquid_volume_2000ml_passed": null,
|
||||||
|
"plausible_dimensions_passed": true,
|
||||||
|
"transparent_pet_passed": null,
|
||||||
|
"glb_triangles": 194,
|
||||||
|
"glb_dimensions_m": [
|
||||||
|
0.1080000028014183,
|
||||||
|
0.11499999836087227,
|
||||||
|
0.09399999876040965
|
||||||
|
],
|
||||||
|
"studio_excluded_from_glb": true,
|
||||||
|
"technical_validation_passed": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"visual_review_notes": "Triangular slice, two chocolate sponge layers, cream filling, frosting and strawberry are correctly proportioned and visible.",
|
||||||
|
"cap_assembly_test_passed": null
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,60 @@
|
|||||||
|
{
|
||||||
|
"asset": "Croissant_Root",
|
||||||
|
"design_id": "croissant",
|
||||||
|
"blender_version": "5.2.0 LTS",
|
||||||
|
"units": "meters",
|
||||||
|
"axis_convention": "Blender Z up; GLB Y up",
|
||||||
|
"triangle_limit": 1000,
|
||||||
|
"triangles": 456,
|
||||||
|
"passed_triangle_budget": true,
|
||||||
|
"mesh_components": {
|
||||||
|
"Croissant_Rolled_Pastry": 456
|
||||||
|
},
|
||||||
|
"bounds_min_m": [
|
||||||
|
-0.09190463274717331,
|
||||||
|
-0.0371473990380764,
|
||||||
|
0.0012263512471690774
|
||||||
|
],
|
||||||
|
"bounds_max_m": [
|
||||||
|
0.09190463274717331,
|
||||||
|
0.0447818785905838,
|
||||||
|
0.058773647993803024
|
||||||
|
],
|
||||||
|
"dimensions_m": [
|
||||||
|
0.18380926549434662,
|
||||||
|
0.0819292776286602,
|
||||||
|
0.05754729674663395
|
||||||
|
],
|
||||||
|
"reference_photo": "croissant.jpg",
|
||||||
|
"reference_images_packed": true,
|
||||||
|
"labels_or_brand_graphics": false,
|
||||||
|
"blend": "PerfectCoffee_Croissant.blend",
|
||||||
|
"glb": "PerfectCoffee_Croissant.glb",
|
||||||
|
"preview": "preview.png",
|
||||||
|
"native_reopen_passed": true,
|
||||||
|
"glb_reimport_passed": true,
|
||||||
|
"passed": true,
|
||||||
|
"native_triangles": 456,
|
||||||
|
"native_dimensions_m": [
|
||||||
|
0.18380926549434662,
|
||||||
|
0.0819292776286602,
|
||||||
|
0.05754729674663395
|
||||||
|
],
|
||||||
|
"no_image_textures_or_labels": true,
|
||||||
|
"cap_detach_parenting_passed": null,
|
||||||
|
"cap_blend_and_glb_passed": null,
|
||||||
|
"liquid_volume_2000ml_passed": null,
|
||||||
|
"plausible_dimensions_passed": true,
|
||||||
|
"transparent_pet_passed": null,
|
||||||
|
"glb_triangles": 456,
|
||||||
|
"glb_dimensions_m": [
|
||||||
|
0.18380926549434662,
|
||||||
|
0.0819292776286602,
|
||||||
|
0.05754729674663395
|
||||||
|
],
|
||||||
|
"studio_excluded_from_glb": true,
|
||||||
|
"technical_validation_passed": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"visual_review_notes": "Curved crescent silhouette, tapered tips and rolled laminated bands are readable in the render.",
|
||||||
|
"cap_assembly_test_passed": null
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
import bpy
|
||||||
|
from pathlib import Path
|
||||||
|
from mathutils import Vector
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parent
|
||||||
|
ASSETS = [
|
||||||
|
("01 CROISSANT", "bakery_and_cake/Croissant/PerfectCoffee_Croissant.blend"),
|
||||||
|
("02 CAKE SLICE", "bakery_and_cake/CakeSlice/PerfectCoffee_CakeSlice.blend"),
|
||||||
|
("03 CREAM TOAST", "toast_and_wrap/AvocadoToast/PerfectCoffee_AvocadoToast.blend"),
|
||||||
|
]
|
||||||
|
POSITIONS = [(-0.25, 0), (0, 0), (0.25, 0)]
|
||||||
|
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.render.engine = "BLENDER_EEVEE"
|
||||||
|
scene.render.resolution_x = 1600
|
||||||
|
scene.render.resolution_y = 1250
|
||||||
|
scene.render.resolution_percentage = 100
|
||||||
|
scene.render.image_settings.file_format = "PNG"
|
||||||
|
scene.render.film_transparent = False
|
||||||
|
scene.view_settings.view_transform = "AgX"
|
||||||
|
scene.view_settings.look = "AgX - Medium High Contrast"
|
||||||
|
scene.view_settings.exposure = -0.5
|
||||||
|
scene.world = bpy.data.worlds.new("Review_World")
|
||||||
|
scene.world.use_nodes = True
|
||||||
|
scene.world.node_tree.nodes["Background"].inputs["Color"].default_value = (0.72, 0.78, 0.82, 1)
|
||||||
|
scene.world.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.3
|
||||||
|
|
||||||
|
for (label, relative_path), (x, y) in zip(ASSETS, POSITIONS):
|
||||||
|
with bpy.data.libraries.load(str(ROOT / relative_path), link=False) as (source, target):
|
||||||
|
target.collections = ["Model"]
|
||||||
|
model = target.collections[0]
|
||||||
|
instance = bpy.data.objects.new(label, None)
|
||||||
|
instance.instance_type = "COLLECTION"
|
||||||
|
instance.instance_collection = model
|
||||||
|
instance.location = (x, y, 0)
|
||||||
|
scene.collection.objects.link(instance)
|
||||||
|
meshes = [obj for obj in model.all_objects if obj.type == "MESH"]
|
||||||
|
triangle_count = 0
|
||||||
|
for obj in meshes:
|
||||||
|
obj.data.calc_loop_triangles()
|
||||||
|
triangle_count += len(obj.data.loop_triangles)
|
||||||
|
assert triangle_count <= 1000, (label, triangle_count)
|
||||||
|
print("FOOD_REVIEW", label, triangle_count, flush=True)
|
||||||
|
for text, size, offset in [(label, 0.015, -0.105), (f"{triangle_count} TRIANGLES", 0.008, -0.121)]:
|
||||||
|
curve = bpy.data.curves.new(text, "FONT")
|
||||||
|
curve.body = text
|
||||||
|
curve.align_x = "CENTER"
|
||||||
|
curve.size = size
|
||||||
|
text_object = bpy.data.objects.new(text, curve)
|
||||||
|
text_object.location = (x, y + offset, 0.001)
|
||||||
|
scene.collection.objects.link(text_object)
|
||||||
|
|
||||||
|
curve = bpy.data.curves.new("Review_Notes", "FONT")
|
||||||
|
curve.body = "FOOD MODEL REVIEW\n\n3 FOOD ASSETS\nBLENDER 5.2\n1000 TRI LIMIT EACH\nNO PACKAGING\n\nREVIEW SCENE ONLY"
|
||||||
|
curve.align_x = "CENTER"
|
||||||
|
curve.size = 0.014
|
||||||
|
notes = bpy.data.objects.new("Review_Notes", curve)
|
||||||
|
notes.location = (0, 0.29, 0.001)
|
||||||
|
scene.collection.objects.link(notes)
|
||||||
|
|
||||||
|
text_material = bpy.data.materials.new("Review_Text")
|
||||||
|
text_material.diffuse_color = (0.045, 0.055, 0.065, 1)
|
||||||
|
text_material.use_nodes = True
|
||||||
|
text_material.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (0.045, 0.055, 0.065, 1)
|
||||||
|
for obj in scene.objects:
|
||||||
|
if obj.type == "FONT":
|
||||||
|
obj.data.materials.append(text_material)
|
||||||
|
|
||||||
|
material = bpy.data.materials.new("Review_Background")
|
||||||
|
material.diffuse_color = (0.38, 0.41, 0.36, 1)
|
||||||
|
material.use_nodes = True
|
||||||
|
material.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (0.38, 0.41, 0.36, 1)
|
||||||
|
material.node_tree.nodes["Principled BSDF"].inputs["Roughness"].default_value = 0.86
|
||||||
|
bpy.ops.mesh.primitive_plane_add(size=200, location=(0, 0, -0.0002))
|
||||||
|
bpy.context.object.data.materials.append(material)
|
||||||
|
|
||||||
|
for label, offset, power, size in [
|
||||||
|
("Key", (-0.5, -0.5, 0.9), 8, 0.7),
|
||||||
|
("Fill", (0.6, -0.1, 0.5), 4, 0.6),
|
||||||
|
("Rim", (0.0, 0.7, 0.8), 6, 0.6),
|
||||||
|
]:
|
||||||
|
light_data = bpy.data.lights.new(label, "AREA")
|
||||||
|
light_data.energy = power
|
||||||
|
light_data.shape = "DISK"
|
||||||
|
light_data.size = size
|
||||||
|
light_object = bpy.data.objects.new(label, light_data)
|
||||||
|
light_object.location = offset
|
||||||
|
light_object.rotation_euler = (Vector((0, 0.12, 0)) - light_object.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
scene.collection.objects.link(light_object)
|
||||||
|
|
||||||
|
camera_data = bpy.data.cameras.new("Review_Camera")
|
||||||
|
camera = bpy.data.objects.new("Review_Camera", camera_data)
|
||||||
|
camera_data.type = "ORTHO"
|
||||||
|
camera_data.ortho_scale = 0.78
|
||||||
|
scene.collection.objects.link(camera)
|
||||||
|
scene.camera = camera
|
||||||
|
center = Vector((0, 0.105, 0))
|
||||||
|
camera.location = center + Vector((0.25, -0.60, 0.72))
|
||||||
|
camera.rotation_euler = (center - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
scene.render.filepath = str(ROOT / "review_three_quarter.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
|
||||||
|
camera.location = (0, 0.105, 1)
|
||||||
|
camera.rotation_euler = (0, 0, 0)
|
||||||
|
camera_data.ortho_scale = 0.78
|
||||||
|
scene.render.filepath = str(ROOT / "review_top.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
print("FOOD_REVIEW_COMPLETE", flush=True)
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"asset": "AvocadoToast_Root",
|
||||||
|
"design_id": "avocado_toast",
|
||||||
|
"presentation": "Plain toast with one pale-yellow cream layer; no avocado, chili or other toppings",
|
||||||
|
"blender_version": "5.2.0 LTS",
|
||||||
|
"units": "meters",
|
||||||
|
"axis_convention": "Blender Z up; GLB Y up",
|
||||||
|
"triangle_limit": 1000,
|
||||||
|
"triangles": 330,
|
||||||
|
"passed_triangle_budget": true,
|
||||||
|
"mesh_components": {
|
||||||
|
"Toast_Bread_Crust": 148,
|
||||||
|
"Toast_Inner_Crumb": 72,
|
||||||
|
"Toast_PaleYellowCream_Layer": 110
|
||||||
|
},
|
||||||
|
"bounds_min_m": [
|
||||||
|
-0.05700000002980232,
|
||||||
|
-0.05900000035762787,
|
||||||
|
0.0010000000474974513
|
||||||
|
],
|
||||||
|
"bounds_max_m": [
|
||||||
|
0.05700000002980232,
|
||||||
|
0.06400000303983688,
|
||||||
|
0.01940000057220459
|
||||||
|
],
|
||||||
|
"dimensions_m": [
|
||||||
|
0.11400000005960464,
|
||||||
|
0.12300000339746475,
|
||||||
|
0.01840000052470714
|
||||||
|
],
|
||||||
|
"reference_photo": "cream_toast.jpg",
|
||||||
|
"reference_images_packed": true,
|
||||||
|
"labels_or_brand_graphics": false,
|
||||||
|
"blend": "PerfectCoffee_AvocadoToast.blend",
|
||||||
|
"glb": "PerfectCoffee_AvocadoToast.glb",
|
||||||
|
"preview": "preview.png",
|
||||||
|
"native_reopen_passed": true,
|
||||||
|
"glb_reimport_passed": true,
|
||||||
|
"passed": true,
|
||||||
|
"native_triangles": 330,
|
||||||
|
"native_dimensions_m": [
|
||||||
|
0.11400000005960464,
|
||||||
|
0.12300000339746475,
|
||||||
|
0.01840000052470714
|
||||||
|
],
|
||||||
|
"glb_triangles": 330,
|
||||||
|
"glb_dimensions_m": [
|
||||||
|
0.11400000005960464,
|
||||||
|
0.12300000339746475,
|
||||||
|
0.01840000052470714
|
||||||
|
],
|
||||||
|
"no_image_textures_or_labels": true,
|
||||||
|
"plausible_dimensions_passed": true,
|
||||||
|
"studio_excluded_from_glb": true,
|
||||||
|
"technical_validation_passed": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"visual_review_notes": "One continuous pale-yellow cream layer over toast, with an exposed crust and crumb border; no avocado slices, chili or other toppings.",
|
||||||
|
"preview_top": "preview_top.png"
|
||||||
|
}
|
||||||
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,216 @@
|
|||||||
|
{
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"reference_video": "model_assets/reference/juicer/ZMUEX_working_video.mp4",
|
||||||
|
"assembly_segment_seconds": [
|
||||||
|
233,
|
||||||
|
283
|
||||||
|
],
|
||||||
|
"parts": {
|
||||||
|
"fixed_chassis": {
|
||||||
|
"file": "PerfectCoffee_Fixed_Chassis.blend",
|
||||||
|
"preview": "preview_fixed_chassis_part.png",
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"assembly_root": "Fixed_Chassis_Assembly",
|
||||||
|
"source_object_count": 36,
|
||||||
|
"appended_object_count": 36,
|
||||||
|
"root_parent_none": true,
|
||||||
|
"other_assemblies_excluded": true,
|
||||||
|
"control_pod_excluded_from_deck": true,
|
||||||
|
"visible_lcd_states": [
|
||||||
|
"Ready"
|
||||||
|
],
|
||||||
|
"single_ready_state_for_fixed_chassis": true,
|
||||||
|
"studio_placement_offset_m": [
|
||||||
|
-0.00299999862909317,
|
||||||
|
-0.02499999850988388,
|
||||||
|
0.03849999979138374
|
||||||
|
],
|
||||||
|
"non_manifold_edges": {
|
||||||
|
"Cabinet_Base_Plinth": 0,
|
||||||
|
"Chamber_Backplate_Rib": 0,
|
||||||
|
"Chamber_Backplate_Rib.001": 0,
|
||||||
|
"Chamber_Left_Rear_Return": 0,
|
||||||
|
"Chamber_Lower_Backplate": 0,
|
||||||
|
"Chamber_Rear_Wall": 0,
|
||||||
|
"Chamber_Right_Rear_Return": 0,
|
||||||
|
"Collector_Shared_Bay_Sill": 0,
|
||||||
|
"Control_Pod_Base_Standard": 0,
|
||||||
|
"Control_Pod_Rear_Support": 0,
|
||||||
|
"Fixed_Control_Pod_Housing": 0,
|
||||||
|
"LCD_Bezel": 0,
|
||||||
|
"LCD_Screen": 0,
|
||||||
|
"Start_Button": 0,
|
||||||
|
"Start_Button_Rim": 0,
|
||||||
|
"Rear_Vent": 0,
|
||||||
|
"Rear_Vent.001": 0,
|
||||||
|
"Rear_Vent.002": 0,
|
||||||
|
"Rear_Vent.003": 0,
|
||||||
|
"Rear_Vent.004": 0,
|
||||||
|
"Rear_Vent.005": 0,
|
||||||
|
"Rear_Vent.006": 0,
|
||||||
|
"Rear_Vent.007": 0,
|
||||||
|
"Rubber_Foot": 0,
|
||||||
|
"Rubber_Foot.001": 0,
|
||||||
|
"Rubber_Foot.002": 0,
|
||||||
|
"Rubber_Foot.003": 0
|
||||||
|
},
|
||||||
|
"positive_part_volumes_m3": {
|
||||||
|
"Cabinet_Base_Plinth": 0.0026267218681439927,
|
||||||
|
"Chamber_Backplate_Rib": 1.929762107684962e-05,
|
||||||
|
"Chamber_Backplate_Rib.001": 1.929762107684962e-05,
|
||||||
|
"Chamber_Left_Rear_Return": 0.0001793937763793454,
|
||||||
|
"Chamber_Lower_Backplate": 0.002147026444770346,
|
||||||
|
"Chamber_Rear_Wall": 0.0024111397957069947,
|
||||||
|
"Chamber_Right_Rear_Return": 0.00020592286258015806,
|
||||||
|
"Collector_Shared_Bay_Sill": 0.0002557203534650054,
|
||||||
|
"Control_Pod_Base_Standard": 5.307669902303164e-05,
|
||||||
|
"Control_Pod_Rear_Support": 2.499470330921098e-05,
|
||||||
|
"Fixed_Control_Pod_Housing": 0.0005326483468544586,
|
||||||
|
"LCD_Bezel": 9.271448458507361e-06,
|
||||||
|
"LCD_Screen": 1.1142129184479175e-06,
|
||||||
|
"Start_Button": 1.1709904393703893e-06,
|
||||||
|
"Start_Button_Rim": 2.3704550877934783e-06,
|
||||||
|
"Rear_Vent": 4.117127822014996e-07,
|
||||||
|
"Rear_Vent.001": 4.117127822014996e-07,
|
||||||
|
"Rear_Vent.002": 4.117127822014996e-07,
|
||||||
|
"Rear_Vent.003": 4.117127822014996e-07,
|
||||||
|
"Rear_Vent.004": 4.117127822014996e-07,
|
||||||
|
"Rear_Vent.005": 4.117127822014996e-07,
|
||||||
|
"Rear_Vent.006": 4.117127822014996e-07,
|
||||||
|
"Rear_Vent.007": 4.117127822014996e-07,
|
||||||
|
"Rubber_Foot": 1.1860214542753698e-05,
|
||||||
|
"Rubber_Foot.001": 1.1860214542753698e-05,
|
||||||
|
"Rubber_Foot.002": 1.1860214542753698e-05,
|
||||||
|
"Rubber_Foot.003": 1.1860214542753698e-05
|
||||||
|
},
|
||||||
|
"linked_library_count": 0,
|
||||||
|
"missing_external_assets": [],
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"geometry_checks_passed": true,
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"passed": true
|
||||||
|
},
|
||||||
|
"collection_deck": {
|
||||||
|
"file": "PerfectCoffee_Collection_Deck.blend",
|
||||||
|
"preview": "preview_collection_deck_part.png",
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"assembly_root": "Collection_Deck_Assembly",
|
||||||
|
"source_object_count": 15,
|
||||||
|
"appended_object_count": 15,
|
||||||
|
"root_parent_none": true,
|
||||||
|
"other_assemblies_excluded": true,
|
||||||
|
"control_pod_excluded_from_deck": true,
|
||||||
|
"visible_lcd_states": [],
|
||||||
|
"single_ready_state_for_fixed_chassis": true,
|
||||||
|
"studio_placement_offset_m": [
|
||||||
|
-0.0,
|
||||||
|
-0.02550000324845314,
|
||||||
|
-0.16433162987232208
|
||||||
|
],
|
||||||
|
"non_manifold_edges": {
|
||||||
|
"Collection_Deck_Rear_Lip": 0,
|
||||||
|
"Collection_Deck_Rear_Mount": 0,
|
||||||
|
"Collection_Deck_Rear_Mount.001": 0,
|
||||||
|
"Collection_Deck_Shallow_Rear_Tray": 0,
|
||||||
|
"Collection_Deck_Side_Rail_-1": 0,
|
||||||
|
"Collection_Deck_Side_Rail_1": 0,
|
||||||
|
"Juice_Guide_Deck_Cleat": 0,
|
||||||
|
"Juice_Guide_Deck_Cleat.001": 0,
|
||||||
|
"Juice_Guide_Outlet_Cantilever": 0,
|
||||||
|
"Juice_Guide_Solid_Tray_No_Mesh": 0,
|
||||||
|
"Sloping_Black_Plastic_Apron": 0
|
||||||
|
},
|
||||||
|
"positive_part_volumes_m3": {
|
||||||
|
"Collection_Deck_Rear_Lip": 3.758110674252284e-06,
|
||||||
|
"Collection_Deck_Rear_Mount": 1.138687826622772e-06,
|
||||||
|
"Collection_Deck_Rear_Mount.001": 1.138687826622772e-06,
|
||||||
|
"Collection_Deck_Shallow_Rear_Tray": 0.00020371851459343249,
|
||||||
|
"Collection_Deck_Side_Rail_-1": 1.4637013795095009e-05,
|
||||||
|
"Collection_Deck_Side_Rail_1": 1.4601814580332345e-05,
|
||||||
|
"Juice_Guide_Deck_Cleat": 2.5141872919205e-08,
|
||||||
|
"Juice_Guide_Deck_Cleat.001": 9.168200394383904e-07,
|
||||||
|
"Juice_Guide_Outlet_Cantilever": 1.7119408198222023e-05,
|
||||||
|
"Juice_Guide_Solid_Tray_No_Mesh": 2.7470561494559974e-05,
|
||||||
|
"Sloping_Black_Plastic_Apron": 5.727167290823832e-05
|
||||||
|
},
|
||||||
|
"linked_library_count": 0,
|
||||||
|
"missing_external_assets": [],
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"geometry_checks_passed": true,
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"passed": true
|
||||||
|
},
|
||||||
|
"lower_service_covers": {
|
||||||
|
"file": "PerfectCoffee_Lower_Service_Covers.blend",
|
||||||
|
"preview": "preview_lower_service_covers_part.png",
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"assembly_root": "Lower_Service_Cover_Assembly",
|
||||||
|
"source_object_count": 3,
|
||||||
|
"appended_object_count": 3,
|
||||||
|
"root_parent_none": true,
|
||||||
|
"other_assemblies_excluded": true,
|
||||||
|
"control_pod_excluded_from_deck": true,
|
||||||
|
"visible_lcd_states": [],
|
||||||
|
"single_ready_state_for_fixed_chassis": true,
|
||||||
|
"studio_placement_offset_m": [
|
||||||
|
-0.0,
|
||||||
|
0.05350000038743019,
|
||||||
|
0.003999999724328518
|
||||||
|
],
|
||||||
|
"non_manifold_edges": {
|
||||||
|
"Lower_Left_Service_Cover": 0,
|
||||||
|
"Lower_Right_Service_Cover": 0
|
||||||
|
},
|
||||||
|
"positive_part_volumes_m3": {
|
||||||
|
"Lower_Left_Service_Cover": 0.0001766217172683023,
|
||||||
|
"Lower_Right_Service_Cover": 0.00014745020867942138
|
||||||
|
},
|
||||||
|
"linked_library_count": 0,
|
||||||
|
"missing_external_assets": [],
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"geometry_checks_passed": true,
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"passed": true
|
||||||
|
},
|
||||||
|
"transparent_hood": {
|
||||||
|
"file": "PerfectCoffee_Transparent_Hood.blend",
|
||||||
|
"preview": "preview_transparent_hood.png",
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"assembly_root": "Removable_Transparent_Hood_Assembly",
|
||||||
|
"source_object_count": 3,
|
||||||
|
"appended_object_count": 3,
|
||||||
|
"root_parent_none": true,
|
||||||
|
"other_assemblies_excluded": true,
|
||||||
|
"control_pod_excluded_from_deck": true,
|
||||||
|
"visible_lcd_states": [],
|
||||||
|
"single_ready_state_for_fixed_chassis": true,
|
||||||
|
"studio_placement_offset_m": [
|
||||||
|
-0.0,
|
||||||
|
0.0040000006556510925,
|
||||||
|
-0.25979408621788025
|
||||||
|
],
|
||||||
|
"non_manifold_edges": {
|
||||||
|
"Transparent_Hood_Rear_Closure": 0,
|
||||||
|
"Transparent_Hood_With_Curved_Sides": 0
|
||||||
|
},
|
||||||
|
"positive_part_volumes_m3": {
|
||||||
|
"Transparent_Hood_Rear_Closure": 0.00017984367866208557,
|
||||||
|
"Transparent_Hood_With_Curved_Sides": 0.000621221439658863
|
||||||
|
},
|
||||||
|
"linked_library_count": 0,
|
||||||
|
"missing_external_assets": [],
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"geometry_checks_passed": true,
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"passed": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"passed": true
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"file": "PerfectCoffee_Collector_Pair.blend",
|
||||||
|
"preview": "preview_collector_pair.png",
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"acceptance_view": "pair",
|
||||||
|
"source_objects": [
|
||||||
|
"Residue_Collection_Box",
|
||||||
|
"Residue_Box_Open_Rim",
|
||||||
|
"Juice_Collection_Box_Contoured",
|
||||||
|
"Juice_Bin_Contoured_Rim"
|
||||||
|
],
|
||||||
|
"object_count": 4,
|
||||||
|
"center_error_m": 4.8437728076971485e-08,
|
||||||
|
"rim_height_range_m": 0.01303508771929826,
|
||||||
|
"non_manifold_edges": 0,
|
||||||
|
"volume_m3": 0.00027286890833844407,
|
||||||
|
"linked_library_count": 0,
|
||||||
|
"missing_external_assets": [],
|
||||||
|
"machine_parts_excluded": true,
|
||||||
|
"depth_m": 0.1340000033378601,
|
||||||
|
"source_depth_matches": true,
|
||||||
|
"front_shallow_collector": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"collector_wall_gap_m": 0.007013451308012009,
|
||||||
|
"close_pair_without_divider": true,
|
||||||
|
"handle_through_cut_passed": true,
|
||||||
|
"integrated_front_pull_passed": true,
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"passed": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
import bpy
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from mathutils import Vector
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
sys.path.insert(0, str(OUT))
|
||||||
|
from export_collector_parts import studio, evaluated_bin
|
||||||
|
|
||||||
|
MAIN = OUT/'PerfectCoffee_Minex_Mechanism.blend'
|
||||||
|
SPECS = {
|
||||||
|
'fixed_chassis': {
|
||||||
|
'root': 'Fixed_Chassis_Assembly',
|
||||||
|
'file': 'PerfectCoffee_Fixed_Chassis.blend',
|
||||||
|
'preview': 'preview_fixed_chassis_part.png',
|
||||||
|
'camera': ((0.76, 1.30, 0.85), (0, 0, 0.36), 0.980),
|
||||||
|
},
|
||||||
|
'collection_deck': {
|
||||||
|
'root': 'Collection_Deck_Assembly',
|
||||||
|
'file': 'PerfectCoffee_Collection_Deck.blend',
|
||||||
|
'preview': 'preview_collection_deck_part.png',
|
||||||
|
'camera': ((0.46, 0.72, 0.48), (0, 0, 0.12), 0.510),
|
||||||
|
},
|
||||||
|
'lower_service_covers': {
|
||||||
|
'root': 'Lower_Service_Cover_Assembly',
|
||||||
|
'file': 'PerfectCoffee_Lower_Service_Covers.blend',
|
||||||
|
'preview': 'preview_lower_service_covers_part.png',
|
||||||
|
'camera': ((0.50, 0.72, 0.40), (0, 0, 0.17), 0.540),
|
||||||
|
},
|
||||||
|
'transparent_hood': {
|
||||||
|
'root': 'Removable_Transparent_Hood_Assembly',
|
||||||
|
'file': 'PerfectCoffee_Transparent_Hood.blend',
|
||||||
|
'preview': 'preview_transparent_hood.png',
|
||||||
|
'camera': ((0.55, 0.85, 0.60), (0, 0, 0.23), 0.520),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def export_part(kind, spec):
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(MAIN))
|
||||||
|
source_root = bpy.data.objects[spec['root']]
|
||||||
|
names = [source_root.name, *[obj.name for obj in source_root.children_recursive]]
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
with bpy.data.libraries.load(str(MAIN), link=False) as (source, target):
|
||||||
|
target.objects = names
|
||||||
|
appended = [obj for obj in target.objects if obj is not None]
|
||||||
|
assert len(appended) == len(names), f'{kind}: missing source objects'
|
||||||
|
for obj in appended:
|
||||||
|
bpy.context.scene.collection.objects.link(obj)
|
||||||
|
obj.animation_data_clear()
|
||||||
|
obj.hide_render = kind == 'fixed_chassis' and obj.name in {'LCD_Status_Processing', 'LCD_Status_Stopped'}
|
||||||
|
obj.hide_viewport = obj.hide_render
|
||||||
|
assembly = bpy.data.objects[spec['root']]
|
||||||
|
assembly.parent = None
|
||||||
|
assembly.matrix_parent_inverse.identity()
|
||||||
|
assembly.location = (0, 0, 0)
|
||||||
|
assembly.rotation_euler = (0, 0, 0)
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
points = []
|
||||||
|
for obj in assembly.children_recursive:
|
||||||
|
if obj.type != 'MESH':
|
||||||
|
continue
|
||||||
|
evaluated = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
|
||||||
|
data = evaluated.to_mesh()
|
||||||
|
points.extend(evaluated.matrix_world @ vertex.co for vertex in data.vertices)
|
||||||
|
evaluated.to_mesh_clear()
|
||||||
|
assert points, f'{kind}: assembly has no mesh geometry'
|
||||||
|
low = Vector(tuple(min(point[i] for point in points) for i in range(3)))
|
||||||
|
high = Vector(tuple(max(point[i] for point in points) for i in range(3)))
|
||||||
|
offset = Vector((-(low.x+high.x)/2, -(low.y+high.y)/2, 0.039-low.z))
|
||||||
|
assembly.location += offset
|
||||||
|
studio(kind, spec)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.frame_set(1)
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
scene['acceptance_view'] = kind
|
||||||
|
scene['source_model'] = MAIN.name
|
||||||
|
scene['source_sha256'] = hashlib.sha256(MAIN.read_bytes()).hexdigest()
|
||||||
|
scene['geometry_note'] = 'The complete assembly root and descendants are appended from the main juicer; no replacement geometry is drawn'
|
||||||
|
about = bpy.data.texts.new('ABOUT_Assembly_Acceptance')
|
||||||
|
about.write(f'Independent {kind} assembly from {MAIN.name}. Source segment: ZMUEX_working_video.mp4 03:53 onward. Animated visibility and transforms are cleared for static acceptance. Studio placement offset: {list(offset)}.\n')
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
assembly.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = assembly
|
||||||
|
path = OUT/spec['file']
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(path), compress=True)
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(path))
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.frame_set(1)
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
assembly = bpy.data.objects[spec['root']]
|
||||||
|
non_manifold = {}
|
||||||
|
volumes = {}
|
||||||
|
for obj in assembly.children_recursive:
|
||||||
|
if obj.type != 'MESH':
|
||||||
|
continue
|
||||||
|
edges, volume, _ = evaluated_bin(obj)
|
||||||
|
non_manifold[obj.name] = edges
|
||||||
|
volumes[obj.name] = volume
|
||||||
|
other_roots = [item['root'] for item in SPECS.values() if item['root'] != spec['root']]
|
||||||
|
visible_lcd_states = [status for status in ['Ready', 'Processing', 'Stopped'] if 'LCD_Status_'+status in bpy.data.objects and not bpy.data.objects['LCD_Status_'+status].hide_render]
|
||||||
|
report = {
|
||||||
|
'file': spec['file'],
|
||||||
|
'preview': spec['preview'],
|
||||||
|
'source_blend': MAIN.name,
|
||||||
|
'source_blend_sha256': scene['source_sha256'],
|
||||||
|
'assembly_root': spec['root'],
|
||||||
|
'source_object_count': len(names),
|
||||||
|
'appended_object_count': len(appended),
|
||||||
|
'root_parent_none': assembly.parent is None,
|
||||||
|
'other_assemblies_excluded': all(name not in bpy.data.objects for name in other_roots),
|
||||||
|
'control_pod_excluded_from_deck': kind != 'collection_deck' or 'Fixed_Control_Pod_Assembly' not in bpy.data.objects,
|
||||||
|
'visible_lcd_states': visible_lcd_states,
|
||||||
|
'single_ready_state_for_fixed_chassis': kind != 'fixed_chassis' or visible_lcd_states == ['Ready'],
|
||||||
|
'studio_placement_offset_m': list(offset),
|
||||||
|
'non_manifold_edges': non_manifold,
|
||||||
|
'positive_part_volumes_m3': volumes,
|
||||||
|
'linked_library_count': len(bpy.data.libraries),
|
||||||
|
'missing_external_assets': [image.filepath for image in bpy.data.images if image.source == 'FILE' and not image.packed_file and not Path(bpy.path.abspath(image.filepath)).exists()],
|
||||||
|
'visual_review_passed': False,
|
||||||
|
}
|
||||||
|
report['geometry_checks_passed'] = bool(volumes) and all(value == 0 for value in non_manifold.values()) and all(value > 0 for value in volumes.values())
|
||||||
|
report['technical_checks_passed'] = all([
|
||||||
|
report['source_object_count'] == report['appended_object_count'],
|
||||||
|
report['root_parent_none'], report['other_assemblies_excluded'],
|
||||||
|
report['control_pod_excluded_from_deck'], report['geometry_checks_passed'],
|
||||||
|
report['single_ready_state_for_fixed_chassis'],
|
||||||
|
report['linked_library_count'] == 0, not report['missing_external_assets'],
|
||||||
|
])
|
||||||
|
report['passed'] = report['technical_checks_passed']
|
||||||
|
assert report['passed'], f'{kind} assembly export failed: {report}'
|
||||||
|
scene.render.filepath = str(OUT/spec['preview'])
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
print('ASSEMBLY_EXPORT_COMPLETE '+json.dumps(report), flush=True)
|
||||||
|
return report
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
reports = {kind: export_part(kind, spec) for kind, spec in SPECS.items()}
|
||||||
|
result = {
|
||||||
|
'source_blend': MAIN.name,
|
||||||
|
'source_blend_sha256': hashlib.sha256(MAIN.read_bytes()).hexdigest(),
|
||||||
|
'reference_video': 'model_assets/reference/juicer/ZMUEX_working_video.mp4',
|
||||||
|
'assembly_segment_seconds': [233, 283],
|
||||||
|
'parts': reports,
|
||||||
|
'technical_checks_passed': all(report['technical_checks_passed'] for report in reports.values()),
|
||||||
|
'visual_review_passed': False,
|
||||||
|
}
|
||||||
|
result['passed'] = result['technical_checks_passed']
|
||||||
|
(OUT/'assembly_parts_validation.json').write_text(json.dumps(result, ensure_ascii=False, indent=2)+'\n', encoding='utf-8')
|
||||||
|
print('ALL_ASSEMBLY_PARTS_EXPORTED', flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -0,0 +1,229 @@
|
|||||||
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
from mathutils import Vector
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
MAIN = OUT/'PerfectCoffee_Minex_Mechanism.blend'
|
||||||
|
SOURCE_HASH = hashlib.sha256(MAIN.read_bytes()).hexdigest()
|
||||||
|
SPECS = {
|
||||||
|
'residue': {
|
||||||
|
'file': 'PerfectCoffee_Residue_Bin.blend',
|
||||||
|
'preview': 'preview_residue_bin.png',
|
||||||
|
'report': 'residue_bin_validation.json',
|
||||||
|
'objects': ['Residue_Collection_Box', 'Residue_Box_Open_Rim'],
|
||||||
|
'offset': (-0.0625, -0.068, 0),
|
||||||
|
'camera': ((-0.42, 0.54, 0.42), (0, 0, 0.17), 0.510),
|
||||||
|
},
|
||||||
|
'juice': {
|
||||||
|
'file': 'PerfectCoffee_Juice_Bin.blend',
|
||||||
|
'preview': 'preview_juice_bin.png',
|
||||||
|
'report': 'juice_bin_validation.json',
|
||||||
|
'objects': ['Juice_Collection_Box_Contoured', 'Juice_Bin_Contoured_Rim'],
|
||||||
|
'offset': (0.101, -0.087, 0),
|
||||||
|
'camera': ((-0.38, 0.50, 0.32), (0, 0, 0.14), 0.430),
|
||||||
|
},
|
||||||
|
'pair': {
|
||||||
|
'file': 'PerfectCoffee_Collector_Pair.blend',
|
||||||
|
'preview': 'preview_collector_pair.png',
|
||||||
|
'report': 'collector_pair_validation.json',
|
||||||
|
'objects': ['Residue_Collection_Box', 'Residue_Box_Open_Rim', 'Juice_Collection_Box_Contoured', 'Juice_Bin_Contoured_Rim'],
|
||||||
|
'offset': (0.01925, -0.0775, 0),
|
||||||
|
'camera': ((-0.46, 0.62, 0.43), (0, 0.015, 0.16), 0.560),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def aim(obj, target):
|
||||||
|
obj.rotation_euler = (Vector(target)-obj.location).to_track_quat('-Z', 'Y').to_euler()
|
||||||
|
|
||||||
|
|
||||||
|
def center(obj):
|
||||||
|
points = [obj.matrix_world @ Vector(corner) for corner in obj.bound_box]
|
||||||
|
return sum(points, Vector((0, 0, 0))) / len(points)
|
||||||
|
|
||||||
|
|
||||||
|
def area(name, location, energy, size, target):
|
||||||
|
data = bpy.data.lights.new(name, 'AREA')
|
||||||
|
data.energy = energy
|
||||||
|
data.size = size
|
||||||
|
obj = bpy.data.objects.new(name, data)
|
||||||
|
bpy.context.scene.collection.objects.link(obj)
|
||||||
|
obj.location = location
|
||||||
|
aim(obj, target)
|
||||||
|
|
||||||
|
|
||||||
|
def studio(kind, spec):
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.unit_settings.system = 'METRIC'
|
||||||
|
scene.unit_settings.length_unit = 'METERS'
|
||||||
|
scene.render.engine = 'CYCLES'
|
||||||
|
scene.cycles.samples = 48
|
||||||
|
scene.cycles.use_denoising = True
|
||||||
|
scene.render.resolution_x = 1200
|
||||||
|
scene.render.resolution_y = 1000
|
||||||
|
scene.render.resolution_percentage = 100
|
||||||
|
scene.render.image_settings.file_format = 'PNG'
|
||||||
|
scene.render.image_settings.color_mode = 'RGB'
|
||||||
|
scene.view_settings.view_transform = 'AgX'
|
||||||
|
scene.view_settings.look = 'AgX - Medium High Contrast'
|
||||||
|
world = bpy.data.worlds.new('Collector_Studio_World')
|
||||||
|
world.use_nodes = True
|
||||||
|
world.node_tree.nodes['Background'].inputs['Color'].default_value = (0.26, 0.30, 0.33, 1)
|
||||||
|
world.node_tree.nodes['Background'].inputs['Strength'].default_value = 0.40
|
||||||
|
scene.world = world
|
||||||
|
bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0.0365))
|
||||||
|
ground = bpy.context.object
|
||||||
|
ground.name = 'Studio_Ground_Not_Part_Of_Product'
|
||||||
|
ground.dimensions = (200, 200, 0.005)
|
||||||
|
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
|
||||||
|
material = bpy.data.materials.new('Studio_Neutral')
|
||||||
|
material.diffuse_color = (0.12, 0.15, 0.17, 1)
|
||||||
|
material.use_nodes = True
|
||||||
|
material.node_tree.nodes['Principled BSDF'].inputs['Base Color'].default_value = (0.12, 0.15, 0.17, 1)
|
||||||
|
material.node_tree.nodes['Principled BSDF'].inputs['Roughness'].default_value = 0.75
|
||||||
|
ground.data.materials.append(material)
|
||||||
|
area('Studio_Key', (-0.30, 0.40, 0.65), 12, 0.30, (0, 0, 0.16))
|
||||||
|
area('Studio_Fill', (0.40, 0.10, 0.45), 9, 0.26, (0, 0, 0.14))
|
||||||
|
area('Studio_Rim', (-0.20, -0.40, 0.50), 10, 0.24, (0, 0, 0.16))
|
||||||
|
location, target, scale = spec['camera']
|
||||||
|
data = bpy.data.cameras.new('VALIDATION_Camera')
|
||||||
|
camera = bpy.data.objects.new('VALIDATION_Camera', data)
|
||||||
|
scene.collection.objects.link(camera)
|
||||||
|
camera.location = location
|
||||||
|
aim(camera, target)
|
||||||
|
data.type = 'ORTHO'
|
||||||
|
data.ortho_scale = scale
|
||||||
|
data.clip_start = 0.001
|
||||||
|
data.clip_end = 100
|
||||||
|
scene.camera = camera
|
||||||
|
for screen in bpy.data.screens:
|
||||||
|
for area_ in screen.areas:
|
||||||
|
if area_.type == 'VIEW_3D':
|
||||||
|
space = area_.spaces.active
|
||||||
|
space.region_3d.view_perspective = 'CAMERA'
|
||||||
|
space.shading.type = 'MATERIAL'
|
||||||
|
space.overlay.show_extras = False
|
||||||
|
space.clip_start = 0.001
|
||||||
|
space.clip_end = 100
|
||||||
|
|
||||||
|
|
||||||
|
def evaluated_bin(obj):
|
||||||
|
ev = obj.evaluated_get(bpy.context.evaluated_depsgraph_get())
|
||||||
|
mesh = ev.to_mesh()
|
||||||
|
points = [ev.matrix_world @ vertex.co for vertex in mesh.vertices]
|
||||||
|
faces = [list(poly.vertices) for poly in mesh.polygons]
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(mesh)
|
||||||
|
non_manifold = sum(not edge.is_manifold for edge in bm.edges)
|
||||||
|
volume = bm.calc_volume(signed=True)
|
||||||
|
bm.free()
|
||||||
|
ev.to_mesh_clear()
|
||||||
|
tree = BVHTree.FromPolygons(points, faces)
|
||||||
|
return non_manifold, volume, tree
|
||||||
|
|
||||||
|
|
||||||
|
def export_part(kind):
|
||||||
|
spec = SPECS[kind]
|
||||||
|
source_object_names = list(spec['objects'])
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
with bpy.data.libraries.load(str(MAIN), link=False) as (source, target):
|
||||||
|
target.objects = spec['objects']
|
||||||
|
appended = [obj for obj in target.objects if obj is not None]
|
||||||
|
assert len(appended) == len(spec['objects'])
|
||||||
|
for obj in appended:
|
||||||
|
bpy.context.scene.collection.objects.link(obj)
|
||||||
|
obj.parent = None
|
||||||
|
obj.matrix_parent_inverse.identity()
|
||||||
|
obj.animation_data_clear()
|
||||||
|
obj.location = spec['offset']
|
||||||
|
obj.rotation_euler = (0, 0, 0)
|
||||||
|
obj.hide_render = False
|
||||||
|
obj.hide_viewport = False
|
||||||
|
studio(kind, spec)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene['acceptance_view'] = kind
|
||||||
|
scene['source_model'] = MAIN.name
|
||||||
|
scene['source_sha256'] = SOURCE_HASH
|
||||||
|
scene['geometry_note'] = 'Collector geometry is appended from the assembled juicer, not independently redrawn'
|
||||||
|
about = bpy.data.texts.new('ABOUT_Collector_Acceptance')
|
||||||
|
about.write(f'Independent {kind} collector acceptance. Source: {MAIN.name}. Only collector meshes, rims and studio objects are included.\n')
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
appended[0].select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = appended[0]
|
||||||
|
scene.frame_set(1)
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
path = OUT/spec['file']
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(path), compress=True)
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(path))
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.frame_set(1)
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
juice = bpy.data.objects.get('Juice_Collection_Box_Contoured')
|
||||||
|
residue = bpy.data.objects.get('Residue_Collection_Box')
|
||||||
|
primary = residue if kind == 'residue' else juice
|
||||||
|
non_manifold, volume, primary_tree = evaluated_bin(primary)
|
||||||
|
center_error = Vector((center(primary).x,center(primary).y,0)).length if kind != 'pair' else Vector(((center(juice)+center(residue)).x/2,(center(juice)+center(residue)).y/2,0)).length
|
||||||
|
report = {
|
||||||
|
'file': spec['file'],
|
||||||
|
'preview': spec['preview'],
|
||||||
|
'source_blend': MAIN.name,
|
||||||
|
'source_blend_sha256': SOURCE_HASH,
|
||||||
|
'acceptance_view': kind,
|
||||||
|
'source_objects': source_object_names,
|
||||||
|
'object_count': len(appended),
|
||||||
|
'center_error_m': center_error,
|
||||||
|
'rim_height_range_m': primary['rim_max_z_m']-primary['rim_min_z_m'],
|
||||||
|
'non_manifold_edges': non_manifold,
|
||||||
|
'volume_m3': volume,
|
||||||
|
'linked_library_count': len(bpy.data.libraries),
|
||||||
|
'missing_external_assets': [image.filepath for image in bpy.data.images if image.source == 'FILE' and not image.packed_file and not Path(bpy.path.abspath(image.filepath)).exists()],
|
||||||
|
'machine_parts_excluded': all(name not in bpy.data.objects for name in ['Cabinet_Main_Body', 'Chamber_Rear_Wall', 'Chamber_Lower_Backplate', 'Residue_Service_Door', 'Collection_Deck_Assembly', 'Fixed_Control_Pod_Assembly', 'Lower_Service_Cover_Assembly']),
|
||||||
|
'depth_m': primary.dimensions.y,
|
||||||
|
'source_depth_matches': abs(primary.dimensions.y-primary['depth_m']) < 0.0001,
|
||||||
|
'front_shallow_collector': primary.dimensions.y < 0.180,
|
||||||
|
'visual_review_passed': False,
|
||||||
|
}
|
||||||
|
if kind == 'pair':
|
||||||
|
residue_left = min((residue.matrix_world @ Vector(corner)).x for corner in residue.bound_box)
|
||||||
|
juice_right = max((juice.matrix_world @ Vector(corner)).x for corner in juice.bound_box)
|
||||||
|
report['collector_wall_gap_m'] = residue_left-juice_right
|
||||||
|
report['close_pair_without_divider'] = abs(report['collector_wall_gap_m']-0.007) < 0.0001
|
||||||
|
if kind in ['juice', 'pair']:
|
||||||
|
handle_x = center(juice).x-0.060
|
||||||
|
handle_y = 0.060+spec['offset'][1]
|
||||||
|
handle_hit = primary_tree.ray_cast(Vector((handle_x, handle_y, 0.128)), Vector((1, 0, 0)), 0.060)[0]
|
||||||
|
upper_hit = primary_tree.ray_cast(Vector((handle_x, handle_y, 0.175)), Vector((1, 0, 0)), 0.060)[0]
|
||||||
|
report['handle_through_cut_passed'] = handle_hit is None and upper_hit is not None
|
||||||
|
if kind in ['residue','pair']:
|
||||||
|
residue_tree = primary_tree if kind == 'residue' else evaluated_bin(residue)[2]
|
||||||
|
pull_x = 0.0625+spec['offset'][0]
|
||||||
|
pull_y = 0.169+spec['offset'][1]
|
||||||
|
pull_hit = residue_tree.ray_cast(Vector((pull_x,pull_y,0.165)),Vector((0,-1,0)),0.030)[0]
|
||||||
|
wall_hit = residue_tree.ray_cast(Vector((pull_x,pull_y,0.180)),Vector((0,-1,0)),0.030)[0]
|
||||||
|
report['integrated_front_pull_passed'] = pull_hit is None and wall_hit is not None
|
||||||
|
report['technical_checks_passed'] = (
|
||||||
|
report['object_count'] == len(spec['objects']) and report['center_error_m'] < 0.0001
|
||||||
|
and report['rim_height_range_m'] > 0.012 and report['non_manifold_edges'] == 0
|
||||||
|
and report['volume_m3'] > 0 and report['linked_library_count'] == 0
|
||||||
|
and not report['missing_external_assets'] and report['machine_parts_excluded']
|
||||||
|
and report['source_depth_matches'] and report['front_shallow_collector']
|
||||||
|
and report.get('handle_through_cut_passed', True)
|
||||||
|
and report.get('integrated_front_pull_passed', True)
|
||||||
|
and report.get('close_pair_without_divider', True)
|
||||||
|
)
|
||||||
|
report['passed'] = report['technical_checks_passed']
|
||||||
|
assert report['passed'], f'{kind} collector export validation failed: {report}'
|
||||||
|
scene.render.filepath = str(OUT/spec['preview'])
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
(OUT/spec['report']).write_text(json.dumps(report, ensure_ascii=False, indent=2)+'\n', encoding='utf-8')
|
||||||
|
print('COLLECTOR_EXPORT_COMPLETE '+json.dumps(report), flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
for part in ['residue', 'juice', 'pair']:
|
||||||
|
export_part(part)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"file": "PerfectCoffee_Juice_Bin.blend",
|
||||||
|
"preview": "preview_juice_bin.png",
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"acceptance_view": "juice",
|
||||||
|
"source_objects": [
|
||||||
|
"Juice_Collection_Box_Contoured",
|
||||||
|
"Juice_Bin_Contoured_Rim"
|
||||||
|
],
|
||||||
|
"object_count": 2,
|
||||||
|
"center_error_m": 2.514570951461792e-08,
|
||||||
|
"rim_height_range_m": 0.01303508771929826,
|
||||||
|
"non_manifold_edges": 0,
|
||||||
|
"volume_m3": 0.00027286890833844407,
|
||||||
|
"linked_library_count": 0,
|
||||||
|
"missing_external_assets": [],
|
||||||
|
"machine_parts_excluded": true,
|
||||||
|
"depth_m": 0.1340000033378601,
|
||||||
|
"source_depth_matches": true,
|
||||||
|
"front_shallow_collector": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"handle_through_cut_passed": true,
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"passed": true
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
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,26 @@
|
|||||||
|
{
|
||||||
|
"file": "PerfectCoffee_Residue_Bin.blend",
|
||||||
|
"preview": "preview_residue_bin.png",
|
||||||
|
"source_blend": "PerfectCoffee_Minex_Mechanism.blend",
|
||||||
|
"source_blend_sha256": "1aa35413ea2d01adcf8c413cfa0a2c688cf67852c58abf3a259727ecb5c54c4c",
|
||||||
|
"acceptance_view": "residue",
|
||||||
|
"source_objects": [
|
||||||
|
"Residue_Collection_Box",
|
||||||
|
"Residue_Box_Open_Rim"
|
||||||
|
],
|
||||||
|
"object_count": 2,
|
||||||
|
"center_error_m": 1.2485281396559545e-07,
|
||||||
|
"rim_height_range_m": 0.0890375463968901,
|
||||||
|
"non_manifold_edges": 0,
|
||||||
|
"volume_m3": 0.0005133609813965412,
|
||||||
|
"linked_library_count": 0,
|
||||||
|
"missing_external_assets": [],
|
||||||
|
"machine_parts_excluded": true,
|
||||||
|
"depth_m": 0.171999990940094,
|
||||||
|
"source_depth_matches": true,
|
||||||
|
"front_shallow_collector": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"integrated_front_pull_passed": true,
|
||||||
|
"technical_checks_passed": true,
|
||||||
|
"passed": true
|
||||||
|
}
|
||||||
@@ -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')
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -0,0 +1,344 @@
|
|||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from mathutils import Vector
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
ROOT = OUT.parents[1]
|
||||||
|
ASSET = ROOT / "milk_2l"
|
||||||
|
SOURCE = ASSET / "PerfectCoffee_milk_2l.blend"
|
||||||
|
BLEND = ASSET / "PerfectCoffee_milk_2l_Packaged.blend"
|
||||||
|
GLB = BLEND.with_suffix(".glb")
|
||||||
|
TEXTURE = OUT / "milk_wrap.png"
|
||||||
|
LABEL_Z_MIN = 0.025
|
||||||
|
LABEL_Z_MAX = 0.115
|
||||||
|
LABEL_OFFSET = 0.00012
|
||||||
|
HANDLE_BOTTOM = 0.122
|
||||||
|
|
||||||
|
|
||||||
|
def sha256(path):
|
||||||
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def mesh_objects():
|
||||||
|
return [obj for obj in bpy.context.scene.objects if obj.type == "MESH" and not obj.name.startswith("Studio_")]
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_count(objects):
|
||||||
|
total = 0
|
||||||
|
for obj in objects:
|
||||||
|
obj.data.calc_loop_triangles()
|
||||||
|
total += len(obj.data.loop_triangles)
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
def clip_polygon(points, threshold, keep_above):
|
||||||
|
result = []
|
||||||
|
for first, second in zip(points, points[1:] + points[:1]):
|
||||||
|
first_inside = first.z >= threshold if keep_above else first.z <= threshold
|
||||||
|
second_inside = second.z >= threshold if keep_above else second.z <= threshold
|
||||||
|
if first_inside:
|
||||||
|
result.append(first.copy())
|
||||||
|
if first_inside != second_inside:
|
||||||
|
amount = (threshold - first.z) / (second.z - first.z)
|
||||||
|
result.append(first.lerp(second, amount))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def cross_2d(origin, first, second):
|
||||||
|
return (first[0] - origin[0]) * (second[1] - origin[1]) - (first[1] - origin[1]) * (second[0] - origin[0])
|
||||||
|
|
||||||
|
|
||||||
|
def convex_hull(points):
|
||||||
|
points = sorted(set((round(point[0], 7), round(point[1], 7)) for point in points))
|
||||||
|
lower = []
|
||||||
|
for point in points:
|
||||||
|
while len(lower) >= 2 and cross_2d(lower[-2], lower[-1], point) <= 0:
|
||||||
|
lower.pop()
|
||||||
|
lower.append(point)
|
||||||
|
upper = []
|
||||||
|
for point in reversed(points):
|
||||||
|
while len(upper) >= 2 and cross_2d(upper[-2], upper[-1], point) <= 0:
|
||||||
|
upper.pop()
|
||||||
|
upper.append(point)
|
||||||
|
return lower[:-1] + upper[:-1]
|
||||||
|
|
||||||
|
|
||||||
|
def perimeter_mapping(points):
|
||||||
|
hull = convex_hull(points)
|
||||||
|
back_index = max(range(len(hull)), key=lambda i: (hull[i][1] + hull[(i + 1) % len(hull)][1]) / 2)
|
||||||
|
first = Vector(hull[back_index])
|
||||||
|
second = Vector(hull[(back_index + 1) % len(hull)])
|
||||||
|
start = (first + second) / 2
|
||||||
|
outline = [start] + [Vector(hull[i]) for i in range(back_index + 1, len(hull))]
|
||||||
|
outline += [Vector(hull[i]) for i in range(back_index + 1)] + [start]
|
||||||
|
lengths = [(second - first).length for first, second in zip(outline[:-1], outline[1:])]
|
||||||
|
total = sum(lengths)
|
||||||
|
|
||||||
|
def map_point(point):
|
||||||
|
point = Vector(point)
|
||||||
|
best_distance = None
|
||||||
|
best_length = 0.0
|
||||||
|
accumulated = 0.0
|
||||||
|
for first, second, length in zip(outline[:-1], outline[1:], lengths):
|
||||||
|
edge = second - first
|
||||||
|
amount = max(0.0, min(1.0, (point - first).dot(edge) / edge.length_squared))
|
||||||
|
nearest = first + amount * edge
|
||||||
|
distance = (point - nearest).length_squared
|
||||||
|
if best_distance is None or distance < best_distance:
|
||||||
|
best_distance = distance
|
||||||
|
best_length = accumulated + amount * length
|
||||||
|
accumulated += length
|
||||||
|
return best_length / total
|
||||||
|
|
||||||
|
return map_point, total
|
||||||
|
|
||||||
|
|
||||||
|
def create_label(body, root):
|
||||||
|
polygons = []
|
||||||
|
for polygon in body.data.polygons:
|
||||||
|
if abs(polygon.normal.z) > 0.1:
|
||||||
|
continue
|
||||||
|
if polygon.center.x * polygon.normal.x + polygon.center.y * polygon.normal.y <= 0:
|
||||||
|
continue
|
||||||
|
points = [body.data.vertices[index].co.copy() for index in polygon.vertices]
|
||||||
|
if max(point.z for point in points) < LABEL_Z_MIN or min(point.z for point in points) > LABEL_Z_MAX:
|
||||||
|
continue
|
||||||
|
clipped = clip_polygon(clip_polygon(points, LABEL_Z_MIN, True), LABEL_Z_MAX, False)
|
||||||
|
if len(clipped) >= 3:
|
||||||
|
polygons.append(clipped)
|
||||||
|
vertices = []
|
||||||
|
faces = []
|
||||||
|
vertex_map = {}
|
||||||
|
for polygon in polygons:
|
||||||
|
face = []
|
||||||
|
for point in polygon:
|
||||||
|
key = tuple(round(value, 7) for value in point)
|
||||||
|
if key not in vertex_map:
|
||||||
|
vertex_map[key] = len(vertices)
|
||||||
|
vertices.append(tuple(point))
|
||||||
|
face.append(vertex_map[key])
|
||||||
|
faces.append(tuple(face))
|
||||||
|
assert len(faces) >= 8, f"Unexpected milk label face count: {len(faces)}"
|
||||||
|
mesh = bpy.data.meshes.new("Milk_Label_Surface_Mesh")
|
||||||
|
mesh.from_pydata(vertices, [], faces)
|
||||||
|
mesh.update()
|
||||||
|
label = bpy.data.objects.new("Milk_Label_Surface", mesh)
|
||||||
|
bpy.data.collections["Model"].objects.link(label)
|
||||||
|
label.parent = root
|
||||||
|
map_point, perimeter = perimeter_mapping(vertices)
|
||||||
|
uv = mesh.uv_layers.new(name="UVMap_TightLabel")
|
||||||
|
for polygon in mesh.polygons:
|
||||||
|
values = []
|
||||||
|
for loop_index in polygon.loop_indices:
|
||||||
|
vertex = mesh.vertices[mesh.loops[loop_index].vertex_index].co
|
||||||
|
u = map_point((vertex.x, vertex.y))
|
||||||
|
v = (vertex.z - LABEL_Z_MIN) / (LABEL_Z_MAX - LABEL_Z_MIN)
|
||||||
|
values.append((loop_index, u, v))
|
||||||
|
if max(value[1] for value in values) - min(value[1] for value in values) > 0.5:
|
||||||
|
values = [(index, u + 1 if u < 0.5 else u, v) for index, u, v in values]
|
||||||
|
for loop_index, u, v in values:
|
||||||
|
uv.data[loop_index].uv = (u, v)
|
||||||
|
image = bpy.data.images.load(str(TEXTURE), check_existing=True)
|
||||||
|
image.name = "Milk_LowPoly_MeadowLabel"
|
||||||
|
image.colorspace_settings.name = "sRGB"
|
||||||
|
image.use_fake_user = True
|
||||||
|
image.pack()
|
||||||
|
material = bpy.data.materials.new("Milk_Label_Meadow")
|
||||||
|
material.use_nodes = True
|
||||||
|
material.use_backface_culling = False
|
||||||
|
shader = material.node_tree.nodes.get("Principled BSDF")
|
||||||
|
texture = material.node_tree.nodes.new("ShaderNodeTexImage")
|
||||||
|
texture.name = "Image Texture"
|
||||||
|
texture.image = image
|
||||||
|
texture.extension = "REPEAT"
|
||||||
|
texture.interpolation = "Linear"
|
||||||
|
shader.inputs["Roughness"].default_value = 0.66
|
||||||
|
material.node_tree.links.new(texture.outputs["Color"], shader.inputs["Base Color"])
|
||||||
|
material.node_tree.links.new(shader.outputs["BSDF"], material.node_tree.nodes["Material Output"].inputs["Surface"])
|
||||||
|
mesh.materials.append(material)
|
||||||
|
modifier = label.modifiers.new("Tight_To_Bottle", "SHRINKWRAP")
|
||||||
|
modifier.target = body
|
||||||
|
modifier.wrap_method = "NEAREST_SURFACEPOINT"
|
||||||
|
modifier.wrap_mode = "OUTSIDE_SURFACE"
|
||||||
|
modifier.offset = LABEL_OFFSET
|
||||||
|
label["label_surface_offset_m"] = LABEL_OFFSET
|
||||||
|
label["label_z_range_m"] = [LABEL_Z_MIN, LABEL_Z_MAX]
|
||||||
|
label["below_handle"] = True
|
||||||
|
label["texture_contains_percentage_claim"] = False
|
||||||
|
root["label_fit_method"] = "Surface-cut geometry with shrinkwrap to the actual milk bottle exterior"
|
||||||
|
return label, perimeter, len(polygons)
|
||||||
|
|
||||||
|
|
||||||
|
def surface_gaps(body, label):
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
|
tree = BVHTree.FromObject(body, depsgraph)
|
||||||
|
evaluated = label.evaluated_get(depsgraph)
|
||||||
|
mesh = evaluated.to_mesh()
|
||||||
|
inverse = body.matrix_world.inverted()
|
||||||
|
gaps = []
|
||||||
|
for vertex in mesh.vertices:
|
||||||
|
point = inverse @ (label.matrix_world @ vertex.co)
|
||||||
|
nearest, normal, _, _ = tree.find_nearest(point)
|
||||||
|
gaps.append((point - nearest).dot(normal))
|
||||||
|
evaluated.to_mesh_clear()
|
||||||
|
return [min(gaps) * 1000, max(gaps) * 1000]
|
||||||
|
|
||||||
|
|
||||||
|
def export_collection():
|
||||||
|
collection = bpy.data.collections["Model"]
|
||||||
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
for obj in collection.all_objects:
|
||||||
|
obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = bpy.data.objects["Milk_Label_Surface"]
|
||||||
|
bpy.ops.export_scene.gltf(
|
||||||
|
filepath=str(GLB), export_format="GLB", use_selection=True,
|
||||||
|
export_yup=True, export_apply=True, export_texcoords=True,
|
||||||
|
export_cameras=False, export_lights=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
source_hash = sha256(SOURCE)
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(SOURCE))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
assert {obj.name for obj in mesh_objects()} == {"Milk_Bottle_Body", "Milk_Cap"}
|
||||||
|
body = bpy.data.objects["Milk_Bottle_Body"]
|
||||||
|
root = bpy.data.objects["Milk2L_Root"]
|
||||||
|
cap = bpy.data.objects["Milk_Cap"]
|
||||||
|
assert triangle_count(mesh_objects()) == 906
|
||||||
|
assert cap.parent == bpy.data.objects["Milk_Cap_Pivot"]
|
||||||
|
reference_images = [image.name for image in bpy.data.images if image.name.startswith("REFERENCE_")]
|
||||||
|
for image in list(bpy.data.images):
|
||||||
|
if image.name in reference_images:
|
||||||
|
bpy.data.images.remove(image)
|
||||||
|
label, perimeter, source_face_count = create_label(body, root)
|
||||||
|
root.name = "Milk2L_Packaged_Root"
|
||||||
|
root["label_design"] = "Original low-poly dairy cow and meadow in a rounded arch, with a cream and navy text card"
|
||||||
|
root["label_artwork_origin"] = "Seedream 5.5 text-to-image illustration without image inputs; original SVG layout"
|
||||||
|
root["reference_usage"] = "General ivory, blue, sky and pasture inspiration only; no brand graphics or packaging layout reproduced"
|
||||||
|
root["seedream_prompt"] = "model_assets/labels/milk/seedream55_meadow_prompt.txt"
|
||||||
|
root["label_below_handle"] = True
|
||||||
|
root["percentage_purity_claims_present"] = False
|
||||||
|
source_triangles = triangle_count(mesh_objects())
|
||||||
|
assert source_triangles <= 1000
|
||||||
|
export_collection()
|
||||||
|
scene = bpy.context.scene
|
||||||
|
camera = scene.camera
|
||||||
|
camera.location = (0.20, -0.28, 0.18)
|
||||||
|
camera.rotation_euler = (Vector((0, 0, 0.14)) - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = 0.325
|
||||||
|
scene.render.filepath = str(ASSET / "preview_packaged.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
for name, position in (("front", (0, -0.55, 0.18)), ("back", (0, 0.55, 0.18)), ("fit", (0.20, -0.28, 0.16))):
|
||||||
|
camera.location = position
|
||||||
|
target = Vector((0, 0, 0.14 if name != "fit" else 0.075))
|
||||||
|
camera.rotation_euler = (target - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = 0.325 if name != "fit" else 0.205
|
||||||
|
scene.render.resolution_x = 900
|
||||||
|
scene.render.resolution_y = 900
|
||||||
|
scene.render.filepath = str(ASSET / f"preview_packaged_{name}.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
camera.location = (0.20, -0.28, 0.18)
|
||||||
|
camera.rotation_euler = (Vector((0, 0, 0.14)) - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = 0.325
|
||||||
|
scene.render.resolution_x = 720
|
||||||
|
scene.render.resolution_y = 720
|
||||||
|
scene.render.filepath = str(ASSET / "preview_packaged.png")
|
||||||
|
assert sha256(SOURCE) == source_hash
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(BLEND), compress=True)
|
||||||
|
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(BLEND))
|
||||||
|
body = bpy.data.objects["Milk_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["Milk_Label_Surface"]
|
||||||
|
native_triangles = triangle_count(mesh_objects())
|
||||||
|
native_gaps = surface_gaps(body, label)
|
||||||
|
native_texture = bpy.data.materials["Milk_Label_Meadow"].node_tree.nodes["Image Texture"]
|
||||||
|
native_alpha = bpy.data.materials["Milk_HDPE"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
native_ok = (
|
||||||
|
native_triangles == source_triangles and native_triangles <= 1000
|
||||||
|
and len(mesh_objects()) == 3
|
||||||
|
and len(body.data.polygons) == 682 and len(bpy.data.objects["Milk_Cap"].data.polygons) == 128
|
||||||
|
and abs(native_alpha - 1.0) < 0.00001
|
||||||
|
and bpy.data.objects["Milk_Cap"].parent == bpy.data.objects["Milk_Cap_Pivot"]
|
||||||
|
and label.modifiers["Tight_To_Bottle"].target == body
|
||||||
|
and bool(label.data.uv_layers)
|
||||||
|
and native_texture.image.name == "Milk_LowPoly_MeadowLabel"
|
||||||
|
and list(native_texture.image.size) == [3584, 768]
|
||||||
|
and native_texture.image.packed_file is not None
|
||||||
|
and bpy.data.images.get("REFERENCE_milk_2l_woolworths") is None
|
||||||
|
and max(native_gaps) <= 0.121 and min(native_gaps) > 0
|
||||||
|
and LABEL_Z_MAX < HANDLE_BOTTOM
|
||||||
|
)
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
bpy.ops.import_scene.gltf(filepath=str(GLB))
|
||||||
|
imported_objects = mesh_objects()
|
||||||
|
body = bpy.data.objects["Milk_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["Milk_Label_Surface"]
|
||||||
|
glb_triangles = triangle_count(imported_objects)
|
||||||
|
glb_gaps = surface_gaps(body, label)
|
||||||
|
glb_texture = bpy.data.materials["Milk_Label_Meadow"].node_tree.nodes["Image Texture"]
|
||||||
|
glb_alpha = bpy.data.materials["Milk_HDPE"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
glb_ok = (
|
||||||
|
glb_triangles == native_triangles and len(imported_objects) == 3
|
||||||
|
and abs(glb_alpha - 1.0) < 0.00001
|
||||||
|
and bool(label.data.uv_layers)
|
||||||
|
and glb_texture is not None and list(glb_texture.image.size) == [3584, 768]
|
||||||
|
and max(glb_gaps) <= 0.121 and min(glb_gaps) > 0
|
||||||
|
and bpy.data.objects["Milk_Cap"].parent is not None
|
||||||
|
)
|
||||||
|
assert native_ok and glb_ok, "Milk packaged label validation failed"
|
||||||
|
assert sha256(SOURCE) == source_hash
|
||||||
|
report = {
|
||||||
|
"asset": "Milk2L_Packaged_Root",
|
||||||
|
"source_model": "model_assets/milk_2l/PerfectCoffee_milk_2l.blend",
|
||||||
|
"source_unchanged": True,
|
||||||
|
"source_sha256": source_hash,
|
||||||
|
"design_id": "premade_milk_packaged_low_poly_meadow",
|
||||||
|
"release_role": "Packaged variant of the approved 2L milk bottle; original model retained separately",
|
||||||
|
"artwork": "Original low-poly dairy cow and meadow with ivory and navy SVG packaging",
|
||||||
|
"seedream_model": "seedream_5.5",
|
||||||
|
"seedream_node": "node_3090jfx4nz",
|
||||||
|
"seedream_resource": "1bc79bf5-fc06-4942-b349-a90b8b358f6c",
|
||||||
|
"seedream_reference_images_used": False,
|
||||||
|
"seedream_asset": "model_assets/labels/milk/seedream55_meadow.png",
|
||||||
|
"seedream_prompt": "model_assets/labels/milk/seedream55_meadow_prompt.txt",
|
||||||
|
"reference_usage": "Ivory and navy palette, sky and pasture subject only; no brand, barcode, nutrition panel or full-cream claim",
|
||||||
|
"brand_logo_present": False,
|
||||||
|
"percentage_purity_claim_present": False,
|
||||||
|
"reference_photo_packed": False,
|
||||||
|
"label_texture": "model_assets/labels/milk/milk_wrap.png",
|
||||||
|
"body_opacity": native_alpha,
|
||||||
|
"native_triangles": native_triangles,
|
||||||
|
"glb_triangles": glb_triangles,
|
||||||
|
"triangle_limit": 1000,
|
||||||
|
"cap_independent": True,
|
||||||
|
"cap_color": "blue",
|
||||||
|
"label_method": "Clipped bottle-surface mesh with shrinkwrap",
|
||||||
|
"label_z_range_m": [LABEL_Z_MIN, LABEL_Z_MAX],
|
||||||
|
"handle_bottom_z_m": HANDLE_BOTTOM,
|
||||||
|
"label_below_handle": True,
|
||||||
|
"label_nominal_offset_mm": LABEL_OFFSET * 1000,
|
||||||
|
"native_surface_gap_mm": native_gaps,
|
||||||
|
"glb_surface_gap_mm": glb_gaps,
|
||||||
|
"label_source_face_count": source_face_count,
|
||||||
|
"label_perimeter_m": perimeter,
|
||||||
|
"texture_dimensions": [3584, 768],
|
||||||
|
"native_reopen_passed": native_ok,
|
||||||
|
"glb_reimport_passed": glb_ok,
|
||||||
|
"technical_validation_passed": True,
|
||||||
|
"visual_review_passed": False,
|
||||||
|
"godot_validation_performed": False,
|
||||||
|
"passed": False,
|
||||||
|
"blend": BLEND.name,
|
||||||
|
"glb": GLB.name,
|
||||||
|
"preview": "preview_packaged.png",
|
||||||
|
"preview_front": "preview_packaged_front.png",
|
||||||
|
"preview_back": "preview_packaged_back.png",
|
||||||
|
"preview_fit": "preview_packaged_fit.png",
|
||||||
|
}
|
||||||
|
(ASSET / "validation_packaged.json").write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import base64
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
image = base64.b64encode((OUT / "seedream55_meadow.png").read_bytes()).decode("ascii")
|
||||||
|
|
||||||
|
|
||||||
|
def side_icon(x):
|
||||||
|
return f'''<g transform="translate({x} 354)">
|
||||||
|
<path d="M0 -74 L43 -8 L30 40 L0 60 L-30 40 L-43 -8 Z" fill="#2d5b79"/>
|
||||||
|
<path d="M0 -74 L0 60 L-30 40 L-43 -8 Z" fill="#497f98"/>
|
||||||
|
<path d="M0 -42 L22 -5 L12 24 L-9 32 L-21 5 Z" fill="#f8f8ed"/>
|
||||||
|
<path d="M-12 72 L12 72" stroke="#7f9f8a" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
</g>'''
|
||||||
|
|
||||||
|
|
||||||
|
scene_path = "M1250 224 Q1250 62 1412 62 L1762 62 Q1924 62 1924 224 L1924 662 L1250 662 Z"
|
||||||
|
parts = [f'''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="3584" height="768" viewBox="0 0 3584 768">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="milkSky" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#d4e7ef"/>
|
||||||
|
<stop offset="1" stop-color="#edf3ef"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="meadowTile"><path d="{scene_path}"/></clipPath>
|
||||||
|
</defs>
|
||||||
|
<rect width="3584" height="768" fill="#f6f6eb"/>
|
||||||
|
<path d="M0 0 L3584 0 L3584 92 C2860 144 2250 48 1630 114 C1020 170 560 80 0 136 Z" fill="url(#milkSky)"/>
|
||||||
|
<path d="M0 636 C640 590 1080 684 1630 640 C2240 590 2940 662 3584 606 L3584 684 L0 684 Z" fill="#e3ebde"/>
|
||||||
|
<path d="M0 692 C640 660 1160 720 1720 680 C2360 640 2940 712 3584 674 L3584 742 L0 742 Z" fill="#244f70"/>
|
||||||
|
<path d="M0 742 L3584 742" stroke="#7e9e88" stroke-width="10"/>
|
||||||
|
<path d="M0 758 L3584 758" stroke="#d4e7ef" stroke-width="5"/>
|
||||||
|
''']
|
||||||
|
for x in (0, 640, 2944, 3584):
|
||||||
|
parts.append(side_icon(x))
|
||||||
|
for x in (640, 2944):
|
||||||
|
parts.append(f'<text x="{x}" y="506" text-anchor="middle" font-family="Arial, sans-serif" font-size="27" font-weight="700" letter-spacing="5" fill="#244f70">MILK</text>')
|
||||||
|
parts.append(f'''
|
||||||
|
<path d="{scene_path}" fill="#d8e9ed" stroke="#244f70" stroke-width="7"/>
|
||||||
|
<image x="1250" y="62" width="674" height="600" preserveAspectRatio="xMidYMid slice" clip-path="url(#meadowTile)" xlink:href="data:image/png;base64,{image}"/>
|
||||||
|
<path d="{scene_path}" fill="none" stroke="#244f70" stroke-width="7"/>
|
||||||
|
<g transform="translate(80 0)">
|
||||||
|
<rect x="1798" y="150" width="412" height="484" rx="34" fill="#fbf8eb"/>
|
||||||
|
<path d="M1798 184 Q1798 150 1832 150 L1838 150 L1838 634 L1832 634 Q1798 634 1798 600 Z" fill="#2d5b79"/>
|
||||||
|
<path d="M1885 191 L1905 226 L1897 251 L1885 260 L1873 251 L1865 226 Z" fill="#7c9eaa"/>
|
||||||
|
<path d="M1885 191 L1885 260 L1873 251 L1865 226 Z" fill="#a9c2c7"/>
|
||||||
|
<text x="1870" y="342" font-family="Arial, sans-serif" font-size="80" font-weight="900" letter-spacing="3" fill="#244f70">MILK</text>
|
||||||
|
<path d="M1874 374 L2124 374" stroke="#9ab69b" stroke-width="4"/>
|
||||||
|
<rect x="1872" y="404" width="264" height="82" rx="41" fill="#2d5b79"/>
|
||||||
|
<text x="2004" y="460" text-anchor="middle" font-family="PingFang SC, Microsoft YaHei, sans-serif" font-size="47" font-weight="600" letter-spacing="8" fill="#fbf8eb">牛奶</text>
|
||||||
|
<text x="1874" y="572" font-family="Arial, sans-serif" font-size="37" font-weight="700" letter-spacing="4" fill="#244f70">2 L</text>
|
||||||
|
<path d="M2072 548 L2122 548 L2122 598 L2072 598 Z" fill="#a8bda2"/>
|
||||||
|
<path d="M2080 586 L2096 564 L2114 586" fill="none" stroke="#fbf8eb" stroke-width="5" stroke-linejoin="round"/>
|
||||||
|
</g>
|
||||||
|
</svg>''')
|
||||||
|
svg = "\n".join(parts)
|
||||||
|
for banned in ("woolworths", "full cream", "100%"):
|
||||||
|
assert banned not in svg.lower()
|
||||||
|
(OUT / "milk_wrap.svg").write_text(svg, encoding="utf-8")
|
||||||
|
subprocess.run(["sips", "-s", "format", "png", str(OUT / "milk_wrap.svg"), "--out", str(OUT / "milk_wrap.png")], check=True)
|
||||||
|
subprocess.run([
|
||||||
|
"ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-i", str(OUT / "milk_wrap.png"),
|
||||||
|
"-vf", "crop=1376:768:1000:0", "-frames:v", "1", str(OUT / "milk_front.png"),
|
||||||
|
], check=True)
|
||||||
|
print(OUT / "milk_wrap.png")
|
||||||
|
print(OUT / "milk_front.png")
|
||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 4.4 MiB |
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
为校园咖啡店题材的低多边形游戏绘制一幅原创牛奶包装主插画素材,画面只有插画,不要包装和文字。主体是一头侧身站立、头朝左的风格化奶牛,由清晰简洁的几何块面构成,奶白色身体配深蓝黑色不规则斑纹,比例自然、四足结构清楚,神态温和。奶牛站在一片起伏舒缓的鼠尾草绿色低多边形牧场上,远处有一到两座简洁的青山,天空是两朵小巧的浅蓝多边形云朵。整体采用二维扁平矢量与低多边形结合的风格,色块干净、轮廓清晰,以奶白、雾蓝、深蓝和柔和绿色为主,明亮自然、轻松友好,与低多边形橙树插画属于同一视觉系列。主体居中偏下,四周保留足够空白,背景为均匀的浅天空蓝,便于后期裁切和排版。不要真实包装、牛奶瓶、文字、字母、汉字、数字、商标、Logo、地图、营养表、条码、二维码或任何现有品牌元素;不要模仿任何现有商品包装的具体构图;不要写实摄影、复杂渐变、纸张纹理、投影或三维场景。
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"source_blend_sha256": "b21ac50c76a191ece61abb486a794f59ba0f59c69c003e074850e7f384098498",
|
||||||
|
"cap_file_hashes": {
|
||||||
|
"PerfectCoffee_orange_juice_2l_Cap.blend": "b6ef7541002077a5f71dc95e63a5380e1c9a37608468e4526a6d80655123fb23",
|
||||||
|
"PerfectCoffee_orange_juice_2l_Cap.glb": "6f1d380edc9dde6505265990389da757c07e094132e119f0a8a3e92cb597a83e"
|
||||||
|
},
|
||||||
|
"source_triangles": 960,
|
||||||
|
"source_vertices": 274,
|
||||||
|
"source_polygons": 288,
|
||||||
|
"cap_files_untouched": true,
|
||||||
|
"native_reopen_passed": true,
|
||||||
|
"glb_reimport_passed": true,
|
||||||
|
"native_triangles": 960,
|
||||||
|
"glb_triangles": 960,
|
||||||
|
"technical_validation_passed": true,
|
||||||
|
"visual_review_passed": true,
|
||||||
|
"passed": true,
|
||||||
|
"label_applied": false,
|
||||||
|
"label_removed_reason": "Poor visual fit to the bottle body",
|
||||||
|
"label_texture_files_retained": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,299 @@
|
|||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from mathutils import Vector
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
ROOT = OUT.parents[1]
|
||||||
|
ASSET = ROOT / "orange_juice_2l"
|
||||||
|
BLEND = ASSET / "PerfectCoffee_orange_juice_2l.blend"
|
||||||
|
GLB = ASSET / "PerfectCoffee_orange_juice_2l.glb"
|
||||||
|
TEXTURE = OUT / "orange_juice_wrap.png"
|
||||||
|
REPORT = ASSET / "validation.json"
|
||||||
|
STATE = OUT / "application_validation.json"
|
||||||
|
BODY = "OrangeJuice_Bottle_Body"
|
||||||
|
LABEL_MATERIAL = "OrangeJuice_Label"
|
||||||
|
LABEL_UV = "UVMap_Label"
|
||||||
|
Z_MIN, Z_MAX = 0.023, 0.113
|
||||||
|
|
||||||
|
|
||||||
|
def sha256(path):
|
||||||
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def mesh_objects():
|
||||||
|
return [obj for obj in bpy.context.scene.objects if obj.type == "MESH" and not obj.name.startswith("Studio_")]
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_count(objects):
|
||||||
|
total = 0
|
||||||
|
for obj in objects:
|
||||||
|
obj.data.calc_loop_triangles()
|
||||||
|
total += len(obj.data.loop_triangles)
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
def label_polygons(body):
|
||||||
|
return [
|
||||||
|
polygon for polygon in body.data.polygons
|
||||||
|
if all(Z_MIN - 0.00001 <= body.data.vertices[index].co.z <= Z_MAX + 0.00001
|
||||||
|
for index in polygon.vertices)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def apply_label():
|
||||||
|
assert "100%" not in (OUT / "orange_juice_wrap.svg").read_text()
|
||||||
|
initial = {
|
||||||
|
"source_blend_sha256": sha256(BLEND),
|
||||||
|
"cap_file_hashes": {
|
||||||
|
name: sha256(ASSET / name)
|
||||||
|
for name in ("PerfectCoffee_orange_juice_2l_Cap.blend", "PerfectCoffee_orange_juice_2l_Cap.glb")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
backup = OUT / "_work"
|
||||||
|
backup.mkdir(exist_ok=True)
|
||||||
|
if not (backup / "unlabeled.blend").exists():
|
||||||
|
shutil.copy2(BLEND, backup / "unlabeled.blend")
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(BLEND))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
body = bpy.data.objects[BODY]
|
||||||
|
initial["source_triangles"] = triangle_count(mesh_objects())
|
||||||
|
initial["source_vertices"] = len(body.data.vertices)
|
||||||
|
initial["source_polygons"] = len(body.data.polygons)
|
||||||
|
polygons = label_polygons(body)
|
||||||
|
assert len(polygons) == 64, f"Expected 64 outer-wall label faces, got {len(polygons)}"
|
||||||
|
uv = body.data.uv_layers.get(LABEL_UV) or body.data.uv_layers.new(name=LABEL_UV)
|
||||||
|
body.data.uv_layers.active = uv
|
||||||
|
for polygon in polygons:
|
||||||
|
coordinates = []
|
||||||
|
for loop_index in polygon.loop_indices:
|
||||||
|
vertex = body.data.vertices[body.data.loops[loop_index].vertex_index].co
|
||||||
|
u = (math.atan2(vertex.y, vertex.x) - math.pi / 2) / math.tau % 1.0
|
||||||
|
v = (vertex.z - Z_MIN) / (Z_MAX - Z_MIN)
|
||||||
|
coordinates.append((loop_index, u, v))
|
||||||
|
seam = max(value[1] for value in coordinates) - min(value[1] for value in coordinates) > 0.5
|
||||||
|
for loop_index, u, v in coordinates:
|
||||||
|
if seam and u < 0.5:
|
||||||
|
u += 1.0
|
||||||
|
uv.data[loop_index].uv = (u, v)
|
||||||
|
image = bpy.data.images.load(str(TEXTURE), check_existing=True)
|
||||||
|
image.name = "OrangeJuice_Wrap_NoPercentage"
|
||||||
|
image.colorspace_settings.name = "sRGB"
|
||||||
|
image.use_fake_user = True
|
||||||
|
image.pack()
|
||||||
|
mat = bpy.data.materials.get(LABEL_MATERIAL) or bpy.data.materials.new(LABEL_MATERIAL)
|
||||||
|
mat.use_nodes = True
|
||||||
|
mat.use_backface_culling = False
|
||||||
|
mat.node_tree.nodes.clear()
|
||||||
|
output = mat.node_tree.nodes.new("ShaderNodeOutputMaterial")
|
||||||
|
shader = mat.node_tree.nodes.new("ShaderNodeBsdfPrincipled")
|
||||||
|
texture = mat.node_tree.nodes.new("ShaderNodeTexImage")
|
||||||
|
texture.image = image
|
||||||
|
texture.interpolation = "Linear"
|
||||||
|
texture.extension = "REPEAT"
|
||||||
|
shader.inputs["Roughness"].default_value = 0.62
|
||||||
|
shader.inputs["Alpha"].default_value = 1.0
|
||||||
|
mat.node_tree.links.new(texture.outputs["Color"], shader.inputs["Base Color"])
|
||||||
|
mat.node_tree.links.new(shader.outputs["BSDF"], output.inputs["Surface"])
|
||||||
|
if LABEL_MATERIAL not in [slot.name for slot in body.data.materials]:
|
||||||
|
body.data.materials.append(mat)
|
||||||
|
material_index = [slot.name for slot in body.data.materials].index(LABEL_MATERIAL)
|
||||||
|
for polygon in polygons:
|
||||||
|
polygon.material_index = material_index
|
||||||
|
body["label_scope"] = "Outer straight wall only; original generic artwork without percentage claims"
|
||||||
|
body["label_z_range_m"] = [Z_MIN, Z_MAX]
|
||||||
|
body["label_seam"] = "Back (+Y); front label centered at -Y"
|
||||||
|
assert triangle_count(mesh_objects()) == initial["source_triangles"]
|
||||||
|
assert len(body.data.vertices) == initial["source_vertices"]
|
||||||
|
assert len(body.data.polygons) == initial["source_polygons"]
|
||||||
|
collection = bpy.data.collections["Model"]
|
||||||
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
for obj in collection.all_objects:
|
||||||
|
obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = body
|
||||||
|
bpy.ops.export_scene.gltf(
|
||||||
|
filepath=str(GLB), export_format="GLB", use_selection=True,
|
||||||
|
export_yup=True, export_apply=True, export_texcoords=True,
|
||||||
|
export_cameras=False, export_lights=False,
|
||||||
|
)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
scene.render.filepath = str(ASSET / "preview.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
pivot = bpy.data.objects["OrangeJuice_Cap_Pivot"]
|
||||||
|
location = pivot.location.copy()
|
||||||
|
pivot.location += Vector((0.045, 0, 0.055))
|
||||||
|
scene.render.filepath = str(ASSET / "preview_cap_removed.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
pivot.location = location
|
||||||
|
camera = scene.camera
|
||||||
|
camera_matrix = camera.matrix_world.copy()
|
||||||
|
camera_scale = camera.data.ortho_scale
|
||||||
|
resolution = (scene.render.resolution_x, scene.render.resolution_y)
|
||||||
|
for name, position in (("front", (0, -0.55, 0.18)), ("back", (0, 0.55, 0.18))):
|
||||||
|
camera.location = position
|
||||||
|
target = Vector((0, 0, 0.14))
|
||||||
|
camera.rotation_euler = (target - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = 0.325
|
||||||
|
scene.render.resolution_x = 900
|
||||||
|
scene.render.resolution_y = 900
|
||||||
|
scene.render.filepath = str(ASSET / f"preview_label_{name}.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
camera.matrix_world = camera_matrix
|
||||||
|
camera.data.ortho_scale = camera_scale
|
||||||
|
scene.render.resolution_x, scene.render.resolution_y = resolution
|
||||||
|
scene.render.filepath = str(ASSET / "preview.png")
|
||||||
|
assert sha256(BLEND) == initial["source_blend_sha256"], "Bottle changed on disk during label application; not saving"
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(BLEND), compress=True)
|
||||||
|
for name, old_hash in initial["cap_file_hashes"].items():
|
||||||
|
assert sha256(ASSET / name) == old_hash
|
||||||
|
initial["label_faces"] = len(polygons)
|
||||||
|
initial["label_triangle_increase"] = 0
|
||||||
|
initial["label_png_dimensions"] = [2048, 768]
|
||||||
|
initial["cap_files_untouched"] = True
|
||||||
|
STATE.write_text(json.dumps(initial, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
report = json.loads(REPORT.read_text())
|
||||||
|
report["visual_review_passed"] = False
|
||||||
|
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
|
||||||
|
|
||||||
|
def validate(visual_reviewed):
|
||||||
|
state = json.loads(STATE.read_text())
|
||||||
|
report = json.loads(REPORT.read_text())
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(BLEND))
|
||||||
|
body = bpy.data.objects[BODY]
|
||||||
|
native_triangles = triangle_count(mesh_objects())
|
||||||
|
native_faces = label_polygons(body)
|
||||||
|
label_uv = body.data.uv_layers.get(LABEL_UV)
|
||||||
|
uv_loops = sum(len(polygon.loop_indices) for polygon in native_faces)
|
||||||
|
native_texture = bpy.data.materials[LABEL_MATERIAL].node_tree.nodes.get("Image Texture")
|
||||||
|
native_ok = (
|
||||||
|
native_triangles == state["source_triangles"]
|
||||||
|
and len(body.data.vertices) == state["source_vertices"]
|
||||||
|
and len(body.data.polygons) == state["source_polygons"]
|
||||||
|
and len(native_faces) == 64
|
||||||
|
and uv_loops == 256
|
||||||
|
and label_uv is not None
|
||||||
|
and all(polygon.material_index < len(body.data.materials)
|
||||||
|
and body.data.materials[polygon.material_index].name == LABEL_MATERIAL
|
||||||
|
for polygon in native_faces)
|
||||||
|
and native_texture is not None
|
||||||
|
and list(native_texture.image.size) == [2048, 768]
|
||||||
|
and native_texture.image.packed_file is not None
|
||||||
|
)
|
||||||
|
for name, old_hash in state["cap_file_hashes"].items():
|
||||||
|
assert sha256(ASSET / name) == old_hash
|
||||||
|
for obj in list(bpy.context.scene.objects):
|
||||||
|
if not obj.name.startswith("Studio_"):
|
||||||
|
bpy.data.objects.remove(obj, do_unlink=True)
|
||||||
|
for mesh in list(bpy.data.meshes):
|
||||||
|
if mesh.users == 0:
|
||||||
|
bpy.data.meshes.remove(mesh)
|
||||||
|
for material in list(bpy.data.materials):
|
||||||
|
if material.users == 0:
|
||||||
|
bpy.data.materials.remove(material)
|
||||||
|
bpy.ops.import_scene.gltf(filepath=str(GLB))
|
||||||
|
imported_objects = mesh_objects()
|
||||||
|
glb_triangles = triangle_count(imported_objects)
|
||||||
|
imported_label_faces = 0
|
||||||
|
imported_label_uv = False
|
||||||
|
imported_texture_size = None
|
||||||
|
for obj in imported_objects:
|
||||||
|
for polygon in obj.data.polygons:
|
||||||
|
material = obj.data.materials[polygon.material_index]
|
||||||
|
if material and material.name == LABEL_MATERIAL:
|
||||||
|
imported_label_faces += 1
|
||||||
|
imported_label_uv = imported_label_uv or bool(obj.data.uv_layers)
|
||||||
|
for node in material.node_tree.nodes:
|
||||||
|
if node.type == "TEX_IMAGE" and node.image:
|
||||||
|
imported_texture_size = list(node.image.size)
|
||||||
|
glb_ok = (
|
||||||
|
glb_triangles == state["source_triangles"]
|
||||||
|
and imported_label_faces == 128
|
||||||
|
and imported_label_uv
|
||||||
|
and imported_texture_size == [2048, 768]
|
||||||
|
and not any(obj.name.startswith("Studio_") for obj in imported_objects)
|
||||||
|
)
|
||||||
|
if glb_ok:
|
||||||
|
scene = bpy.context.scene
|
||||||
|
camera = scene.camera
|
||||||
|
camera.location = (0, -0.55, 0.18)
|
||||||
|
camera.rotation_euler = (Vector((0, 0, 0.14)) - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = 0.325
|
||||||
|
scene.render.resolution_x = 900
|
||||||
|
scene.render.resolution_y = 900
|
||||||
|
scene.render.filepath = str(OUT / "preview_glb_front.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
technical_passed = native_ok and glb_ok
|
||||||
|
report.update({
|
||||||
|
"native_reopen_passed": native_ok,
|
||||||
|
"glb_reimport_passed": glb_ok,
|
||||||
|
"native_triangles": native_triangles,
|
||||||
|
"glb_triangles": glb_triangles,
|
||||||
|
"passed_triangle_budget": native_triangles <= 1000 and glb_triangles <= 1000,
|
||||||
|
"technical_validation_passed": technical_passed,
|
||||||
|
"generic_label_applied": True,
|
||||||
|
"brand_graphics": False,
|
||||||
|
"percentage_purity_claims_present": False,
|
||||||
|
"label_texture": "model_assets/labels/orange_juice/orange_juice_wrap.png",
|
||||||
|
"label_uv_faces": 64,
|
||||||
|
"label_uv_loops": uv_loops,
|
||||||
|
"label_triangle_increase": 0,
|
||||||
|
"label_texture_packed": True,
|
||||||
|
"glb_label_texture_verified": imported_texture_size == [2048, 768],
|
||||||
|
"no_image_textures_or_labels": False,
|
||||||
|
"cap_files_untouched_by_label_application": True,
|
||||||
|
})
|
||||||
|
report.pop("labels_or_brand_graphics", None)
|
||||||
|
if visual_reviewed:
|
||||||
|
report["visual_review_passed"] = True
|
||||||
|
report["visual_review_notes"] = (
|
||||||
|
"Original orange-tree wrap is centered on the front, with a clean rear seam, legible generic text, "
|
||||||
|
"no 100% claim and transparent PET retained above and below the label. Independent cap and bottle geometry unchanged."
|
||||||
|
)
|
||||||
|
report["passed"] = technical_passed and report.get("visual_review_passed", False)
|
||||||
|
REPORT.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
state.update({
|
||||||
|
"native_reopen_passed": native_ok,
|
||||||
|
"glb_reimport_passed": glb_ok,
|
||||||
|
"native_triangles": native_triangles,
|
||||||
|
"glb_triangles": glb_triangles,
|
||||||
|
"glb_label_faces": imported_label_faces,
|
||||||
|
"glb_label_triangles": imported_label_faces,
|
||||||
|
"glb_label_uv_verified": imported_label_uv,
|
||||||
|
"glb_texture_dimensions": imported_texture_size,
|
||||||
|
"technical_validation_passed": technical_passed,
|
||||||
|
"visual_review_passed": report.get("visual_review_passed", False),
|
||||||
|
"passed": report["passed"],
|
||||||
|
})
|
||||||
|
STATE.write_text(json.dumps(state, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
summary_path = ROOT / "low_poly_consumables_validation.json"
|
||||||
|
summary = json.loads(summary_path.read_text())
|
||||||
|
for asset in summary["assets"]:
|
||||||
|
if asset["directory"] == "orange_juice_2l":
|
||||||
|
asset.update({
|
||||||
|
"native_triangles": native_triangles,
|
||||||
|
"glb_triangles": glb_triangles,
|
||||||
|
"technical_validation_passed": technical_passed,
|
||||||
|
"visual_review_passed": report.get("visual_review_passed", False),
|
||||||
|
"passed": report["passed"],
|
||||||
|
})
|
||||||
|
summary["all_technical_checks_passed"] = all(asset["technical_validation_passed"] for asset in summary["assets"])
|
||||||
|
summary["all_visual_reviews_passed"] = all(asset["visual_review_passed"] for asset in summary["assets"])
|
||||||
|
summary_path.write_text(json.dumps(summary, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
assert technical_passed, "Orange label validation failed"
|
||||||
|
print(json.dumps(state, ensure_ascii=False, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--check", action="store_true")
|
||||||
|
parser.add_argument("--visual-reviewed", action="store_true")
|
||||||
|
args = parser.parse_args(sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
|
||||||
|
if not args.check:
|
||||||
|
apply_label()
|
||||||
|
validate(args.visual_reviewed)
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from mathutils import Vector
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
ROOT = OUT.parents[1]
|
||||||
|
ASSET = ROOT / "orange_juice_2l"
|
||||||
|
SOURCE = ASSET / "PerfectCoffee_orange_juice_2l_MilkJug_LabelTest.blend"
|
||||||
|
BLEND = ASSET / "PerfectCoffee_orange_juice_2l_MilkJug_OriginalLabel.blend"
|
||||||
|
GLB = BLEND.with_suffix(".glb")
|
||||||
|
TEXTURE = OUT / "orange_grove_wrap.png"
|
||||||
|
MATERIAL_NAME = "OrangeJuice_Label_Original"
|
||||||
|
IMAGE_NAME = "OrangeGrove_OriginalVector"
|
||||||
|
|
||||||
|
|
||||||
|
def sha256(path):
|
||||||
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def mesh_objects():
|
||||||
|
return [obj for obj in bpy.context.scene.objects if obj.type == "MESH" and not obj.name.startswith("Studio_")]
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_count(objects):
|
||||||
|
total = 0
|
||||||
|
for obj in objects:
|
||||||
|
obj.data.calc_loop_triangles()
|
||||||
|
total += len(obj.data.loop_triangles)
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
def surface_gaps(body, label):
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
|
tree = BVHTree.FromObject(body, depsgraph)
|
||||||
|
evaluated = label.evaluated_get(depsgraph)
|
||||||
|
mesh = evaluated.to_mesh()
|
||||||
|
inverse = body.matrix_world.inverted()
|
||||||
|
gaps = []
|
||||||
|
for vertex in mesh.vertices:
|
||||||
|
point = inverse @ (label.matrix_world @ vertex.co)
|
||||||
|
nearest, normal, _, _ = tree.find_nearest(point)
|
||||||
|
gaps.append((point - nearest).dot(normal))
|
||||||
|
evaluated.to_mesh_clear()
|
||||||
|
return [min(gaps) * 1000, max(gaps) * 1000]
|
||||||
|
|
||||||
|
|
||||||
|
source_hash = sha256(SOURCE)
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(SOURCE))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
root = bpy.data.objects["OrangeJuice2L_MilkJug_LabelTest_Root"]
|
||||||
|
source_triangles = triangle_count(mesh_objects())
|
||||||
|
material = bpy.data.materials["OrangeJuice_Label_Tight"]
|
||||||
|
material.name = MATERIAL_NAME
|
||||||
|
texture_node = material.node_tree.nodes["Image Texture"]
|
||||||
|
image = bpy.data.images.load(str(TEXTURE), check_existing=True)
|
||||||
|
image.name = IMAGE_NAME
|
||||||
|
image.colorspace_settings.name = "sRGB"
|
||||||
|
image.use_fake_user = True
|
||||||
|
image.pack()
|
||||||
|
texture_node.image = image
|
||||||
|
old_image = bpy.data.images.get("OrangeJuice_Wrap_Tight")
|
||||||
|
if old_image:
|
||||||
|
bpy.data.images.remove(old_image)
|
||||||
|
root.name = "OrangeJuice2L_MilkJug_OriginalLabel_Root"
|
||||||
|
root["label_design"] = "Original asymmetric geometric citrus tree with a separate right-hand text card"
|
||||||
|
root["label_artwork_origin"] = "Original vector composition; no brand logo and no reference-derived label raster"
|
||||||
|
root["label_fit_method"] = "Surface-cut geometry with shrinkwrap to the actual bottle exterior"
|
||||||
|
assert source_triangles == 970
|
||||||
|
assert triangle_count(mesh_objects()) == source_triangles
|
||||||
|
collection = bpy.data.collections["Model"]
|
||||||
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
for obj in collection.all_objects:
|
||||||
|
obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = label
|
||||||
|
bpy.ops.export_scene.gltf(
|
||||||
|
filepath=str(GLB), export_format="GLB", use_selection=True,
|
||||||
|
export_yup=True, export_apply=True, export_texcoords=True,
|
||||||
|
export_cameras=False, export_lights=False,
|
||||||
|
)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
camera = scene.camera
|
||||||
|
camera_matrix = camera.matrix_world.copy()
|
||||||
|
camera_scale = camera.data.ortho_scale
|
||||||
|
scene.render.filepath = str(ASSET / "preview_original_label.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
for name, position in (("front", (0, -0.55, 0.18)), ("back", (0, 0.55, 0.18)), ("fit", (0.20, -0.28, 0.16))):
|
||||||
|
camera.location = position
|
||||||
|
target = Vector((0, 0, 0.14 if name != "fit" else 0.075))
|
||||||
|
camera.rotation_euler = (target - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = 0.325 if name != "fit" else 0.205
|
||||||
|
scene.render.resolution_x = 900
|
||||||
|
scene.render.resolution_y = 900
|
||||||
|
scene.render.filepath = str(ASSET / f"preview_original_label_{name}.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
camera.matrix_world = camera_matrix
|
||||||
|
camera.data.ortho_scale = camera_scale
|
||||||
|
scene.render.resolution_x = 720
|
||||||
|
scene.render.resolution_y = 720
|
||||||
|
scene.render.filepath = str(ASSET / "preview_original_label.png")
|
||||||
|
assert sha256(SOURCE) == source_hash, "Source label-test model changed during original-label application"
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(BLEND), compress=True)
|
||||||
|
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(BLEND))
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
native_gaps = surface_gaps(body, label)
|
||||||
|
native_texture = bpy.data.materials[MATERIAL_NAME].node_tree.nodes["Image Texture"]
|
||||||
|
native_alpha = bpy.data.materials["OrangeJuice_PET_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
native_ok = (
|
||||||
|
triangle_count(mesh_objects()) == source_triangles
|
||||||
|
and abs(native_alpha - 0.15) < 0.00001
|
||||||
|
and native_texture.image.name == IMAGE_NAME
|
||||||
|
and list(native_texture.image.size) == [3584, 768]
|
||||||
|
and native_texture.image.packed_file is not None
|
||||||
|
and bpy.data.images.get("OrangeJuice_Wrap_Tight") is None
|
||||||
|
and max(native_gaps) <= 0.061 and min(native_gaps) > 0
|
||||||
|
and label.modifiers["Tight_To_Bottle"].target == body
|
||||||
|
)
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
bpy.ops.import_scene.gltf(filepath=str(GLB))
|
||||||
|
imported_objects = mesh_objects()
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
glb_gaps = surface_gaps(body, label)
|
||||||
|
glb_texture = bpy.data.materials[MATERIAL_NAME].node_tree.nodes["Image Texture"]
|
||||||
|
glb_alpha = bpy.data.materials["OrangeJuice_PET_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
glb_ok = (
|
||||||
|
triangle_count(imported_objects) == source_triangles
|
||||||
|
and abs(glb_alpha - 0.15) < 0.00001
|
||||||
|
and list(glb_texture.image.size) == [3584, 768]
|
||||||
|
and bool(label.data.uv_layers)
|
||||||
|
and bpy.data.images.get("OrangeJuice_Wrap_Tight") is None
|
||||||
|
and max(glb_gaps) <= 0.061 and min(glb_gaps) > 0
|
||||||
|
)
|
||||||
|
assert native_ok and glb_ok, "Original label validation failed"
|
||||||
|
report = {
|
||||||
|
"asset": "OrangeJuice2L_MilkJug_OriginalLabel_Root",
|
||||||
|
"source_model": "model_assets/orange_juice_2l/PerfectCoffee_orange_juice_2l_MilkJug_LabelTest.blend",
|
||||||
|
"source_unchanged": True,
|
||||||
|
"source_sha256": source_hash,
|
||||||
|
"artwork": "Original vector citrus grove with asymmetric geometric tree and right-hand text card",
|
||||||
|
"design_changes": [
|
||||||
|
"Asymmetric low-poly canopy and angled trunk replace the reference-like wreath tree",
|
||||||
|
"Text moves to a separate right-hand cream card",
|
||||||
|
"Oval frame and orange lower semicircle are removed",
|
||||||
|
"Mint-blue palette and diagonal background shapes create a distinct layout",
|
||||||
|
],
|
||||||
|
"brand_logo_present": False,
|
||||||
|
"percentage_purity_claim_present": False,
|
||||||
|
"previous_label_raster_packed": False,
|
||||||
|
"label_texture": "model_assets/labels/orange_juice/orange_grove_wrap.png",
|
||||||
|
"body_opacity": 0.15,
|
||||||
|
"interior_empty": True,
|
||||||
|
"native_triangles": source_triangles,
|
||||||
|
"glb_triangles": source_triangles,
|
||||||
|
"triangle_limit": 1000,
|
||||||
|
"native_surface_gap_mm": native_gaps,
|
||||||
|
"glb_surface_gap_mm": glb_gaps,
|
||||||
|
"label_below_handle": True,
|
||||||
|
"native_reopen_passed": native_ok,
|
||||||
|
"glb_reimport_passed": glb_ok,
|
||||||
|
"technical_validation_passed": True,
|
||||||
|
"visual_review_passed": False,
|
||||||
|
"passed": False,
|
||||||
|
"blend": BLEND.name,
|
||||||
|
"glb": GLB.name,
|
||||||
|
"preview": "preview_original_label.png",
|
||||||
|
"preview_front": "preview_original_label_front.png",
|
||||||
|
"preview_back": "preview_original_label_back.png",
|
||||||
|
"preview_fit": "preview_original_label_fit.png",
|
||||||
|
}
|
||||||
|
(ASSET / "validation_original_label.json").write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
from mathutils import Vector
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
ROOT = OUT.parents[1]
|
||||||
|
ASSET = ROOT / "orange_juice_2l"
|
||||||
|
SOURCE = ASSET / "PerfectCoffee_orange_juice_2l_MilkJug_OriginalLabel.blend"
|
||||||
|
BLEND = ASSET / "PerfectCoffee_orange_juice_2l_MilkJug_SeedreamLabel.blend"
|
||||||
|
GLB = BLEND.with_suffix(".glb")
|
||||||
|
TEXTURE = OUT / "orange_seedream_wrap.png"
|
||||||
|
MATERIAL_NAME = "OrangeJuice_Label_Seedream"
|
||||||
|
IMAGE_NAME = "OrangeJuice_SeedreamGroveLabel"
|
||||||
|
|
||||||
|
|
||||||
|
def sha256(path):
|
||||||
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def mesh_objects():
|
||||||
|
return [obj for obj in bpy.context.scene.objects if obj.type == "MESH" and not obj.name.startswith("Studio_")]
|
||||||
|
|
||||||
|
|
||||||
|
def triangle_count(objects):
|
||||||
|
total = 0
|
||||||
|
for obj in objects:
|
||||||
|
obj.data.calc_loop_triangles()
|
||||||
|
total += len(obj.data.loop_triangles)
|
||||||
|
return total
|
||||||
|
|
||||||
|
|
||||||
|
def surface_gaps(body, label):
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
depsgraph = bpy.context.evaluated_depsgraph_get()
|
||||||
|
tree = BVHTree.FromObject(body, depsgraph)
|
||||||
|
evaluated = label.evaluated_get(depsgraph)
|
||||||
|
mesh = evaluated.to_mesh()
|
||||||
|
inverse = body.matrix_world.inverted()
|
||||||
|
gaps = []
|
||||||
|
for vertex in mesh.vertices:
|
||||||
|
point = inverse @ (label.matrix_world @ vertex.co)
|
||||||
|
nearest, normal, _, _ = tree.find_nearest(point)
|
||||||
|
gaps.append((point - nearest).dot(normal))
|
||||||
|
evaluated.to_mesh_clear()
|
||||||
|
return [min(gaps) * 1000, max(gaps) * 1000]
|
||||||
|
|
||||||
|
|
||||||
|
source_hash = sha256(SOURCE)
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(SOURCE))
|
||||||
|
bpy.context.preferences.filepaths.save_version = 0
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
root = bpy.data.objects["OrangeJuice2L_MilkJug_OriginalLabel_Root"]
|
||||||
|
source_triangles = triangle_count(mesh_objects())
|
||||||
|
material = bpy.data.materials["OrangeJuice_Label_Original"]
|
||||||
|
material.name = MATERIAL_NAME
|
||||||
|
texture_node = material.node_tree.nodes["Image Texture"]
|
||||||
|
image = bpy.data.images.load(str(TEXTURE), check_existing=True)
|
||||||
|
image.name = IMAGE_NAME
|
||||||
|
image.colorspace_settings.name = "sRGB"
|
||||||
|
image.use_fake_user = True
|
||||||
|
image.pack()
|
||||||
|
texture_node.image = image
|
||||||
|
old_image = bpy.data.images.get("OrangeGrove_OriginalVector")
|
||||||
|
if old_image:
|
||||||
|
bpy.data.images.remove(old_image)
|
||||||
|
root.name = "OrangeJuice2L_MilkJug_SeedreamLabel_Root"
|
||||||
|
root["label_design"] = "Seedream geometric citrus tree in a hexagonal illustration tile with a right-hand text card"
|
||||||
|
root["label_artwork_origin"] = "Seedream 5.5 text-to-image asset without reference images; original SVG layout"
|
||||||
|
root["seedream_prompt"] = "model_assets/labels/orange_juice/seedream55_grove_prompt.txt"
|
||||||
|
assert source_triangles == 970
|
||||||
|
assert triangle_count(mesh_objects()) == source_triangles
|
||||||
|
collection = bpy.data.collections["Model"]
|
||||||
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
|
for obj in collection.all_objects:
|
||||||
|
obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active = label
|
||||||
|
bpy.ops.export_scene.gltf(
|
||||||
|
filepath=str(GLB), export_format="GLB", use_selection=True,
|
||||||
|
export_yup=True, export_apply=True, export_texcoords=True,
|
||||||
|
export_cameras=False, export_lights=False,
|
||||||
|
)
|
||||||
|
scene = bpy.context.scene
|
||||||
|
camera = scene.camera
|
||||||
|
camera_matrix = camera.matrix_world.copy()
|
||||||
|
camera_scale = camera.data.ortho_scale
|
||||||
|
scene.render.filepath = str(ASSET / "preview_seedream_label.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
for name, position in (("front", (0, -0.55, 0.18)), ("back", (0, 0.55, 0.18)), ("fit", (0.20, -0.28, 0.16))):
|
||||||
|
camera.location = position
|
||||||
|
target = Vector((0, 0, 0.14 if name != "fit" else 0.075))
|
||||||
|
camera.rotation_euler = (target - camera.location).to_track_quat("-Z", "Y").to_euler()
|
||||||
|
camera.data.ortho_scale = 0.325 if name != "fit" else 0.205
|
||||||
|
scene.render.resolution_x = 900
|
||||||
|
scene.render.resolution_y = 900
|
||||||
|
scene.render.filepath = str(ASSET / f"preview_seedream_label_{name}.png")
|
||||||
|
bpy.ops.render.render(write_still=True)
|
||||||
|
camera.matrix_world = camera_matrix
|
||||||
|
camera.data.ortho_scale = camera_scale
|
||||||
|
scene.render.resolution_x = 720
|
||||||
|
scene.render.resolution_y = 720
|
||||||
|
scene.render.filepath = str(ASSET / "preview_seedream_label.png")
|
||||||
|
assert sha256(SOURCE) == source_hash, "Source model changed during Seedream-label application"
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(BLEND), compress=True)
|
||||||
|
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(BLEND))
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
native_gaps = surface_gaps(body, label)
|
||||||
|
native_texture = bpy.data.materials[MATERIAL_NAME].node_tree.nodes["Image Texture"]
|
||||||
|
native_alpha = bpy.data.materials["OrangeJuice_PET_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
native_ok = (
|
||||||
|
triangle_count(mesh_objects()) == source_triangles
|
||||||
|
and abs(native_alpha - 0.15) < 0.00001
|
||||||
|
and native_texture.image.name == IMAGE_NAME
|
||||||
|
and list(native_texture.image.size) == [3584, 768]
|
||||||
|
and native_texture.image.packed_file is not None
|
||||||
|
and bpy.data.images.get("OrangeGrove_OriginalVector") is None
|
||||||
|
and max(native_gaps) <= 0.061 and min(native_gaps) > 0
|
||||||
|
and label.modifiers["Tight_To_Bottle"].target == body
|
||||||
|
)
|
||||||
|
bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||||
|
bpy.ops.import_scene.gltf(filepath=str(GLB))
|
||||||
|
imported_objects = mesh_objects()
|
||||||
|
body = bpy.data.objects["OrangeJuice_Bottle_Body"]
|
||||||
|
label = bpy.data.objects["OrangeJuice_Label_Surface"]
|
||||||
|
glb_gaps = surface_gaps(body, label)
|
||||||
|
glb_texture = bpy.data.materials[MATERIAL_NAME].node_tree.nodes["Image Texture"]
|
||||||
|
glb_alpha = bpy.data.materials["OrangeJuice_PET_Observe15"].node_tree.nodes["Principled BSDF"].inputs["Alpha"].default_value
|
||||||
|
glb_ok = (
|
||||||
|
triangle_count(imported_objects) == source_triangles
|
||||||
|
and abs(glb_alpha - 0.15) < 0.00001
|
||||||
|
and list(glb_texture.image.size) == [3584, 768]
|
||||||
|
and bool(label.data.uv_layers)
|
||||||
|
and bpy.data.images.get("OrangeGrove_OriginalVector") is None
|
||||||
|
and max(glb_gaps) <= 0.061 and min(glb_gaps) > 0
|
||||||
|
)
|
||||||
|
assert native_ok and glb_ok, "Seedream label validation failed"
|
||||||
|
report = {
|
||||||
|
"asset": "OrangeJuice2L_MilkJug_SeedreamLabel_Root",
|
||||||
|
"source_model": "model_assets/orange_juice_2l/PerfectCoffee_orange_juice_2l_MilkJug_OriginalLabel.blend",
|
||||||
|
"source_unchanged": True,
|
||||||
|
"source_sha256": source_hash,
|
||||||
|
"artwork": "Seedream 5.5 original geometric citrus tree in a hexagonal tile, with original SVG text layout",
|
||||||
|
"seedream_model": "seedream_5.5",
|
||||||
|
"seedream_reference_images_used": False,
|
||||||
|
"seedream_asset": "model_assets/labels/orange_juice/seedream55_grove.png",
|
||||||
|
"seedream_prompt": "model_assets/labels/orange_juice/seedream55_grove_prompt.txt",
|
||||||
|
"brand_logo_present": False,
|
||||||
|
"percentage_purity_claim_present": False,
|
||||||
|
"previous_label_raster_packed": False,
|
||||||
|
"label_texture": "model_assets/labels/orange_juice/orange_seedream_wrap.png",
|
||||||
|
"body_opacity": 0.15,
|
||||||
|
"interior_empty": True,
|
||||||
|
"native_triangles": source_triangles,
|
||||||
|
"glb_triangles": source_triangles,
|
||||||
|
"triangle_limit": 1000,
|
||||||
|
"native_surface_gap_mm": native_gaps,
|
||||||
|
"glb_surface_gap_mm": glb_gaps,
|
||||||
|
"label_below_handle": True,
|
||||||
|
"native_reopen_passed": native_ok,
|
||||||
|
"glb_reimport_passed": glb_ok,
|
||||||
|
"technical_validation_passed": True,
|
||||||
|
"visual_review_passed": False,
|
||||||
|
"passed": False,
|
||||||
|
"blend": BLEND.name,
|
||||||
|
"glb": GLB.name,
|
||||||
|
"preview": "preview_seedream_label.png",
|
||||||
|
"preview_front": "preview_seedream_label_front.png",
|
||||||
|
"preview_back": "preview_seedream_label_back.png",
|
||||||
|
"preview_fit": "preview_seedream_label_fit.png",
|
||||||
|
}
|
||||||
|
(ASSET / "validation_seedream_label.json").write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
|
||||||
|
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import base64
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
WIDTH, HEIGHT = 2048, 768
|
||||||
|
BLUE = "#07527b"
|
||||||
|
ORANGE = "#ed8208"
|
||||||
|
YELLOW = "#fff2a6"
|
||||||
|
|
||||||
|
|
||||||
|
def orange_icon(cx, cy, scale=1.0):
|
||||||
|
return f'''<g transform="translate({cx} {cy}) scale({scale})">
|
||||||
|
<path d="M 4 -29 C 17 -62 43 -68 65 -62 C 56 -37 33 -24 4 -29 Z" fill="#246d37"/>
|
||||||
|
<path d="M -2 -27 C -15 -51 -38 -55 -52 -45 C -41 -23 -20 -17 -2 -27 Z" fill="#9bbd3e"/>
|
||||||
|
<path d="M 0 -25 Q 9 -42 24 -51" fill="none" stroke="#326b32" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
<circle cx="0" cy="14" r="46" fill="#f28a09"/>
|
||||||
|
<path d="M -27 2 Q -8 -14 18 -5" fill="none" stroke="#f9ac22" stroke-width="6" stroke-linecap="round" opacity="0.65"/>
|
||||||
|
</g>'''
|
||||||
|
|
||||||
|
|
||||||
|
def text(x, y, value, size, fill=BLUE, weight=700, family="Arial, sans-serif", spacing=0):
|
||||||
|
return (f'<text x="{x}" y="{y}" text-anchor="middle" font-family="{family}" '
|
||||||
|
f'font-size="{size}" font-weight="{weight}" letter-spacing="{spacing}" fill="{fill}">{value}</text>')
|
||||||
|
|
||||||
|
|
||||||
|
base64_image = base64.b64encode((OUT / "decorative_base_cutout.png").read_bytes()).decode("ascii")
|
||||||
|
parts = [f'''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{WIDTH}" height="{HEIGHT}" viewBox="0 0 {WIDTH} {HEIGHT}">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#eaf9ff"/>
|
||||||
|
<stop offset="0.58" stop-color="#cceef7"/>
|
||||||
|
<stop offset="1" stop-color="#a7ddec"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect width="2048" height="768" fill="url(#sky)"/>
|
||||||
|
<rect width="2048" height="12" fill="{ORANGE}"/>
|
||||||
|
<rect y="716" width="2048" height="52" fill="{ORANGE}"/>
|
||||||
|
<path d="M0 701 Q256 681 512 701 T1024 701 T1536 701 T2048 701" fill="none" stroke="#f5a51b" stroke-width="5"/>
|
||||||
|
''']
|
||||||
|
for x in (0, WIDTH):
|
||||||
|
parts.append(orange_icon(x, 346, 1.1))
|
||||||
|
for x in (290, 1758):
|
||||||
|
parts.append(orange_icon(x, 245, 1.25))
|
||||||
|
parts.append(text(x, 385, "ORANGE", 24, weight=700, spacing=1.8))
|
||||||
|
parts.append(f'<image x="694" y="34" width="660" height="700" xlink:href="data:image/png;base64,{base64_image}"/>')
|
||||||
|
parts.extend([
|
||||||
|
text(1024, 309, "ORANGE", 65, weight=900, spacing=1),
|
||||||
|
text(1024, 380, "JUICE", 58, weight=900, spacing=4),
|
||||||
|
'<path d="M 957 402 L 1091 402" stroke="#ee8909" stroke-width="5" stroke-linecap="round"/>',
|
||||||
|
text(1024, 556, "FRESH & FRUITY", 17, fill=YELLOW, weight=700, spacing=2.5),
|
||||||
|
text(1024, 616, "鲜橙汁", 45, fill=YELLOW, weight=600, family="PingFang SC, Microsoft YaHei, sans-serif", spacing=4),
|
||||||
|
text(1024, 669, "2 L", 28, fill=YELLOW, weight=700, spacing=3),
|
||||||
|
'</svg>',
|
||||||
|
])
|
||||||
|
svg_path = OUT / "orange_juice_wrap.svg"
|
||||||
|
svg_path.write_text("\n".join(parts), encoding="utf-8")
|
||||||
|
subprocess.run(["sips", "-s", "format", "png", str(svg_path), "--out", str(OUT / "orange_juice_wrap.png")], check=True)
|
||||||
|
subprocess.run([
|
||||||
|
"ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-i", str(OUT / "orange_juice_wrap.png"),
|
||||||
|
"-vf", "crop=960:768:544:0", "-frames:v", "1", str(OUT / "orange_juice_front.png"),
|
||||||
|
], check=True)
|
||||||
|
print(OUT / "orange_juice_wrap.svg")
|
||||||
|
print(OUT / "orange_juice_wrap.png")
|
||||||
|
print(OUT / "orange_juice_front.png")
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
WIDTH, HEIGHT = 3584, 768
|
||||||
|
|
||||||
|
|
||||||
|
def side_icon(x):
|
||||||
|
return f'''<g transform="translate({x} 360)">
|
||||||
|
<path d="M 0 -62 L 46 -8 L 0 48 L -46 -8 Z" fill="#f28a19"/>
|
||||||
|
<path d="M 0 -48 C 8 -79 34 -89 57 -82 C 45 -57 23 -43 0 -48 Z" fill="#397c55"/>
|
||||||
|
<path d="M -3 -42 C -18 -66 -39 -66 -53 -55 C -38 -34 -20 -31 -3 -42 Z" fill="#91bd68"/>
|
||||||
|
<path d="M -16 -9 L 4 13" stroke="#ffd37c" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
</g>'''
|
||||||
|
|
||||||
|
|
||||||
|
parts = ['''<svg xmlns="http://www.w3.org/2000/svg" width="3584" height="768" viewBox="0 0 3584 768">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="mintSky" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#e5f7f3"/>
|
||||||
|
<stop offset="0.62" stop-color="#ccece9"/>
|
||||||
|
<stop offset="1" stop-color="#abd9dc"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect width="3584" height="768" fill="url(#mintSky)"/>
|
||||||
|
<path d="M0 102 C640 12 1050 192 1590 98 C2200 -10 2850 96 3584 28 L3584 0 L0 0 Z" fill="#f6faf1" opacity="0.75"/>
|
||||||
|
<path d="M0 668 C620 614 1030 722 1600 654 C2220 580 2860 712 3584 628" fill="none" stroke="#f8fcf7" stroke-width="38" opacity="0.65"/>
|
||||||
|
<path d="M0 732 L3584 732" stroke="#f28a19" stroke-width="12"/>
|
||||||
|
<path d="M0 744 L3584 744" stroke="#247763" stroke-width="4" opacity="0.55"/>
|
||||||
|
''']
|
||||||
|
for x in (0, 640, 2944, 3584):
|
||||||
|
parts.append(side_icon(x))
|
||||||
|
for x in (640, 2944):
|
||||||
|
parts.append(f'<text x="{x}" y="510" text-anchor="middle" font-family="Arial, sans-serif" font-size="25" font-weight="700" letter-spacing="3" fill="#17666a">ORANGE</text>')
|
||||||
|
parts.append('''
|
||||||
|
<g id="asymmetric-citrus-tree">
|
||||||
|
<path d="M1460 630 L1487 478 L1526 363 L1570 264" fill="none" stroke="#be7535" stroke-width="25" stroke-linecap="square" stroke-linejoin="bevel"/>
|
||||||
|
<path d="M1492 472 L1408 390 L1360 312 M1514 423 L1610 355 L1654 278" fill="none" stroke="#be7535" stroke-width="14" stroke-linecap="square"/>
|
||||||
|
<path d="M1290 330 L1350 205 L1450 175 L1510 260 L1450 360 L1350 400 Z" fill="#4b8b59"/>
|
||||||
|
<path d="M1490 248 L1570 145 L1668 195 L1705 300 L1615 352 L1530 330 Z" fill="#77ac62"/>
|
||||||
|
<path d="M1288 440 L1355 345 L1450 365 L1480 450 L1400 510 L1315 505 Z" fill="#86b96a"/>
|
||||||
|
<path d="M1530 380 L1620 320 L1700 375 L1675 470 L1580 470 Z" fill="#2f7450"/>
|
||||||
|
<path d="M1310 283 L1370 235 L1418 250 L1372 310 Z" fill="#2e744b" opacity="0.8"/>
|
||||||
|
<path d="M1540 235 L1590 177 L1622 216 L1582 275 Z" fill="#a0c875"/>
|
||||||
|
<path d="M1320 442 L1385 388 L1420 423 L1362 474 Z" fill="#a4c873"/>
|
||||||
|
<path d="M1580 401 L1632 355 L1670 384 L1628 436 Z" fill="#57955c"/>
|
||||||
|
<circle cx="1404" cy="281" r="39" fill="#f28a19"/>
|
||||||
|
<circle cx="1586" cy="258" r="43" fill="#ed7e12"/>
|
||||||
|
<circle cx="1480" cy="405" r="36" fill="#f3971d"/>
|
||||||
|
<path d="M1382 267 Q1396 250 1417 257" fill="none" stroke="#ffb63c" stroke-width="7" stroke-linecap="round"/>
|
||||||
|
<path d="M1568 239 Q1582 221 1603 232" fill="none" stroke="#ffb63c" stroke-width="7" stroke-linecap="round"/>
|
||||||
|
<path d="M1342 479 A42 42 0 0 1 1426 479 Z" fill="#f49a20"/>
|
||||||
|
<path d="M1350 476 A34 34 0 0 1 1418 476 Z" fill="#ffd580"/>
|
||||||
|
<path d="M1384 476 L1361 449 M1384 476 L1407 449 M1384 476 L1384 443" stroke="#fff2c2" stroke-width="4"/>
|
||||||
|
<path d="M1455 632 L1510 632" stroke="#a9602c" stroke-width="14" stroke-linecap="square"/>
|
||||||
|
</g>
|
||||||
|
<g id="right-aligned-label-copy">
|
||||||
|
<rect x="1760" y="154" width="430" height="480" rx="34" fill="#faf6e9"/>
|
||||||
|
<path d="M1760 188 Q1760 154 1794 154 L1794 634 L1794 634 Q1760 634 1760 600 Z" fill="#f28a19"/>
|
||||||
|
<text x="1822" y="229" font-family="Arial, sans-serif" font-size="24" font-weight="700" letter-spacing="6" fill="#3a806d">CITRUS</text>
|
||||||
|
<text x="1817" y="322" font-family="Arial, sans-serif" font-size="66" font-weight="900" fill="#0c5961">ORANGE</text>
|
||||||
|
<text x="1820" y="394" font-family="Arial, sans-serif" font-size="56" font-weight="800" letter-spacing="4" fill="#0c5961">JUICE</text>
|
||||||
|
<path d="M1822 423 L2105 423" stroke="#e4b35e" stroke-width="4"/>
|
||||||
|
<rect x="1820" y="451" width="304" height="75" rx="37" fill="#ed8a22"/>
|
||||||
|
<text x="1972" y="501" text-anchor="middle" font-family="PingFang SC, Microsoft YaHei, sans-serif" font-size="38" font-weight="600" letter-spacing="4" fill="#fff7df">鲜橙汁</text>
|
||||||
|
<text x="1822" y="585" font-family="Arial, sans-serif" font-size="31" font-weight="700" letter-spacing="3" fill="#0c5961">2 L</text>
|
||||||
|
<path d="M2050 562 L2090 562 L2090 602 L2050 602 Z" fill="#9fc7b0"/>
|
||||||
|
<path d="M2057 589 Q2070 570 2083 589" fill="none" stroke="#faf6e9" stroke-width="4"/>
|
||||||
|
</g>
|
||||||
|
</svg>''')
|
||||||
|
svg_path = OUT / "orange_grove_wrap.svg"
|
||||||
|
svg_path.write_text("\n".join(parts), encoding="utf-8")
|
||||||
|
assert "100%" not in svg_path.read_text()
|
||||||
|
assert "eastcoast" not in svg_path.read_text().lower()
|
||||||
|
subprocess.run(["sips", "-s", "format", "png", str(svg_path), "--out", str(OUT / "orange_grove_wrap.png")], check=True)
|
||||||
|
subprocess.run([
|
||||||
|
"ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-i", str(OUT / "orange_grove_wrap.png"),
|
||||||
|
"-vf", "crop=1376:768:1104:0", "-frames:v", "1", str(OUT / "orange_grove_front.png"),
|
||||||
|
], check=True)
|
||||||
|
print(OUT / "orange_grove_wrap.png")
|
||||||
|
print(OUT / "orange_grove_front.png")
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import base64
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
WIDTH, HEIGHT = 3584, 768
|
||||||
|
image = base64.b64encode((OUT / "seedream55_grove.png").read_bytes()).decode("ascii")
|
||||||
|
|
||||||
|
|
||||||
|
def side_icon(x):
|
||||||
|
return f'''<g transform="translate({x} 360)">
|
||||||
|
<path d="M 0 -62 L 46 -8 L 0 48 L -46 -8 Z" fill="#f28a19"/>
|
||||||
|
<path d="M 0 -48 C 8 -79 34 -89 57 -82 C 45 -57 23 -43 0 -48 Z" fill="#397c55"/>
|
||||||
|
<path d="M -3 -42 C -18 -66 -39 -66 -53 -55 C -38 -34 -20 -31 -3 -42 Z" fill="#91bd68"/>
|
||||||
|
<path d="M -16 -9 L 4 13" stroke="#ffd37c" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
</g>'''
|
||||||
|
|
||||||
|
|
||||||
|
parts = [f'''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="3584" height="768" viewBox="0 0 3584 768">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="mintSky" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#e5f7f3"/>
|
||||||
|
<stop offset="0.62" stop-color="#ccece9"/>
|
||||||
|
<stop offset="1" stop-color="#abd9dc"/>
|
||||||
|
</linearGradient>
|
||||||
|
<clipPath id="groveTile">
|
||||||
|
<path d="M1360 62 L1812 62 L1922 384 L1812 706 L1360 706 L1248 384 Z"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<rect width="3584" height="768" fill="url(#mintSky)"/>
|
||||||
|
<path d="M0 102 C640 12 1050 192 1590 98 C2200 -10 2850 96 3584 28 L3584 0 L0 0 Z" fill="#f6faf1" opacity="0.75"/>
|
||||||
|
<path d="M0 668 C620 614 1030 722 1600 654 C2220 580 2860 712 3584 628" fill="none" stroke="#f8fcf7" stroke-width="38" opacity="0.65"/>
|
||||||
|
<path d="M0 732 L3584 732" stroke="#f28a19" stroke-width="12"/>
|
||||||
|
<path d="M0 744 L3584 744" stroke="#247763" stroke-width="4" opacity="0.55"/>
|
||||||
|
''']
|
||||||
|
for x in (0, 640, 2944, 3584):
|
||||||
|
parts.append(side_icon(x))
|
||||||
|
for x in (640, 2944):
|
||||||
|
parts.append(f'<text x="{x}" y="510" text-anchor="middle" font-family="Arial, sans-serif" font-size="25" font-weight="700" letter-spacing="3" fill="#17666a">ORANGE</text>')
|
||||||
|
parts.append(f'''
|
||||||
|
<path d="M1360 62 L1812 62 L1922 384 L1812 706 L1360 706 L1248 384 Z" fill="#f7f5e9" stroke="#397c55" stroke-width="7"/>
|
||||||
|
<image x="1288" y="62" width="634" height="644" clip-path="url(#groveTile)" xlink:href="data:image/png;base64,{image}"/>
|
||||||
|
<path d="M1360 62 L1812 62 L1922 384 L1812 706 L1360 706 L1248 384 Z" fill="none" stroke="#397c55" stroke-width="7"/>
|
||||||
|
<g id="right-aligned-label-copy" transform="translate(180 0)">
|
||||||
|
<rect x="1760" y="154" width="430" height="480" rx="34" fill="#faf6e9"/>
|
||||||
|
<path d="M1760 188 Q1760 154 1794 154 L1794 634 L1794 634 Q1760 634 1760 600 Z" fill="#f28a19"/>
|
||||||
|
<text x="1822" y="229" font-family="Arial, sans-serif" font-size="24" font-weight="700" letter-spacing="6" fill="#3a806d">CITRUS</text>
|
||||||
|
<text x="1817" y="322" font-family="Arial, sans-serif" font-size="66" font-weight="900" fill="#0c5961">ORANGE</text>
|
||||||
|
<text x="1820" y="394" font-family="Arial, sans-serif" font-size="56" font-weight="800" letter-spacing="4" fill="#0c5961">JUICE</text>
|
||||||
|
<path d="M1822 423 L2105 423" stroke="#e4b35e" stroke-width="4"/>
|
||||||
|
<rect x="1820" y="451" width="304" height="75" rx="37" fill="#ed8a22"/>
|
||||||
|
<text x="1972" y="501" text-anchor="middle" font-family="PingFang SC, Microsoft YaHei, sans-serif" font-size="38" font-weight="600" letter-spacing="4" fill="#fff7df">鲜橙汁</text>
|
||||||
|
<text x="1822" y="585" font-family="Arial, sans-serif" font-size="31" font-weight="700" letter-spacing="3" fill="#0c5961">2 L</text>
|
||||||
|
<path d="M2050 562 L2090 562 L2090 602 L2050 602 Z" fill="#9fc7b0"/>
|
||||||
|
<path d="M2057 589 Q2070 570 2083 589" fill="none" stroke="#faf6e9" stroke-width="4"/>
|
||||||
|
</g>
|
||||||
|
</svg>''')
|
||||||
|
svg_path = OUT / "orange_seedream_wrap.svg"
|
||||||
|
svg_path.write_text("\n".join(parts), encoding="utf-8")
|
||||||
|
assert "100%" not in svg_path.read_text()
|
||||||
|
assert "eastcoast" not in svg_path.read_text().lower()
|
||||||
|
subprocess.run(["sips", "-s", "format", "png", str(svg_path), "--out", str(OUT / "orange_seedream_wrap.png")], check=True)
|
||||||
|
subprocess.run([
|
||||||
|
"ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-i", str(OUT / "orange_seedream_wrap.png"),
|
||||||
|
"-vf", "crop=1376:768:1000:0", "-frames:v", "1", str(OUT / "orange_seedream_front.png"),
|
||||||
|
], check=True)
|
||||||
|
print(OUT / "orange_seedream_wrap.png")
|
||||||
|
print(OUT / "orange_seedream_front.png")
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import base64
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
OUT = Path(__file__).resolve().parent
|
||||||
|
WIDTH, HEIGHT = 3584, 768
|
||||||
|
source = (OUT / "orange_juice_wrap.png").read_bytes()
|
||||||
|
assert b"100%" not in (OUT / "orange_juice_wrap.svg").read_bytes()
|
||||||
|
encoded = base64.b64encode(source).decode("ascii")
|
||||||
|
|
||||||
|
|
||||||
|
def orange_icon(cx):
|
||||||
|
return f'''<g transform="translate({cx} 345) scale(1.1)">
|
||||||
|
<path d="M4 -29 C17 -62 43 -68 65 -62 C56 -37 33 -24 4 -29 Z" fill="#246d37"/>
|
||||||
|
<path d="M-2 -27 C-15 -51 -38 -55 -52 -45 C-41 -23 -20 -17 -2 -27 Z" fill="#9bbd3e"/>
|
||||||
|
<circle cx="0" cy="14" r="46" fill="#f28a09"/>
|
||||||
|
</g>'''
|
||||||
|
|
||||||
|
|
||||||
|
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="{WIDTH}" height="{HEIGHT}" viewBox="0 0 {WIDTH} {HEIGHT}">
|
||||||
|
<defs><linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#eaf9ff"/><stop offset="0.58" stop-color="#cceef7"/><stop offset="1" stop-color="#a7ddec"/>
|
||||||
|
</linearGradient></defs>
|
||||||
|
<rect width="3584" height="768" fill="url(#sky)"/>
|
||||||
|
<rect width="3584" height="12" fill="#ed8208"/><rect y="716" width="3584" height="52" fill="#ed8208"/>
|
||||||
|
<path d="M0 701 Q448 681 896 701 T1792 701 T2688 701 T3584 701" fill="none" stroke="#f5a51b" stroke-width="5"/>
|
||||||
|
{orange_icon(0)}{orange_icon(3584)}
|
||||||
|
{orange_icon(384)}{orange_icon(3200)}
|
||||||
|
<image x="768" y="0" width="2048" height="768" xlink:href="data:image/png;base64,{encoded}"/>
|
||||||
|
</svg>'''
|
||||||
|
svg_path = OUT / "orange_juice_wrap_wide.svg"
|
||||||
|
svg_path.write_text(svg, encoding="utf-8")
|
||||||
|
subprocess.run(["sips", "-s", "format", "png", str(svg_path), "--out", str(OUT / "orange_juice_wrap_wide.png")], check=True)
|
||||||
|
print(OUT / "orange_juice_wrap_wide.png")
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"jobKey": "perfect-coffee-original-orange-label",
|
||||||
|
"canvasId": "3cee1497-ce35-4c74-9d12-a6d09136c1a4",
|
||||||
|
"canvasUrl": "https://jimeng.jianying.com/ai-tool/ai-canvas/3cee1497-ce35-4c74-9d12-a6d09136c1a4",
|
||||||
|
"reference": {
|
||||||
|
"pageUrl": "https://eastcoastbeverages.com.au/products/orange-juice/",
|
||||||
|
"imageUrl": "https://eastcoastbeverages.com.au/wp-content/uploads/orange-juice.jpg",
|
||||||
|
"resourceId": "d3323f6f-2790-4c93-b759-3a7b5f41f40a",
|
||||||
|
"usage": "Composition and color reference only; original game label, no brand reproduction"
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"decorative-label-base": {
|
||||||
|
"nodeId": "node_8ad2hvmxjf",
|
||||||
|
"model": "seedream_5.5",
|
||||||
|
"ratio": "1:1",
|
||||||
|
"resolution": "2K",
|
||||||
|
"count": 1,
|
||||||
|
"textAddedSeparately": true,
|
||||||
|
"submitId": "304a3a66-eb79-4f09-b62b-73d425389d1b",
|
||||||
|
"operationRef": "304a3a66-eb79-4f09-b62b-73d425389d1b",
|
||||||
|
"selectedResourceId": "7ffc8922-7717-437d-8caf-0a68f2bb24ba",
|
||||||
|
"resourceState": "succeeded",
|
||||||
|
"sourceImageSize": [2048, 2048],
|
||||||
|
"download": "decorative_base.png",
|
||||||
|
"downloadSha256": "634a475cf29f3c42c284799f8c7cf84be09f659dcab3c53941cd18d0bf283c9e"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"deliverables": {
|
||||||
|
"wrapSvg": "orange_juice_wrap.svg",
|
||||||
|
"wrapPng": "orange_juice_wrap.png",
|
||||||
|
"frontPreview": "orange_juice_front.png",
|
||||||
|
"wideWrapSvg": "orange_juice_wrap_wide.svg",
|
||||||
|
"wideWrapPng": "orange_juice_wrap_wide.png",
|
||||||
|
"wideDimensions": [3584, 768],
|
||||||
|
"labelTestBlend": "model_assets/orange_juice_2l/PerfectCoffee_orange_juice_2l_MilkJug_LabelTest.blend",
|
||||||
|
"labelTestSurfaceGapMm": [0.04242360228090547, 0.060001304518664256],
|
||||||
|
"labelTestApplied": true,
|
||||||
|
"originalVectorVariant": {
|
||||||
|
"svg": "orange_grove_wrap.svg",
|
||||||
|
"png": "orange_grove_wrap.png",
|
||||||
|
"frontPreview": "orange_grove_front.png",
|
||||||
|
"blend": "model_assets/orange_juice_2l/PerfectCoffee_orange_juice_2l_MilkJug_OriginalLabel.blend",
|
||||||
|
"artworkSource": "New original vector geometry and layout; no reference image used for this variant",
|
||||||
|
"previousLabelRasterPacked": false,
|
||||||
|
"applied": true
|
||||||
|
},
|
||||||
|
"dimensions": [2048, 768],
|
||||||
|
"frontCenterU": 0.5,
|
||||||
|
"seamU": 0.0,
|
||||||
|
"editableElements": "Text, palette, background bands and layout in SVG; orange-tree artwork is raster",
|
||||||
|
"text": ["ORANGE", "JUICE", "FRESH & FRUITY", "鲜橙汁", "2 L"],
|
||||||
|
"removedClaims": ["100%"],
|
||||||
|
"brandLogoUsed": false,
|
||||||
|
"appliedToBottleOrUvModified": false,
|
||||||
|
"applicationScript": "apply_label.py",
|
||||||
|
"removalScript": "remove_label.py",
|
||||||
|
"applicationStatus": "Removed after bottle-fit review; source textures retained"
|
||||||
|
},
|
||||||
|
"modelFilesModified": {
|
||||||
|
"orange_juice": true,
|
||||||
|
"milk": false,
|
||||||
|
"milk_frother": false
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,76 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="3584" height="768" viewBox="0 0 3584 768">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="mintSky" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#e5f7f3"/>
|
||||||
|
<stop offset="0.62" stop-color="#ccece9"/>
|
||||||
|
<stop offset="1" stop-color="#abd9dc"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect width="3584" height="768" fill="url(#mintSky)"/>
|
||||||
|
<path d="M0 102 C640 12 1050 192 1590 98 C2200 -10 2850 96 3584 28 L3584 0 L0 0 Z" fill="#f6faf1" opacity="0.75"/>
|
||||||
|
<path d="M0 668 C620 614 1030 722 1600 654 C2220 580 2860 712 3584 628" fill="none" stroke="#f8fcf7" stroke-width="38" opacity="0.65"/>
|
||||||
|
<path d="M0 732 L3584 732" stroke="#f28a19" stroke-width="12"/>
|
||||||
|
<path d="M0 744 L3584 744" stroke="#247763" stroke-width="4" opacity="0.55"/>
|
||||||
|
|
||||||
|
<g transform="translate(0 360)">
|
||||||
|
<path d="M 0 -62 L 46 -8 L 0 48 L -46 -8 Z" fill="#f28a19"/>
|
||||||
|
<path d="M 0 -48 C 8 -79 34 -89 57 -82 C 45 -57 23 -43 0 -48 Z" fill="#397c55"/>
|
||||||
|
<path d="M -3 -42 C -18 -66 -39 -66 -53 -55 C -38 -34 -20 -31 -3 -42 Z" fill="#91bd68"/>
|
||||||
|
<path d="M -16 -9 L 4 13" stroke="#ffd37c" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
|
<g transform="translate(640 360)">
|
||||||
|
<path d="M 0 -62 L 46 -8 L 0 48 L -46 -8 Z" fill="#f28a19"/>
|
||||||
|
<path d="M 0 -48 C 8 -79 34 -89 57 -82 C 45 -57 23 -43 0 -48 Z" fill="#397c55"/>
|
||||||
|
<path d="M -3 -42 C -18 -66 -39 -66 -53 -55 C -38 -34 -20 -31 -3 -42 Z" fill="#91bd68"/>
|
||||||
|
<path d="M -16 -9 L 4 13" stroke="#ffd37c" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
|
<g transform="translate(2944 360)">
|
||||||
|
<path d="M 0 -62 L 46 -8 L 0 48 L -46 -8 Z" fill="#f28a19"/>
|
||||||
|
<path d="M 0 -48 C 8 -79 34 -89 57 -82 C 45 -57 23 -43 0 -48 Z" fill="#397c55"/>
|
||||||
|
<path d="M -3 -42 C -18 -66 -39 -66 -53 -55 C -38 -34 -20 -31 -3 -42 Z" fill="#91bd68"/>
|
||||||
|
<path d="M -16 -9 L 4 13" stroke="#ffd37c" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
|
<g transform="translate(3584 360)">
|
||||||
|
<path d="M 0 -62 L 46 -8 L 0 48 L -46 -8 Z" fill="#f28a19"/>
|
||||||
|
<path d="M 0 -48 C 8 -79 34 -89 57 -82 C 45 -57 23 -43 0 -48 Z" fill="#397c55"/>
|
||||||
|
<path d="M -3 -42 C -18 -66 -39 -66 -53 -55 C -38 -34 -20 -31 -3 -42 Z" fill="#91bd68"/>
|
||||||
|
<path d="M -16 -9 L 4 13" stroke="#ffd37c" stroke-width="5" stroke-linecap="round"/>
|
||||||
|
</g>
|
||||||
|
<text x="640" y="510" text-anchor="middle" font-family="Arial, sans-serif" font-size="25" font-weight="700" letter-spacing="3" fill="#17666a">ORANGE</text>
|
||||||
|
<text x="2944" y="510" text-anchor="middle" font-family="Arial, sans-serif" font-size="25" font-weight="700" letter-spacing="3" fill="#17666a">ORANGE</text>
|
||||||
|
|
||||||
|
<g id="asymmetric-citrus-tree">
|
||||||
|
<path d="M1460 630 L1487 478 L1526 363 L1570 264" fill="none" stroke="#be7535" stroke-width="25" stroke-linecap="square" stroke-linejoin="bevel"/>
|
||||||
|
<path d="M1492 472 L1408 390 L1360 312 M1514 423 L1610 355 L1654 278" fill="none" stroke="#be7535" stroke-width="14" stroke-linecap="square"/>
|
||||||
|
<path d="M1290 330 L1350 205 L1450 175 L1510 260 L1450 360 L1350 400 Z" fill="#4b8b59"/>
|
||||||
|
<path d="M1490 248 L1570 145 L1668 195 L1705 300 L1615 352 L1530 330 Z" fill="#77ac62"/>
|
||||||
|
<path d="M1288 440 L1355 345 L1450 365 L1480 450 L1400 510 L1315 505 Z" fill="#86b96a"/>
|
||||||
|
<path d="M1530 380 L1620 320 L1700 375 L1675 470 L1580 470 Z" fill="#2f7450"/>
|
||||||
|
<path d="M1310 283 L1370 235 L1418 250 L1372 310 Z" fill="#2e744b" opacity="0.8"/>
|
||||||
|
<path d="M1540 235 L1590 177 L1622 216 L1582 275 Z" fill="#a0c875"/>
|
||||||
|
<path d="M1320 442 L1385 388 L1420 423 L1362 474 Z" fill="#a4c873"/>
|
||||||
|
<path d="M1580 401 L1632 355 L1670 384 L1628 436 Z" fill="#57955c"/>
|
||||||
|
<circle cx="1404" cy="281" r="39" fill="#f28a19"/>
|
||||||
|
<circle cx="1586" cy="258" r="43" fill="#ed7e12"/>
|
||||||
|
<circle cx="1480" cy="405" r="36" fill="#f3971d"/>
|
||||||
|
<path d="M1382 267 Q1396 250 1417 257" fill="none" stroke="#ffb63c" stroke-width="7" stroke-linecap="round"/>
|
||||||
|
<path d="M1568 239 Q1582 221 1603 232" fill="none" stroke="#ffb63c" stroke-width="7" stroke-linecap="round"/>
|
||||||
|
<path d="M1342 479 A42 42 0 0 1 1426 479 Z" fill="#f49a20"/>
|
||||||
|
<path d="M1350 476 A34 34 0 0 1 1418 476 Z" fill="#ffd580"/>
|
||||||
|
<path d="M1384 476 L1361 449 M1384 476 L1407 449 M1384 476 L1384 443" stroke="#fff2c2" stroke-width="4"/>
|
||||||
|
<path d="M1455 632 L1510 632" stroke="#a9602c" stroke-width="14" stroke-linecap="square"/>
|
||||||
|
</g>
|
||||||
|
<g id="right-aligned-label-copy">
|
||||||
|
<rect x="1760" y="154" width="430" height="480" rx="34" fill="#faf6e9"/>
|
||||||
|
<path d="M1760 188 Q1760 154 1794 154 L1794 634 L1794 634 Q1760 634 1760 600 Z" fill="#f28a19"/>
|
||||||
|
<text x="1822" y="229" font-family="Arial, sans-serif" font-size="24" font-weight="700" letter-spacing="6" fill="#3a806d">CITRUS</text>
|
||||||
|
<text x="1817" y="322" font-family="Arial, sans-serif" font-size="66" font-weight="900" fill="#0c5961">ORANGE</text>
|
||||||
|
<text x="1820" y="394" font-family="Arial, sans-serif" font-size="56" font-weight="800" letter-spacing="4" fill="#0c5961">JUICE</text>
|
||||||
|
<path d="M1822 423 L2105 423" stroke="#e4b35e" stroke-width="4"/>
|
||||||
|
<rect x="1820" y="451" width="304" height="75" rx="37" fill="#ed8a22"/>
|
||||||
|
<text x="1972" y="501" text-anchor="middle" font-family="PingFang SC, Microsoft YaHei, sans-serif" font-size="38" font-weight="600" letter-spacing="4" fill="#fff7df">鲜橙汁</text>
|
||||||
|
<text x="1822" y="585" font-family="Arial, sans-serif" font-size="31" font-weight="700" letter-spacing="3" fill="#0c5961">2 L</text>
|
||||||
|
<path d="M2050 562 L2090 562 L2090 602 L2050 602 Z" fill="#9fc7b0"/>
|
||||||
|
<path d="M2057 589 Q2070 570 2083 589" fill="none" stroke="#faf6e9" stroke-width="4"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.4 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user