feat: 建立关卡工坊并整理项目目录
- 加入 Godot 基础试玩、画风展示和通孔验证场景 - 支持自由放球、多层叠放、墙壁、锥口球洞及固定 +5 m/s 定向加速方块 - 保存 Blender 源资产、模型导出、资源制作脚本和关卡编辑存档逻辑 - 按七类目录归档工程,集中 zsh 启动入口并补充 AGENTS.md 文件索引 - 同步设计规则、依赖锁定、验证报告和目录迁移记录 验证:目录迁移后的资源导入与四个场景加载通过;本次提交前检查暂存内容,未重复运行整套物理测试。
This commit is contained in:
@@ -1 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
.venv/
|
||||||
|
__pycache__/
|
||||||
|
.cache/
|
||||||
|
godot_engine/.godot/
|
||||||
|
*.blend1
|
||||||
|
playtest/artifacts/**/*.log
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
3.14
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
# IntoHole 文件索引与工作约定
|
||||||
|
|
||||||
|
本文件是仓库导航入口。先查所属目录与具体设计文档,再修改内容。不要在根目录重新创建零散脚本、模型、测试输出或 `docs/`、`reference/`、`validation/` 等并行目录。
|
||||||
|
|
||||||
|
## 顶层目录
|
||||||
|
|
||||||
|
| 目录 | 职责与入口 |
|
||||||
|
| --- | --- |
|
||||||
|
| [godot_engine](godot_engine/README.md) | Godot 工程配置、共享适配代码、导入缓存和可选引擎程序。唯一工程入口为 [project.godot](godot_engine/project.godot)。 |
|
||||||
|
| [references](references/README.md) | 项目已确认规则与外部参考,按 `design/`、`games/`、`mechanics/` 分开。 |
|
||||||
|
| [assets](assets/README.md) | 游戏资产及制作代码,按 **资源类型 / 资源名** 隔离。 |
|
||||||
|
| [playtest](playtest/README.md) | 所有非正式实验场景、示例布局、检查与截图脚本、历史产物。 |
|
||||||
|
| [levels](levels/README.md) | 正式游戏关卡;当前无已发布正式关卡。 |
|
||||||
|
| [designer](designer/README.md) | 工坊、编辑器逻辑和未发布草稿。 |
|
||||||
|
| [scripts](scripts/README.md) | 启动、执行、维护脚本;新增入口优先 bash/zsh。 |
|
||||||
|
|
||||||
|
根目录保留 README.md、AGENTS.md、.gitignore 与现有 uv 配置。`.venv/`、`.python-version`、`pyproject.toml`、`uv.lock` 未经明确要求不要迁移或调整;`.git/` 是版本元数据。
|
||||||
|
|
||||||
|
## 常用入口
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./scripts/workshop.zsh
|
||||||
|
./scripts/showcase.zsh
|
||||||
|
./scripts/underpass.zsh
|
||||||
|
./scripts/playtest.zsh
|
||||||
|
```
|
||||||
|
|
||||||
|
四个 `.command` 双击快捷方式也在 `scripts/`,仅转调对应 zsh 文件。复杂调度在 [studio.py](scripts/python/studio.py) 和 [baseline.py](scripts/python/baseline.py),它们是开发工具,不是游戏主体。
|
||||||
|
|
||||||
|
## Godot 工程
|
||||||
|
|
||||||
|
- [godot_engine/project.godot](godot_engine/project.godot) 默认启动关卡工坊。
|
||||||
|
- `godot_engine/assets`、`designer`、`playtest`、`levels` 是指向同名顶层目录的相对符号链接,非第二份文件。`res://assets/...` 等资源路径通过这些链接访问唯一资源;复制仓库时保留链接。
|
||||||
|
- 共享资产加载适配在 [runtime/asset_library.gd](godot_engine/runtime/asset_library.gd)。资源自身行为和制作代码随资源放入 `assets/`。
|
||||||
|
- `.uid` 与 `.import` 跟随对应脚本和模型。移动后同步资源路径、目录配置、构建输出和文档链接,并做必要导入。
|
||||||
|
- `godot_engine/.godot/` 是自动缓存。资产 `source/` 与 `playtest/artifacts/` 中的 `.gdignore` 避免导入制作源文件和历史输出。
|
||||||
|
- 使用系统引擎或 `godot_engine/bin/`;不要未经要求复制引擎程序。
|
||||||
|
|
||||||
|
## 资产索引
|
||||||
|
|
||||||
|
每个资源采用 `assets/<资源类型>/<资源名>/`:
|
||||||
|
|
||||||
|
```text
|
||||||
|
assets/blocks/directional_boost/
|
||||||
|
model.glb
|
||||||
|
model.glb.import
|
||||||
|
behavior.gd
|
||||||
|
source/
|
||||||
|
model.blend
|
||||||
|
build.py
|
||||||
|
.gdignore
|
||||||
|
```
|
||||||
|
|
||||||
|
| 类型 | 资源 |
|
||||||
|
| --- | --- |
|
||||||
|
| [chutes](assets/chutes) | `straight`、`turn_cw`、`turn_ccw`、`gentle`、`steep`、`y_merge`。 |
|
||||||
|
| [balls](assets/balls) | `iron_ball`,物理行为在 [physics.gd](assets/balls/iron_ball/physics.gd)。 |
|
||||||
|
| [blocks](assets/blocks) | `wall`、`directional_boost`。 |
|
||||||
|
| [goals](assets/goals) | `goal_hole`。 |
|
||||||
|
| [collections](assets/collections) | `baseline` 与 `storybook` 两个资源集合,保存目录配置、共享制作代码和整套源文件。 |
|
||||||
|
|
||||||
|
当前模型直接放在资源目录,早期模型变体在相同资源的 `baseline/`。每个资源的 `source/build.py` 是制作入口,复用 [集合制作代码](assets/collections/storybook/source/build.py),只导出目标资源。所有实际制作代码均在 `assets/`;[asset.zsh](scripts/asset.zsh) 只负责执行。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./scripts/asset.zsh directional_boost
|
||||||
|
./scripts/asset.zsh all
|
||||||
|
./scripts/asset.zsh baseline
|
||||||
|
```
|
||||||
|
|
||||||
|
几何、尺寸、外观由 Blender 资产负责。当前资源目录为 [catalog.json](assets/collections/storybook/catalog.json),物理配置为 [physics.json](assets/collections/storybook/physics.json),实体分类为 [entities.json](assets/collections/storybook/entities.json)。
|
||||||
|
|
||||||
|
来源快照在 `assets/collections/storybook/source/snapshot/`,是生成输入而非缓存。快照原始路径和旧校验值属于历史证据,不作为现用资源路径批量重写。参数化重建会重新生成相应源文件,保留手工编辑成果后再决定是否运行生成器。
|
||||||
|
|
||||||
|
## 场景、关卡与规则索引
|
||||||
|
|
||||||
|
- 工坊:[workshop.tscn](designer/scenes/workshop.tscn)。编辑编排:[studio.gd](designer/scripts/studio.gd);摆放:[placement.gd](designer/scripts/placement.gd);存档:[level_data.gd](designer/scripts/level_data.gd)。
|
||||||
|
- 工坊默认空白,保存到 [designer/drafts](designer/drafts)。内置示例从 `playtest/` 读取,保存时写入草稿副本,不直接覆盖实验原件。
|
||||||
|
- 展示:[showcase.tscn](playtest/showcase/scenes/showcase.tscn);通孔:[underpass.tscn](playtest/underpass/scenes/underpass.tscn);早期试玩:[main.tscn](playtest/baseline/scenes/main.tscn)。
|
||||||
|
- `levels/` 仅用于明确发布的正式关卡。不要把试跑成功、示例或工坊草稿自动当作正式关卡。
|
||||||
|
- [blocks.md](references/design/blocks.md) 是方块完整规则的唯一维护文档,保留“滑槽 / 实体”结构;[physics_system.md](references/design/physics_system.md) 管理物理和小球数据;[game_reference.md](references/design/game_reference.md) 管理整体玩法及参考方向。
|
||||||
|
- 外部游戏资料在 `references/games/`,机械笔记在 `references/mechanics/`。区分资料中的建议、用户指令与已确认规则。
|
||||||
|
- 定向加速方块每次固定增加 **5 m/s**,工坊与运行中均不可调;旧存档的 `speedGain` 不得覆盖该规则。
|
||||||
|
|
||||||
|
## 验证与迁移记录
|
||||||
|
|
||||||
|
- 检查脚本在 `playtest/checks/`,早期专项在 `playtest/baseline/checks/`,截图脚本在 `playtest/captures/`。
|
||||||
|
- `playtest/artifacts/baseline/`、`styled/`、`reorganization/` 分别收纳早期产物、当前画风实验产物及迁移记录。历史报告中的旧路径是当时证据,移动文件不代表重新运行了实验。
|
||||||
|
- [迁移清单](playtest/artifacts/reorganization/files.json) 保存旧路径、新路径及迁移前 SHA-256;[路径映射](playtest/artifacts/reorganization/path_map.json) 用于追溯。
|
||||||
|
- 用户不希望为小改动重复跑全套物理实验。验证应匹配改动:目录调整主要检查路径、语法、导入和入口加载;仅在确实涉及相应行为时运行必要专项。
|
||||||
|
- 保留未提交工作、用户关卡与源资产,不因目录混乱直接删除,不自动提交或批量暂存。讨论提案与已确认规则分开维护。
|
||||||
|
|
||||||
|
<!-- context7 -->
|
||||||
|
## 当前文档查询
|
||||||
|
|
||||||
|
Use `ctx7` to fetch current documentation when the user asks about a library, framework, SDK, API, CLI tool or cloud service, including syntax, configuration, migration, library-specific debugging, setup and CLI usage. Do not use it for refactoring, business logic, code review or general programming concepts.
|
||||||
|
|
||||||
|
1. Resolve first: `npx ctx7@latest library <name> "<user's full question>"`; use the official library name.
|
||||||
|
2. Choose the best valid `/org/project` ID by relevance, reputation and coverage; use a returned version ID when appropriate.
|
||||||
|
3. Fetch: `npx ctx7@latest docs <libraryId> "<user's full question>"`.
|
||||||
|
4. Answer using the fetched documentation.
|
||||||
|
|
||||||
|
Call `library` first unless the user supplied an ID. Run at most three commands per question. Never include credentials. Run Context7 outside the default sandbox; on DNS/network errors retry outside the sandbox. On quota errors, inform the user and suggest `npx ctx7@latest login` or `CONTEXT7_API_KEY`; do not silently fall back to remembered API details.
|
||||||
|
<!-- context7 -->
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# IntoHole
|
||||||
|
|
||||||
|
日常关卡搭建入口:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./scripts/workshop.zsh
|
||||||
|
```
|
||||||
|
|
||||||
|
也可双击 [scripts/Workshop.command](scripts/Workshop.command)。完整文件索引与归档规则见 [AGENTS.md](AGENTS.md)。
|
||||||
|
|
||||||
|
| 目录 | 用途 |
|
||||||
|
| --- | --- |
|
||||||
|
| [godot_engine](godot_engine/README.md) | Godot 工程配置、共享适配、资源链接与可选引擎本体。 |
|
||||||
|
| [references](references/README.md) | 项目设计规则、游戏参考、来源图片和机械结构笔记。 |
|
||||||
|
| [assets](assets/README.md) | 按资源类型 / 资源名归档的模型、源文件和制作代码。 |
|
||||||
|
| [playtest](playtest/README.md) | 非正式场景、示例布局、检查和截图脚本、历史产物。 |
|
||||||
|
| [levels](levels/README.md) | 正式关卡;当前尚未发布正式关卡。 |
|
||||||
|
| [designer](designer/README.md) | 工坊、编辑器代码和未发布草稿。 |
|
||||||
|
| [scripts](scripts/README.md) | zsh 启动与执行入口、内部 Python 工具。 |
|
||||||
|
|
||||||
|
根目录保留 README、AGENTS、Git 配置和现有 uv 环境文件。`.venv`、`.python-version`、`pyproject.toml`、`uv.lock` 没有迁移或修改。
|
||||||
|
|
||||||
|
其他入口:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./scripts/showcase.zsh
|
||||||
|
./scripts/underpass.zsh
|
||||||
|
./scripts/playtest.zsh
|
||||||
|
```
|
||||||
|
|
||||||
|
Godot 工程入口是 [godot_engine/project.godot](godot_engine/project.godot),默认场景是工坊。保存的关卡进入 [designer/drafts](designer/drafts);内置实验示例仍可载入,保存时生成草稿副本。正式关卡只在明确发布时进入 `levels/`。
|
||||||
|
|
||||||
|
定向加速方块固定增加 **5 m/s**,工坊与运行中均不可调;见 [方块设定](references/design/blocks.md#定向加速方块)。
|
||||||
|
|
||||||
|
2026-11-16 目录整理进行了文件/链接检查、Godot 导入和四场景短启动检查,没有重建模型或重跑整套物理实验。原始产物保存在 [playtest/artifacts](playtest/artifacts),旧路径、新路径及原始校验值见 [迁移清单](playtest/artifacts/reorganization/files.json)。
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# 游戏资产
|
||||||
|
|
||||||
|
按 **资源类型 / 资源名** 组织;模型、源文件和制作入口位于同一资源目录。
|
||||||
|
|
||||||
|
| 类型 | 资源 |
|
||||||
|
| --- | --- |
|
||||||
|
| [chutes](chutes) | 直行、两种拐弯、缓坡、陡坡、Y 汇流。 |
|
||||||
|
| [balls](balls) | 铁球模型及物理行为。 |
|
||||||
|
| [blocks](blocks) | 标准墙壁、定向加速方块。 |
|
||||||
|
| [goals](goals) | 锥口球洞。 |
|
||||||
|
| [collections](collections) | 基础集合与当前画风集合的共享制作代码、参数、整套源文件和快照。 |
|
||||||
|
|
||||||
|
`model.glb` 用于运行;`source/model.blend` 用于编辑,`source/build.py` 是制作入口;`baseline/model.glb` 为早期变体。`source/.gdignore` 使 Godot 跳过制作源文件。
|
||||||
|
|
||||||
|
例如定向加速方块:[模型](blocks/directional_boost/model.glb)、[源文件](blocks/directional_boost/source/model.blend)、[制作入口](blocks/directional_boost/source/build.py)、[行为](blocks/directional_boost/behavior.gd)。
|
||||||
|
|
||||||
|
从根目录运行 `./scripts/asset.zsh directional_boost` 可制作指定资源;`all` 制作当前画风整套,`baseline` 制作基础整套。单资源入口复用集合代码,只导出目标资源。参数化重建会重新生成相应源文件,手工修改模型后先决定是否继续使用生成器。
|
||||||
|
|
||||||
|
当前资产目录:[catalog.json](collections/storybook/catalog.json);物理参数:[physics.json](collections/storybook/physics.json);实体分类:[entities.json](collections/storybook/entities.json)。[来源快照](collections/storybook/source/snapshot) 是生成输入,不是可随意删除的缓存。
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://bqbwiuklxhu3m"
|
||||||
|
path="res://.godot/imported/model.glb-5e055581ba61e2c0c52215a9c57579de.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/balls/iron_ball/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-5e055581ba61e2c0c52215a9c57579de.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://u75pywkqa11i"
|
||||||
|
path="res://.godot/imported/model.glb-84ea59e03d48e9c4a39ea66137920174.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/balls/iron_ball/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-84ea59e03d48e9c4a39ea66137920174.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
extends RigidBody3D
|
||||||
|
|
||||||
|
const Booster = preload("res://assets/blocks/directional_boost/behavior.gd")
|
||||||
|
var boost_controller = Booster.new()
|
||||||
|
var radius: float = 0.3
|
||||||
|
var drag_coefficient: float = 0.47
|
||||||
|
var air_density: float = 1.225
|
||||||
|
var wind_velocity := Vector3.ZERO
|
||||||
|
var mu_static: float = 0.42
|
||||||
|
var mu_dynamic: float = 0.32
|
||||||
|
var rolling_resistance: float = 0.025
|
||||||
|
var friction_enabled := true
|
||||||
|
var rolling_enabled := true
|
||||||
|
var drag_enabled := true
|
||||||
|
var contact_count := 0
|
||||||
|
var ball_contact_count := 0
|
||||||
|
var contact_slip := 0.0
|
||||||
|
var air_force := Vector3.ZERO
|
||||||
|
var rolling_torque := Vector3.ZERO
|
||||||
|
var travelled := 0.0
|
||||||
|
var previous_position := Vector3.ZERO
|
||||||
|
var tracking_started := false
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
continuous_cd = true
|
||||||
|
contact_monitor = true
|
||||||
|
max_contacts_reported = 12
|
||||||
|
can_sleep = false
|
||||||
|
linear_damp_mode = RigidBody3D.DAMP_MODE_REPLACE
|
||||||
|
angular_damp_mode = RigidBody3D.DAMP_MODE_REPLACE
|
||||||
|
linear_damp = 0.0
|
||||||
|
angular_damp = 0.0
|
||||||
|
|
||||||
|
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||||
|
if freeze:
|
||||||
|
return
|
||||||
|
contact_count = state.get_contact_count()
|
||||||
|
ball_contact_count = 0
|
||||||
|
contact_slip = 0.0
|
||||||
|
var support_normal := Vector3.ZERO
|
||||||
|
for i in range(contact_count):
|
||||||
|
if state.get_contact_collider_object(i) is RigidBody3D:ball_contact_count+=1
|
||||||
|
# Contact positions are global; the sphere's radial direction is unambiguous.
|
||||||
|
var n := (state.transform.origin - state.get_contact_local_position(i)).normalized()
|
||||||
|
var relative := state.get_contact_local_velocity_at_position(i) - state.get_contact_collider_velocity_at_position(i)
|
||||||
|
var slip := relative - n * relative.dot(n)
|
||||||
|
contact_slip = maxf(contact_slip, slip.length())
|
||||||
|
if n.dot(Vector3.UP) > 0.15:
|
||||||
|
support_normal += n
|
||||||
|
# Godot exposes one native friction coefficient. Select a slip-dependent
|
||||||
|
# coefficient; native contact solver still owns the friction impulse.
|
||||||
|
physics_material_override.friction = (mu_static if contact_slip < 0.035 else mu_dynamic) if friction_enabled else 0.0
|
||||||
|
boost_controller.integrate(state, radius)
|
||||||
|
var relative_air := state.linear_velocity - wind_velocity
|
||||||
|
air_force = -0.5 * air_density * drag_coefficient * PI * radius * radius * relative_air.length() * relative_air if drag_enabled else Vector3.ZERO
|
||||||
|
state.apply_central_force(air_force)
|
||||||
|
rolling_torque = Vector3.ZERO
|
||||||
|
if rolling_enabled and support_normal.length_squared() > 0.001:
|
||||||
|
var n := support_normal.normalized()
|
||||||
|
var roll := state.angular_velocity - n * state.angular_velocity.dot(n)
|
||||||
|
if roll.length() > 0.0001:
|
||||||
|
var support := maxf(0.0, -(mass * state.total_gravity + air_force).dot(n))
|
||||||
|
var moment := 0.4 * mass * radius * radius
|
||||||
|
var limit := roll.length() * moment / state.step
|
||||||
|
rolling_torque = -roll.normalized() * minf(rolling_resistance * support * radius, limit)
|
||||||
|
state.apply_torque(rolling_torque)
|
||||||
|
if tracking_started:
|
||||||
|
travelled += state.transform.origin.distance_to(previous_position)
|
||||||
|
previous_position = state.transform.origin
|
||||||
|
tracking_started = true
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://ieaoae3mjv03
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
@@ -0,0 +1,46 @@
|
|||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
const KIND := "directional_boost"
|
||||||
|
const SPEED_GAIN := 5.0
|
||||||
|
|
||||||
|
# One latch per ball and block. A small separation margin tolerates contact jitter.
|
||||||
|
var active: Dictionary = {}
|
||||||
|
var events: Array = []
|
||||||
|
|
||||||
|
func integrate(state: PhysicsDirectBodyState3D, radius: float) -> void:
|
||||||
|
var touching: Dictionary = {}
|
||||||
|
for i in range(state.get_contact_count()):
|
||||||
|
var collider: Node = state.get_contact_collider_object(i)
|
||||||
|
if collider == null or collider.get_meta("piece_type", "") != KIND:continue
|
||||||
|
var block: Node = collider
|
||||||
|
while block != null and not block.has_meta("boost_bounds"):block = block.get_parent()
|
||||||
|
if block == null:continue
|
||||||
|
var contact: Vector3 = state.get_contact_collider_position(i)
|
||||||
|
var normal := (state.transform.origin - contact).normalized()
|
||||||
|
var local: Vector3 = block.to_local(contact)
|
||||||
|
var bounds: AABB = block.get_meta("boost_bounds")
|
||||||
|
if normal.y < .9 or absf(local.y - bounds.end.y) > .025:continue
|
||||||
|
touching[block.get_instance_id()] = block
|
||||||
|
for id in active.keys():
|
||||||
|
if touching.has(id):continue
|
||||||
|
var block = active[id]
|
||||||
|
if not is_instance_valid(block):active.erase(id);continue
|
||||||
|
var local: Vector3 = block.to_local(state.transform.origin)
|
||||||
|
var bounds: AABB = block.get_meta("boost_bounds")
|
||||||
|
if local.x < bounds.position.x-.025 or local.x > bounds.end.x+.025 or local.z < bounds.position.z-.025 or local.z > bounds.end.z+.025 or absf(local.y-bounds.end.y-radius) > .06:
|
||||||
|
active.erase(id)
|
||||||
|
# Stable order for the rare case of simultaneously touching two top faces.
|
||||||
|
var blocks: Array = touching.values()
|
||||||
|
blocks.sort_custom(func(a,b):return str(a.get_meta("record_id",a.name)) < str(b.get_meta("record_id",b.name)))
|
||||||
|
for block in blocks:
|
||||||
|
var id: int = block.get_instance_id()
|
||||||
|
if active.has(id):continue
|
||||||
|
active[id] = block
|
||||||
|
var before := state.linear_velocity
|
||||||
|
var direction: Vector3 = block.global_basis * Vector3(block.get_meta("boost_direction"))
|
||||||
|
direction.y = 0;direction = direction.normalized()
|
||||||
|
var speed := Vector2(before.x,before.z).length() + SPEED_GAIN
|
||||||
|
var after := direction * speed
|
||||||
|
after.y = before.y
|
||||||
|
state.linear_velocity = after
|
||||||
|
events.append({"blockId":str(block.get_meta("record_id",block.name)),"before":before,"after":after,"tick":Engine.get_physics_frames()})
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bkojodf5an6c
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://ctugu4qe5hoes"
|
||||||
|
path="res://.godot/imported/model.glb-3291d7d4697a980d05594124bc8e18d7.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/blocks/directional_boost/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-3291d7d4697a980d05594124bc8e18d7.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://dsvx7y6xfcrhn"
|
||||||
|
path="res://.godot/imported/model.glb-e70e20d2f6a47b149d655452336f7d1c.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/blocks/wall/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-e70e20d2f6a47b149d655452336f7d1c.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://4sm5aojhi4w6"
|
||||||
|
path="res://.godot/imported/model.glb-30148fc463f54166480e9ba8cd6d2b86.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/gentle/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-30148fc463f54166480e9ba8cd6d2b86.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://n03eiy33il2p"
|
||||||
|
path="res://.godot/imported/model.glb-9065d1c9f3286b5fbe96b779e9a3e00f.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/gentle/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-9065d1c9f3286b5fbe96b779e9a3e00f.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://epjlp7an81xf"
|
||||||
|
path="res://.godot/imported/model.glb-112c5cd7a38ef7dc0dc0d0b7a878ac70.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/steep/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-112c5cd7a38ef7dc0dc0d0b7a878ac70.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://b8wromjqvf3ts"
|
||||||
|
path="res://.godot/imported/model.glb-2d1ec72b64a498d19c6e0bf09de04d98.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/steep/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-2d1ec72b64a498d19c6e0bf09de04d98.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://dh35m1i5jcrl7"
|
||||||
|
path="res://.godot/imported/model.glb-9d61925d33fd2393aeb0ff4916d19c8e.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/straight/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-9d61925d33fd2393aeb0ff4916d19c8e.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://beylngg07k5gy"
|
||||||
|
path="res://.godot/imported/model.glb-4d0ec11a54c0bb43d31739e394c20e98.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/straight/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-4d0ec11a54c0bb43d31739e394c20e98.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://o5060myig6kq"
|
||||||
|
path="res://.godot/imported/model.glb-2b9ee2beae2e83a5588df2ea7c521130.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/turn_ccw/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-2b9ee2beae2e83a5588df2ea7c521130.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://dbxxkob8q3w4v"
|
||||||
|
path="res://.godot/imported/model.glb-0089b79a457b3713a90bb539ab3bb695.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/turn_ccw/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-0089b79a457b3713a90bb539ab3bb695.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://udqhm02r1d0h"
|
||||||
|
path="res://.godot/imported/model.glb-f6bb67f1d252bcf9f455b21480ac71bd.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/turn_cw/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-f6bb67f1d252bcf9f455b21480ac71bd.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://d0h3bueayotgr"
|
||||||
|
path="res://.godot/imported/model.glb-1c5027ed37edf492253cd17d2dc61ee9.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/turn_cw/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-1c5027ed37edf492253cd17d2dc61ee9.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://b3e4pi6yhstur"
|
||||||
|
path="res://.godot/imported/model.glb-eab00978b144585fd2168d1e604c12da.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/y_merge/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-eab00978b144585fd2168d1e604c12da.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://bjl5i582aemjl"
|
||||||
|
path="res://.godot/imported/model.glb-1a5369006eace15b2d8f0d4219753534.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/chutes/y_merge/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-1a5369006eace15b2d8f0d4219753534.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"ballTypes": [
|
||||||
|
{
|
||||||
|
"ballTypeId": "iron_ball",
|
||||||
|
"assetId": "iron_ball",
|
||||||
|
"physicsProfileId": "solid_iron_test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"physicsProfiles": {
|
||||||
|
"solid_iron_test": {
|
||||||
|
"massKg": 890.0760306150601,
|
||||||
|
"inertiaModel": "solidSphere",
|
||||||
|
"dragCoefficient": 0.47,
|
||||||
|
"contactMaterialId": "iron"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contactMaterialPairs": [
|
||||||
|
{
|
||||||
|
"materialAId": "iron",
|
||||||
|
"materialBId": "painted_wood",
|
||||||
|
"staticFriction": 0.42,
|
||||||
|
"dynamicFriction": 0.32,
|
||||||
|
"rollingResistance": 0.025,
|
||||||
|
"restitution": 0.08
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"materialAId": "iron",
|
||||||
|
"materialBId": "iron",
|
||||||
|
"staticFriction": 0.35,
|
||||||
|
"dynamicFriction": 0.25,
|
||||||
|
"rollingResistance": 0.01,
|
||||||
|
"restitution": 0.15
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"notes": [
|
||||||
|
"Experimental contact coefficients; iron material is unchanged.",
|
||||||
|
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg."
|
||||||
|
],
|
||||||
|
"airDensity": 1.225
|
||||||
|
}
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
"""Run inside Blender: parameterized wooden chutes + an iron sphere.
|
||||||
|
Authoring axes: Z up. GLB export: (x, y, z) -> Godot (x, z, -y).
|
||||||
|
Dimensions and colliders originate here, never in the gameplay physics table.
|
||||||
|
"""
|
||||||
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
from pathlib import Path
|
||||||
|
from mathutils import Vector
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
OUT = ROOT / 'assets/collections/baseline'
|
||||||
|
SOURCE = Path(__file__).resolve().parent
|
||||||
|
BALL_R = 0.3
|
||||||
|
FIT_CLEARANCE = 0.02
|
||||||
|
R = BALL_R + FIT_CLEARANCE
|
||||||
|
HOLE_R = BALL_R + FIT_CLEARANCE
|
||||||
|
GOAL_R = BALL_R + FIT_CLEARANCE
|
||||||
|
GOAL_DEPTH = 0.55
|
||||||
|
SIDES = 64
|
||||||
|
OUT.mkdir(parents=True, exist_ok=True)
|
||||||
|
SOURCE.mkdir(parents=True, exist_ok=True)
|
||||||
|
(ROOT/'playtest/artifacts/baseline').mkdir(parents=True, exist_ok=True)
|
||||||
|
bpy.ops.object.select_all(action='SELECT')
|
||||||
|
bpy.ops.object.delete(use_global=False)
|
||||||
|
bpy.context.scene.unit_settings.system = 'METRIC'
|
||||||
|
bpy.context.scene.unit_settings.scale_length = 1.0
|
||||||
|
|
||||||
|
|
||||||
|
def material(name, color, roughness, metallic=0):
|
||||||
|
m = bpy.data.materials.new(name)
|
||||||
|
m.diffuse_color = (*color, 1)
|
||||||
|
m.use_nodes = True
|
||||||
|
node = m.node_tree.nodes.get('Principled BSDF')
|
||||||
|
node.inputs['Base Color'].default_value = (*color, 1)
|
||||||
|
node.inputs['Roughness'].default_value = roughness
|
||||||
|
node.inputs['Metallic'].default_value = metallic
|
||||||
|
return m
|
||||||
|
|
||||||
|
wood = material('Painted wood - warm ochre', (0.48, 0.29, 0.12), .48)
|
||||||
|
channel = material('Painted wood - satin groove', (0.78, 0.59, 0.33), .40)
|
||||||
|
iron = material('Iron - brushed', (.24, .29, .33), .24, .96)
|
||||||
|
mark = material('Iron ball - orientation stripe', (.04, .075, .10), .46, .60)
|
||||||
|
goal_material = material('Goal rim - green', (.063, .26, .17), .4, .25)
|
||||||
|
|
||||||
|
|
||||||
|
def mesh_obj(name, verts, faces):
|
||||||
|
mesh = bpy.data.meshes.new(name)
|
||||||
|
mesh.from_pydata(verts, [], faces)
|
||||||
|
mesh.validate()
|
||||||
|
mesh.update()
|
||||||
|
obj = bpy.data.objects.new(name, mesh)
|
||||||
|
bpy.context.collection.objects.link(obj)
|
||||||
|
bm = bmesh.new()
|
||||||
|
bm.from_mesh(mesh)
|
||||||
|
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
|
||||||
|
bm.to_mesh(mesh)
|
||||||
|
bm.free()
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def top_height(x, rise):
|
||||||
|
return 1 if rise == 0 else .5 + rise * (x + .5)
|
||||||
|
|
||||||
|
|
||||||
|
def block(name, rise):
|
||||||
|
half = 1.0 if name == 'y_merge' else .5
|
||||||
|
verts = [(x, y, z) for z in [0, 1] for y in [-half, half] for x in [-half, half]]
|
||||||
|
verts = [(x, y, top_height(x, rise) if z else 0) for x, y, z in verts]
|
||||||
|
faces = [(0,2,3,1),(4,5,7,6),(0,1,5,4),(2,6,7,3),(0,4,6,2),(1,3,7,5)]
|
||||||
|
obj = mesh_obj(name, verts, faces)
|
||||||
|
obj.data.materials.append(wood)
|
||||||
|
obj.data.materials.append(channel)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def tube(name, points, radius, mat):
|
||||||
|
# Vertical semicircle section maintained along authoring path.
|
||||||
|
vertices = []
|
||||||
|
for i, point in enumerate(points):
|
||||||
|
tangent = Vector(points[min(i+1,len(points)-1)]) - Vector(points[max(0,i-1)])
|
||||||
|
side = Vector((-tangent.y, tangent.x, 0)).normalized()
|
||||||
|
for j in range(SIDES):
|
||||||
|
a = j * math.tau / SIDES
|
||||||
|
v = Vector(point) + radius * math.cos(a) * side + Vector((0,0,radius*math.sin(a)))
|
||||||
|
vertices.append(tuple(v))
|
||||||
|
faces = []
|
||||||
|
for i in range(len(points)-1):
|
||||||
|
for j in range(SIDES):
|
||||||
|
k=i*SIDES+j; n=i*SIDES+(j+1)%SIDES
|
||||||
|
faces.append((k,n,n+SIDES,k+SIDES))
|
||||||
|
faces += [tuple(reversed(range(SIDES))),tuple((len(points)-1)*SIDES+j for j in range(SIDES))]
|
||||||
|
obj=mesh_obj(name,vertices,faces)
|
||||||
|
obj.data.materials.append(wood)
|
||||||
|
obj.data.materials.append(mat)
|
||||||
|
for face in obj.data.polygons:
|
||||||
|
face.material_index=1
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def cut(body, cutter):
|
||||||
|
bpy.context.view_layer.objects.active=body
|
||||||
|
mod=body.modifiers.new('Actual channel void','BOOLEAN')
|
||||||
|
mod.operation='DIFFERENCE'
|
||||||
|
mod.solver='EXACT'
|
||||||
|
mod.object=cutter
|
||||||
|
bpy.ops.object.modifier_apply(modifier=mod.name)
|
||||||
|
bpy.data.objects.remove(cutter,do_unlink=True)
|
||||||
|
|
||||||
|
|
||||||
|
def extend(points, amount=.18):
|
||||||
|
p=[Vector(v) for v in points]
|
||||||
|
first=(p[1]-p[0]); first/=math.hypot(first.x,first.y)
|
||||||
|
last=(p[-1]-p[-2]); last/=math.hypot(last.x,last.y)
|
||||||
|
return [tuple(p[0]-first*amount)]+points+[tuple(p[-1]+last*amount)]
|
||||||
|
|
||||||
|
|
||||||
|
def paths(kind,rise):
|
||||||
|
if kind in ('straight','gentle','steep'):
|
||||||
|
return [[(x,0,top_height(x,rise)) for x in [-.5+i/24 for i in range(25)]]]
|
||||||
|
if kind in ('turn_cw','turn_ccw'):
|
||||||
|
sign=-1 if kind=='turn_cw' else 1
|
||||||
|
return [[(-.5+.5*math.sin(t),sign*(.5-.5*math.cos(t)),1) for t in [i*math.pi/2/48 for i in range(49)]]]
|
||||||
|
# 2x2 Y connector: adjacent 1m lanes on the -X face, both at the same height.
|
||||||
|
# Lane A continues straight; lane B merges through a tangent-continuous S.
|
||||||
|
direct=[(-1+i/64*2,-.5,1) for i in range(65)]
|
||||||
|
# Spread the lateral shift over the whole 2m length so the merging ball
|
||||||
|
# retains forward momentum instead of striking the far wall sideways.
|
||||||
|
branch=[]
|
||||||
|
for i in range(129):
|
||||||
|
t=i/128
|
||||||
|
blend=3*t*t-2*t*t*t
|
||||||
|
branch.append((-1+2*t,.5-blend,1))
|
||||||
|
return [direct,branch]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def asset_dir(kind):
|
||||||
|
category = 'balls' if kind == 'iron_ball' else 'goals' if kind == 'goal_hole' else 'blocks' if kind in ('wall','directional_boost') else 'chutes'
|
||||||
|
return ROOT / 'assets' / category / kind
|
||||||
|
|
||||||
|
def export_objects(objects, name):
|
||||||
|
export_path = asset_dir(name) / 'baseline/model.glb'
|
||||||
|
export_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
for obj in objects: obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active=objects[0]
|
||||||
|
bpy.ops.export_scene.gltf(filepath=str(export_path),export_format='GLB',use_selection=True,export_yup=True,export_extras=True,export_apply=True)
|
||||||
|
|
||||||
|
|
||||||
|
def godot(v): return [round(v[0],6),round(v[2],6),round(-v[1],6)]
|
||||||
|
|
||||||
|
catalog={'schemaVersion':1,'unitsPerMeter':1,'authoringUp':'Z','runtimeUp':'Y','models':{}}
|
||||||
|
report={'generator':'Blender Python','ball_radius_m':BALL_R,'groove_radius_m':R,'hole_radius_m':HOLE_R,'assets':[],
|
||||||
|
'fit_clearance_m':FIT_CLEARANCE,'goal_radius_m':GOAL_R,
|
||||||
|
'important':['Flat blocks now contain closed circular passages; ramp passages can open through the bottom and use the test platform as support.',
|
||||||
|
'The steep ramp preserves 1m rise; its retained 1.5m prototype envelope remains explicitly flagged.']}
|
||||||
|
showcase=[]
|
||||||
|
for kind,rise in [('straight',0),('turn_cw',0),('turn_ccw',0),('gentle',.5),('steep',1),('y_merge',0)]:
|
||||||
|
body=block(kind,rise)
|
||||||
|
upper_paths=paths(kind,rise)
|
||||||
|
for n,path in enumerate(upper_paths):
|
||||||
|
cut(body,tube(f'{kind}_upper_{n}',extend(path),R,channel))
|
||||||
|
floor_center=top_height(0,rise)-R
|
||||||
|
hole_z=floor_center-HOLE_R*math.sqrt(1+rise*rise)-.02
|
||||||
|
# Diagonal mirror swaps X/Y, while keeping lower passages level.
|
||||||
|
lower_paths=[[(y,x,hole_z) for x,y,z in path] for path in upper_paths]
|
||||||
|
for n,path in enumerate(lower_paths):
|
||||||
|
cut(body,tube(f'{kind}_lower_{n}',extend(path),HOLE_R,wood))
|
||||||
|
for face in body.data.polygons:
|
||||||
|
face.use_smooth=(face.material_index==1)
|
||||||
|
body['asset_id']=kind
|
||||||
|
body['groove_radius_m']=R
|
||||||
|
declared_size=[2.0,2.0,1.0] if kind=='y_merge' else [1.0,1.0,1.0]
|
||||||
|
body['declared_size_m']=declared_size
|
||||||
|
body['rise_m']=rise
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
coords=[body.matrix_world @ v.co for v in body.data.vertices]
|
||||||
|
low=[min(v[i] for v in coords) for i in range(3)]
|
||||||
|
high=[max(v[i] for v in coords) for i in range(3)]
|
||||||
|
bounds=[round(high[i]-low[i],6) for i in range(3)]
|
||||||
|
# Sample the actual final boolean mesh for open channels and clearance.
|
||||||
|
from mathutils.bvhtree import BVHTree
|
||||||
|
tree=BVHTree.FromObject(body,bpy.context.evaluated_depsgraph_get())
|
||||||
|
minimum_clearance=10.0
|
||||||
|
for path in lower_paths:
|
||||||
|
for point in path[::4]:
|
||||||
|
loc,normal,index,distance=tree.find_nearest(Vector(point))
|
||||||
|
if loc is not None: minimum_clearance=min(minimum_clearance,distance)
|
||||||
|
manifold=bmesh.new();manifold.from_mesh(body.data)
|
||||||
|
bad_edges=sum(not e.is_manifold for e in manifold.edges);manifold.free()
|
||||||
|
upper_ports=[]
|
||||||
|
for path in upper_paths:
|
||||||
|
for idx in [0,-1]:
|
||||||
|
v=Vector(path[idx]);v.z-=R
|
||||||
|
tangent=Vector(path[1])-Vector(path[0]) if idx==0 else Vector(path[-1])-Vector(path[-2])
|
||||||
|
tangent.normalize()
|
||||||
|
if kind=='y_merge':
|
||||||
|
tangent=Vector((1,0,0)) # parallel interfaces on the opposite X faces
|
||||||
|
entry={'surface':godot(v),'travel':godot(tangent)}
|
||||||
|
if not any(p['surface']==entry['surface'] for p in upper_ports):upper_ports.append(entry)
|
||||||
|
meta={'path':'res://'+str((asset_dir(kind)/'baseline/model.glb').relative_to(ROOT)),'radius':None,'rise':rise,'grooveRadius':R,'passageRadius':HOLE_R,
|
||||||
|
'upperPaths':[[godot(p) for p in path] for path in upper_paths],
|
||||||
|
'lowerPaths':[[godot(p) for p in path] for path in lower_paths],
|
||||||
|
'ports':upper_ports,'bottomArchCenter':hole_z,'bottomRouteFloor':hole_z-HOLE_R,
|
||||||
|
'boundsBlender':{'min':low,'max':high,'size':bounds},'nominalCellFits':all(d<=1.001 for d in bounds),
|
||||||
|
'cellFootprint':[int(declared_size[0]),int(declared_size[1])],
|
||||||
|
'declaredSize':declared_size,'declaredBoundsFits':all(bounds[i]<=declared_size[i]+.001 for i in range(3)),
|
||||||
|
'prototypeNotes':[] if rise!=1 else ['Full semicircle plus 1m rise exceeds the nominal 1m cell height.']}
|
||||||
|
body['single_cell_compliant']=meta['nominalCellFits']
|
||||||
|
body['declared_size_compliant']=meta['declaredBoundsFits']
|
||||||
|
export_objects([body],kind)
|
||||||
|
catalog['models'][kind]=meta
|
||||||
|
report['assets'].append({'id':kind,'size_m':bounds,'single_cell_compliant':meta['nominalCellFits'],
|
||||||
|
'declared_size_m':declared_size,'declared_size_compliant':meta['declaredBoundsFits'],
|
||||||
|
'mesh_vertices':len(body.data.vertices),'mesh_faces':len(body.data.polygons),'non_manifold_edges':bad_edges,
|
||||||
|
'lower_path_min_distance_to_mesh_m':round(minimum_clearance,6),'lower_route_floor_local_z':hole_z-HOLE_R,
|
||||||
|
'passage_open_at_bottom':hole_z-HOLE_R<0})
|
||||||
|
showcase.append(body)
|
||||||
|
|
||||||
|
if kind=='y_merge':
|
||||||
|
report['y_connections']={'inlet_surface_positions':[godot((-1,-.5,1-R)),godot((-1,.5,1-R))],
|
||||||
|
'outlet_surface_position':godot((1,-.5,1-R)),'inlet_center_spacing_m':1.0,'inlet_height_difference_m':0.0,
|
||||||
|
'lower_passage':'closed circular bore in the same block'}
|
||||||
|
|
||||||
|
bpy.ops.mesh.primitive_uv_sphere_add(segments=64,ring_count=32,radius=BALL_R,location=(0,0,0))
|
||||||
|
ball=bpy.context.object;ball.name='iron_ball';ball.data.materials.append(iron);ball.data.materials.append(mark)
|
||||||
|
for face in ball.data.polygons:
|
||||||
|
face.use_smooth=True
|
||||||
|
# A narrow painted orientation band makes true rotation visible.
|
||||||
|
center=sum((ball.data.vertices[i].co for i in face.vertices),Vector())/len(face.vertices)
|
||||||
|
if abs(center.y)<.025:face.material_index=1
|
||||||
|
ball['asset_id']='iron_ball';ball['radius_m']=BALL_R
|
||||||
|
export_objects([ball],'iron_ball')
|
||||||
|
catalog['models']['iron_ball']={'path':'res://assets/balls/iron_ball/baseline/model.glb','radius':BALL_R,'boundsBlender':{'size':[2*BALL_R]*3}}
|
||||||
|
report['measured_ball_radius_m']=max(v.co.length for v in ball.data.vertices)
|
||||||
|
|
||||||
|
# A true narrow goal aperture: both entrance and throat have the same radius.
|
||||||
|
goal_vertices=[]
|
||||||
|
for z,rad in [(0,GOAL_R),(0,GOAL_R+.04),(-GOAL_DEPTH,GOAL_R),(-GOAL_DEPTH,GOAL_R+.04)]:
|
||||||
|
for i in range(96):
|
||||||
|
a=i*math.tau/96
|
||||||
|
goal_vertices.append((rad*math.cos(a),rad*math.sin(a),z))
|
||||||
|
goal_faces=[]
|
||||||
|
for i in range(96):
|
||||||
|
j=(i+1)%96
|
||||||
|
goal_faces += [(i,j,96+j,96+i),(192+i,288+i,288+j,192+j),(i,192+i,192+j,j),(96+i,96+j,288+j,288+i)]
|
||||||
|
goal=mesh_obj('goal_hole',goal_vertices,goal_faces)
|
||||||
|
goal.data.materials.append(goal_material)
|
||||||
|
goal['asset_id']='goal_hole';goal['opening_radius_m']=GOAL_R
|
||||||
|
export_objects([goal],'goal_hole')
|
||||||
|
catalog['models']['goal_hole']={'path':'res://assets/goals/goal_hole/baseline/model.glb','role':'goal','openingRadius':GOAL_R,'depth':GOAL_DEPTH,'rimThickness':.04}
|
||||||
|
(OUT/'catalog.json').write_text(json.dumps(catalog,indent=2,ensure_ascii=False))
|
||||||
|
(ROOT/'playtest/artifacts/baseline/geometry_report.json').write_text(json.dumps(report,indent=2,ensure_ascii=False))
|
||||||
|
for i,obj in enumerate(showcase):obj.location=(i%3*1.6,i//3*1.8,0)
|
||||||
|
ball.location=(5.5,.5,BALL_R)
|
||||||
|
goal.location=(6.5,.5,GOAL_DEPTH)
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(SOURCE/'collection.blend'))
|
||||||
|
print('INTOHOLE_ASSETS_READY',OUT)
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"interactive": [
|
||||||
|
{
|
||||||
|
"id": "directional_boost",
|
||||||
|
"name": "定向加速",
|
||||||
|
"assetId": "directional_boost"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nonInteractive": [
|
||||||
|
{
|
||||||
|
"id": "wall",
|
||||||
|
"name": "标准墙壁",
|
||||||
|
"assetId": "wall"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "goal_hole",
|
||||||
|
"name": "锥口球洞",
|
||||||
|
"assetId": "goal_hole"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"ballTypes": [
|
||||||
|
{
|
||||||
|
"ballTypeId": "iron_ball",
|
||||||
|
"assetId": "iron_ball",
|
||||||
|
"physicsProfileId": "solid_iron_test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"physicsProfiles": {
|
||||||
|
"solid_iron_test": {
|
||||||
|
"massKg": 890.0760306150601,
|
||||||
|
"inertiaModel": "solidSphere",
|
||||||
|
"dragCoefficient": 0.47,
|
||||||
|
"contactMaterialId": "iron"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contactMaterialPairs": [
|
||||||
|
{
|
||||||
|
"materialAId": "iron",
|
||||||
|
"materialBId": "painted_wood",
|
||||||
|
"staticFriction": 0.42,
|
||||||
|
"dynamicFriction": 0.32,
|
||||||
|
"rollingResistance": 0.025,
|
||||||
|
"restitution": 0.08
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"materialAId": "iron",
|
||||||
|
"materialBId": "iron",
|
||||||
|
"staticFriction": 0.35,
|
||||||
|
"dynamicFriction": 0.25,
|
||||||
|
"rollingResistance": 0.01,
|
||||||
|
"restitution": 0.15
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"notes": [
|
||||||
|
"Experimental contact coefficients; iron material is unchanged.",
|
||||||
|
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg."
|
||||||
|
],
|
||||||
|
"airDensity": 1.225
|
||||||
|
}
|
||||||
@@ -0,0 +1,245 @@
|
|||||||
|
"""Blender-only authoring of a separate Railbound-inspired asset family.
|
||||||
|
|
||||||
|
Copies a stable source once; never writes to the baseline assets. To adopt a
|
||||||
|
later baseline, remove only this family's source_snapshot files explicitly.
|
||||||
|
"""
|
||||||
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
from mathutils import Vector
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
SOURCE = Path(__file__).resolve().parent
|
||||||
|
SNAPSHOT = SOURCE / 'snapshot'
|
||||||
|
SNAPSHOT.mkdir(parents=True, exist_ok=True)
|
||||||
|
ONLY_ASSET = globals().get('ONLY_ASSET')
|
||||||
|
REPORTS = ROOT / 'playtest/artifacts/styled'
|
||||||
|
REPORTS.mkdir(parents=True, exist_ok=True)
|
||||||
|
OUT = SOURCE.parent
|
||||||
|
SOURCE.mkdir(parents=True, exist_ok=True)
|
||||||
|
snapshot = SNAPSHOT / 'source_snapshot.blend'
|
||||||
|
inputs = [ROOT/'assets/collections/baseline/source/collection.blend',
|
||||||
|
ROOT/'assets/collections/baseline/catalog.json', ROOT/'assets/collections/baseline/physics.json']
|
||||||
|
def digest(path):
|
||||||
|
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||||
|
|
||||||
|
if not snapshot.exists():
|
||||||
|
before = [digest(p) for p in inputs]
|
||||||
|
time.sleep(3)
|
||||||
|
if before != [digest(p) for p in inputs]:
|
||||||
|
raise RuntimeError('Baseline is changing. Wait for its current build, then retry.')
|
||||||
|
copies = [snapshot, SNAPSHOT/'source_catalog.json', SNAPSHOT/'source_physics.json']
|
||||||
|
for src, dst in zip(inputs, copies):
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
if before != [digest(p) for p in inputs] or before != [digest(p) for p in copies]:
|
||||||
|
for p in copies: p.unlink(missing_ok=True)
|
||||||
|
raise RuntimeError('Baseline changed during copy. No snapshot was retained.')
|
||||||
|
(SNAPSHOT/'source_manifest.json').write_text(json.dumps({
|
||||||
|
'files': {str(p.relative_to(ROOT)): h for p,h in zip(inputs,before)},
|
||||||
|
'copiedAtUnix': time.time(), 'readOnlyBaseline': True}, indent=2))
|
||||||
|
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(snapshot))
|
||||||
|
bpy.context.preferences.filepaths.save_version=0
|
||||||
|
catalog = json.loads((SNAPSHOT/'source_catalog.json').read_text())
|
||||||
|
physics = json.loads((SNAPSHOT/'source_physics.json').read_text())
|
||||||
|
palette = {'body':'B98A56', 'top':'E9C88B', 'groove':'FFF0C5',
|
||||||
|
'ink':'342E38', 'iron':'788A9E', 'iron_light':'C6DFE5',
|
||||||
|
'red':'CB6652', 'green':'799361'}
|
||||||
|
def mat(name, color, metallic=0.0, roughness=.85):
|
||||||
|
m = bpy.data.materials.new('Storybook / '+name)
|
||||||
|
rgba = tuple(int(color[i:i+2],16)/255 for i in (0,2,4))+(1,)
|
||||||
|
# Hex palette is sRGB; Blender's material values are linear.
|
||||||
|
rgba = tuple(((v+.055)/1.055)**2.4 if v>.04045 else v/12.92 for v in rgba[:3])+(1,)
|
||||||
|
m.diffuse_color = rgba
|
||||||
|
m.use_nodes = True
|
||||||
|
bsdf = m.node_tree.nodes.get('Principled BSDF')
|
||||||
|
bsdf.inputs['Base Color'].default_value = rgba
|
||||||
|
bsdf.inputs['Metallic'].default_value = metallic
|
||||||
|
bsdf.inputs['Roughness'].default_value = roughness
|
||||||
|
return m
|
||||||
|
mats={k:mat(k,v) for k,v in palette.items()}
|
||||||
|
mats['iron']=mat('iron satin','788A9E',.35,.5)
|
||||||
|
mats['wall']=mat('wall stone','A29E8B')
|
||||||
|
mats['wall_top']=mat('wall stone top','D8D3B4')
|
||||||
|
|
||||||
|
def mesh_object(name,vertices,faces):
|
||||||
|
mesh=bpy.data.meshes.new(name)
|
||||||
|
mesh.from_pydata(vertices,[],faces);mesh.update()
|
||||||
|
bm=bmesh.new();bm.from_mesh(mesh)
|
||||||
|
bmesh.ops.recalc_face_normals(bm,faces=bm.faces);bm.to_mesh(mesh);bm.free()
|
||||||
|
obj=bpy.data.objects.new(name,mesh);bpy.context.collection.objects.link(obj)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
def build_funnel():
|
||||||
|
bpy.data.objects.remove(bpy.data.objects['goal_hole'],do_unlink=True)
|
||||||
|
# A closed shell with a wide conical entrance and a true narrow outlet.
|
||||||
|
profile=[(.46,0),(.32,-.35),(.32,-1),(.36,-1),(.50,0)]
|
||||||
|
sides=96
|
||||||
|
vertices=[(radius*math.cos(i*math.tau/sides),radius*math.sin(i*math.tau/sides),z)
|
||||||
|
for radius,z in profile for i in range(sides)]
|
||||||
|
faces=[]
|
||||||
|
for ring in range(len(profile)):
|
||||||
|
next_ring=(ring+1)%len(profile)
|
||||||
|
for i in range(sides):
|
||||||
|
j=(i+1)%sides
|
||||||
|
faces.append((ring*sides+i,ring*sides+j,next_ring*sides+j,next_ring*sides+i))
|
||||||
|
return mesh_object('goal_hole',vertices,faces)
|
||||||
|
|
||||||
|
def build_wall(name='wall'):
|
||||||
|
vertices=[(x,y,z) for z in (0,1) for y in (-.5,.5) for x in (-.5,.5)]
|
||||||
|
faces=[(0,2,3,1),(4,5,7,6),(0,1,5,4),(2,6,7,3),(0,4,6,2),(1,3,7,5)]
|
||||||
|
return mesh_object(name,vertices,faces)
|
||||||
|
|
||||||
|
build_funnel();build_wall();build_wall('directional_boost')
|
||||||
|
catalog['models']['wall']={'role':'solid','category':'nonInteractive','collisionShape':'box',
|
||||||
|
'cellFootprint':[1,1],'boundsBlender':{'min':[-.5,-.5,0],'max':[.5,.5,1],'size':[1,1,1]},
|
||||||
|
'declaredSize':[1,1,1],'geometryOrigin':'authored'}
|
||||||
|
catalog['models']['directional_boost']={'role':'boost','category':'interactive','collisionShape':'box',
|
||||||
|
'cellFootprint':[1,1],'boundsBlender':{'min':[-.5,-.5,0],'max':[.5,.5,1],'size':[1,1,1]},
|
||||||
|
'declaredSize':[1,1,1],'geometryOrigin':'authored','arrowDirectionGodot':[1,0,0]}
|
||||||
|
catalog['models']['goal_hole']={'role':'goal','category':'nonInteractive','openingRadius':.32,
|
||||||
|
'entranceRadius':.46,'funnelDepth':.35,'depth':1.0,'cellFootprint':[1,1],
|
||||||
|
'boundsBlender':{'min':[-.5,-.5,-1],'max':[.5,.5,0],'size':[1,1,1]},
|
||||||
|
'declaredSize':[1,1,1],'geometryOrigin':'authored'}
|
||||||
|
|
||||||
|
def export(objects, path):
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
for obj in objects: obj.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active=objects[0]
|
||||||
|
path.parent.mkdir(parents=True,exist_ok=True)
|
||||||
|
bpy.ops.export_scene.gltf(filepath=str(path),export_format='GLB',
|
||||||
|
use_selection=True,export_yup=True,export_extras=True,export_apply=True)
|
||||||
|
|
||||||
|
def lines(name, segments, radius=.012):
|
||||||
|
curve=bpy.data.curves.new('ink_'+name,'CURVE')
|
||||||
|
curve.dimensions='3D'; curve.bevel_depth=radius; curve.bevel_resolution=0
|
||||||
|
curve.resolution_u=1
|
||||||
|
for points in segments:
|
||||||
|
spline=curve.splines.new('POLY'); spline.points.add(len(points)-1)
|
||||||
|
for point, value in zip(spline.points,points):point.co=(*value,1)
|
||||||
|
obj=bpy.data.objects.new('ink_'+name,curve)
|
||||||
|
bpy.context.collection.objects.link(obj); obj.data.materials.append(mats['ink'])
|
||||||
|
obj['visual_only']=True
|
||||||
|
return obj
|
||||||
|
|
||||||
|
def outline(obj):
|
||||||
|
bm=bmesh.new();bm.from_mesh(obj.data);bm.normal_update()
|
||||||
|
segments=[]
|
||||||
|
for edge in bm.edges:
|
||||||
|
if len(edge.link_faces)!=2 or edge.calc_face_angle(0)>math.radians(36):
|
||||||
|
segments.append([tuple(v.co) for v in edge.verts])
|
||||||
|
bm.free()
|
||||||
|
return lines(obj.name,segments)
|
||||||
|
|
||||||
|
def boost_arrow():
|
||||||
|
# Flat authored graphic above the top face; excluded from collision like ink outlines.
|
||||||
|
points=[(-.34,-.12),(.04,-.12),(.04,-.28),(.36,0),(.04,.28),(.04,.12),(-.34,.12)]
|
||||||
|
result=[]
|
||||||
|
for suffix,scale,z,color in [('border',1,1.002,'ink'),('fill',.82,1.003,'red')]:
|
||||||
|
arrow=mesh_object('ink_boost_arrow_'+suffix,[(x*scale,y*scale,z) for x,y in points],[tuple(range(7))])
|
||||||
|
arrow.data.materials.append(mats[color]);arrow['visual_only']=True
|
||||||
|
result.append(arrow)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def asset_dir(kind):
|
||||||
|
category = 'balls' if kind == 'iron_ball' else 'goals' if kind == 'goal_hole' else 'blocks' if kind in ('wall','directional_boost') else 'chutes'
|
||||||
|
return ROOT / 'assets' / category / kind
|
||||||
|
|
||||||
|
kinds=['straight','turn_cw','turn_ccw','gentle','steep','y_merge']
|
||||||
|
groups=[];report=[]
|
||||||
|
all_kinds=kinds+['iron_ball','goal_hole','wall','directional_boost']
|
||||||
|
if ONLY_ASSET is not None and ONLY_ASSET not in all_kinds:raise ValueError(ONLY_ASSET)
|
||||||
|
for kind in ([ONLY_ASSET] if ONLY_ASSET else all_kinds):
|
||||||
|
obj=bpy.data.objects[kind]
|
||||||
|
obj.location=(0,0,0)
|
||||||
|
obj.data=obj.data.copy()
|
||||||
|
before_coords=[tuple(v.co) for v in obj.data.vertices]
|
||||||
|
old_indices=[p.material_index for p in obj.data.polygons]
|
||||||
|
obj.data.materials.clear()
|
||||||
|
if kind in kinds:
|
||||||
|
for key in ['body','groove','top']:obj.data.materials.append(mats[key])
|
||||||
|
for face,old in zip(obj.data.polygons,old_indices):
|
||||||
|
face.material_index=1 if old==1 else (2 if face.normal.z>.55 else 0)
|
||||||
|
group=[obj,outline(obj)]
|
||||||
|
category='chutes'
|
||||||
|
elif kind=='iron_ball':
|
||||||
|
for key in ['iron','ink','iron_light']:obj.data.materials.append(mats[key])
|
||||||
|
for face,old in zip(obj.data.polygons,old_indices):
|
||||||
|
face.material_index=1 if old==1 else 0
|
||||||
|
# An authored, low-detail bright cap gives the sphere a graphic highlight.
|
||||||
|
if face.center.z>0.19 and face.center.x<-.04 and old!=1:face.material_index=2
|
||||||
|
group=[obj]
|
||||||
|
category='balls'
|
||||||
|
elif kind=='goal_hole':
|
||||||
|
obj.data.materials.append(mats['red'])
|
||||||
|
obj.data.materials.append(mats['top'])
|
||||||
|
obj.data.materials.append(mats['ink'])
|
||||||
|
for face in obj.data.polygons:
|
||||||
|
face.material_index=1 if face.index<96 else (2 if face.index<192 else 0)
|
||||||
|
face.use_smooth=face.index<192
|
||||||
|
group=[obj,outline(obj)]
|
||||||
|
category='environment'
|
||||||
|
else:
|
||||||
|
obj.data.materials.append(mats['wall']);obj.data.materials.append(mats['wall_top'])
|
||||||
|
for face in obj.data.polygons:face.material_index=1 if face.normal.z>.5 else 0
|
||||||
|
group=[obj,outline(obj)]
|
||||||
|
if kind=='directional_boost':group+=boost_arrow()
|
||||||
|
category='entities'
|
||||||
|
obj['style_family']='railbound_inspired'
|
||||||
|
obj['collision_source']='authored mesh' if kind in ('wall','goal_hole','directional_boost') else 'unchanged source mesh'
|
||||||
|
export(group,asset_dir(kind)/'model.glb')
|
||||||
|
catalog['models'][kind]['path']='res://'+str((asset_dir(kind)/'model.glb').relative_to(ROOT))
|
||||||
|
catalog['models'][kind]['sourceBlend']=str((asset_dir(kind)/'source/model.blend').relative_to(ROOT))
|
||||||
|
for member in group:
|
||||||
|
if member.type=='CURVE':
|
||||||
|
bpy.ops.object.select_all(action='DESELECT');member.select_set(True)
|
||||||
|
bpy.context.view_layer.objects.active=member
|
||||||
|
bpy.ops.object.convert(target='MESH')
|
||||||
|
source_path=asset_dir(kind)/'source/model.blend'
|
||||||
|
source_path.parent.mkdir(parents=True,exist_ok=True)
|
||||||
|
# A separate editable source file contains only one asset family member.
|
||||||
|
report.append({'id':kind,'collisionGeometryUnchanged':kind not in ('wall','goal_hole','directional_boost') and before_coords==[tuple(v.co) for v in obj.data.vertices],
|
||||||
|
'vertices':len(obj.data.vertices),'separateBlend':str(source_path.relative_to(ROOT))})
|
||||||
|
groups.append(group)
|
||||||
|
|
||||||
|
if ONLY_ASSET:
|
||||||
|
existing=json.loads((OUT/'catalog.json').read_text())
|
||||||
|
existing['models'][ONLY_ASSET]=catalog['models'][ONLY_ASSET]
|
||||||
|
catalog=existing
|
||||||
|
else:
|
||||||
|
catalog['models']={k:catalog['models'][k] for k in all_kinds}
|
||||||
|
catalog['styleFamily']='railbound_inspired'
|
||||||
|
catalog['palette']=palette
|
||||||
|
(OUT/'catalog.json').write_text(json.dumps(catalog,ensure_ascii=False,indent=2))
|
||||||
|
if not ONLY_ASSET:
|
||||||
|
(OUT/'physics.json').write_text(json.dumps(physics,ensure_ascii=False,indent=2))
|
||||||
|
(OUT/'entities.json').write_text(json.dumps({'interactive':[{'id':'directional_boost','name':'定向加速','assetId':'directional_boost'}],
|
||||||
|
'nonInteractive':[{'id':'wall','name':'标准墙壁','assetId':'wall'},
|
||||||
|
{'id':'goal_hole','name':'锥口球洞','assetId':'goal_hole'}]},ensure_ascii=False,indent=2))
|
||||||
|
if ONLY_ASSET:
|
||||||
|
names={member.name for member in groups[0]}
|
||||||
|
for obj in list(bpy.data.objects):
|
||||||
|
if obj.name not in names:bpy.data.objects.remove(obj,do_unlink=True)
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(ROOT/report[0]['separateBlend']))
|
||||||
|
else:
|
||||||
|
for i,group in enumerate(groups):
|
||||||
|
for member in group:member.location=(i%4*2.6,i//4*3,0)
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(SOURCE/'collection.blend'))
|
||||||
|
group_names=[[member.name for member in group] for group in groups]
|
||||||
|
for entry, names in zip(report,group_names):
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(SOURCE/'collection.blend'))
|
||||||
|
for obj in list(bpy.data.objects):
|
||||||
|
if obj.name not in names:bpy.data.objects.remove(obj,do_unlink=True)
|
||||||
|
else:obj.location=(0,0,0)
|
||||||
|
bpy.ops.wm.save_as_mainfile(filepath=str(ROOT/entry['separateBlend']))
|
||||||
|
(REPORTS/(('asset_'+ONLY_ASSET+'.json') if ONLY_ASSET else 'assets.json')).write_text(json.dumps({
|
||||||
|
'sourceManifest':json.loads((SNAPSHOT/'source_manifest.json').read_text()),
|
||||||
|
'models':report,'radius':catalog['models']['iron_ball']['radius'],
|
||||||
|
'physicalMaterialUnchanged':True,'outlineGeometry':'visual only'},indent=2))
|
||||||
|
print('STYLE_ASSETS_READY')
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"files": {
|
||||||
|
"assets/collections/baseline/source/collection.blend": "f81477cb30f5f5eb5a486a3a5e75c95b097204cfa5380c286cb1b40a85ee6962",
|
||||||
|
"assets/collections/baseline/catalog.json": "7af16a52c10655df0353198e0de97864aaa1b7669503139e7c4f727450929085",
|
||||||
|
"assets/collections/baseline/physics.json": "b12802f7763c162d037b0795e79272955031162790424831e88c939288f5526e"
|
||||||
|
},
|
||||||
|
"copiedAtUnix": 1794720924.17409,
|
||||||
|
"readOnlyBaseline": true,
|
||||||
|
"layoutMigration": "2026-11-16: paths moved; catalog resource paths rewritten; previous hashes retained in source_manifest.pre_reorganization.json"
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"files": {
|
||||||
|
"assets/blender/intohole_playtest.blend": "f81477cb30f5f5eb5a486a3a5e75c95b097204cfa5380c286cb1b40a85ee6962",
|
||||||
|
"playtest/assets/generated/catalog.json": "e2b22e92f53b2d26f6ee90a72f4148084c3d6402f51ce6d6c5b8bc552e21af86",
|
||||||
|
"playtest/data/physics.json": "b12802f7763c162d037b0795e79272955031162790424831e88c939288f5526e"
|
||||||
|
},
|
||||||
|
"copiedAtUnix": 1794720924.17409,
|
||||||
|
"readOnlyBaseline": true
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"ballTypes": [
|
||||||
|
{
|
||||||
|
"ballTypeId": "iron_ball",
|
||||||
|
"assetId": "iron_ball",
|
||||||
|
"physicsProfileId": "solid_iron_test"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"physicsProfiles": {
|
||||||
|
"solid_iron_test": {
|
||||||
|
"massKg": 890.0760306150601,
|
||||||
|
"inertiaModel": "solidSphere",
|
||||||
|
"dragCoefficient": 0.47,
|
||||||
|
"contactMaterialId": "iron"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contactMaterialPairs": [
|
||||||
|
{
|
||||||
|
"materialAId": "iron",
|
||||||
|
"materialBId": "painted_wood",
|
||||||
|
"staticFriction": 0.42,
|
||||||
|
"dynamicFriction": 0.32,
|
||||||
|
"rollingResistance": 0.025,
|
||||||
|
"restitution": 0.08
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"materialAId": "iron",
|
||||||
|
"materialBId": "iron",
|
||||||
|
"staticFriction": 0.35,
|
||||||
|
"dynamicFriction": 0.25,
|
||||||
|
"rollingResistance": 0.01,
|
||||||
|
"restitution": 0.15
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"notes": [
|
||||||
|
"Experimental contact coefficients; iron material is unchanged.",
|
||||||
|
"Solid iron sphere radius 0.3 m at nominal density 7870 kg/m³: mass about 890.08 kg."
|
||||||
|
],
|
||||||
|
"airDensity": 1.225
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -0,0 +1,68 @@
|
|||||||
|
"""Reopen every delivered .blend and compare physical meshes with the snapshot."""
|
||||||
|
import bpy
|
||||||
|
import bmesh
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT=Path(__file__).resolve().parents[4]
|
||||||
|
SOURCE=Path(__file__).resolve().parent/'snapshot'
|
||||||
|
catalog=json.loads((ROOT/'assets/collections/storybook/catalog.json').read_text())
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(SOURCE/'source_snapshot.blend'))
|
||||||
|
|
||||||
|
def geometry(obj):
|
||||||
|
return ([list(v.co) for v in obj.data.vertices],
|
||||||
|
[list(p.vertices) for p in obj.data.polygons])
|
||||||
|
|
||||||
|
baseline={kind:geometry(bpy.data.objects[kind]) for kind in catalog['models'] if kind in bpy.data.objects}
|
||||||
|
checks=[]
|
||||||
|
for kind,data in catalog['models'].items():
|
||||||
|
path=ROOT/data['sourceBlend']
|
||||||
|
bpy.ops.wm.open_mainfile(filepath=str(path))
|
||||||
|
obj=bpy.data.objects[kind]
|
||||||
|
physical=[o for o in bpy.context.scene.objects if not o.name.startswith('ink_')]
|
||||||
|
authored=data.get('geometryOrigin')=='authored'
|
||||||
|
mesh_match=None if authored else geometry(obj)==baseline[kind]
|
||||||
|
correct=(len(physical)==1 and physical[0].name==kind and
|
||||||
|
(authored or mesh_match) and obj.location.length<1e-6 and
|
||||||
|
all(abs(x-1)<1e-6 for x in obj.scale))
|
||||||
|
check={'id':kind,'passed':correct,'objects':[o.name for o in bpy.context.scene.objects],
|
||||||
|
'geometryMatchesSnapshot':mesh_match,
|
||||||
|
'origin':list(obj.location),'dimensions':list(obj.dimensions),
|
||||||
|
'materials':[m.name for m in obj.data.materials]}
|
||||||
|
if kind=='iron_ball':
|
||||||
|
radius=max(v.co.length for v in obj.data.vertices)
|
||||||
|
check['measuredRadius']=radius
|
||||||
|
correct=correct and abs(radius-data['radius'])<1e-6
|
||||||
|
check['passed']=correct
|
||||||
|
if authored:
|
||||||
|
bm=bmesh.new();bm.from_mesh(obj.data)
|
||||||
|
volume=abs(bm.calc_volume(signed=True));closed=all(e.is_manifold for e in bm.edges);bm.free()
|
||||||
|
correct=correct and closed and all(abs(d-1)<1e-6 for d in obj.dimensions)
|
||||||
|
if kind in ('wall','directional_boost'):
|
||||||
|
correct=correct and abs(volume-1)<1e-6
|
||||||
|
if kind=='directional_boost':
|
||||||
|
arrow=bpy.data.objects.get('ink_boost_arrow_fill')
|
||||||
|
correct=correct and arrow is not None
|
||||||
|
if arrow is not None:
|
||||||
|
points=[v.co for v in arrow.data.vertices]
|
||||||
|
tip=max(points,key=lambda v:v.x)
|
||||||
|
correct=correct and tip.x>0 and abs(tip.y)<1e-6 and all(1<v.z<1.01 for v in points)
|
||||||
|
check['arrowTipBlender']=list(tip)
|
||||||
|
else:
|
||||||
|
rings={}
|
||||||
|
for vertex in obj.data.vertices:
|
||||||
|
z=round(vertex.co.z,5);radius=round((vertex.co.x**2+vertex.co.y**2)**.5,5)
|
||||||
|
rings.setdefault(str(z),set()).add(radius)
|
||||||
|
correct=correct and rings=={'0.0':{.46,.5},'-0.35':{.32},'-1.0':{.32,.36}}
|
||||||
|
check['measuredRings']={k:sorted(v) for k,v in rings.items()}
|
||||||
|
check.update({'passed':correct,'closedManifold':closed,'solidVolume':volume})
|
||||||
|
checks.append(check)
|
||||||
|
manifest=json.loads((SOURCE/'source_manifest.json').read_text())
|
||||||
|
source_status={p:hashlib.sha256((ROOT/p).read_bytes()).hexdigest()==sha
|
||||||
|
for p,sha in manifest['files'].items()}
|
||||||
|
result={'passed':sum(c['passed'] for c in checks),'failed':sum(not c['passed'] for c in checks),
|
||||||
|
'baselineStillMatchesSnapshot':source_status,'checks':checks}
|
||||||
|
(ROOT/'playtest/artifacts/styled/reopened_assets.json').write_text(json.dumps(result,indent=2))
|
||||||
|
if result['failed']:raise RuntimeError('Standalone source asset verification failed')
|
||||||
|
print('REOPENED_ASSETS_VERIFIED',result['passed'])
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://ddese740rynta"
|
||||||
|
path="res://.godot/imported/model.glb-3c704f2ca09a958e53029997aab04263.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/goals/goal_hole/baseline/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-3c704f2ca09a958e53029997aab04263.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
Binary file not shown.
@@ -0,0 +1,45 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://b47w5my036nwg"
|
||||||
|
path="res://.godot/imported/model.glb-d285c1a541c65e53b4e6765b5169a459.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/goals/goal_hole/model.glb"
|
||||||
|
dest_files=["res://.godot/imported/model.glb-d285c1a541c65e53b4e6765b5169a459.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/root_script=null
|
||||||
|
mesh_library/use_node_names_as_mesh_names=false
|
||||||
|
array_mesh/deduplicate_surfaces=true
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
nodes/use_name_suffixes=true
|
||||||
|
nodes/use_node_type_suffixes=true
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
materials/extract=0
|
||||||
|
materials/extract_format=0
|
||||||
|
materials/extract_path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=2
|
||||||
|
gltf/embedded_image_handling=1
|
||||||
|
gltf/texture_map_mode=1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
"""Rebuild only this resource using the shared collection authoring code."""
|
||||||
|
from pathlib import Path
|
||||||
|
import runpy
|
||||||
|
|
||||||
|
RESOURCE = Path(__file__).resolve().parent.parent.name
|
||||||
|
ROOT = Path(__file__).resolve().parents[4]
|
||||||
|
runpy.run_path(str(ROOT / 'assets/collections/storybook/source/build.py'),
|
||||||
|
init_globals={'ONLY_ASSET': RESOURCE}, run_name='__main__')
|
||||||
Binary file not shown.
@@ -0,0 +1,123 @@
|
|||||||
|
# 参考画风副本与关卡工坊
|
||||||
|
|
||||||
|
更新日期:2026-11-16。此目录是一套可直接运行的独立美术副本与关卡创作工具。参考游戏是调查文档中的 Railbound,四张官方截图及视觉分析见 [参考目录](../references/games/railbound/README.md)。
|
||||||
|
|
||||||
|
## 启动
|
||||||
|
|
||||||
|
在项目根目录运行:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./scripts/showcase.zsh
|
||||||
|
./scripts/workshop.zsh
|
||||||
|
```
|
||||||
|
|
||||||
|
也可以双击根目录的 [scripts/Showcase.command](../scripts/Showcase.command) 或 [scripts/Workshop.command](../scripts/Workshop.command)。两个场景可在 Godot 中直接打开并按 F6 运行:
|
||||||
|
|
||||||
|
- [showcase.tscn](../playtest/showcase/scenes/showcase.tscn):固定的基础展示关卡。
|
||||||
|
- [workshop.tscn](scenes/workshop.tscn):不限滑槽数量的关卡工坊。
|
||||||
|
|
||||||
|
两个场景分别绑定自己的启动脚本,独立启动且不提供相互切换的入口。展示场景只载入固定展示路线;关卡工坊每次从空白布局开始,需要时通过存档列表手动载入已保存关卡。
|
||||||
|
|
||||||
|
原来的 `scripts/python/baseline.py play / merge / compare` 及主场景保持原有用途。新入口不重建原滑槽资产。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 独立资产
|
||||||
|
|
||||||
|
新资产位于 `assets/<资源类型>/<资源名>/model.glb`,可编辑源文件位于 `assets/<资源类型>/<资源名>/source/`。六种滑槽分别具有自己的 `.blend` 和 `.glb`;整体陈列文件为 [style_collection.blend](../assets/collections/storybook/source/collection.blend)。
|
||||||
|
|
||||||
|
| 类型 | 独立建模源文件 |
|
||||||
|
| --- | --- |
|
||||||
|
| 直行 | [straight.blend](../assets/chutes/straight/source/model.blend) |
|
||||||
|
| 顺时针拐弯 | [turn_cw.blend](../assets/chutes/turn_cw/source/model.blend) |
|
||||||
|
| 逆时针拐弯 | [turn_ccw.blend](../assets/chutes/turn_ccw/source/model.blend) |
|
||||||
|
| 缓坡 | [gentle.blend](../assets/chutes/gentle/source/model.blend) |
|
||||||
|
| 陡坡 | [steep.blend](../assets/chutes/steep/source/model.blend) |
|
||||||
|
| Y 汇流 | [y_merge.blend](../assets/chutes/y_merge/source/model.blend) |
|
||||||
|
| 铁球 | [iron_ball.blend](../assets/balls/iron_ball/source/model.blend) |
|
||||||
|
| 锥口球洞(非交互) | [goal_hole.blend](../assets/goals/goal_hole/source/model.blend) |
|
||||||
|
| 标准实心墙壁(非交互) | [wall.blend](../assets/blocks/wall/source/model.blend) |
|
||||||
|
| 定向加速方块(交互) | [directional_boost.blend](../assets/blocks/directional_boost/source/model.blend) |
|
||||||
|
|
||||||
|
六种滑槽和铁球基于稳定快照进行分色与轮廓建模,仍保留 **球半径 0.3 m、槽/通孔半径 0.32 m**;这七个模型的接触网格与快照一致。Y 汇流保留 2×2 占用;陡坡保留现有 1×1×1.5 m 试验包围尺寸和 1 m 高差。新增描边网格仅供渲染,不加入碰撞体。
|
||||||
|
|
||||||
|
标准墙壁是实心 **1×1×1 m** 立方体,碰撞采用从模型包围尺寸生成的实心盒体。球洞重新建模为 **1×1×1 m** 的漏斗外形:上口半径 0.46 m,锥面下降 0.35 m 后收窄至 0.32 m 的喉口,通道总深度 1 m。锥面和喉口均有真实三角面碰撞,靠重力与接触引导球进入,没有吸附或轨迹牵引。球洞的模型原点仍在上沿,墙壁的模型原点在底部;工坊坐标栏统一显示方块底面,内部自动换算模型原点,既有存档坐标不整体平移。
|
||||||
|
|
||||||
|
目前只制作铁球这一种材质球,其文件、资源索引和物理预设都与滑槽分开。关卡中的两颗铁球是同一资产的两个独立刚体实例,不是合并模型。后续每种球应在 `assets/balls/<资源名>/` 下建立自己的源文件、制作入口和导出文件,并在独立 [physics.json](../assets/collections/storybook/physics.json) 中增加 `ballTypeId / assetId / physicsProfileId`;目前没有创建未经定义的其他材质球。
|
||||||
|
|
||||||
|
[source_manifest.json](../assets/collections/storybook/source/snapshot/source_manifest.json) 记录基线来源哈希。首次复制前后均检查源文件稳定性,随后重建只读取副本快照。后续如要接入新的模型优化,应显式刷新这套快照并重新验证,避免在其他 Agent 建模时混入半成品。正式设计文档中的数值同步由原模型优化任务处理,本文件说明的是当前副本的实际资产。
|
||||||
|
|
||||||
|
## 基础展示关卡
|
||||||
|
|
||||||
|
“林间汇流”使用 14 块滑槽:8 块直行、2 块缓坡、两种拐弯各 1 块、1 块陡坡、1 块 Y 汇流。布局与起点见 [showcase.json](../playtest/showcase/data/showcase.json)。
|
||||||
|
|
||||||
|
两颗铁球在同一物理帧从同高的两条支路释放,默认初速度为 0,即静止释放。A 支路比 B 多一个直槽,靠真实行程产生到达时间差;汇流后共同经过左转、右转、陡坡和末端直槽,再进入同一个窄洞口。初速度仅在启动时设置一次,没有持续推力、运行中速度重设、路径牵引、延迟放球或隐藏承托碰撞体。
|
||||||
|
|
||||||
|
末端另有一块旋转 90° 的直槽,以其可见实体侧面作为洞后止挡,承接剩余水平速度。早期没有止挡时,重复试跑曾出现越过窄洞口的情况;加入这块现有滑槽后,通过 30 次连续完整双球试跑。它也是可选中、移动和删除的普通直槽,不是隐藏墙体或新实体类型。
|
||||||
|
|
||||||
|
两球间碰撞保持开启,保留快照中的摩擦、回弹、空气阻力与滚动阻力。入洞按穿过洞口底部截面和真实孔径净空检测,每球只计一次;入洞后移除其碰撞并隐藏,全部入洞才成功,丢球不减少目标数量。
|
||||||
|
|
||||||
|
测试场景界面只保留“启动”“重置”和初速度滑块。初速度范围为 0–5 m/s,步长 0.1 m/s,同时作用于两颗铁球,方向沿各自出生槽的下坡切线。启动后锁定滑块,再次实验先点击重置;重置恢复两颗球并保留当前滑块值。`空格` 启动,`T` 重置;右键拖动旋转观察,中键拖动平移,滚轮缩放,`F` 回到全景。
|
||||||
|
|
||||||
|
默认 0 m/s 时,自动测试中的完成时间约 8 秒,逐次结果见验证报告。物理求解与运行帧调度会使结果略有差异;调节初速度后的行进结果由实际物理运动决定。
|
||||||
|
|
||||||
|
## 人工搭建
|
||||||
|
|
||||||
|
工坊默认打开空白布局,不自动载入展示路线或旧会话草稿。侧栏可以滚动;画面下方始终显示操作结果。工坊是关卡作者工具,允许放置不相邻的初始路线,便于创建多条出生支路;这不修改正式玩家玩法的依附与逐关配额规则。
|
||||||
|
|
||||||
|
1. 在素材栏选择 **滑槽 / 小球 / 交互方块 / 非交互方块**。小球是与滑槽并列的独立菜单项,位于菜单第一行右侧;滑槽显示六种积木,选择小球后直接显示铁球坐标与放置控件;非交互方块显示“标准墙壁”和“锥口球洞”;交互方块显示“定向加速”。
|
||||||
|
2. 默认使用 **放置模式**。点击地面选择 Y=0 的位置;点击已有墙块的顶面会把待放方块底面对齐到墙顶,点击侧面则选择相邻格位。选好后点击 **放置新方块**。这个按钮始终新增,绝不会移动或替换原方块。
|
||||||
|
3. 方块坐标统一为 **X / 底面 Y / Z**,可见地面与固定网格都是 **Y=0**。例如标准墙第一层底面为 0,第二层为 1,第三层为 2;可以直接输入坐标后连续新增,无需先取消选中。修改已有方块时切换到 **选择 / 移动**,点击目标方块,修改坐标或类型,再点 **应用修改到选中方块**。`R` 在放置模式旋转预览,在选择模式旋转选中方块;删除只作用于明确选中的方块或球。支持撤销、重做和多层占用检查,所有九种现有方块均可放在墙顶。
|
||||||
|
4. 点击菜单中的 **小球**,默认使用 **贴表面点选**:点击地面或墙面会按球的实际半径计算球心,点击滑槽会对准最近的上方槽线。槽口紧邻墙体时会寻找同一槽内最近的无重叠位置,容不下球时会提示重新选点。半透明球预览落点,点击 **+ 放置铁球** 才实际新增。也可以切换 **按 Y 高度点选(悬空)**,先设置球心 Y,再点击场景选择该水平面上的 X/Z;无须先放滑槽。坐标仍可按 0.01 m 精度输入或微调,Y 始终表示球心高度。切回方块菜单只隐藏小球编辑控件和预览,已放置的小球保留。
|
||||||
|
5. 移动已有球时,先从铁球列表或场景中点击选球,再点击目标墙面、滑槽或指定高度平面,最后点击 **移动选中铁球**。点选新位置只更新预览,不会擅自移动旧球;“+ 放置铁球”始终新增。也可直接改坐标后移动,支持撤销、重做、重置和存档。移动或删除方块不会牵动已放置的小球。
|
||||||
|
6. 球洞作为非交互方块,使用与墙块相同的放置、选择、移动、删除、撤销及存档流程。可放置多个球洞,任意球进入任意球洞都只记一次;所有预设球入洞后才算成功。
|
||||||
|
7. 按空格试跑,悬空球会自由下落并与墙体、滑槽或锥面发生真实碰撞;运行和暂停期间锁定编辑。按 `T` 恢复原布局与所有球的球心坐标。
|
||||||
|
8. 在侧栏下部输入名称并保存。文件写入 `designer/drafts/<名称>.json`,覆盖时保留 `.json.bak`。从列表选择名称后点击“载入”;非法对象、非数值坐标或方块重叠会被拒绝,失败不会清空当前关卡。
|
||||||
|
|
||||||
|
选择 **交互方块 → 定向加速**,选位置并点击“放置新方块”;按 `R` 旋转箭头方向。所有方块每次触发均固定增加 **5 m/s**,工坊只显示“固定增速:+5 m/s”,不提供调节入口,运行中也不可更改。
|
||||||
|
|
||||||
|
把铁球放在方块顶面并启动,即可在首次真实顶面接触时沿箭头起步。运动中的球先改为箭头方向,再在原水平速率上加上增量:原水平速率 2 m/s 时,触发结果为沿箭头的 7 m/s。保留当时的竖直速度和角速度;之后继续正常物理运动。侧面、底面及悬空经过不触发;每颗球每次接触只触发一次,充分离开再接触可重新触发,暂停/继续不重复增速,重置会清空触发记录。顶面被其他实体覆盖时,不会隔着覆盖物加速。方块仍提供完整实心碰撞,箭头为不参与碰撞的平面标识。
|
||||||
|
|
||||||
|
加速方块以 `kind: "directional_boost"`、位置与 `quarter` 保存到实体记录中,支持保存/载入、移动、删除、撤销和重做。速度增量属于固定玩法规则,不写入关卡数据。旧存档中的 `speedGain` 会在载入时忽略,再次保存时移除;任何旧数值均不能覆盖固定的 +5 m/s。不含加速方块的旧关卡不会新增加速效果。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
地面是编辑器的可视坐标基准,不新增地面碰撞行为;球的运动仍由已放置的实体碰撞决定。高层放置只显示局部轮廓与高度辅助线,整片网格不会随所选高度升起。球洞跨越 Y=0 时,地面预留开口,避免盖住洞内通道。
|
||||||
|
|
||||||
|
当前存档版本为 **2**:`pieces` 保存滑槽,`entities` 保存墙壁、球洞和定向加速方块,`balls[].position` 保存独立球心坐标。版本 1 的旧存档仍可载入:旧 `pieceId / pathT / branch` 会按当时滑槽姿态换算为世界坐标,旧 `goal` 字段会转换成非交互球洞实例。再次保存才写为新版本,不自动覆盖磁盘上的旧文件。方块仍存储模型原点坐标,因此读取旧球洞时,会将原点高度减去模型底面偏移后显示,不改变它的实际位置。
|
||||||
|
|
||||||
|
旧版 [meadowexample.json](../playtest/showcase/data/meadowexample.json) 保留作为兼容性样本,需要时可从存档列表载入。载入后仍处于关卡工坊,不会启动或修改展示场景。关闭应用前请保存。
|
||||||
|
|
||||||
|
[entities.json](../assets/collections/storybook/entities.json) 是实体素材分类目录。交互方块已接入定向加速方块;非交互方块已经接入实心墙壁和锥口球洞。后续添加实体时需同时补齐模型、碰撞、数据与行为。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 验证与重建
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./scripts/run.zsh build
|
||||||
|
./scripts/run.zsh test
|
||||||
|
./scripts/run.zsh capture
|
||||||
|
```
|
||||||
|
|
||||||
|
`build` 从快照重建六种滑槽与铁球,并生成墙体、锥口球洞和定向加速方块,写入独立目录,不覆盖原试玩资产。`test` 重新打开 10 个独立 Blender 源文件:七个快照模型检查几何一致性,墙体检查闭合、1 m 尺寸和 1 m³ 实体体积,球洞检查闭合壳体以及各高度的真实半径,加速方块检查实心体积和箭头几何朝向。随后运行 42 项场景/工坊检查、40 项实体与自由小球检查、26 项叠放/地面检查、40 项鼠标点选放球检查、67 项定向加速检查和 30 次完整双球试跑。`capture` 保存两个独立场景的原生渲染。
|
||||||
|
|
||||||
|
最近验证记录:10 个源文件检查、215 项运行检查通过,30 次双球试跑全部入洞。报告分别为 [reopened_assets.json](../playtest/artifacts/styled/reopened_assets.json)、[report.json](../playtest/artifacts/styled/report.json)、[entities_report.json](../playtest/artifacts/styled/entities_report.json)、[stacking_report.json](../playtest/artifacts/styled/stacking_report.json)、[ball_placement_report.json](../playtest/artifacts/styled/ball_placement_report.json)、[boost_report.json](../playtest/artifacts/styled/boost_report.json) 和 [repeat_runs.json](../playtest/artifacts/styled/repeat_runs.json)。
|
||||||
|
|
||||||
|
实体专项覆盖四类菜单、小球放置控件无需滚动即可看到、墙壁接住落球与阻挡横向球、任意球心坐标冻结/下落/重置、独立移动与撤销、删除方块保留小球、8 个偏心落点的锥面导入、多洞计数、实体编辑与存档往返,以及旧存档迁移。展示关卡仍只保留启动、重置和初速度三个控件。
|
||||||
|
|
||||||
|
原生渲染已检查;叠放专项使用 Viewport.push_input 注入鼠标按下/释放事件,经过真实 GUI 按钮、未处理输入和物理射线流程,覆盖截图同坐标两块底层墙、输入 Y=1 新增、三层鼠标叠放、侧面拼接、顶部放滑槽、显式移动、重叠拒绝与存档往返。其余编辑检查使用节点信号、射线选取及物理运行验证。测试覆盖当前示例和所列操作路径,不代表任意人工布局都可通关;可以用工坊的真实物理试跑继续检查新关卡。
|
||||||
|
|
||||||
|
小球点选专项经过完整 Viewport 鼠标输入和 GUI 按钮流程,覆盖地面、三层墙顶、六种滑槽的四个朝向、固定 Y 悬空选点、选中移动、撤销重做、运行时锁定与存档。自动生成的槽内落点用真实 SphereShape3D 与场景碰撞几何查询验证不重叠;放置后的运动仍由刚体物理决定,点选槽线仅用于编辑阶段的初始定位。
|
||||||
|
|
||||||
|
定向加速专项经过真实刚体顶面接触,覆盖四个朝向与静止、同向、反向、侧向来球,核对触发前后速率相加及保留竖直速度;同时检查停留去重、暂停/继续、离开重入、重置、多球、连续多个加速方块、侧面/底面/悬空/遮挡不触发,以及固定增速显示、工坊无调节入口、旧存档和旧运行元数据不能覆盖固定 +5 m/s、存档和撤销恢复。完整鼠标流程另覆盖墙上叠放加速方块、点顶面放球并点击启动。
|
||||||
|
|
||||||
|
2026-11-16 固定增速修订:重新完成 67 项定向加速检查、42 项场景/工坊检查和 40 项实体与存档检查,均通过;其余模型、叠放、放球和重复试跑记录沿用前次验证。
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# 关卡草稿
|
||||||
|
|
||||||
|
工坊保存的 JSON 位于此处,覆盖时保留 `.json.bak`,尚未作为正式关卡发布。
|
||||||
|
|
||||||
|
工坊列表也提供 `playtest/` 中的内置示例;载入后保存会写入此处,不覆盖示例原件。
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene load_steps=2 format=3]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://designer/scripts/workshop.gd" id="1"]
|
||||||
|
|
||||||
|
[node name="Workshop" type="Node3D"]
|
||||||
|
script = ExtResource("1")
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
var lib
|
||||||
|
var chutes: Array
|
||||||
|
var entity_ids: Array=[]
|
||||||
|
|
||||||
|
func _init(library, chute_ids: Array) -> void:
|
||||||
|
lib=library;chutes=chute_ids
|
||||||
|
var registry=JSON.parse_string(FileAccess.get_file_as_string("res://assets/collections/storybook/entities.json"))
|
||||||
|
for group in ["interactive","nonInteractive"]:
|
||||||
|
for item in registry[group]:entity_ids.append(item.id)
|
||||||
|
|
||||||
|
func valid_vector(value: Variant) -> bool:
|
||||||
|
if not value is Array or value.size()!=3:return false
|
||||||
|
for n in value:
|
||||||
|
if not (n is float or n is int) or not is_finite(float(n)):return false
|
||||||
|
return true
|
||||||
|
|
||||||
|
func overlaps(a: Dictionary,b: Dictionary) -> bool:
|
||||||
|
var ab: AABB=lib.record_bounds(a);var bb: AABB=lib.record_bounds(b)
|
||||||
|
var extent: Vector3=ab.end.min(bb.end)-ab.position.max(bb.position)
|
||||||
|
return extent.x>.001 and extent.y>.001 and extent.z>.001
|
||||||
|
|
||||||
|
func validate(data: Variant) -> String:
|
||||||
|
if not data is Dictionary:return "关卡文件必须是 JSON 对象"
|
||||||
|
var version=data.get("schemaVersion")
|
||||||
|
if not (version is int or version is float):return "缺少关卡版本"
|
||||||
|
if (version!=1 and version!=2) or data.get("assetFamily")!="railbound_inspired":return "关卡版本或资产系列不匹配"
|
||||||
|
if not data.get("pieces") is Array or not data.get("balls") is Array or not data.get("entities",[]) is Array:return "缺少积木、实体或铁球数据"
|
||||||
|
var legacy: bool=data.schemaVersion==1
|
||||||
|
if legacy and (not valid_vector(data.get("goal")) or not data.get("entities",[]).is_empty()):return "旧版洞口或实体数据无效"
|
||||||
|
var ids: Array=[];var decoded: Array=[]
|
||||||
|
for group in ["pieces","entities"]:
|
||||||
|
for r in data.get(group,[]):
|
||||||
|
var allowed: Array=chutes if group=="pieces" else entity_ids
|
||||||
|
if not r is Dictionary or r.get("kind") not in allowed or not valid_vector(r.get("position")):return "无效的方块类型或坐标"
|
||||||
|
if not r.get("id") is String or r.id.is_empty() or r.id in ids:return "方块编号缺失或重复"
|
||||||
|
if not (r.get("quarter") is float or r.get("quarter") is int):return "无效的旋转值"
|
||||||
|
if r.quarter!=int(r.quarter) or r.quarter<0 or r.quarter>3:return "旋转必须为 0 / 90 / 180 / 270 度"
|
||||||
|
if r.kind!="goal_hole" and (r.position[0]!=round(r.position[0]) or r.position[2]!=round(r.position[2]) or r.position[1]*2!=round(r.position[1]*2)):return "积木坐标必须对齐网格"
|
||||||
|
var d={"id":r.id,"kind":r.kind,"position":lib.vector(r.position),"quarter":int(r.quarter)}
|
||||||
|
for other in decoded:
|
||||||
|
if overlaps(d,other):return "关卡中有重叠方块"
|
||||||
|
decoded.append(d);ids.append(r.id)
|
||||||
|
var ball_ids: Array=[]
|
||||||
|
for b in data.balls:
|
||||||
|
if not b is Dictionary or not b.get("id") is String or b.id.is_empty() or b.id in ball_ids:return "铁球编号缺失或重复"
|
||||||
|
if legacy:
|
||||||
|
if b.get("pieceId") not in ids:return "旧版铁球起点引用无效"
|
||||||
|
if not (b.get("pathT") is float or b.get("pathT") is int) or not is_finite(float(b.pathT)) or b.pathT<0 or b.pathT>1:return "旧版起点位置必须位于槽内"
|
||||||
|
var r: Dictionary=decoded[ids.find(b.pieceId)]
|
||||||
|
if not (b.get("branch") is float or b.get("branch") is int) or b.branch!=int(b.branch) or b.branch<0 or b.branch>=lib.catalog[r.kind].upperPaths.size():return "旧版起点分支无效"
|
||||||
|
else:
|
||||||
|
if not valid_vector(b.get("position")):return "铁球球心坐标无效"
|
||||||
|
if b.get("ballTypeId","iron_ball")!="iron_ball":return "未知的小球类型"
|
||||||
|
if b.has("launchDirection") and not valid_vector(b.launchDirection):return "初速度方向无效"
|
||||||
|
ball_ids.append(b.id)
|
||||||
|
return ""
|
||||||
|
|
||||||
|
func array_from(v: Vector3) -> Array:
|
||||||
|
return [v.x,v.y,v.z]
|
||||||
|
|
||||||
|
func normalize(data: Dictionary) -> Dictionary:
|
||||||
|
var records: Array=[]
|
||||||
|
for r in data.pieces+data.get("entities",[]):
|
||||||
|
var record={"id":r.id,"kind":r.kind,"position":lib.vector(r.position),"quarter":int(r.quarter)}
|
||||||
|
# Obsolete per-block speedGain fields are intentionally discarded on load.
|
||||||
|
records.append(record)
|
||||||
|
var balls: Array=[]
|
||||||
|
if data.schemaVersion==1:
|
||||||
|
for b in data.balls:
|
||||||
|
var record: Dictionary={}
|
||||||
|
for r in records:
|
||||||
|
if r.id==b.pieceId:record=r;break
|
||||||
|
var basis:=Basis(Vector3.UP,-int(record.quarter)*PI/2)
|
||||||
|
var position: Vector3=lib.record_center(record)+basis*lib.ball_on_surface(record.kind,float(b.pathT),int(b.branch))
|
||||||
|
var direction: Vector3=basis*lib.path_tangent(record.kind,float(b.pathT),int(b.branch))
|
||||||
|
if direction.y>0:direction=-direction
|
||||||
|
balls.append({"id":b.id,"ballTypeId":"iron_ball","position":array_from(position),"launchDirection":array_from(direction.normalized())})
|
||||||
|
var goal_id: String="legacy_goal"
|
||||||
|
while records.any(func(r):return r.id==goal_id):goal_id+="_"
|
||||||
|
records.append({"id":goal_id,"kind":"goal_hole","position":lib.vector(data.goal),"quarter":0})
|
||||||
|
else:
|
||||||
|
for b in data.balls:
|
||||||
|
balls.append({"id":b.id,"ballTypeId":"iron_ball","position":array_from(lib.vector(b.position)),"launchDirection":array_from(lib.vector(b.get("launchDirection",[1,0,0])))})
|
||||||
|
return {"records":records,"balls":balls}
|
||||||
|
|
||||||
|
func encode(records: Array,balls: Array,title: String) -> Dictionary:
|
||||||
|
var pieces: Array=[];var entities: Array=[]
|
||||||
|
for r in records:
|
||||||
|
var item={"id":r.id,"kind":r.kind,"position":array_from(r.position),"quarter":r.quarter}
|
||||||
|
if r.kind in chutes:pieces.append(item)
|
||||||
|
else:entities.append(item)
|
||||||
|
return {"schemaVersion":2,"assetFamily":"railbound_inspired","title":title,"pieces":pieces,"entities":entities,"balls":balls.duplicate(true)}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bs6caehm4udx2
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
# The editor always works in bottom-face coordinates; imported mesh origins stay intact.
|
||||||
|
var lib
|
||||||
|
func _init(library) -> void:lib=library
|
||||||
|
|
||||||
|
func bottom_of(record: Dictionary) -> Vector3:
|
||||||
|
return record.position+Vector3.UP*float(lib.catalog[record.kind].boundsBlender.min[2])
|
||||||
|
|
||||||
|
func record_at(kind: String,bottom: Vector3,quarter: int,id: String) -> Dictionary:
|
||||||
|
var at:=bottom
|
||||||
|
if kind!="goal_hole":at=Vector3(round(at.x),snappedf(at.y,.5),round(at.z))
|
||||||
|
var local_min: float=lib.catalog[kind].boundsBlender.min[2]
|
||||||
|
return {"id":id,"kind":kind,"position":at-Vector3.UP*local_min,"quarter":quarter}
|
||||||
|
|
||||||
|
func on_face(support: Dictionary,point: Vector3,normal: Vector3,kind: String,quarter: int) -> Vector3:
|
||||||
|
var bounds: AABB=lib.record_bounds(support)
|
||||||
|
var size: Vector2i=lib.footprint(kind,quarter)
|
||||||
|
var height: float=lib.catalog[kind].boundsBlender.size[2]
|
||||||
|
var result:=Vector3(round(point.x),bounds.position.y,round(point.z))
|
||||||
|
var axis:=normal.abs().max_axis_index()
|
||||||
|
if axis==1:
|
||||||
|
result.y=bounds.end.y if normal.y>=0 else bounds.position.y-height
|
||||||
|
elif axis==0:
|
||||||
|
result.x=bounds.end.x+.5 if normal.x>=0 else bounds.position.x+.5-size.x
|
||||||
|
else:
|
||||||
|
result.z=bounds.end.z+.5 if normal.z>=0 else bounds.position.z+.5-size.y
|
||||||
|
if kind!="goal_hole":
|
||||||
|
if axis==1:result.y=ceilf(result.y*2-.0001)/2 if normal.y>=0 else floorf(result.y*2+.0001)/2
|
||||||
|
elif axis==0:result.x=ceilf(result.x-.0001) if normal.x>=0 else floorf(result.x+.0001)
|
||||||
|
else:result.z=ceilf(result.z-.0001) if normal.z>=0 else floorf(result.z+.0001)
|
||||||
|
return result
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dek3whv0flsft
|
||||||
@@ -0,0 +1,907 @@
|
|||||||
|
extends Node3D
|
||||||
|
|
||||||
|
const Library = preload("res://runtime/asset_library.gd")
|
||||||
|
const LevelData = preload("res://designer/scripts/level_data.gd")
|
||||||
|
const Placement = preload("res://designer/scripts/placement.gd")
|
||||||
|
const Booster = preload("res://assets/blocks/directional_boost/behavior.gd")
|
||||||
|
const IDS = ["straight", "turn_cw", "turn_ccw", "gentle", "steep", "y_merge"]
|
||||||
|
const TITLES = ["直行", "右转", "左转", "缓坡 ½", "陡坡 1", "Y 汇流"]
|
||||||
|
const INK = Color("343143")
|
||||||
|
const PAPER = Color("fff4d9")
|
||||||
|
const ACCENT = Color("bf6050")
|
||||||
|
const SAVE_DIR = "res://designer/drafts"
|
||||||
|
const EXAMPLE_LEVELS = ["res://playtest/showcase/data/meadowexample.json", "res://playtest/underpass/data/underpass_validation.json"]
|
||||||
|
var editor_mode := false
|
||||||
|
var lib = Library.new()
|
||||||
|
var codec = LevelData.new(lib,IDS)
|
||||||
|
var placement = Placement.new(lib)
|
||||||
|
var entity_registry: Dictionary=JSON.parse_string(FileAccess.get_file_as_string("res://assets/collections/storybook/entities.json"))
|
||||||
|
var records: Array = []
|
||||||
|
var spawn_specs: Array = []
|
||||||
|
var goal_position := Vector3.ZERO # Compatibility: first goal position.
|
||||||
|
var goals: Array=[]
|
||||||
|
var pieces: Array = []
|
||||||
|
var balls: Array = []
|
||||||
|
var tags: Array = []
|
||||||
|
var previous: Array = []
|
||||||
|
var entered := {}
|
||||||
|
var lost := {}
|
||||||
|
var events: Array = []
|
||||||
|
var samples: Array = []
|
||||||
|
var release_ticks: Array = []
|
||||||
|
var pause_states: Array = []
|
||||||
|
var visited := {}
|
||||||
|
var contact_visited := {}
|
||||||
|
var elapsed := 0.0
|
||||||
|
var started := false
|
||||||
|
var paused := false
|
||||||
|
var status := "准备好,让两颗铁球一起出发。"
|
||||||
|
var world := Node3D.new()
|
||||||
|
var actors := Node3D.new()
|
||||||
|
var camera := Camera3D.new()
|
||||||
|
var grid := Node3D.new()
|
||||||
|
var selection := Node3D.new()
|
||||||
|
var cursor := Vector3.ZERO # Bottom-face placement coordinates, ground Y = 0.
|
||||||
|
var block_mode := "place"
|
||||||
|
var last_placed_id := ""
|
||||||
|
var mode_buttons: Dictionary={}
|
||||||
|
var place_button: Button
|
||||||
|
var apply_button: Button
|
||||||
|
var delete_button: Button
|
||||||
|
var boost_controls: VBoxContainer
|
||||||
|
var ground_view := MeshInstance3D.new()
|
||||||
|
var ground_holes: Array=[]
|
||||||
|
var quarter := 0
|
||||||
|
var kind := "straight"
|
||||||
|
var selected_id := ""
|
||||||
|
var serial := 0
|
||||||
|
var undo_stack: Array = []
|
||||||
|
var redo_stack: Array = []
|
||||||
|
var yaw := .72
|
||||||
|
var pitch := .78
|
||||||
|
var target := Vector3(1.5,1,0)
|
||||||
|
var orbiting := false
|
||||||
|
var panning := false
|
||||||
|
var camera_size := 12.0
|
||||||
|
var name_field: LineEdit
|
||||||
|
var file_list: OptionButton
|
||||||
|
var status_label: Label
|
||||||
|
var count_label: Label
|
||||||
|
var detail_label: Label
|
||||||
|
var notice_label: Label
|
||||||
|
var run_button: Button
|
||||||
|
var position_fields: Array = []
|
||||||
|
var ball_list: OptionButton
|
||||||
|
var palette_box: GridContainer
|
||||||
|
var block_controls: VBoxContainer
|
||||||
|
var ball_controls: VBoxContainer
|
||||||
|
var add_ball_button: Button
|
||||||
|
var sidebar_scroll: ScrollContainer
|
||||||
|
var category_buttons: Dictionary={}
|
||||||
|
var category := "chutes"
|
||||||
|
var ball_position_fields: Array=[]
|
||||||
|
var ball_cursor := Vector3(0,2,0)
|
||||||
|
var selected_ball_id := ""
|
||||||
|
var ball_marker := Node3D.new()
|
||||||
|
var ball_pick_mode: OptionButton
|
||||||
|
var ball_pick_hint: Label
|
||||||
|
var move_ball_button: Button
|
||||||
|
var editable: Array = []
|
||||||
|
var font := SystemFont.new()
|
||||||
|
var capture_path := ""
|
||||||
|
var capture_count := -1
|
||||||
|
var autorun := false
|
||||||
|
var syncing := false
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
get_window().title="IntoHole · 关卡工坊" if editor_mode else "IntoHole · 林间汇流"
|
||||||
|
font.font_names=PackedStringArray(["PingFang SC","Noto Sans CJK SC","Arial"])
|
||||||
|
add_child(world);add_child(actors);add_child(grid);add_child(selection);add_child(ball_marker)
|
||||||
|
setup_environment()
|
||||||
|
setup_ui()
|
||||||
|
initialize_level()
|
||||||
|
for arg in OS.get_cmdline_user_args():
|
||||||
|
if arg.begins_with("--capture="):capture_path=arg.trim_prefix("--capture=");capture_count=15
|
||||||
|
if arg=="--autorun":autorun=true
|
||||||
|
if autorun:toggle_run()
|
||||||
|
|
||||||
|
func initialize_level() -> void:
|
||||||
|
pass # Each standalone scene owns its startup layout.
|
||||||
|
|
||||||
|
func material(color: Color) -> StandardMaterial3D:
|
||||||
|
var m:=StandardMaterial3D.new();m.albedo_color=color;m.roughness=.92
|
||||||
|
return m
|
||||||
|
|
||||||
|
func box(size: Vector3, at: Vector3, color: Color, parent: Node3D) -> Node3D:
|
||||||
|
var object: Node3D=lib.create_box(size,at,color,false)
|
||||||
|
parent.add_child(object)
|
||||||
|
return object
|
||||||
|
|
||||||
|
func setup_environment() -> void:
|
||||||
|
var env:=Environment.new()
|
||||||
|
env.background_mode=Environment.BG_COLOR;env.background_color=Color("e8e1bd")
|
||||||
|
env.ambient_light_source=Environment.AMBIENT_SOURCE_COLOR
|
||||||
|
env.ambient_light_color=Color.WHITE;env.ambient_light_energy=.3
|
||||||
|
env.tonemap_mode=Environment.TONE_MAPPER_ACES;env.tonemap_exposure=.85
|
||||||
|
var we:=WorldEnvironment.new();we.environment=env;add_child(we)
|
||||||
|
var light:=DirectionalLight3D.new();light.rotation_degrees=Vector3(-58,-28,0)
|
||||||
|
light.light_color=Color.WHITE;light.light_energy=.35;light.shadow_enabled=true
|
||||||
|
light.directional_shadow_max_distance=65;add_child(light)
|
||||||
|
add_child(camera);camera.projection=Camera3D.PROJECTION_ORTHOGONAL
|
||||||
|
camera.near=.05;camera.far=250;camera.current=true;camera.h_offset=-1.9
|
||||||
|
update_camera()
|
||||||
|
ground_view.name="GroundY0";add_child(ground_view);refresh_ground()
|
||||||
|
# Authored low-poly scenery stays outside the working track. No invisible collisions.
|
||||||
|
for p in [Vector3(-5,0,-4),Vector3(-3,0,-4.5),Vector3(2,0,-4.5),Vector3(7,0,-3),Vector3(9,0,3.5),Vector3(-5,0,4.2)]:
|
||||||
|
make_tree(p)
|
||||||
|
for p in [Vector3(-4,.18,-3),Vector3(4,.18,-3.5),Vector3(8,.18,3)]:
|
||||||
|
var rock:=MeshInstance3D.new();var mesh:=SphereMesh.new()
|
||||||
|
mesh.radial_segments=7;mesh.rings=3;mesh.radius=.35;mesh.height=.45
|
||||||
|
rock.mesh=mesh;rock.material_override=material(Color("93937a"));rock.position=p;add_child(rock)
|
||||||
|
# Small ground marks make the large quiet color area feel drawn.
|
||||||
|
var rng:=RandomNumberGenerator.new();rng.seed=42
|
||||||
|
for i in range(150):
|
||||||
|
var at:=Vector3(rng.randf_range(-7,11),.002,rng.randf_range(-6,6))
|
||||||
|
box(Vector3(.035,.003,.09),at,Color("a3ad7c"),self)
|
||||||
|
|
||||||
|
func make_tree(at: Vector3) -> void:
|
||||||
|
var trunk:=box(Vector3(.18,.65,.18),at+Vector3.UP*.32,Color("73553f"),self)
|
||||||
|
for i in range(3):
|
||||||
|
var cone:=CylinderMesh.new();cone.top_radius=0;cone.bottom_radius=.65-i*.13
|
||||||
|
cone.height=.95;cone.radial_segments=7
|
||||||
|
var view:=MeshInstance3D.new();view.mesh=cone
|
||||||
|
view.material_override=material(Color("748657") if i%2==0 else Color("8c9b64"))
|
||||||
|
view.position=at+Vector3.UP*(.9+i*.46);add_child(view)
|
||||||
|
var rim:=CylinderMesh.new();rim.top_radius=0;rim.bottom_radius=cone.bottom_radius+.012
|
||||||
|
rim.height=.035;rim.radial_segments=7
|
||||||
|
var outline:=MeshInstance3D.new();outline.mesh=rim;outline.material_override=material(INK)
|
||||||
|
outline.position=view.position-Vector3.UP*.47;add_child(outline)
|
||||||
|
trunk.name="DecorativeTree"
|
||||||
|
|
||||||
|
func style(color: Color, border:=INK, radius:=12) -> StyleBoxFlat:
|
||||||
|
var s:=StyleBoxFlat.new();s.bg_color=color;s.border_color=border
|
||||||
|
s.set_border_width_all(2);s.set_corner_radius_all(radius)
|
||||||
|
s.content_margin_left=12;s.content_margin_right=12;s.content_margin_top=9;s.content_margin_bottom=9
|
||||||
|
return s
|
||||||
|
|
||||||
|
func label(text: String, size:=16, color:=INK) -> Label:
|
||||||
|
var l:=Label.new();l.text=text;l.add_theme_font_override("font",font)
|
||||||
|
l.add_theme_font_size_override("font_size",size);l.add_theme_color_override("font_color",color)
|
||||||
|
return l
|
||||||
|
|
||||||
|
func button(text: String, action: Callable, primary:=false, lock:=false) -> Button:
|
||||||
|
var b:=Button.new();b.text=text;b.custom_minimum_size.y=36
|
||||||
|
b.add_theme_font_override("font",font);b.add_theme_font_size_override("font_size",15)
|
||||||
|
b.add_theme_stylebox_override("normal",style(ACCENT if primary else PAPER))
|
||||||
|
b.add_theme_stylebox_override("hover",style(Color("f0d7a6")))
|
||||||
|
b.add_theme_stylebox_override("pressed",style(Color("c3cd98")))
|
||||||
|
b.add_theme_color_override("font_color",Color.WHITE if primary else INK)
|
||||||
|
b.add_theme_color_override("font_hover_color",INK);b.add_theme_color_override("font_pressed_color",INK)
|
||||||
|
b.pressed.connect(action)
|
||||||
|
if lock:editable.append(b)
|
||||||
|
return b
|
||||||
|
|
||||||
|
func row(parent: Node) -> HBoxContainer:
|
||||||
|
var r:=HBoxContainer.new();r.add_theme_constant_override("separation",6);parent.add_child(r);return r
|
||||||
|
|
||||||
|
func setup_ui() -> void:
|
||||||
|
var layer:=CanvasLayer.new();add_child(layer)
|
||||||
|
var panel:=PanelContainer.new();panel.position=Vector2(20,20);panel.size=Vector2(294,860)
|
||||||
|
panel.add_theme_stylebox_override("panel",style(PAPER));layer.add_child(panel)
|
||||||
|
var scroll:=ScrollContainer.new();sidebar_scroll=scroll;scroll.custom_minimum_size=Vector2(266,830);panel.add_child(scroll)
|
||||||
|
scroll.horizontal_scroll_mode=ScrollContainer.SCROLL_MODE_DISABLED
|
||||||
|
var col:=VBoxContainer.new();col.size_flags_horizontal=Control.SIZE_EXPAND_FILL
|
||||||
|
col.add_theme_constant_override("separation",10);scroll.add_child(col)
|
||||||
|
col.add_child(label("INTO / HOLE",28))
|
||||||
|
col.add_child(label("关卡工坊" if editor_mode else "01 林间汇流",20))
|
||||||
|
col.add_child(label("无限积木 · 自由编排" if editor_mode else "六种滑槽 · 两颗铁球 · 一个洞",14,Color("7a7366")))
|
||||||
|
count_label=label("",18);col.add_child(count_label)
|
||||||
|
run_button=button("▶ 同时释放",toggle_run,true);col.add_child(run_button)
|
||||||
|
col.add_child(button("↺ 重试 / 返回编辑" if editor_mode else "↺ 重新开始",reset_simulation))
|
||||||
|
if editor_mode:build_editor_ui(col)
|
||||||
|
else:
|
||||||
|
col.add_child(label("沿途积木",17))
|
||||||
|
for i in range(IDS.size()):col.add_child(label("%02d %s" % [i+1,TITLES[i]],16))
|
||||||
|
col.add_child(label("空格 释放 / 暂停\nT 重试\n右键拖动 旋转视角\n中键拖动 平移\n滚轮 缩放\nF 回到全景",14,Color("7a7366")))
|
||||||
|
status_label=label("",15);status_label.autowrap_mode=TextServer.AUTOWRAP_WORD_SMART
|
||||||
|
status_label.custom_minimum_size.x=255;col.add_child(status_label)
|
||||||
|
var footer:=PanelContainer.new();footer.position=Vector2(340,824);footer.size=Vector2(660,52)
|
||||||
|
footer.add_theme_stylebox_override("panel",style(PAPER));layer.add_child(footer)
|
||||||
|
notice_label=label("林间实验场 / 滑槽积木 × 手绘色彩",16)
|
||||||
|
notice_label.autowrap_mode=TextServer.AUTOWRAP_WORD_SMART;footer.add_child(notice_label)
|
||||||
|
|
||||||
|
func build_editor_ui(col: VBoxContainer) -> void:
|
||||||
|
var categories:=GridContainer.new();categories.columns=2;categories.add_theme_constant_override("h_separation",6);categories.add_theme_constant_override("v_separation",6);col.add_child(categories)
|
||||||
|
var group:=ButtonGroup.new()
|
||||||
|
for entry in [["chutes","滑槽"],["balls","小球"],["interactive","交互方块"],["nonInteractive","非交互方块"]]:
|
||||||
|
var id: String=entry[0]
|
||||||
|
var tab:=button(entry[1],func():select_category(id),false,true)
|
||||||
|
tab.toggle_mode=true;tab.button_group=group;tab.button_pressed=id==category
|
||||||
|
tab.add_theme_font_size_override("font_size",14);tab.custom_minimum_size.x=126
|
||||||
|
categories.add_child(tab);category_buttons[id]=tab
|
||||||
|
palette_box=GridContainer.new();palette_box.columns=2;col.add_child(palette_box)
|
||||||
|
block_controls=VBoxContainer.new();block_controls.add_theme_constant_override("separation",10);col.add_child(block_controls)
|
||||||
|
detail_label=label("",14);block_controls.add_child(detail_label)
|
||||||
|
boost_controls=VBoxContainer.new();block_controls.add_child(boost_controls)
|
||||||
|
boost_controls.add_child(label("固定增速:+%.0f m/s" % Booster.SPEED_GAIN,14))
|
||||||
|
var boost_hint:=label("顶面接触一次:先转向,再增速。\n离开后再次接触可重新触发。",13,Color("7a7366"))
|
||||||
|
boost_controls.add_child(boost_hint)
|
||||||
|
var modes:=row(block_controls)
|
||||||
|
var mode_group:=ButtonGroup.new()
|
||||||
|
for entry in [["place","放置模式"],["edit","选择 / 移动"]]:
|
||||||
|
var mode: String=entry[0]
|
||||||
|
var b:=button(entry[1],func():set_block_mode(mode),false,true)
|
||||||
|
b.toggle_mode=true;b.button_group=mode_group;b.button_pressed=mode==block_mode
|
||||||
|
mode_buttons[mode]=b;modes.add_child(b)
|
||||||
|
block_controls.add_child(label("方块底面坐标 · 地面 Y = 0",13,Color("7a7366")))
|
||||||
|
var coords:=row(block_controls)
|
||||||
|
for i in range(3):
|
||||||
|
var field:=SpinBox.new();field.min_value=-10000;field.max_value=10000
|
||||||
|
field.step=.5 if i==1 else 1;field.prefix=["X ","Y ","Z "][i]
|
||||||
|
field.custom_minimum_size.x=83;field.add_theme_font_size_override("font_size",13)
|
||||||
|
var axis:=i
|
||||||
|
field.value_changed.connect(func(v):
|
||||||
|
if syncing:return
|
||||||
|
cursor[axis]=v;refresh_selection())
|
||||||
|
coords.add_child(field);position_fields.append(field);editable.append(field)
|
||||||
|
var actions:=row(block_controls)
|
||||||
|
place_button=button("放置新方块",place_current,false,true);actions.add_child(place_button)
|
||||||
|
actions.add_child(button("旋转 R",rotate_current,false,true))
|
||||||
|
apply_button=button("应用修改到选中方块",apply_selected,false,true);block_controls.add_child(apply_button)
|
||||||
|
actions=row(block_controls);delete_button=button("删除 Del",remove_current,false,true);actions.add_child(delete_button)
|
||||||
|
ball_controls=VBoxContainer.new();ball_controls.add_theme_constant_override("separation",10);col.add_child(ball_controls)
|
||||||
|
ball_pick_mode=OptionButton.new()
|
||||||
|
ball_pick_mode.add_item("贴表面点选")
|
||||||
|
ball_pick_mode.add_item("按 Y 高度点选(悬空)")
|
||||||
|
ball_controls.add_child(ball_pick_mode);editable.append(ball_pick_mode)
|
||||||
|
ball_pick_mode.item_selected.connect(func(_index):refresh_ball_pick_hint())
|
||||||
|
ball_pick_hint=label("",13,Color("7a7366"))
|
||||||
|
ball_pick_hint.autowrap_mode=TextServer.AUTOWRAP_WORD_SMART;ball_pick_hint.custom_minimum_size.x=255
|
||||||
|
ball_controls.add_child(ball_pick_hint);refresh_ball_pick_hint()
|
||||||
|
ball_controls.add_child(label("铁球 · 球心坐标",17))
|
||||||
|
var ball_coords:=row(ball_controls)
|
||||||
|
for i in range(3):
|
||||||
|
var field:=SpinBox.new();field.min_value=-10000;field.max_value=10000
|
||||||
|
field.step=.01;field.allow_greater=true;field.allow_lesser=true
|
||||||
|
field.prefix=["X ","Y ","Z "][i];field.value=ball_cursor[i]
|
||||||
|
field.custom_minimum_size.x=83;field.add_theme_font_size_override("font_size",12)
|
||||||
|
var axis:=i
|
||||||
|
field.value_changed.connect(func(v):
|
||||||
|
if syncing:return
|
||||||
|
ball_cursor[axis]=v;refresh_ball_marker())
|
||||||
|
ball_coords.add_child(field);ball_position_fields.append(field);editable.append(field)
|
||||||
|
add_ball_button=button("+ 放置铁球",add_spawn,true,true);ball_controls.add_child(add_ball_button)
|
||||||
|
ball_list=OptionButton.new();ball_controls.add_child(ball_list);editable.append(ball_list)
|
||||||
|
ball_list.item_selected.connect(select_ball)
|
||||||
|
actions=row(ball_controls);move_ball_button=button("移动选中铁球",move_spawn,false,true);actions.add_child(move_ball_button)
|
||||||
|
actions.add_child(button("移除铁球",remove_spawn,false,true))
|
||||||
|
ball_controls.add_child(label("可悬空;启动后受重力影响。",13,Color("7a7366")))
|
||||||
|
actions=row(col);actions.add_child(button("撤销",undo,false,true));actions.add_child(button("重做",redo,false,true))
|
||||||
|
col.add_child(label("关卡文件",17))
|
||||||
|
name_field=LineEdit.new();name_field.text="my_level";name_field.placeholder_text="关卡名称"
|
||||||
|
col.add_child(name_field);editable.append(name_field)
|
||||||
|
actions=row(col);actions.add_child(button("保存",save_named,false,true));actions.add_child(button("载入",load_named,false,true))
|
||||||
|
file_list=OptionButton.new();col.add_child(file_list);refresh_files();editable.append(file_list)
|
||||||
|
file_list.item_selected.connect(func(i):name_field.text=file_list.get_item_text(i))
|
||||||
|
col.add_child(button("新建空白",clear_level,false,true))
|
||||||
|
col.add_child(label("放置模式:点顶面向上叠放,点侧面拼接
|
||||||
|
选择模式:点方块后修改坐标并应用
|
||||||
|
铁球 Y 为球心高度
|
||||||
|
R 旋转 · Del 删除 · F 全景
|
||||||
|
空格试跑,T 回到原布局
|
||||||
|
右键旋转 / 中键平移 / 滚轮缩放",13,Color("7a7366")))
|
||||||
|
refresh_palette()
|
||||||
|
|
||||||
|
func kind_name(id: String) -> String:
|
||||||
|
if id=="iron_ball":return "铁球"
|
||||||
|
if id in IDS:return TITLES[IDS.find(id)]
|
||||||
|
for group in entity_registry.values():
|
||||||
|
for item in group:
|
||||||
|
if item.id==id:return item.name
|
||||||
|
return "未选择方块"
|
||||||
|
|
||||||
|
func kinds_in_category(id: String) -> Array:
|
||||||
|
if id=="balls":return ["iron_ball"]
|
||||||
|
if id=="chutes":return IDS.duplicate()
|
||||||
|
return entity_registry[id].map(func(item):return item.id)
|
||||||
|
|
||||||
|
func select_category(id: String) -> void:
|
||||||
|
if started:return
|
||||||
|
category=id
|
||||||
|
if id=="balls":
|
||||||
|
selected_id=""
|
||||||
|
else:
|
||||||
|
selected_ball_id=""
|
||||||
|
var options:=kinds_in_category(id)
|
||||||
|
if kind not in options:kind="" if options.is_empty() else options[0]
|
||||||
|
if sidebar_scroll!=null:sidebar_scroll.scroll_vertical=0
|
||||||
|
refresh_palette();refresh_selection();refresh_ball_marker()
|
||||||
|
|
||||||
|
func refresh_palette() -> void:
|
||||||
|
clear_children(palette_box)
|
||||||
|
var options:=kinds_in_category(category)
|
||||||
|
if options.is_empty():palette_box.add_child(label("暂无交互方块 · 待添加",14,Color("7a7366")))
|
||||||
|
for id in options:
|
||||||
|
var chosen: String=id
|
||||||
|
palette_box.add_child(button(kind_name(id)+" ∞",func():
|
||||||
|
if started:return
|
||||||
|
if category=="balls":refresh_ball_marker()
|
||||||
|
else:kind=chosen;refresh_selection(),false,true))
|
||||||
|
for id in category_buttons:category_buttons[id].button_pressed=id==category
|
||||||
|
if block_controls!=null:block_controls.visible=category!="balls"
|
||||||
|
if ball_controls!=null:ball_controls.visible=category=="balls"
|
||||||
|
ball_marker.visible=category=="balls"
|
||||||
|
|
||||||
|
func category_for(id: String) -> String:
|
||||||
|
if id in IDS:return "chutes"
|
||||||
|
for group in entity_registry:
|
||||||
|
if entity_registry[group].any(func(item):return item.id==id):return group
|
||||||
|
return "chutes"
|
||||||
|
|
||||||
|
func encode() -> Dictionary:
|
||||||
|
return codec.encode(records,spawn_specs,name_field.text if editor_mode else "林间汇流")
|
||||||
|
|
||||||
|
func validate_level(data: Variant) -> String:
|
||||||
|
return codec.validate(data)
|
||||||
|
|
||||||
|
func valid_vector(value: Variant) -> bool:
|
||||||
|
return codec.valid_vector(value)
|
||||||
|
|
||||||
|
func apply_data(data: Dictionary) -> void:
|
||||||
|
var normalized: Dictionary=codec.normalize(data)
|
||||||
|
records=normalized.records;spawn_specs=normalized.balls
|
||||||
|
selected_id="";selected_ball_id="";block_mode="place"
|
||||||
|
rebuild();reset_simulation();frame_level()
|
||||||
|
|
||||||
|
func clear_level() -> void:
|
||||||
|
if started:return
|
||||||
|
remember();records.clear();spawn_specs.clear()
|
||||||
|
selected_id="";selected_ball_id="";block_mode="place";cursor=Vector3.ZERO;ball_cursor=Vector3(0,2,0)
|
||||||
|
rebuild();reset_simulation();frame_level()
|
||||||
|
status="空白关卡:选择方块分类或添加悬空铁球。";refresh_ui()
|
||||||
|
|
||||||
|
func remember() -> void:
|
||||||
|
undo_stack.append(encode());redo_stack.clear()
|
||||||
|
if undo_stack.size()>100:undo_stack.pop_front()
|
||||||
|
|
||||||
|
func undo() -> void:
|
||||||
|
if started or undo_stack.is_empty():return
|
||||||
|
redo_stack.append(encode());apply_data(undo_stack.pop_back());status="已撤销";refresh_ui()
|
||||||
|
|
||||||
|
func redo() -> void:
|
||||||
|
if started or redo_stack.is_empty():return
|
||||||
|
undo_stack.append(encode());apply_data(redo_stack.pop_back());status="已重做";refresh_ui()
|
||||||
|
|
||||||
|
func index_for(id: String) -> int:
|
||||||
|
for i in range(records.size()):
|
||||||
|
if records[i].id==id:return i
|
||||||
|
return -1
|
||||||
|
|
||||||
|
func unique_id(prefix: String) -> String:
|
||||||
|
serial+=1
|
||||||
|
return prefix+"_"+str(Time.get_ticks_usec())+"_"+str(serial)
|
||||||
|
|
||||||
|
func overlaps(a: Dictionary,b: Dictionary) -> bool:
|
||||||
|
return codec.overlaps(a,b)
|
||||||
|
|
||||||
|
func placement_error(candidate: Dictionary, ignore: String="") -> String:
|
||||||
|
# A level author may create disconnected route seeds; occupancy still applies.
|
||||||
|
for r in records:
|
||||||
|
if r.id!=ignore and overlaps(candidate,r):return "这个位置与已有积木重叠。"
|
||||||
|
return ""
|
||||||
|
|
||||||
|
func place_current() -> void:
|
||||||
|
if started or not editor_mode or category=="balls":return
|
||||||
|
if kind.is_empty():status="此分类暂无可用方块。";refresh_ui();return
|
||||||
|
# Adding never overwrites or moves an existing record, even if it was selected.
|
||||||
|
var record: Dictionary=placement.record_at(kind,cursor,quarter,unique_id("piece"))
|
||||||
|
var issue:=placement_error(record)
|
||||||
|
if not issue.is_empty():status=issue;refresh_ui();return
|
||||||
|
remember();records.append(record);last_placed_id=record.id
|
||||||
|
cursor=placement.bottom_of(record);selected_id="";selected_ball_id="";block_mode="place"
|
||||||
|
rebuild();reset_simulation()
|
||||||
|
status="已新增 %s · 底面 Y %.2f;点顶面可继续叠放" % [kind_name(kind),cursor.y];refresh_ui()
|
||||||
|
|
||||||
|
func set_block_mode(mode: String) -> void:
|
||||||
|
if started or not editor_mode:return
|
||||||
|
block_mode=mode;selected_id="";selected_ball_id=""
|
||||||
|
status="点方块顶面或侧面选择新位置,再放置。" if mode=="place" else "点击要修改的方块,再调整坐标并应用修改。"
|
||||||
|
refresh_selection()
|
||||||
|
|
||||||
|
func select_record(id: String) -> void:
|
||||||
|
if started:return
|
||||||
|
var index:=index_for(id)
|
||||||
|
if index<0:return
|
||||||
|
block_mode="edit";selected_ball_id="";selected_id=id
|
||||||
|
var record: Dictionary=records[index]
|
||||||
|
cursor=placement.bottom_of(record);kind=record.kind;quarter=record.quarter
|
||||||
|
category=category_for(kind);refresh_palette();refresh_selection()
|
||||||
|
|
||||||
|
func apply_selected() -> void:
|
||||||
|
if started or not editor_mode:return
|
||||||
|
var index:=index_for(selected_id)
|
||||||
|
if block_mode!="edit" or index<0:status="先用选择模式选中要修改的方块。";refresh_ui();return
|
||||||
|
if kind.is_empty():return
|
||||||
|
var candidate: Dictionary=placement.record_at(kind,cursor,quarter,selected_id)
|
||||||
|
var issue:=placement_error(candidate,selected_id)
|
||||||
|
if not issue.is_empty():status=issue;refresh_ui();return
|
||||||
|
remember();records[index]=candidate;cursor=placement.bottom_of(candidate)
|
||||||
|
rebuild();reset_simulation();status="已修改选中方块;其他方块保持原位。";refresh_ui()
|
||||||
|
|
||||||
|
func rotate_current() -> void:
|
||||||
|
if started or not editor_mode or category=="balls":return
|
||||||
|
var old:=quarter;quarter=(quarter+1)%4
|
||||||
|
var idx:=index_for(selected_id) if block_mode=="edit" else -1
|
||||||
|
if idx>=0:
|
||||||
|
var candidate: Dictionary=records[idx].duplicate();candidate.quarter=quarter
|
||||||
|
var issue:=placement_error(candidate,selected_id)
|
||||||
|
if not issue.is_empty():quarter=old;status=issue;refresh_ui();return
|
||||||
|
remember();records[idx]=candidate;rebuild();reset_simulation()
|
||||||
|
refresh_selection()
|
||||||
|
|
||||||
|
func remove_current() -> void:
|
||||||
|
if started or not editor_mode:return
|
||||||
|
if not selected_ball_id.is_empty():remove_spawn();return
|
||||||
|
var idx:=index_for(selected_id)
|
||||||
|
if idx<0:return
|
||||||
|
remember();records.remove_at(idx)
|
||||||
|
selected_id="";rebuild();reset_simulation();status="方块已移除,铁球坐标保持不变。";refresh_ui()
|
||||||
|
|
||||||
|
func add_spawn() -> void:
|
||||||
|
if started or not editor_mode:return
|
||||||
|
remember();selected_ball_id=unique_id("iron");selected_id=""
|
||||||
|
spawn_specs.append({"id":selected_ball_id,"ballTypeId":"iron_ball","position":codec.array_from(ball_cursor),"launchDirection":codec.array_from(Vector3.RIGHT)})
|
||||||
|
reset_simulation();status="已按球心坐标放置铁球,可悬空。";refresh_ui()
|
||||||
|
|
||||||
|
func refresh_ball_pick_hint() -> void:
|
||||||
|
if ball_pick_hint==null:return
|
||||||
|
ball_pick_hint.text="点击场景选位置,再点“放置铁球”。\n滑槽会自动对准槽内。" if ball_pick_mode.selected==0 else "先设置球心 Y,再点击场景选 X/Z,\n最后点“放置铁球”。"
|
||||||
|
|
||||||
|
func ball_position_is_clear(at: Vector3) -> bool:
|
||||||
|
var shape:=SphereShape3D.new();shape.radius=float(lib.catalog.iron_ball.radius)
|
||||||
|
var query:=PhysicsShapeQueryParameters3D.new();query.shape=shape
|
||||||
|
query.transform=Transform3D(Basis.IDENTITY,at);query.collision_mask=1;query.margin=0
|
||||||
|
return get_world_3d().direct_space_state.intersect_shape(query).is_empty()
|
||||||
|
|
||||||
|
func ball_position_on_chute(hit: Dictionary) -> Variant:
|
||||||
|
var node: Node=hit.collider
|
||||||
|
while node!=null and not node.has_meta("record_id"):node=node.get_parent()
|
||||||
|
if node==null:return null
|
||||||
|
var record: Dictionary=records[index_for(node.get_meta("record_id"))]
|
||||||
|
if record.kind not in IDS:return null
|
||||||
|
var transform:=Transform3D(Basis(Vector3.UP,-int(record.quarter)*PI/2),lib.record_center(record))
|
||||||
|
var local: Vector3=transform.affine_inverse()*Vector3(hit.position)
|
||||||
|
var point:=Vector2(local.x,local.z)
|
||||||
|
var paths: Array=lib.catalog[record.kind].upperPaths
|
||||||
|
var distance:=INF;var best_t:=0.0;var best_branch:=0
|
||||||
|
for branch in range(paths.size()):
|
||||||
|
var path: Array=paths[branch]
|
||||||
|
for i in range(path.size()-1):
|
||||||
|
var a:=Vector2(path[i][0],path[i][2]);var b:=Vector2(path[i+1][0],path[i+1][2])
|
||||||
|
var segment:=b-a
|
||||||
|
var ratio:=clampf((point-a).dot(segment)/maxf(segment.length_squared(),.000001),0,1)
|
||||||
|
var d:=point.distance_squared_to(a+segment*ratio)
|
||||||
|
if d<distance:distance=d;best_t=(i+ratio)/(path.size()-1);best_branch=branch
|
||||||
|
var candidate: Vector3=(transform*lib.ball_on_surface(record.kind,best_t,best_branch)).snapped(Vector3.ONE*.01)
|
||||||
|
if ball_position_is_clear(candidate):return candidate
|
||||||
|
# At a seam a nearby wall can obstruct the ideal groove point. Find the
|
||||||
|
# closest clear point on this same asset without moving or altering any block.
|
||||||
|
var best_distance:=INF
|
||||||
|
for branch in range(paths.size()):
|
||||||
|
for i in range(paths[branch].size()):
|
||||||
|
var t: float=float(i)/(paths[branch].size()-1)
|
||||||
|
var alternative: Vector3=(transform*lib.ball_on_surface(record.kind,t,branch)).snapped(Vector3.ONE*.01)
|
||||||
|
var d: float=alternative.distance_squared_to(Vector3(hit.position))
|
||||||
|
if d<best_distance and ball_position_is_clear(alternative):candidate=alternative;best_distance=d
|
||||||
|
return candidate
|
||||||
|
|
||||||
|
func pick_ball_position(origin: Vector3,direction: Vector3,hit: Dictionary) -> void:
|
||||||
|
var candidate: Variant=null
|
||||||
|
var radius: float=lib.catalog.iron_ball.radius
|
||||||
|
if ball_pick_mode.selected==1:
|
||||||
|
candidate=Plane(Vector3.UP,ball_cursor.y).intersects_ray(origin,direction)
|
||||||
|
elif not hit.is_empty():
|
||||||
|
candidate=ball_position_on_chute(hit)
|
||||||
|
if candidate==null:
|
||||||
|
var normal: Vector3=hit.normal
|
||||||
|
if normal.length_squared()<.001:return
|
||||||
|
candidate=hit.position+normal.normalized()*(radius+.018)
|
||||||
|
else:
|
||||||
|
var ground=Plane(Vector3.UP,0).intersects_ray(origin,direction)
|
||||||
|
if ground!=null:candidate=ground+Vector3.UP*(radius+.018)
|
||||||
|
if candidate==null:return
|
||||||
|
var rounded: Vector3=Vector3(candidate).snapped(Vector3.ONE*.01)
|
||||||
|
if not ball_position_is_clear(rounded):
|
||||||
|
status="这里容不下铁球;请换个位置或提高球心 Y。";refresh_ui();return
|
||||||
|
ball_cursor=rounded
|
||||||
|
refresh_ball_marker()
|
||||||
|
status="已选球心 (%.2f, %.2f, %.2f) · 点放置新增,或移动选中铁球" % [ball_cursor.x,ball_cursor.y,ball_cursor.z]
|
||||||
|
refresh_ui()
|
||||||
|
|
||||||
|
func select_ball(index: int) -> void:
|
||||||
|
if started or index<0 or index>=spawn_specs.size():return
|
||||||
|
selected_ball_id=spawn_specs[index].id;selected_id=""
|
||||||
|
category="balls";refresh_palette()
|
||||||
|
if sidebar_scroll!=null:sidebar_scroll.scroll_vertical=0
|
||||||
|
ball_cursor=lib.vector(spawn_specs[index].position)
|
||||||
|
syncing=true
|
||||||
|
for i in range(ball_position_fields.size()):ball_position_fields[i].value=ball_cursor[i]
|
||||||
|
syncing=false
|
||||||
|
refresh_selection();refresh_ball_marker()
|
||||||
|
|
||||||
|
func ball_index() -> int:
|
||||||
|
for i in range(spawn_specs.size()):
|
||||||
|
if spawn_specs[i].id==selected_ball_id:return i
|
||||||
|
return -1
|
||||||
|
|
||||||
|
func move_spawn() -> void:
|
||||||
|
if started:return
|
||||||
|
var index:=ball_index()
|
||||||
|
if index<0:status="先选择一颗铁球。";refresh_ui();return
|
||||||
|
remember();spawn_specs[index].position=codec.array_from(ball_cursor)
|
||||||
|
reset_simulation();status="已移动铁球球心。";refresh_ui()
|
||||||
|
|
||||||
|
func refresh_ball_marker() -> void:
|
||||||
|
clear_children(ball_marker)
|
||||||
|
if not editor_mode or started or category!="balls":return
|
||||||
|
syncing=true
|
||||||
|
for i in range(ball_position_fields.size()):ball_position_fields[i].value=ball_cursor[i]
|
||||||
|
syncing=false
|
||||||
|
var index:=ball_index()
|
||||||
|
if index>=0 and lib.vector(spawn_specs[index].position).is_equal_approx(ball_cursor):return
|
||||||
|
var preview: Node3D=load(lib.catalog.iron_ball.path).instantiate()
|
||||||
|
preview.position=ball_cursor;ball_marker.add_child(preview);ghost(preview)
|
||||||
|
if absf(ball_cursor.y)>.02:
|
||||||
|
box(Vector3(.012,absf(ball_cursor.y),.012),Vector3(ball_cursor.x,ball_cursor.y*.5,ball_cursor.z),Color("649e82"),ball_marker)
|
||||||
|
box(Vector3(.15,.008,.15),Vector3(ball_cursor.x,.008,ball_cursor.z),Color("649e82"),ball_marker)
|
||||||
|
|
||||||
|
func remove_spawn() -> void:
|
||||||
|
if started:return
|
||||||
|
var index:=ball_index()
|
||||||
|
if index<0:return
|
||||||
|
remember();spawn_specs.remove_at(index);selected_ball_id="";reset_simulation()
|
||||||
|
|
||||||
|
func place_goal() -> void:
|
||||||
|
if started or not editor_mode:return
|
||||||
|
kind="goal_hole";category="nonInteractive";refresh_palette();place_current()
|
||||||
|
|
||||||
|
func clear_children(node: Node) -> void:
|
||||||
|
for child in node.get_children():node.remove_child(child);child.queue_free()
|
||||||
|
|
||||||
|
func rebuild() -> void:
|
||||||
|
clear_children(world);pieces.clear();goals.clear()
|
||||||
|
for r in records:
|
||||||
|
var object: Node3D=lib.create_piece(r.kind,lib.record_center(r),r.quarter)
|
||||||
|
object.set_meta("record_id",r.id);world.add_child(object);pieces.append(object)
|
||||||
|
if r.kind=="goal_hole":goals.append(r)
|
||||||
|
goal_position=Vector3.ZERO if goals.is_empty() else goals[0].position
|
||||||
|
refresh_ground();refresh_selection()
|
||||||
|
|
||||||
|
func reset_simulation() -> void:
|
||||||
|
clear_children(actors);balls.clear();tags.clear();previous.clear()
|
||||||
|
entered.clear();lost.clear();events.clear();samples.clear();visited.clear();contact_visited.clear();release_ticks.clear();pause_states.clear()
|
||||||
|
elapsed=0;started=false;paused=false
|
||||||
|
for spec in spawn_specs:
|
||||||
|
var ball=lib.create_ball();ball.freeze=true;ball.name=spec.id;ball.set_meta("ball_id",spec.id)
|
||||||
|
actors.add_child(ball);ball.position=lib.vector(spec.position)
|
||||||
|
balls.append(ball);previous.append(ball.position)
|
||||||
|
var tag:=Label3D.new();tag.text=str(balls.size());tag.font=font;tag.font_size=42
|
||||||
|
tag.pixel_size=.006;tag.modulate=ACCENT;tag.outline_size=3;tag.outline_modulate=PAPER
|
||||||
|
tag.billboard=BaseMaterial3D.BILLBOARD_ENABLED;actors.add_child(tag);tags.append(tag)
|
||||||
|
refresh_ball_marker()
|
||||||
|
status="准备释放 %d 颗铁球。" % balls.size();refresh_ui()
|
||||||
|
|
||||||
|
func initial_velocity(_index: int) -> Vector3:
|
||||||
|
return Vector3.ZERO
|
||||||
|
|
||||||
|
func toggle_run() -> void:
|
||||||
|
if balls.is_empty():status="请先添加至少一个铁球起点。";refresh_ui();return
|
||||||
|
if not started:
|
||||||
|
started=true;paused=false;clear_children(ball_marker)
|
||||||
|
for i in range(balls.size()):
|
||||||
|
balls[i].freeze=false
|
||||||
|
balls[i].linear_velocity=initial_velocity(i)
|
||||||
|
balls[i].angular_velocity=Vector3.ZERO
|
||||||
|
release_ticks.append(Engine.get_physics_frames())
|
||||||
|
elif not paused:
|
||||||
|
pause_states.clear()
|
||||||
|
for b in balls:pause_states.append([b.linear_velocity,b.angular_velocity]);b.freeze=true
|
||||||
|
paused=true
|
||||||
|
else:
|
||||||
|
for i in range(balls.size()):
|
||||||
|
if entered.has(i) or lost.has(i):continue
|
||||||
|
balls[i].freeze=false;balls[i].linear_velocity=pause_states[i][0];balls[i].angular_velocity=pause_states[i][1]
|
||||||
|
paused=false
|
||||||
|
refresh_ui()
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
for i in range(tags.size()):tags[i].position=balls[i].position+Vector3.UP*.6
|
||||||
|
if not started or paused:return
|
||||||
|
if entered.size()+lost.size()==balls.size():return
|
||||||
|
elapsed+=delta
|
||||||
|
for i in range(balls.size()):
|
||||||
|
if entered.has(i) or lost.has(i):continue
|
||||||
|
var b=balls[i]
|
||||||
|
for collider in b.get_colliding_bodies():
|
||||||
|
if collider.has_meta("piece_type"):contact_visited[str(collider.get_meta("piece_type"))]=true
|
||||||
|
for r in records:
|
||||||
|
var bounds: AABB=lib.record_bounds(r)
|
||||||
|
if bounds.grow(.08).has_point(b.position-Vector3.UP*b.radius):visited[r.kind]=true
|
||||||
|
var reached: String=crossed_goal_id(previous[i],b.position,b.radius)
|
||||||
|
if not reached.is_empty():
|
||||||
|
entered[i]=true;events.append({"ballId":str(b.name),"goalId":reached,"time":elapsed,"position":[b.position.x,b.position.y,b.position.z]})
|
||||||
|
b.freeze=true;b.hide();b.collision_layer=0;b.collision_mask=0;tags[i].hide()
|
||||||
|
elif b.position.y<minimum_y()-3:
|
||||||
|
lost[i]=true;b.freeze=true
|
||||||
|
previous[i]=b.position
|
||||||
|
if Engine.get_physics_frames()%6==0:
|
||||||
|
var positions: Array=[]
|
||||||
|
for b in balls:positions.append([b.position.x,b.position.y,b.position.z])
|
||||||
|
samples.append({"time":elapsed,"positions":positions,"entered":entered.size()})
|
||||||
|
if entered.size()==balls.size():status="全部入洞! %.2f 秒" % elapsed
|
||||||
|
elif not lost.is_empty():status="有铁球离轨。按 T 回到编辑。"
|
||||||
|
else:status="运行中 · %.1f 秒" % elapsed
|
||||||
|
refresh_ui()
|
||||||
|
|
||||||
|
func crossed_goal_id(before: Vector3,after: Vector3,radius: float) -> String:
|
||||||
|
for goal in goals:
|
||||||
|
if lib.crossed_goal(before,after,goal.position,radius):return goal.id
|
||||||
|
return ""
|
||||||
|
|
||||||
|
func minimum_y() -> float:
|
||||||
|
var result:=0.0
|
||||||
|
for r in records:result=minf(result,lib.record_bounds(r).position.y)
|
||||||
|
for spawn in spawn_specs:result=minf(result,float(spawn.position[1]))
|
||||||
|
return result
|
||||||
|
|
||||||
|
func refresh_ui() -> void:
|
||||||
|
if status_label==null:return
|
||||||
|
status_label.text=status
|
||||||
|
if notice_label!=null:notice_label.text=status
|
||||||
|
count_label.text="%d / %d 已入洞" % [entered.size(),balls.size()]
|
||||||
|
run_button.text="继续" if paused else ("暂停" if started else "▶ 同时释放")
|
||||||
|
editable=editable.filter(func(control):return is_instance_valid(control))
|
||||||
|
for control in editable:
|
||||||
|
if control is BaseButton:control.disabled=started
|
||||||
|
elif control is SpinBox or control is LineEdit:control.editable=not started
|
||||||
|
elif control is Range:control.editable=not started
|
||||||
|
if editor_mode:
|
||||||
|
boost_controls.visible=category!="balls" and kind==Booster.KIND
|
||||||
|
for mode in mode_buttons:mode_buttons[mode].button_pressed=mode==block_mode
|
||||||
|
if apply_button!=null:apply_button.disabled=started or block_mode!="edit" or index_for(selected_id)<0
|
||||||
|
if delete_button!=null:delete_button.disabled=started or (index_for(selected_id)<0 and ball_index()<0)
|
||||||
|
if place_button!=null:place_button.disabled=started or kind.is_empty()
|
||||||
|
if move_ball_button!=null:move_ball_button.disabled=started or ball_index()<0
|
||||||
|
ball_list.clear()
|
||||||
|
for i in range(spawn_specs.size()):
|
||||||
|
var p: Array=spawn_specs[i].position
|
||||||
|
ball_list.add_item("铁球 %d · (%.2f, %.2f, %.2f)" % [i+1,p[0],p[1],p[2]])
|
||||||
|
ball_list.select(ball_index())
|
||||||
|
if detail_label!=null:detail_label.text="%s · %d° · %d 块" % [kind_name(kind),quarter*90,records.size()]
|
||||||
|
|
||||||
|
func refresh_selection() -> void:
|
||||||
|
clear_children(selection)
|
||||||
|
if not editor_mode:return
|
||||||
|
if category=="balls":refresh_grid();refresh_ui();return
|
||||||
|
if kind.is_empty():refresh_grid();refresh_ui();return
|
||||||
|
var candidate: Dictionary=placement.record_at(kind,cursor,quarter,"preview")
|
||||||
|
var bounds: AABB=lib.record_bounds(candidate)
|
||||||
|
var center: Vector3=bounds.get_center();center.y=bounds.position.y
|
||||||
|
var footprint: Vector2i=lib.footprint(kind,quarter)
|
||||||
|
var issue:=placement_error(candidate,selected_id if block_mode=="edit" else "")
|
||||||
|
var tint:=Color("4d8c70") if issue.is_empty() else ACCENT
|
||||||
|
for axis in range(2):
|
||||||
|
for side in [-1,1]:
|
||||||
|
var size:=Vector3(.03,.03,footprint.y) if axis==0 else Vector3(footprint.x,.03,.03)
|
||||||
|
var p:=center+(Vector3(side*footprint.x*.5,.025,0) if axis==0 else Vector3(0,.025,side*footprint.y*.5))
|
||||||
|
box(size,p,tint,selection)
|
||||||
|
var editing_unchanged:=false
|
||||||
|
var index:=index_for(selected_id)
|
||||||
|
if block_mode=="edit" and index>=0:
|
||||||
|
editing_unchanged=records[index].position.is_equal_approx(candidate.position) and records[index].kind==kind and records[index].quarter==quarter
|
||||||
|
if issue.is_empty() and not editing_unchanged:
|
||||||
|
var preview: Node3D=load(lib.catalog[kind].path).instantiate()
|
||||||
|
preview.position=lib.record_center(candidate);preview.rotation.y=-quarter*PI/2
|
||||||
|
selection.add_child(preview);ghost(preview)
|
||||||
|
if absf(center.y)>.01:
|
||||||
|
box(Vector3(.012,absf(center.y),.012),Vector3(center.x,center.y*.5,center.z),tint,selection)
|
||||||
|
syncing=true
|
||||||
|
for i in range(position_fields.size()):
|
||||||
|
position_fields[i].step=.01 if kind=="goal_hole" else (.5 if i==1 else 1)
|
||||||
|
position_fields[i].value=cursor[i]
|
||||||
|
syncing=false
|
||||||
|
refresh_grid();refresh_ui()
|
||||||
|
|
||||||
|
func ghost(node: Node) -> void:
|
||||||
|
if node is MeshInstance3D:
|
||||||
|
var m:=StandardMaterial3D.new();m.albedo_color=Color(.7,.85,.7,.35)
|
||||||
|
m.transparency=BaseMaterial3D.TRANSPARENCY_ALPHA;node.material_override=m
|
||||||
|
node.cast_shadow=GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||||
|
for child in node.get_children():ghost(child)
|
||||||
|
|
||||||
|
func refresh_ground() -> void:
|
||||||
|
# Y=0 is a visual construction datum. Cut out goal footprints so the plane
|
||||||
|
# does not cover mouths/outlets that cross it. Physics remains geometry driven.
|
||||||
|
ground_holes.clear()
|
||||||
|
for goal in goals:
|
||||||
|
var bounds: AABB=lib.record_bounds(goal)
|
||||||
|
if bounds.position.y<=.001 and bounds.end.y>=-.001:
|
||||||
|
ground_holes.append(Rect2(bounds.position.x,bounds.position.z,bounds.size.x,bounds.size.z))
|
||||||
|
var regions: Array=[Rect2(-100,-100,200,200)]
|
||||||
|
for hole: Rect2 in ground_holes:
|
||||||
|
var split: Array=[]
|
||||||
|
for region: Rect2 in regions:
|
||||||
|
if not region.intersects(hole):split.append(region);continue
|
||||||
|
var cut:=region.intersection(hole)
|
||||||
|
var candidates=[Rect2(region.position,Vector2(cut.position.x-region.position.x,region.size.y)),
|
||||||
|
Rect2(Vector2(cut.end.x,region.position.y),Vector2(region.end.x-cut.end.x,region.size.y)),
|
||||||
|
Rect2(Vector2(cut.position.x,region.position.y),Vector2(cut.size.x,cut.position.y-region.position.y)),
|
||||||
|
Rect2(Vector2(cut.position.x,cut.end.y),Vector2(cut.size.x,region.end.y-cut.end.y))]
|
||||||
|
for rect: Rect2 in candidates:
|
||||||
|
if rect.size.x>.00001 and rect.size.y>.00001:split.append(rect)
|
||||||
|
regions=split
|
||||||
|
var mesh:=ImmediateMesh.new();mesh.surface_begin(Mesh.PRIMITIVE_TRIANGLES)
|
||||||
|
mesh.surface_set_normal(Vector3.UP)
|
||||||
|
for region: Rect2 in regions:
|
||||||
|
var a:=Vector3(region.position.x,0,region.position.y)
|
||||||
|
var b:=Vector3(region.position.x,0,region.end.y)
|
||||||
|
var c:=Vector3(region.end.x,0,region.end.y)
|
||||||
|
var d:=Vector3(region.end.x,0,region.position.y)
|
||||||
|
for vertex in [a,c,b,a,d,c]:mesh.surface_add_vertex(vertex)
|
||||||
|
mesh.surface_end();ground_view.mesh=mesh
|
||||||
|
ground_view.cast_shadow=GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||||
|
var mat:=material(Color("8b9a64"));mat.cull_mode=BaseMaterial3D.CULL_DISABLED
|
||||||
|
ground_view.material_override=mat
|
||||||
|
|
||||||
|
func refresh_grid() -> void:
|
||||||
|
clear_children(grid)
|
||||||
|
if not editor_mode:return
|
||||||
|
# Grid stays on the datum, independent of the selected height.
|
||||||
|
for axis in range(2):
|
||||||
|
for i in range(-12,13):
|
||||||
|
var fixed: float=(cursor.x if axis==0 else cursor.z)+i-.5
|
||||||
|
var along: float=cursor.z if axis==0 else cursor.x
|
||||||
|
var intervals: Array=[Vector2(along-12,along+12)]
|
||||||
|
for hole: Rect2 in ground_holes:
|
||||||
|
var across_min: float=hole.position.x if axis==0 else hole.position.y
|
||||||
|
var across_max: float=hole.end.x if axis==0 else hole.end.y
|
||||||
|
if fixed<across_min or fixed>across_max:continue
|
||||||
|
var start: float=hole.position.y if axis==0 else hole.position.x
|
||||||
|
var end: float=hole.end.y if axis==0 else hole.end.x
|
||||||
|
var next: Array=[]
|
||||||
|
for interval: Vector2 in intervals:
|
||||||
|
if interval.y<=start or interval.x>=end:next.append(interval)
|
||||||
|
else:
|
||||||
|
if interval.x<start:next.append(Vector2(interval.x,start))
|
||||||
|
if interval.y>end:next.append(Vector2(end,interval.y))
|
||||||
|
intervals=next
|
||||||
|
for interval: Vector2 in intervals:
|
||||||
|
var length: float=interval.y-interval.x;var middle: float=(interval.x+interval.y)*.5
|
||||||
|
var size:=Vector3(.008,.004,length) if axis==0 else Vector3(length,.004,.008)
|
||||||
|
var at:=Vector3(fixed,.004,middle) if axis==0 else Vector3(middle,.004,fixed)
|
||||||
|
box(size,at,Color("a2aa7c"),grid)
|
||||||
|
|
||||||
|
func frame_level() -> void:
|
||||||
|
if records.is_empty() and spawn_specs.is_empty():target=Vector3.ZERO;camera_size=12;update_camera();return
|
||||||
|
var low:=Vector3(INF,INF,INF);var high:=-low
|
||||||
|
for r in records:
|
||||||
|
var bounds: AABB=lib.record_bounds(r);low=low.min(bounds.position);high=high.max(bounds.end)
|
||||||
|
for spawn in spawn_specs:
|
||||||
|
var p: Vector3=lib.vector(spawn.position);low=low.min(p);high=high.max(p)
|
||||||
|
target=(low+high)*.5;camera_size=maxf(9.0,(high-low).length()*.93+2)
|
||||||
|
update_camera()
|
||||||
|
|
||||||
|
func update_camera() -> void:
|
||||||
|
camera.size=camera_size
|
||||||
|
camera.position=target+Vector3(cos(yaw)*cos(pitch),sin(pitch),sin(yaw)*cos(pitch))*40
|
||||||
|
camera.look_at(target)
|
||||||
|
|
||||||
|
func select_at(screen: Vector2) -> void:
|
||||||
|
if started or not editor_mode:return
|
||||||
|
var origin:=camera.project_ray_origin(screen);var dir:=camera.project_ray_normal(screen)
|
||||||
|
var query:=PhysicsRayQueryParameters3D.create(origin,origin+dir*300,3)
|
||||||
|
var hit:=get_world_3d().direct_space_state.intersect_ray(query)
|
||||||
|
if not hit.is_empty():
|
||||||
|
var node: Node=hit.collider
|
||||||
|
if node.has_meta("ball_id"):
|
||||||
|
for i in range(spawn_specs.size()):
|
||||||
|
if spawn_specs[i].id==str(node.get_meta("ball_id")):select_ball(i);refresh_ui();return
|
||||||
|
if category=="balls":pick_ball_position(origin,dir,hit);return
|
||||||
|
while node!=null and not node.has_meta("record_id"):node=node.get_parent()
|
||||||
|
if node!=null:
|
||||||
|
var id: String=node.get_meta("record_id")
|
||||||
|
if block_mode=="edit":select_record(id);return
|
||||||
|
if kind.is_empty():status="先选择要放置的方块。";refresh_ui();return
|
||||||
|
cursor=placement.on_face(records[index_for(id)],hit.position,hit.normal,kind,quarter)
|
||||||
|
selected_id="";selected_ball_id=""
|
||||||
|
status="新方块底面 Y %.2f · 原方块保持不动" % cursor.y
|
||||||
|
refresh_selection();return
|
||||||
|
if category=="balls":pick_ball_position(origin,dir,{});return
|
||||||
|
var p=Plane(Vector3.UP,0).intersects_ray(origin,dir)
|
||||||
|
if p!=null:
|
||||||
|
cursor=Vector3(round(p.x),0,round(p.z));selected_id="";selected_ball_id=""
|
||||||
|
refresh_selection()
|
||||||
|
|
||||||
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
if event is InputEventKey and event.pressed and not event.echo:
|
||||||
|
match event.keycode:
|
||||||
|
KEY_SPACE:toggle_run()
|
||||||
|
KEY_T:reset_simulation()
|
||||||
|
KEY_R:rotate_current()
|
||||||
|
KEY_DELETE,KEY_BACKSPACE:remove_current()
|
||||||
|
KEY_F:frame_level()
|
||||||
|
KEY_Z:
|
||||||
|
if event.ctrl_pressed or event.meta_pressed:undo()
|
||||||
|
if event is InputEventMouseButton:
|
||||||
|
if event.button_index==MOUSE_BUTTON_RIGHT:orbiting=event.pressed
|
||||||
|
if event.button_index==MOUSE_BUTTON_MIDDLE:panning=event.pressed
|
||||||
|
if event.pressed:
|
||||||
|
if event.button_index==MOUSE_BUTTON_WHEEL_UP:camera_size=maxf(3,camera_size-.7);update_camera()
|
||||||
|
if event.button_index==MOUSE_BUTTON_WHEEL_DOWN:camera_size=minf(150,camera_size+.7);update_camera()
|
||||||
|
if event.button_index==MOUSE_BUTTON_LEFT:select_at(event.position)
|
||||||
|
if event is InputEventMouseMotion:
|
||||||
|
if orbiting:yaw-=event.relative.x*.006;pitch=clampf(pitch+event.relative.y*.004,.18,1.4);update_camera()
|
||||||
|
if panning:
|
||||||
|
target-=camera.global_basis.x*event.relative.x*camera_size/900
|
||||||
|
target+=Vector3(camera.global_basis.y.x,0,camera.global_basis.y.z)*event.relative.y*camera_size/900
|
||||||
|
update_camera()
|
||||||
|
|
||||||
|
func save_level(path: String) -> Error:
|
||||||
|
var f:=FileAccess.open(path,FileAccess.WRITE)
|
||||||
|
if f==null:return FileAccess.get_open_error()
|
||||||
|
f.store_string(JSON.stringify(encode()," "));f.close();return OK
|
||||||
|
|
||||||
|
func load_level(path: String) -> String:
|
||||||
|
if started:return "请先返回编辑。"
|
||||||
|
if not FileAccess.file_exists(path):return "未找到关卡文件。"
|
||||||
|
var parsed:=JSON.new()
|
||||||
|
if parsed.parse(FileAccess.get_file_as_string(path))!=OK:return "JSON 格式有误。"
|
||||||
|
var issue:=validate_level(parsed.data)
|
||||||
|
if not issue.is_empty():return issue
|
||||||
|
remember();apply_data(parsed.data);return ""
|
||||||
|
|
||||||
|
func safe_name() -> String:
|
||||||
|
return name_field.text.strip_edges().validate_filename().replace(".","_")
|
||||||
|
|
||||||
|
func save_named() -> void:
|
||||||
|
if started:return
|
||||||
|
var title:=safe_name()
|
||||||
|
if title.is_empty():status="请输入关卡名称。";refresh_ui();return
|
||||||
|
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(SAVE_DIR))
|
||||||
|
var path:=SAVE_DIR+"/"+title+".json"
|
||||||
|
# Keep one local backup on replacement.
|
||||||
|
if FileAccess.file_exists(path):DirAccess.copy_absolute(ProjectSettings.globalize_path(path),ProjectSettings.globalize_path(path+".bak"))
|
||||||
|
var err:=save_level(path)
|
||||||
|
status="已保存:designer/drafts/"+title+".json" if err==OK else "保存失败:"+error_string(err)
|
||||||
|
refresh_files();refresh_ui()
|
||||||
|
|
||||||
|
func load_named() -> void:
|
||||||
|
var path:=SAVE_DIR+"/"+safe_name()+".json"
|
||||||
|
if not FileAccess.file_exists(path):
|
||||||
|
for i in range(file_list.item_count):
|
||||||
|
if file_list.get_item_text(i)==safe_name():path=str(file_list.get_item_metadata(i));break
|
||||||
|
var issue:=load_level(path)
|
||||||
|
status="关卡已载入。" if issue.is_empty() else issue;refresh_ui()
|
||||||
|
|
||||||
|
func refresh_files() -> void:
|
||||||
|
if file_list==null:return
|
||||||
|
file_list.clear()
|
||||||
|
var dir:=DirAccess.open(SAVE_DIR)
|
||||||
|
var listed: Array=[]
|
||||||
|
if dir!=null:
|
||||||
|
for file in dir.get_files():
|
||||||
|
if file.ends_with(".json"):
|
||||||
|
var title:=file.trim_suffix(".json");listed.append(title);file_list.add_item(title)
|
||||||
|
file_list.set_item_metadata(file_list.item_count-1,SAVE_DIR+"/"+file)
|
||||||
|
for path in EXAMPLE_LEVELS:
|
||||||
|
var title: String=path.get_file().trim_suffix(".json")
|
||||||
|
if title not in listed and FileAccess.file_exists(path):
|
||||||
|
file_list.add_item(title);file_list.set_item_metadata(file_list.item_count-1,path)
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if capture_count<0:return
|
||||||
|
capture_count-=1
|
||||||
|
if capture_count==0:
|
||||||
|
await RenderingServer.frame_post_draw
|
||||||
|
get_viewport().get_texture().get_image().save_png(capture_path)
|
||||||
|
get_tree().quit()
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user