@wildshard/sdk 0.0.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GUIDE.md +790 -0
- package/README.md +14 -4
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +371 -4
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +46 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +247 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +18 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +234 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
"""Pine Hollow birds (round 16), step 1 per mesh: a generated bird → an oriented, sized, decimated low mesh with its own
|
|
2
|
+
0..1 UVs and a 1024² base colour baked from the generation (un-graded), plus the measurements the game animates by.
|
|
3
|
+
|
|
4
|
+
blender -b -P scripts/img2mesh/birds/birds_post.py -- --config scripts/img2mesh/birds/birds.json --out <dir> [--only raven_fly,…]
|
|
5
|
+
|
|
6
|
+
birds.json: { "<mesh>": { "src": glb, "rot": [rx,ry,rz] (Blender Euler XYZ°, after import), "pose": "perch"|"fly",
|
|
7
|
+
"fit": "length"|"span", "size": metres, "tris": budget, "flatten": bool (fly: wings to one horizontal plane),
|
|
8
|
+
"level": bool (fly: wing plane → horizontal), "span": m (fly: stretch the wings), "inflate": k (fly: thicken the body),
|
|
9
|
+
"remesh": voxel m (decimate a remeshed copy), "neck"/"headAxis"/"tailRoot"/"tailAxis" (glTF, hand-read pivots),
|
|
10
|
+
"minPart": share } }. Also writes <mesh>.pos.npy (the position bake, for birds_atlas.py's eye paint).
|
|
11
|
+
Blender frame while working: beak −Y, up +Z, right wing +X (= glTF / three: beak +Z, up +Y, right wing +X).
|
|
12
|
+
Writes <out>/<mesh>.low.glb (low mesh, tile-local UVs, baked image), <out>/<mesh>.png (1024² bake), <out>/<mesh>.json
|
|
13
|
+
(measurements in glTF/three coordinates, metres; the pack step re-measures after the atlas remap but keeps these).
|
|
14
|
+
"""
|
|
15
|
+
import argparse
|
|
16
|
+
import json
|
|
17
|
+
import math
|
|
18
|
+
import os
|
|
19
|
+
import sys
|
|
20
|
+
|
|
21
|
+
import bmesh
|
|
22
|
+
import bpy
|
|
23
|
+
import numpy as np
|
|
24
|
+
from mathutils import Euler, Matrix, Vector
|
|
25
|
+
|
|
26
|
+
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
|
27
|
+
ap = argparse.ArgumentParser()
|
|
28
|
+
ap.add_argument("--config", required=True)
|
|
29
|
+
ap.add_argument("--out", required=True)
|
|
30
|
+
ap.add_argument("--only", default="")
|
|
31
|
+
ap.add_argument("--bake", type=int, default=1024)
|
|
32
|
+
a = ap.parse_args(argv)
|
|
33
|
+
os.makedirs(a.out, exist_ok=True)
|
|
34
|
+
CFG = json.load(open(a.config))
|
|
35
|
+
only = [s for s in a.only.split(",") if s]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def g2(v):
|
|
39
|
+
"""Blender (x, y, z) → glTF/three (x, z, −y)"""
|
|
40
|
+
return [round(float(v[0]), 4), round(float(v[2]), 4), round(float(-v[1]), 4)]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def verts_np(o):
|
|
44
|
+
n = len(o.data.vertices)
|
|
45
|
+
arr = np.empty(n * 3, dtype=np.float64)
|
|
46
|
+
o.data.vertices.foreach_get("co", arr)
|
|
47
|
+
return arr.reshape(n, 3)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def set_verts(o, P):
|
|
51
|
+
o.data.vertices.foreach_set("co", P.astype(np.float64).ravel())
|
|
52
|
+
o.data.update()
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def drop_crumbs(o, share):
|
|
56
|
+
bm = bmesh.new()
|
|
57
|
+
bm.from_mesh(o.data)
|
|
58
|
+
bm.verts.ensure_lookup_table()
|
|
59
|
+
seen, parts = set(), []
|
|
60
|
+
for v in bm.verts:
|
|
61
|
+
if v.index in seen:
|
|
62
|
+
continue
|
|
63
|
+
stack, comp = [v], []
|
|
64
|
+
seen.add(v.index)
|
|
65
|
+
while stack:
|
|
66
|
+
x = stack.pop()
|
|
67
|
+
comp.append(x)
|
|
68
|
+
for e in x.link_edges:
|
|
69
|
+
y = e.other_vert(x)
|
|
70
|
+
if y.index not in seen:
|
|
71
|
+
seen.add(y.index)
|
|
72
|
+
stack.append(y)
|
|
73
|
+
parts.append(comp)
|
|
74
|
+
parts.sort(key=len, reverse=True)
|
|
75
|
+
kill = [v for p in parts[1:] if len(p) < share * len(parts[0]) for v in p]
|
|
76
|
+
if kill:
|
|
77
|
+
bmesh.ops.delete(bm, geom=kill, context="VERTS")
|
|
78
|
+
bm.to_mesh(o.data)
|
|
79
|
+
bm.free()
|
|
80
|
+
return len(parts), len(kill)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def tri_count(o):
|
|
84
|
+
return sum(len(p.vertices) - 2 for p in o.data.polygons)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def body_half_width(P, span):
|
|
88
|
+
"""fly: the |x| where the vertical thickness drops off the body into the wing"""
|
|
89
|
+
ax = np.abs(P[:, 0])
|
|
90
|
+
edges = np.linspace(0, ax.max(), 61)
|
|
91
|
+
th = []
|
|
92
|
+
for i in range(60):
|
|
93
|
+
m = (ax >= edges[i]) & (ax < edges[i + 1])
|
|
94
|
+
th.append(np.percentile(P[m, 2], 97) - np.percentile(P[m, 2], 3) if m.sum() > 8 else 0.0)
|
|
95
|
+
th = np.array(th)
|
|
96
|
+
t0 = th[:3].max()
|
|
97
|
+
for i in range(2, 60):
|
|
98
|
+
if th[i] < 0.42 * t0:
|
|
99
|
+
return float(edges[i]), th
|
|
100
|
+
return float(span * 0.1), th
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def flatten_wings(P, hw):
|
|
104
|
+
"""move every vertex outboard of the body by −(its wing's median height at that |x| − the root's): no droop, no dihedral"""
|
|
105
|
+
Q = P.copy()
|
|
106
|
+
for side in (-1, 1):
|
|
107
|
+
m = (P[:, 0] * side) > hw * 0.9
|
|
108
|
+
if m.sum() < 20:
|
|
109
|
+
continue
|
|
110
|
+
x = np.abs(P[m, 0])
|
|
111
|
+
edges = np.linspace(hw * 0.9, x.max() + 1e-6, 41)
|
|
112
|
+
mids, med = [], []
|
|
113
|
+
for i in range(40):
|
|
114
|
+
k = (x >= edges[i]) & (x < edges[i + 1])
|
|
115
|
+
if k.sum() >= 4:
|
|
116
|
+
mids.append((edges[i] + edges[i + 1]) / 2)
|
|
117
|
+
med.append(np.median(P[m, 2][k]))
|
|
118
|
+
mids, med = np.array(mids), np.array(med)
|
|
119
|
+
# a running median smooths the feather-tip noise
|
|
120
|
+
sm = np.array([np.median(med[max(0, i - 2):i + 3]) for i in range(len(med))])
|
|
121
|
+
base = sm[0]
|
|
122
|
+
off = np.interp(x, mids, sm) - base
|
|
123
|
+
ramp = np.clip((x - hw) / (hw * 0.35 + 1e-6), 0, 1)
|
|
124
|
+
Q[np.where(m)[0], 2] = P[m, 2] - off * ramp
|
|
125
|
+
return Q
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def slabs(P, a, n=50, rmax=1e9):
|
|
129
|
+
"""sections of P perpendicular to the unit axis `a` (in the YZ plane): s centres, thickness (in-plane ⊥), width (x), ⊥ centre"""
|
|
130
|
+
a = np.asarray(a, dtype=np.float64)
|
|
131
|
+
b = np.cross(a, [1.0, 0, 0]) # the in-plane perpendicular
|
|
132
|
+
s, q = P @ a, P @ b
|
|
133
|
+
keep = np.abs(q) < rmax # a cylinder about the axis: the legs / tail do not project into the head's sections
|
|
134
|
+
P, s, q = P[keep], s[keep], q[keep]
|
|
135
|
+
edges = np.linspace(0, s.max(), n + 1)
|
|
136
|
+
S, H, W, C = [], [], [], []
|
|
137
|
+
for i in range(n):
|
|
138
|
+
k = (s >= edges[i]) & (s < edges[i + 1])
|
|
139
|
+
S.append((edges[i] + edges[i + 1]) / 2)
|
|
140
|
+
if k.sum() >= 6:
|
|
141
|
+
H.append(np.percentile(q[k], 97) - np.percentile(q[k], 3))
|
|
142
|
+
W.append(np.percentile(P[k, 0], 97) - np.percentile(P[k, 0], 3))
|
|
143
|
+
C.append((np.percentile(q[k], 97) + np.percentile(q[k], 3)) / 2)
|
|
144
|
+
else:
|
|
145
|
+
H.append(0.0); W.append(0.0); C.append(0.0)
|
|
146
|
+
return np.array(S), np.array(H), np.array(W), np.array(C), b
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def unit(v):
|
|
150
|
+
v = np.array([0.0, v[1], v[2]])
|
|
151
|
+
return v / (np.linalg.norm(v) + 1e-12)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def measure(P, pose, hw, ov=None):
|
|
155
|
+
"""the game's pivots, from the high mesh (already centred on the body). Returns a dict in glTF coordinates."""
|
|
156
|
+
lo, hi = P.min(0), P.max(0)
|
|
157
|
+
body = P if pose == "perch" else P[np.abs(P[:, 0]) < hw]
|
|
158
|
+
beak = body[np.argmin(body[:, 1])]
|
|
159
|
+
tailtip = body[np.argmax(np.linalg.norm(body - beak, axis=1))]
|
|
160
|
+
ah = np.array([0.0, -1.0, 0.0]) if pose == "fly" else unit(beak)
|
|
161
|
+
at = np.array([0.0, 1.0, 0.0]) if pose == "fly" else unit(tailtip)
|
|
162
|
+
# head / neck: walking in from the beak tip, the first local maximum of the section (the head), then the minimum behind it
|
|
163
|
+
Lb = float(np.linalg.norm(tailtip - beak))
|
|
164
|
+
S, H, W, C, b = slabs(body, ah, rmax=0.2 * Lb if pose == "perch" else 1e9)
|
|
165
|
+
A = np.convolve(H * W, np.ones(3) / 3, mode="same")
|
|
166
|
+
n = len(S)
|
|
167
|
+
idx = list(range(n - 1, -1, -1)) # from the tip inwards
|
|
168
|
+
head_i = neck_i = None
|
|
169
|
+
for j in range(2, n - 2):
|
|
170
|
+
i = idx[j]
|
|
171
|
+
if A[i] >= A[i + 1] and A[i] >= A[i - 1] and A[i] > 0.15 * A.max():
|
|
172
|
+
head_i = i
|
|
173
|
+
break
|
|
174
|
+
if head_i is not None:
|
|
175
|
+
for i in range(head_i - 1, max(1, int(n * 0.2)), -1):
|
|
176
|
+
if A[i] <= A[i - 1] and A[i] <= A[i + 1]:
|
|
177
|
+
neck_i = i
|
|
178
|
+
break
|
|
179
|
+
if os.environ.get("BIRDS_DEBUG"):
|
|
180
|
+
print("S", np.round(S, 3).tolist(), "\nA", np.round(A * 1e4, 1).tolist(), "\nH", np.round(H, 3).tolist(), "head", head_i, "neck", neck_i, flush=True)
|
|
181
|
+
if head_i is None:
|
|
182
|
+
head_i = int(n * 0.8)
|
|
183
|
+
if neck_i is None or A[neck_i] > 0.9 * A[head_i]:
|
|
184
|
+
# no clear constriction (the owl's head sits in its shoulders): behind the head's widest section by half its size
|
|
185
|
+
ns = S[head_i] - 0.5 * H[head_i]
|
|
186
|
+
how = "head-max − 0.5·head size"
|
|
187
|
+
else:
|
|
188
|
+
ns = S[neck_i]
|
|
189
|
+
how = "section minimum"
|
|
190
|
+
j = int(np.clip(np.searchsorted(S, ns), 0, n - 1))
|
|
191
|
+
neck = ah * ns + b * C[j]
|
|
192
|
+
if ov and "neck" in ov: # the hand-read pivot (glTF) → Blender
|
|
193
|
+
neck = np.array([ov["neck"][0], -ov["neck"][2], ov["neck"][1]], dtype=np.float64)
|
|
194
|
+
# the tail root: in from the tail tip, the first section at least half the body's thickness
|
|
195
|
+
St, Ht, Wt, Ct, bt = slabs(body, at, rmax=0.2 * Lb if pose == "perch" else 1e9)
|
|
196
|
+
hmax = Ht.max()
|
|
197
|
+
ti = next((i for i in range(len(St) - 1, -1, -1) if Ht[i] > 0.5 * hmax), 0)
|
|
198
|
+
troot = at * St[ti] + bt * Ct[ti]
|
|
199
|
+
# shoulders
|
|
200
|
+
if pose == "fly":
|
|
201
|
+
sh = []
|
|
202
|
+
for sgn in (-1, 1):
|
|
203
|
+
k = (np.abs(P[:, 0] - sgn * hw) < max(hw * 0.12, 0.004))
|
|
204
|
+
zl, zt = np.percentile(P[k, 1], 3), np.percentile(P[k, 1], 97) # Blender −Y = forward: zl is the leading edge
|
|
205
|
+
sh.append([sgn * hw, float(zl + 0.25 * (zt - zl)), float(np.median(P[k, 2]))])
|
|
206
|
+
else:
|
|
207
|
+
# folded: the wing root on the upper flank, halfway from the body centre to the neck
|
|
208
|
+
p = neck * 0.5
|
|
209
|
+
k = np.linalg.norm(P[:, 1:] - p[1:], axis=1) < 0.06 * (hi[2] - lo[2])
|
|
210
|
+
xm = float(np.percentile(np.abs(P[k, 0]), 95)) if k.sum() > 8 else 0.05
|
|
211
|
+
sh = [[-xm * 0.8, p[1], p[2]], [xm * 0.8, p[1], p[2]]]
|
|
212
|
+
hw = xm
|
|
213
|
+
G = np.array([[v[0], v[2], -v[1]] for v in (lo, hi)])
|
|
214
|
+
return {
|
|
215
|
+
"bbox": {"min": [round(float(v), 4) for v in G.min(0)], "max": [round(float(v), 4) for v in G.max(0)]},
|
|
216
|
+
"shoulderL": g2(sh[0]), "shoulderR": g2(sh[1]),
|
|
217
|
+
"bodyHalfWidth": round(float(hw), 4),
|
|
218
|
+
"neck": g2(neck), "headZ": g2(neck)[2], "headY": g2(neck)[1], "headAxis": g2(ah),
|
|
219
|
+
"feetY": round(float(lo[2]), 4),
|
|
220
|
+
"tailRoot": g2(troot), "tailZ": g2(troot)[2], "tailAxis": g2(at),
|
|
221
|
+
"beakTip": g2(beak), "tailTip": g2(tailtip),
|
|
222
|
+
"neckHow": how,
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def mark_chart_seams(o, min_share):
|
|
227
|
+
"""few, large UV charts: faces grouped by their dominant axis (±X ±Y ±Z), connected, the small groups merged into
|
|
228
|
+
the neighbour they share the most border with; the chart borders become the seams"""
|
|
229
|
+
bm = bmesh.new()
|
|
230
|
+
bm.from_mesh(o.data)
|
|
231
|
+
bm.faces.ensure_lookup_table()
|
|
232
|
+
D = np.array([[1, 0, 0], [-1, 0, 0], [0, 1, 0], [0, -1, 0], [0, 0, 1], [0, 0, -1]], dtype=np.float64)
|
|
233
|
+
N = np.array([f.normal[:] for f in bm.faces])
|
|
234
|
+
lab = np.argmax(N @ D.T, 1)
|
|
235
|
+
nf = len(bm.faces)
|
|
236
|
+
nb = [[e.link_faces[1].index if e.link_faces[0].index == f.index else e.link_faces[0].index
|
|
237
|
+
for e in f.edges if len(e.link_faces) == 2] for f in bm.faces]
|
|
238
|
+
|
|
239
|
+
def comps():
|
|
240
|
+
cid = -np.ones(nf, dtype=int); k = 0
|
|
241
|
+
for i in range(nf):
|
|
242
|
+
if cid[i] >= 0:
|
|
243
|
+
continue
|
|
244
|
+
st = [i]; cid[i] = k
|
|
245
|
+
while st:
|
|
246
|
+
x = st.pop()
|
|
247
|
+
for y in nb[x]:
|
|
248
|
+
if cid[y] < 0 and lab[y] == lab[x]:
|
|
249
|
+
cid[y] = k; st.append(y)
|
|
250
|
+
k += 1
|
|
251
|
+
return cid, k
|
|
252
|
+
for _ in range(30):
|
|
253
|
+
cid, k = comps()
|
|
254
|
+
size = np.bincount(cid, minlength=k)
|
|
255
|
+
small = [q for q in np.argsort(size) if size[q] < min_share * nf]
|
|
256
|
+
if not small:
|
|
257
|
+
break
|
|
258
|
+
changed = False
|
|
259
|
+
for q in small:
|
|
260
|
+
faces = np.where(cid == q)[0]
|
|
261
|
+
border = {}
|
|
262
|
+
for x in faces:
|
|
263
|
+
for y in nb[x]:
|
|
264
|
+
if cid[y] != q:
|
|
265
|
+
border[cid[y]] = border.get(cid[y], 0) + 1
|
|
266
|
+
if border:
|
|
267
|
+
tgt = max(border, key=border.get)
|
|
268
|
+
lab[faces] = lab[np.where(cid == tgt)[0][0]]
|
|
269
|
+
cid[faces] = tgt
|
|
270
|
+
changed = True
|
|
271
|
+
if not changed:
|
|
272
|
+
break
|
|
273
|
+
cid, k = comps()
|
|
274
|
+
for e in bm.edges:
|
|
275
|
+
lf = e.link_faces
|
|
276
|
+
e.seam = bool(len(lf) != 2 or cid[lf[0].index] != cid[lf[1].index])
|
|
277
|
+
bm.to_mesh(o.data)
|
|
278
|
+
bm.free()
|
|
279
|
+
return k
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def bake_position(lo_o, name, size):
|
|
283
|
+
"""the low mesh's object-space position per texel (Blender frame) → <name>.pos.npy (H, W, 3) float16, image rows top-down"""
|
|
284
|
+
img = bpy.data.images.new(name + "_pos", size, size, alpha=False, float_buffer=True)
|
|
285
|
+
img.colorspace_settings.name = "Non-Color"
|
|
286
|
+
mat = bpy.data.materials.new(name + "_pos")
|
|
287
|
+
mat.use_nodes = True
|
|
288
|
+
nt = mat.node_tree
|
|
289
|
+
for nd in list(nt.nodes):
|
|
290
|
+
nt.nodes.remove(nd)
|
|
291
|
+
geo = nt.nodes.new("ShaderNodeNewGeometry")
|
|
292
|
+
em = nt.nodes.new("ShaderNodeEmission")
|
|
293
|
+
outn = nt.nodes.new("ShaderNodeOutputMaterial")
|
|
294
|
+
tex = nt.nodes.new("ShaderNodeTexImage")
|
|
295
|
+
tex.image = img
|
|
296
|
+
nt.links.new(geo.outputs["Position"], em.inputs["Color"])
|
|
297
|
+
nt.links.new(em.outputs["Emission"], outn.inputs["Surface"])
|
|
298
|
+
nt.nodes.active = tex
|
|
299
|
+
keep = list(lo_o.data.materials)
|
|
300
|
+
lo_o.data.materials.clear()
|
|
301
|
+
lo_o.data.materials.append(mat)
|
|
302
|
+
bpy.ops.object.select_all(action="DESELECT")
|
|
303
|
+
lo_o.select_set(True)
|
|
304
|
+
bpy.context.view_layer.objects.active = lo_o
|
|
305
|
+
bpy.ops.object.bake(type="EMIT", use_selected_to_active=False, margin=4, margin_type="EXTEND")
|
|
306
|
+
px = np.empty(size * size * 4, dtype=np.float32)
|
|
307
|
+
img.pixels.foreach_get(px)
|
|
308
|
+
np.save(os.path.join(a.out, name + ".pos.npy"), px.reshape(size, size, 4)[::-1, :, :3].astype(np.float16))
|
|
309
|
+
lo_o.data.materials.clear()
|
|
310
|
+
for m_ in keep:
|
|
311
|
+
lo_o.data.materials.append(m_)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def bake(hi_o, lo_o, name, size):
|
|
315
|
+
img = bpy.data.images.new(name + "_bake", size, size, alpha=False)
|
|
316
|
+
img.colorspace_settings.name = "sRGB"
|
|
317
|
+
mat = bpy.data.materials.new(name + "_lo")
|
|
318
|
+
mat.use_nodes = True
|
|
319
|
+
nt = mat.node_tree
|
|
320
|
+
bsdf = nt.nodes.get("Principled BSDF")
|
|
321
|
+
tex = nt.nodes.new("ShaderNodeTexImage")
|
|
322
|
+
tex.image = img
|
|
323
|
+
nt.links.new(tex.outputs["Color"], bsdf.inputs["Base Color"])
|
|
324
|
+
bsdf.inputs["Metallic"].default_value = 0.0
|
|
325
|
+
bsdf.inputs["Roughness"].default_value = 0.8
|
|
326
|
+
nt.nodes.active = tex
|
|
327
|
+
lo_o.data.materials.clear()
|
|
328
|
+
lo_o.data.materials.append(mat)
|
|
329
|
+
sc = bpy.context.scene
|
|
330
|
+
sc.render.engine = "CYCLES"
|
|
331
|
+
sc.cycles.device = "CPU"
|
|
332
|
+
sc.cycles.samples = 4
|
|
333
|
+
bpy.ops.object.select_all(action="DESELECT")
|
|
334
|
+
hi_o.select_set(True)
|
|
335
|
+
lo_o.select_set(True)
|
|
336
|
+
bpy.context.view_layer.objects.active = lo_o
|
|
337
|
+
d = max(lo_o.dimensions)
|
|
338
|
+
bpy.ops.object.bake(type="DIFFUSE", pass_filter={"COLOR"}, use_selected_to_active=True,
|
|
339
|
+
cage_extrusion=d * 0.02, max_ray_distance=d * 0.08, margin=24, margin_type="EXTEND")
|
|
340
|
+
path = os.path.join(a.out, name + ".png")
|
|
341
|
+
img.filepath_raw = path
|
|
342
|
+
img.file_format = "PNG"
|
|
343
|
+
img.save()
|
|
344
|
+
img.filepath = path
|
|
345
|
+
return path
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
for name, c in CFG.items():
|
|
349
|
+
if name.startswith("_") or (only and name not in only):
|
|
350
|
+
continue
|
|
351
|
+
print(f"\n==== {name}", flush=True)
|
|
352
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
353
|
+
bpy.ops.import_scene.gltf(filepath=os.path.expanduser(c["src"]))
|
|
354
|
+
meshes = [o for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
355
|
+
for o in meshes:
|
|
356
|
+
mw = o.matrix_world.copy()
|
|
357
|
+
o.parent = None
|
|
358
|
+
o.data.transform(mw)
|
|
359
|
+
o.matrix_world = Matrix.Identity(4)
|
|
360
|
+
bpy.ops.object.select_all(action="DESELECT")
|
|
361
|
+
for o in meshes:
|
|
362
|
+
o.select_set(True)
|
|
363
|
+
bpy.context.view_layer.objects.active = meshes[0]
|
|
364
|
+
if len(meshes) > 1:
|
|
365
|
+
bpy.ops.object.join()
|
|
366
|
+
hi_o = bpy.context.view_layer.objects.active
|
|
367
|
+
for o in list(bpy.context.scene.objects):
|
|
368
|
+
if o is not hi_o:
|
|
369
|
+
bpy.data.objects.remove(o)
|
|
370
|
+
hi_o.name = name + "_hi"
|
|
371
|
+
for m in hi_o.data.materials: # a generation's metallic 1 bakes to black
|
|
372
|
+
if m and m.use_nodes:
|
|
373
|
+
for nd in m.node_tree.nodes:
|
|
374
|
+
if nd.type == "BSDF_PRINCIPLED":
|
|
375
|
+
for l in list(nd.inputs["Metallic"].links):
|
|
376
|
+
m.node_tree.links.remove(l)
|
|
377
|
+
nd.inputs["Metallic"].default_value = 0.0
|
|
378
|
+
bm = bmesh.new(); bm.from_mesh(hi_o.data) # a painted generation is split along its UV seams: weld it first
|
|
379
|
+
nv = len(bm.verts)
|
|
380
|
+
bmesh.ops.remove_doubles(bm, verts=bm.verts, dist=1e-5 * max(hi_o.dimensions))
|
|
381
|
+
print(f"welded {nv} → {len(bm.verts)} verts", flush=True)
|
|
382
|
+
bm.to_mesh(hi_o.data); bm.free()
|
|
383
|
+
parts, killed = drop_crumbs(hi_o, c.get("minPart", 0.02))
|
|
384
|
+
print(f"parts {parts}, crumbs dropped {killed} verts", flush=True)
|
|
385
|
+
|
|
386
|
+
# orient, size
|
|
387
|
+
hi_o.data.transform(Euler([math.radians(v) for v in c.get("rot", [0, 0, 0])], "XYZ").to_matrix().to_4x4())
|
|
388
|
+
P = verts_np(hi_o)
|
|
389
|
+
if c.get("level"): # fly: turn about X so the wing plane (least-variance axis, wing verts) faces +Z
|
|
390
|
+
Q = P - P.mean(0)
|
|
391
|
+
wing = Q[np.abs(Q[:, 0]) > 0.25 * np.abs(Q[:, 0]).max()]
|
|
392
|
+
w, V = np.linalg.eigh(np.cov(wing.T))
|
|
393
|
+
nrm = V[:, 0] if V[2, 0] >= 0 else -V[:, 0]
|
|
394
|
+
ang = math.atan2(nrm[1], nrm[2]) + math.radians(c.get("pitch", 0.0)) # rotate by +ang about X: (y,z) → n on +Z
|
|
395
|
+
R = np.array(Euler((ang, 0, 0), "XYZ").to_matrix())
|
|
396
|
+
P = P @ R.T
|
|
397
|
+
print(f"level: wing normal {np.round(nrm, 3)} → turned {math.degrees(ang):.1f}° about X", flush=True)
|
|
398
|
+
P -= (P.min(0) + P.max(0)) / 2
|
|
399
|
+
dim = P.max(0) - P.min(0)
|
|
400
|
+
fit = c.get("fit", "length")
|
|
401
|
+
if fit == "tips": # beak tip (the most forward vertex, −Y) to the farthest vertex from it (the tail tip)
|
|
402
|
+
tip = P[np.argmin(P[:, 1])]
|
|
403
|
+
cur = float(np.linalg.norm(P - tip, axis=1).max())
|
|
404
|
+
else:
|
|
405
|
+
cur = {"length": dim[1], "span": dim[0], "height": dim[2]}[fit]
|
|
406
|
+
s = c["size"] / cur
|
|
407
|
+
P *= s
|
|
408
|
+
if c.get("span") and c["pose"] == "fly": # stretch the wings outboard of the body to the species' span
|
|
409
|
+
hw0, _ = body_half_width(P, P[:, 0].max() - P[:, 0].min())
|
|
410
|
+
half = (P[:, 0].max() - P[:, 0].min()) / 2
|
|
411
|
+
k = (c["span"] / 2 - hw0) / (half - hw0)
|
|
412
|
+
ax = np.abs(P[:, 0])
|
|
413
|
+
out = ax > hw0
|
|
414
|
+
P[out, 0] = np.sign(P[out, 0]) * (hw0 + (ax[out] - hw0) * k)
|
|
415
|
+
print(f"wings stretched ×{k:.3f} outboard of {hw0:.3f}", flush=True)
|
|
416
|
+
hw = None
|
|
417
|
+
if c["pose"] == "fly":
|
|
418
|
+
hw, th = body_half_width(P, P[:, 0].max() - P[:, 0].min())
|
|
419
|
+
print(f"body half-width {hw:.3f}", flush=True)
|
|
420
|
+
if c.get("flatten", True):
|
|
421
|
+
P = flatten_wings(P, hw)
|
|
422
|
+
if c.get("inflate"): # a top-view generation is a bas-relief: thicken the body (and head) about its mid-plane
|
|
423
|
+
ax = np.abs(P[:, 0])
|
|
424
|
+
w = np.clip((hw * 1.4 - ax) / (hw * 0.6), 0, 1)
|
|
425
|
+
zm = float(np.median(P[ax < hw, 2]))
|
|
426
|
+
P[:, 2] = zm + (P[:, 2] - zm) * (1 + (c["inflate"] - 1) * w)
|
|
427
|
+
print(f"body inflated ×{c['inflate']} about z={zm:.3f}", flush=True)
|
|
428
|
+
# centre: the body's centroid (fly: inside the body half-width; perch: above the legs), x on the mirror plane
|
|
429
|
+
if c["pose"] == "fly":
|
|
430
|
+
B = P[np.abs(P[:, 0]) < hw]
|
|
431
|
+
else:
|
|
432
|
+
B = P[P[:, 2] > P[:, 2].min() + 0.3 * (P[:, 2].max() - P[:, 2].min())]
|
|
433
|
+
ctr = B.mean(0)
|
|
434
|
+
ctr[0] = (P[:, 0].min() + P[:, 0].max()) / 2
|
|
435
|
+
P -= ctr
|
|
436
|
+
set_verts(hi_o, P)
|
|
437
|
+
|
|
438
|
+
# the low mesh: collapse to the budget
|
|
439
|
+
lo_o = hi_o.copy()
|
|
440
|
+
lo_o.data = hi_o.data.copy()
|
|
441
|
+
lo_o.name = name
|
|
442
|
+
bpy.context.scene.collection.objects.link(lo_o)
|
|
443
|
+
if c.get("remesh"): # a generation too torn for the collapse: decimate a voxel-remeshed copy (the bake still reads hi)
|
|
444
|
+
rm = lo_o.modifiers.new("rm", "REMESH")
|
|
445
|
+
rm.mode = "VOXEL"
|
|
446
|
+
rm.voxel_size = c["remesh"]
|
|
447
|
+
rm.adaptivity = 0.0
|
|
448
|
+
dg = bpy.context.evaluated_depsgraph_get()
|
|
449
|
+
me_r = bpy.data.meshes.new_from_object(lo_o.evaluated_get(dg))
|
|
450
|
+
lo_o.modifiers.remove(rm)
|
|
451
|
+
lo_o.data = me_r
|
|
452
|
+
print(f"remeshed at {c['remesh']} m → {tri_count(lo_o)} tris", flush=True)
|
|
453
|
+
src_me = lo_o.data
|
|
454
|
+
target = c["tris"]
|
|
455
|
+
ratio = target / max(1, tri_count(lo_o))
|
|
456
|
+
for it in range(6):
|
|
457
|
+
mod = lo_o.modifiers.new("dec", "DECIMATE")
|
|
458
|
+
mod.decimate_type = "COLLAPSE"
|
|
459
|
+
mod.ratio = min(1.0, ratio)
|
|
460
|
+
mod.use_collapse_triangulate = True
|
|
461
|
+
dg = bpy.context.evaluated_depsgraph_get()
|
|
462
|
+
ev = lo_o.evaluated_get(dg)
|
|
463
|
+
me = bpy.data.meshes.new_from_object(ev)
|
|
464
|
+
lo_o.modifiers.remove(mod)
|
|
465
|
+
t = sum(len(p.vertices) - 2 for p in me.polygons)
|
|
466
|
+
if target * 0.93 <= t <= target or it == 5:
|
|
467
|
+
break
|
|
468
|
+
ratio *= target * 0.97 / max(t, 1)
|
|
469
|
+
bpy.data.meshes.remove(me)
|
|
470
|
+
old = lo_o.data
|
|
471
|
+
lo_o.data = me
|
|
472
|
+
me.name = name
|
|
473
|
+
if tri_count(lo_o) > target:
|
|
474
|
+
# Blender's collapse stalls on a generation's open borders: a quadric simplifier without border locking
|
|
475
|
+
site = os.path.expanduser(os.environ.get("BLENDER_SITE", "~/ml/img2mesh/blender-site"))
|
|
476
|
+
if site not in sys.path:
|
|
477
|
+
sys.path.append(site)
|
|
478
|
+
import fast_simplification
|
|
479
|
+
bm = bmesh.new(); bm.from_mesh(src_me)
|
|
480
|
+
bmesh.ops.triangulate(bm, faces=bm.faces)
|
|
481
|
+
v = np.array([x.co[:] for x in bm.verts], dtype=np.float32)
|
|
482
|
+
bm.verts.index_update()
|
|
483
|
+
f = np.array([[x.index for x in fc.verts] for fc in bm.faces], dtype=np.int64)
|
|
484
|
+
bm.free()
|
|
485
|
+
red = 1.0 - target * 0.98 / len(f)
|
|
486
|
+
for _ in range(4):
|
|
487
|
+
sv, sf = fast_simplification.simplify(v, f, target_reduction=red)
|
|
488
|
+
if len(sf) <= target:
|
|
489
|
+
break
|
|
490
|
+
red = 1.0 - (1.0 - red) * target * 0.97 / len(sf)
|
|
491
|
+
me.clear_geometry()
|
|
492
|
+
me.from_pydata(sv.tolist(), [], sf.tolist())
|
|
493
|
+
me.update()
|
|
494
|
+
print(f"fqmr fallback → {len(sf)} tris", flush=True)
|
|
495
|
+
print(f"tris {tri_count(lo_o)} (hi {tri_count(hi_o)}) ratio {ratio:.4f}", flush=True)
|
|
496
|
+
# triangulate any quads/ngons left
|
|
497
|
+
bm = bmesh.new(); bm.from_mesh(lo_o.data)
|
|
498
|
+
bmesh.ops.triangulate(bm, faces=[f for f in bm.faces if len(f.verts) > 3])
|
|
499
|
+
bm.to_mesh(lo_o.data); bm.free()
|
|
500
|
+
for p in lo_o.data.polygons:
|
|
501
|
+
p.use_smooth = True
|
|
502
|
+
|
|
503
|
+
# UVs: fresh smart projection, packed with a margin
|
|
504
|
+
bpy.ops.object.select_all(action="DESELECT")
|
|
505
|
+
lo_o.select_set(True)
|
|
506
|
+
bpy.context.view_layer.objects.active = lo_o
|
|
507
|
+
while lo_o.data.uv_layers:
|
|
508
|
+
lo_o.data.uv_layers.remove(lo_o.data.uv_layers[0])
|
|
509
|
+
lo_o.data.uv_layers.new(name="UVMap")
|
|
510
|
+
bpy.ops.object.mode_set(mode="EDIT")
|
|
511
|
+
bpy.ops.mesh.select_all(action="SELECT")
|
|
512
|
+
if c.get("uv", "charts") == "smart":
|
|
513
|
+
bpy.ops.uv.smart_project(angle_limit=math.radians(66), island_margin=0.015, area_weight=0.0, correct_aspect=True)
|
|
514
|
+
else:
|
|
515
|
+
bpy.ops.object.mode_set(mode="OBJECT")
|
|
516
|
+
nch = mark_chart_seams(lo_o, c.get("chartMin", 0.03))
|
|
517
|
+
print(f"uv charts {nch}", flush=True)
|
|
518
|
+
bpy.ops.object.mode_set(mode="EDIT")
|
|
519
|
+
bpy.ops.mesh.select_all(action="SELECT")
|
|
520
|
+
bpy.ops.uv.unwrap(method="ANGLE_BASED", margin=0.01)
|
|
521
|
+
bpy.ops.uv.pack_islands(margin=0.012, rotate=True)
|
|
522
|
+
bpy.ops.object.mode_set(mode="OBJECT")
|
|
523
|
+
|
|
524
|
+
path = bake(hi_o, lo_o, name, a.bake)
|
|
525
|
+
bake_position(lo_o, name, a.bake)
|
|
526
|
+
m = measure(verts_np(hi_o), c["pose"], hw if hw else 0.0, c)
|
|
527
|
+
for key in ("neck", "headAxis", "tailRoot", "tailAxis"): # hand-read pivots (grid renders) win over the heuristics
|
|
528
|
+
if key in c:
|
|
529
|
+
m[key] = c[key]
|
|
530
|
+
m["pivots"] = "hand-read from grid renders (birds.json), checked by birds_render.py --seg"
|
|
531
|
+
m["headZ"], m["headY"], m["tailZ"] = m["neck"][2], m["neck"][1], m["tailRoot"][2]
|
|
532
|
+
if "neck" in c:
|
|
533
|
+
m.pop("neckHow", None)
|
|
534
|
+
L = verts_np(lo_o)
|
|
535
|
+
m["tris"] = tri_count(lo_o)
|
|
536
|
+
GL = np.stack([L[:, 0], L[:, 2], -L[:, 1]], 1)
|
|
537
|
+
m["bbox"] = {"min": [round(float(v), 4) for v in GL.min(0)], "max": [round(float(v), 4) for v in GL.max(0)]}
|
|
538
|
+
m["feetY"] = round(float(L[:, 2].min()), 4)
|
|
539
|
+
m["span"] = round(float(L[:, 0].max() - L[:, 0].min()), 4)
|
|
540
|
+
m["length"] = round(float(L[:, 1].max() - L[:, 1].min()), 4)
|
|
541
|
+
m["src"] = c["src"]
|
|
542
|
+
uv = lo_o.data.uv_layers.active.data
|
|
543
|
+
m["uvTris"] = [[[round(uv[li].uv[0], 5), round(uv[li].uv[1], 5)] for li in p.loop_indices] for p in lo_o.data.polygons]
|
|
544
|
+
json.dump(m, open(os.path.join(a.out, name + ".json"), "w"), indent=1)
|
|
545
|
+
print(json.dumps({k: v for k, v in m.items() if k != "uvTris"}), flush=True)
|
|
546
|
+
|
|
547
|
+
bpy.data.objects.remove(hi_o)
|
|
548
|
+
bpy.ops.export_scene.gltf(filepath=os.path.join(a.out, name + ".low.glb"), export_format="GLB",
|
|
549
|
+
export_image_format="AUTO", export_yup=True, export_apply=True)
|
|
550
|
+
print("done", flush=True)
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Pine Hollow birds (round 16): renders of birds.glb, one PNG per mesh and view.
|
|
2
|
+
|
|
3
|
+
blender -b -P scripts/img2mesh/birds/birds_render.py -- <birds.glb> <birds.json> <out dir> [--seg] [--size 512]
|
|
4
|
+
|
|
5
|
+
Default: Eevee, textured (the atlas), a sun + sky fill, views side (beak → right), top (beak ↑) and 3/4.
|
|
6
|
+
--seg: Workbench, every vertex coloured by the sidecar's rules (wing |x| > bodyHalfWidth on fly = green, head past the
|
|
7
|
+
neck plane = red, tail past the tail-root plane = blue, body = grey) + the neck (yellow), shoulders (cyan) as dots:
|
|
8
|
+
a check that the measured pivots cut the mesh where the game will bend it.
|
|
9
|
+
"""
|
|
10
|
+
import math
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
import bpy
|
|
15
|
+
import json
|
|
16
|
+
from mathutils import Vector
|
|
17
|
+
|
|
18
|
+
argv = sys.argv[sys.argv.index("--") + 1:]
|
|
19
|
+
src, side_path, out = argv[0], argv[1], argv[2]
|
|
20
|
+
seg = "--seg" in argv
|
|
21
|
+
size = int(argv[argv.index("--size") + 1]) if "--size" in argv else 512
|
|
22
|
+
os.makedirs(out, exist_ok=True)
|
|
23
|
+
SC = json.load(open(side_path))["meshes"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def b(v): # glTF → Blender
|
|
27
|
+
return Vector((v[0], -v[2], v[1]))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
31
|
+
bpy.ops.import_scene.gltf(filepath=src)
|
|
32
|
+
objs = {o.name: o for o in bpy.context.scene.objects if o.type == "MESH"}
|
|
33
|
+
sc = bpy.context.scene
|
|
34
|
+
sc.render.resolution_x = sc.render.resolution_y = size
|
|
35
|
+
sc.view_settings.view_transform = "Standard"
|
|
36
|
+
sc.world = bpy.data.worlds.new("w")
|
|
37
|
+
if seg:
|
|
38
|
+
sc.render.engine = "BLENDER_WORKBENCH"
|
|
39
|
+
sc.display.shading.light = "STUDIO"
|
|
40
|
+
sc.display.shading.color_type = "VERTEX"
|
|
41
|
+
sc.world.color = (0.85, 0.85, 0.85)
|
|
42
|
+
else:
|
|
43
|
+
eng = {e.identifier for e in bpy.types.RenderSettings.bl_rna.properties["engine"].enum_items}
|
|
44
|
+
sc.render.engine = "BLENDER_EEVEE_NEXT" if "BLENDER_EEVEE_NEXT" in eng else "BLENDER_EEVEE"
|
|
45
|
+
sc.world.use_nodes = True
|
|
46
|
+
bg = sc.world.node_tree.nodes["Background"]
|
|
47
|
+
bg.inputs[0].default_value = (0.78, 0.8, 0.83, 1)
|
|
48
|
+
bg.inputs[1].default_value = 0.9
|
|
49
|
+
sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN"))
|
|
50
|
+
sun.data.energy = 3.2
|
|
51
|
+
sun.rotation_euler = (math.radians(40), math.radians(10), math.radians(-35))
|
|
52
|
+
sc.collection.objects.link(sun)
|
|
53
|
+
for m in bpy.data.materials:
|
|
54
|
+
m.use_backface_culling = False
|
|
55
|
+
|
|
56
|
+
cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam"))
|
|
57
|
+
cam.data.type = "ORTHO"
|
|
58
|
+
sc.collection.objects.link(cam)
|
|
59
|
+
sc.camera = cam
|
|
60
|
+
dots = []
|
|
61
|
+
cams = {}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def dot(p, col):
|
|
65
|
+
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.012, location=p, segments=10, ring_count=6)
|
|
66
|
+
o = bpy.context.active_object
|
|
67
|
+
ca = o.data.color_attributes.new("c", "FLOAT_COLOR", "POINT")
|
|
68
|
+
for d in ca.data:
|
|
69
|
+
d.color = col
|
|
70
|
+
dots.append(o)
|
|
71
|
+
return o
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
for name, ob in objs.items():
|
|
75
|
+
m = SC[name]
|
|
76
|
+
for o in objs.values():
|
|
77
|
+
o.hide_render = o is not ob
|
|
78
|
+
for o in dots:
|
|
79
|
+
bpy.data.objects.remove(o)
|
|
80
|
+
dots.clear()
|
|
81
|
+
if seg:
|
|
82
|
+
me = ob.data
|
|
83
|
+
ca = me.color_attributes.get("seg") or me.color_attributes.new("seg", "FLOAT_COLOR", "POINT")
|
|
84
|
+
me.color_attributes.active_color = ca
|
|
85
|
+
neck, ha = b(m["neck"]), b(m["headAxis"])
|
|
86
|
+
tr, ta = b(m["tailRoot"]), b(m["tailAxis"])
|
|
87
|
+
fly = name.endswith("_fly")
|
|
88
|
+
for v, d in zip(me.vertices, ca.data):
|
|
89
|
+
p = v.co
|
|
90
|
+
if fly and abs(p.x) > m["bodyHalfWidth"]:
|
|
91
|
+
c = (0.1, 0.7, 0.2, 1)
|
|
92
|
+
elif (p - neck).dot(ha) > 0:
|
|
93
|
+
c = (0.85, 0.1, 0.1, 1)
|
|
94
|
+
elif (p - tr).dot(ta) > 0:
|
|
95
|
+
c = (0.1, 0.25, 0.9, 1)
|
|
96
|
+
else:
|
|
97
|
+
c = (0.55, 0.55, 0.55, 1)
|
|
98
|
+
d.color = c
|
|
99
|
+
dot(neck, (1, 0.9, 0, 1))
|
|
100
|
+
dot(b(m["shoulderL"]), (0, 1, 1, 1))
|
|
101
|
+
dot(b(m["shoulderR"]), (0, 1, 1, 1))
|
|
102
|
+
lo = Vector([min((ob.matrix_world @ Vector(c))[i] for c in ob.bound_box) for i in range(3)])
|
|
103
|
+
hi = Vector([max((ob.matrix_world @ Vector(c))[i] for c in ob.bound_box) for i in range(3)])
|
|
104
|
+
c = (lo + hi) / 2
|
|
105
|
+
r = max(hi - lo) * 0.58
|
|
106
|
+
cam.data.ortho_scale = 2 * r
|
|
107
|
+
views = {
|
|
108
|
+
"side": (Vector((-4 * r, 0, 0)), (math.pi / 2, 0, -math.pi / 2)),
|
|
109
|
+
"top": (Vector((0, 0, 4 * r)), (0, 0, math.pi)),
|
|
110
|
+
"q34": (Vector((-2.4 * r, -2.4 * r, 2.2 * r)), None),
|
|
111
|
+
}
|
|
112
|
+
if "--front" in argv:
|
|
113
|
+
views["front"] = (Vector((0, -4 * r, 0)), (math.pi / 2, 0, 0))
|
|
114
|
+
cams[name] = {"c_gltf": [c.x, c.z, -c.y], "halfWidth": r}
|
|
115
|
+
for vn, (off, eu) in views.items():
|
|
116
|
+
cam.location = c + off
|
|
117
|
+
if eu is None:
|
|
118
|
+
d = (c - cam.location).normalized()
|
|
119
|
+
cam.rotation_euler = d.to_track_quat("-Z", "Y").to_euler()
|
|
120
|
+
else:
|
|
121
|
+
cam.rotation_euler = eu
|
|
122
|
+
sc.render.filepath = os.path.join(out, f"{name}.{vn}.png")
|
|
123
|
+
bpy.ops.render.render(write_still=True)
|
|
124
|
+
json.dump(cams, open(os.path.join(out, "cams.json"), "w"), indent=1)
|
|
125
|
+
print("rendered", list(objs))
|