feat: add croissant cake and cream toast
This commit is contained in:
@@ -2,7 +2,6 @@ import bpy
|
||||
import bmesh
|
||||
import json
|
||||
import math
|
||||
import random
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from mathutils import Matrix, Vector
|
||||
@@ -11,7 +10,6 @@ ROOT = Path(__file__).resolve().parent
|
||||
REFERENCE = ROOT / "reference" / "consumables"
|
||||
MAX_TRIANGLES = 1000
|
||||
TAU = math.tau
|
||||
RNG = random.Random(41)
|
||||
MANIFEST = []
|
||||
|
||||
|
||||
@@ -522,126 +520,41 @@ def make_cake(collection, root):
|
||||
root["design_id"] = "cake_slice"
|
||||
|
||||
|
||||
def make_avocado_toast(collection, root):
|
||||
crust = material("Toast_Crust", (0.33, 0.12, 0.032), 0.82)
|
||||
crumb = material("Toast_Crumb", (0.76, 0.49, 0.20), 0.9)
|
||||
spread = material("Avocado_Spread", (0.23, 0.39, 0.047), 0.85)
|
||||
greens = [material(f"Avocado_Slice_{i}", color, 0.62) for i, color in enumerate([
|
||||
(0.48, 0.66, 0.12), (0.40, 0.58, 0.075), (0.57, 0.70, 0.18),
|
||||
])]
|
||||
pepper = material("Toast_Chili", (0.30, 0.045, 0.017), 0.8)
|
||||
outline = [(-0.049, -0.060), (0.049, -0.060), (0.055, -0.050), (0.054, 0.022),
|
||||
(0.052, 0.043), (0.038, 0.060), (0.019, 0.064), (0, 0.059),
|
||||
(-0.019, 0.064), (-0.038, 0.060), (-0.052, 0.043), (-0.054, 0.022),
|
||||
(-0.055, -0.050)]
|
||||
prism("Toast_Bread_Crust", outline, 0.001, 0.022, crust, collection, root)
|
||||
prism("Toast_Inner_Crumb", [(x * 0.90, y * 0.91) for x, y in outline], 0.0215, 0.0235, crumb, collection, root)
|
||||
prism("Toast_Avocado_Spread", [(x * 0.81, y * 0.83) for x, y in outline], 0.0235, 0.026, spread, collection, root)
|
||||
for i in range(7):
|
||||
cx, cy = -0.031 + i * 0.010, -0.017 + i * 0.005
|
||||
angle = -0.28
|
||||
raw = [(-0.006, -0.032), (0.007, -0.032), (0.011, -0.014), (0.012, 0.009),
|
||||
(0.008, 0.026), (0, 0.035), (-0.008, 0.026), (-0.012, 0.009), (-0.011, -0.014)]
|
||||
points = [(cx + x * math.cos(angle) - y * math.sin(angle),
|
||||
cy + x * math.sin(angle) + y * math.cos(angle)) for x, y in raw]
|
||||
prism(f"Toast_Avocado_Fan_{i + 1}", points, 0.026 + i * 0.00045, 0.0295 + i * 0.00045,
|
||||
greens[i % 3], collection, root)
|
||||
for i in range(12):
|
||||
x, y = RNG.uniform(-0.034, 0.035), RNG.uniform(-0.031, 0.031)
|
||||
size = RNG.uniform(0.0014, 0.0027)
|
||||
link_mesh(collection, root, f"Toast_Chili_Flake_{i + 1}", [
|
||||
(x - size, y, 0.034), (x, y + size * 0.65, 0.0345), (x + size, y - size * 0.3, 0.034),
|
||||
], [(0, 1, 2)], [pepper])
|
||||
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"
|
||||
|
||||
|
||||
def make_wrap(collection, root):
|
||||
tortilla = material("Wrap_Tortilla", (0.73, 0.51, 0.26), 0.8)
|
||||
edge = material("Wrap_TortillaEdge", (0.87, 0.68, 0.40), 0.82)
|
||||
lettuce = material("Wrap_Lettuce", (0.15, 0.34, 0.045), 0.8)
|
||||
chicken = material("Wrap_Chicken", (0.59, 0.30, 0.11), 0.75)
|
||||
tomato = material("Wrap_Tomato", (0.62, 0.065, 0.024), 0.58)
|
||||
onion = material("Wrap_Onion", (0.54, 0.20, 0.36), 0.7)
|
||||
segments = 16
|
||||
vertices, faces = [], []
|
||||
for x, radius in [(-0.065, 0.006), (-0.057, 0.028), (-0.040, 0.035), (0.035, 0.035), (0.057, 0.033)]:
|
||||
for j in range(segments):
|
||||
a = TAU * j / segments
|
||||
vertices.append((x, radius * math.cos(a), 0.036 + radius * 0.90 * math.sin(a)))
|
||||
for i in range(4):
|
||||
for j in range(segments):
|
||||
k = (j + 1) % segments
|
||||
faces.append((i * segments + j, i * segments + k, (i + 1) * segments + k, (i + 1) * segments + j))
|
||||
faces += [tuple(reversed(range(segments))), tuple(range(64, 80))]
|
||||
link_mesh(collection, root, "Wrap_Tortilla_Roll", vertices, faces, [tortilla], smooth=True)
|
||||
vertices = []
|
||||
for x, radius in [(0.0572, 0.033), (0.058, 0.029), (0.052, 0.029), (0.052, 0.032)]:
|
||||
for j in range(segments):
|
||||
a = TAU * j / segments
|
||||
vertices.append((x, radius * math.cos(a), 0.036 + radius * 0.90 * math.sin(a)))
|
||||
faces = []
|
||||
for i in range(3):
|
||||
for j in range(segments):
|
||||
k = (j + 1) % segments
|
||||
faces.append((i * segments + j, i * segments + k, (i + 1) * segments + k, (i + 1) * segments + j))
|
||||
link_mesh(collection, root, "Wrap_Cut_Tortilla_Rim", vertices, faces, [edge])
|
||||
ellipsoid("Wrap_Filling_Base", (0.053, 0, 0.036), (0.005, 0.028, 0.024), lettuce, collection, root)
|
||||
for i, (y, z) in enumerate([(-0.014, 0.024), (0.005, 0.021), (0.013, 0.040), (-0.004, 0.052)]):
|
||||
box(f"Wrap_Chicken_{i + 1}", (0.059, y, z), (0.012, 0.016, 0.010), chicken, collection, root, i * 0.65)
|
||||
for i, (y, z) in enumerate([(-0.013, 0.041), (0.008, 0.032), (0.001, 0.014)]):
|
||||
box(f"Wrap_Tomato_{i + 1}", (0.064, y, z), (0.009, 0.012, 0.010), tomato, collection, root, i)
|
||||
for i, (y, z) in enumerate([(-0.019, 0.053), (0.001, 0.058), (0.019, 0.052)]):
|
||||
tube(f"Wrap_Lettuce_Tip_{i + 1}", [(0.055, y * 0.65, z - 0.007), (0.064, y, z), (0.068, y * 1.13, z + 0.003)],
|
||||
0.0035, 4, lettuce, collection, root)
|
||||
tube("Wrap_Onion_Strip", [(0.067, -0.014, 0.032), (0.071, 0, 0.041), (0.067, 0.014, 0.050)], 0.0016, 4, onion, collection, root)
|
||||
root["design_id"] = "wrap"
|
||||
|
||||
|
||||
def leaf(name, center, length, width, angle, tilt, mat, collection, root):
|
||||
vertices = [(center[0], center[1], center[2] + 0.004)]
|
||||
count = 10
|
||||
for j in range(count):
|
||||
a = TAU * j / count
|
||||
x = width * math.cos(a) * (1 + 0.13 * math.cos(5 * a))
|
||||
y = length * math.sin(a)
|
||||
z = tilt * y + 0.004 * math.cos(3 * a)
|
||||
vertices.append((center[0] + x * math.cos(angle) - y * math.sin(angle),
|
||||
center[1] + x * math.sin(angle) + y * math.cos(angle), center[2] + z))
|
||||
faces = [(0, j + 1, (j + 1) % count + 1) for j in range(count)]
|
||||
return link_mesh(collection, root, name, vertices, faces, [mat])
|
||||
|
||||
|
||||
def make_salad(collection, root):
|
||||
bowl_mat = material("Salad_Bowl", (0.73, 0.78, 0.67), 0.4)
|
||||
greens = [material(f"Salad_Lettuce_{i}", color, 0.85) for i, color in enumerate([
|
||||
(0.16, 0.34, 0.035), (0.26, 0.46, 0.060), (0.36, 0.53, 0.09),
|
||||
])]
|
||||
tomato = material("Salad_Tomato", (0.68, 0.055, 0.026), 0.4)
|
||||
cucumber = material("Salad_CucumberSkin", (0.028, 0.16, 0.035), 0.65)
|
||||
cucumber_flesh = material("Salad_CucumberFlesh", (0.61, 0.73, 0.28), 0.7)
|
||||
carrot = material("Salad_Carrot", (0.90, 0.28, 0.026), 0.75)
|
||||
profile = [(0, 0.001), (0.025, 0.001), (0.033, 0.007), (0.048, 0.025),
|
||||
(0.068, 0.051), (0.075, 0.060), (0.076, 0.063), (0.071, 0.063),
|
||||
(0.068, 0.057), (0.044, 0.026), (0.026, 0.009), (0, 0.009)]
|
||||
loft("Salad_Bowl", profile, 20, bowl_mat, collection, root)
|
||||
for i in range(12):
|
||||
a = i * 2.4
|
||||
radius = 0.015 + 0.026 * (i % 3) / 2
|
||||
center = (radius * math.cos(a), radius * math.sin(a), 0.045 + 0.003 * (i % 4))
|
||||
leaf(f"Salad_Leaf_{i + 1}", center, 0.025 + RNG.random() * 0.009,
|
||||
0.015 + RNG.random() * 0.005, a, RNG.uniform(-0.25, 0.45), greens[i % 3], collection, root)
|
||||
for i, (x, y, z) in enumerate([(-0.032, -0.015, 0.060), (0.030, -0.012, 0.062), (0.004, 0.030, 0.065)]):
|
||||
ellipsoid(f"Salad_Cherry_Tomato_{i + 1}", (x, y, z), (0.012, 0.012, 0.011), tomato, collection, root)
|
||||
for i, (x, y, z) in enumerate([(-0.023, 0.017, 0.064), (0.022, 0.013, 0.069), (0.001, -0.025, 0.064)]):
|
||||
loft(f"Salad_Cucumber_Skin_{i + 1}", [(0, z - 0.002), (0.014, z - 0.002), (0.014, z), (0, z)],
|
||||
10, cucumber, collection, root).location = (x, y, 0)
|
||||
loft(f"Salad_Cucumber_Flesh_{i + 1}", [(0, z), (0.0115, z), (0.0115, z + 0.0004), (0, z + 0.0004)],
|
||||
10, cucumber_flesh, collection, root).location = (x, y, 0)
|
||||
for i in range(7):
|
||||
a = i * 2.1
|
||||
box(f"Salad_Carrot_{i + 1}", (0.033 * math.cos(a), 0.029 * math.sin(a), 0.065 + 0.002 * (i % 2)),
|
||||
(0.003, 0.028, 0.003), carrot, collection, root, a)
|
||||
root["design_id"] = "salad"
|
||||
root["presentation"] = "Plain toast with one pale-yellow cream layer; no avocado, chili or other toppings"
|
||||
|
||||
|
||||
def triangle_count(obj, depsgraph=None):
|
||||
@@ -716,6 +629,7 @@ def report_for(root, collection, out, blend, glb, cap=None):
|
||||
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",
|
||||
@@ -801,9 +715,7 @@ ASSETS = [
|
||||
("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", "avocado_toast.jpg", "AvocadoToast_Root"),
|
||||
("food/toast_and_wrap/Wrap", "wrap", "wrap.jpg", "Wrap_Root"),
|
||||
("food/salad/SaladBowl", "salad", "salad.jpg", "SaladBowl_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()
|
||||
@@ -821,11 +733,7 @@ for directory, kind, reference, root_name in ASSETS:
|
||||
elif kind == "cake":
|
||||
make_cake(collection, root)
|
||||
elif kind == "avocado_toast":
|
||||
make_avocado_toast(collection, root)
|
||||
elif kind == "wrap":
|
||||
make_wrap(collection, root)
|
||||
elif kind == "salad":
|
||||
make_salad(collection, root)
|
||||
make_cream_toast(collection, root)
|
||||
finalize(root, collection, directory, cap, cap_pivot)
|
||||
|
||||
if not requested_assets:
|
||||
|
||||
Reference in New Issue
Block a user