contour-to-mesh

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Contour to Mesh

轮廓转网格

Use this when a reference silhouette is the contract. The mesh starts as a filled 2D contour in front-view X/Z, then gets shallow Y depth/crown after validation.
当参考轮廓为硬性要求时使用此方法。网格最初是正视图X/Z平面内的填充2D轮廓,在验证后再添加浅Y轴深度/凸起。

Workflow

工作流程

  1. Extract or select a clean contour/mask for one structural part.
  2. Generate a triangulated mesh recipe with
    scripts/mask_to_mesh_recipe.py
    .
  3. Run the generated Blender Python to create a named
    GEO_*
    mesh.
  4. Assign front-projected UVs immediately.
  5. Add depth only as a modifier or vertex displacement that preserves X/Z boundary positions.
  6. Validate the front render against the source mask.
  1. 提取或选择单个结构部件的清晰轮廓/遮罩。
  2. 使用
    scripts/mask_to_mesh_recipe.py
    生成三角化网格生成脚本。
  3. 运行生成的Blender Python脚本,创建命名为
    GEO_*
    的网格。
  4. 立即分配正投影UV。
  5. 仅通过修改器或顶点位移添加深度,且需保留X/Z边界位置。
  6. 将正面渲染结果与源遮罩进行验证。

Hard rules

硬性规则

  • Do not use radial duplication unless the manifest says the source is symmetric.
  • Do not use a generic ellipse if a contour exists.
  • Boundary vertices must keep source X/Z coordinates.
  • Depth deformation may move Y and inner vertices, but must not alter front silhouette.
  • One structural source part should become one named structural mesh.
  • 除非明确说明源文件对称,否则不要使用径向复制。
  • 若存在轮廓,请勿使用通用椭圆。
  • 边界顶点必须保留源文件的X/Z坐标。
  • 深度变形可移动Y轴和内部顶点,但不得改变正面轮廓。
  • 单个结构源部件应对应一个命名的结构网格。

Blender pattern

Blender规范

Generated mesh coordinates should map image
x
to Blender
X
and image
y
to Blender
Z
with vertical flip. Use
Y
only for thickness/depth.
生成的网格坐标应将图像
x
映射到Blender
X
轴,图像
y
映射到Blender
Z
轴并进行垂直翻转。仅使用
Y
轴表示厚度/深度。

Front-plane rotation rule

正平面旋转规则

In this Blender coordinate convention, the front camera looks along the Y axis and the reference silhouette lives in the X/Z plane. Therefore 2D rotations inside the front view are rotations around the Y axis, not around Z. Use
rotation_euler = (0, angle, 0)
for 2D component orientation in the front projection. Z rotation spins objects into/out of screen-space incorrectly for X/Z-plane meshes.
在此Blender坐标约定中,正面相机沿Y轴方向拍摄,参考轮廓位于X/Z平面内。因此,正视图内的2D旋转是绕Y轴的旋转,而非绕Z轴。在正投影中调整2D组件方向时,使用
rotation_euler = (0, angle, 0)
。绕Z轴旋转会导致X/Z平面内的网格错误地旋入/旋出屏幕空间。

Sources distilled

核心技术来源

  • Blender Mesh API: create meshes from vertices/faces using
    from_pydata
    .
  • Blender BMesh: use for cleanup, triangulation, normals, smoothing.
  • OpenCV contours: detect and simplify boundaries.
  • Delaunay triangulation: useful for filled interior meshes when filtered by mask containment.
  • Blender Mesh API:使用
    from_pydata
    从顶点/面创建网格。
  • Blender BMesh:用于清理、三角化、法线处理和平滑操作。
  • OpenCV contours:检测并简化边界。
  • Delaunay triangulation:在通过遮罩范围过滤时,适用于填充内部网格。

Part-inventory handoff

部件清单交接

When masks come from
source-part-segmentation
, preserve the
part_inventory.json
names in Blender:
GEO_<part_name>
,
MAT_<part_name>
, and UV layer names. Mesh generation must record:
  • source image size;
  • source mask path;
  • contour boundary point count;
  • boundary landmark points (tip, base-left, base-right, centroid/extrema) when detectable;
  • atlas UV rectangle or projection mode.
For exact mascot/logo work, generate boundary vertices from the contour and add interior vertices only for surface support. The boundary is a contract: bevels, solidify, subdivision, shrinkwrap, or sculpt passes must not move front-view X/Z boundary vertices unless a new source mask is produced.
当遮罩来自
source-part-segmentation
时,需在Blender中保留
part_inventory.json
中的名称:
GEO_<part_name>
MAT_<part_name>
以及UV层名称。网格生成必须记录:
  • 源图像尺寸;
  • 源遮罩路径;
  • 轮廓边界点数量;
  • 可检测到的边界特征点(尖端、左基部、右基部、质心/极值点);
  • 图集UV矩形或投影模式。
对于精确的吉祥物/标志制作,从轮廓生成边界顶点,仅添加内部顶点以支撑曲面。 边界是硬性要求:除非生成新的源遮罩,否则倒角、实体化、细分、包裹或雕刻操作不得移动正视图X/Z边界顶点。

Hole and stroke policy

孔洞与描边规则

  • Filled structural masks become meshes.
  • Wireframe strokes guide boundaries/landmarks; they are not structural meshes unless the manifest classifies them as decorative linework.
  • Holes/negative regions should be kept as separate cut masks when they affect silhouette; otherwise implement them as decals/material masks.
  • 填充的结构遮罩将转为网格。
  • 线框描边用于引导边界/特征点;除非明确将其归类为装饰性线条,否则它们不属于结构网格。
  • 若孔洞/负区域影响轮廓,应将其保留为单独的切割遮罩;否则将其实现为贴花/材质遮罩。

Source-locked front-skin fallback

源锁定正面蒙皮 fallback

When a design sheet is painterly/stylized and separate orthographic views are not CAD-consistent, use a front-skin pass before sculptural interpretation:
  1. choose the canonical front/master source;
  2. extract the visible subject mask as a filled contour;
  3. create a shallow 2.5D mesh whose X/Z boundary is that contour;
  4. assign full-image front-projected UVs so the rendered front matches the source pixels;
  5. add depth only along Y and behind the front surface;
  6. optionally add separate relief/backing parts for side plausibility, but keep the front skin as the visual acceptance gate.
This is a generic fallback for logos/mascots where a faithful front read is more important than speculative volume. Mark it as
front_locked_visual_skin
, not as a fully solved turntable model.
当设计图为手绘/风格化且不同正交视图不符合CAD一致性时,在进行雕刻诠释前使用正面蒙皮流程:
  1. 选择标准正面/主源文件;
  2. 提取可见主体遮罩作为填充轮廓;
  3. 创建一个浅2.5D网格,其X/Z边界为该轮廓;
  4. 分配全图像正投影UV,使正面渲染结果与源像素匹配;
  5. 仅沿Y轴并在正面曲面后方添加深度;
  6. 可选择性添加单独的浮雕/背衬部件以保证侧面合理性,但需将正面蒙皮作为视觉验收标准。
这是标志/吉祥物制作的通用 fallback 方案,此时忠实还原正面视觉效果比推测体积更重要。将其标记为
front_locked_visual_skin
,而非完全可旋转的模型。

Script

脚本

  • scripts/source_locked_skin_recipe.py
    extracts a largest/canonical foreground component and emits a mask + contour mesh recipe using full-image front-projected UV coordinates.
  • scripts/source_locked_skin_recipe.py
    提取最大/标准前景组件,并使用全图像正投影UV坐标生成遮罩+轮廓网格生成脚本。