feat: 建立关卡工坊并整理项目目录
- 加入 Godot 基础试玩、画风展示和通孔验证场景 - 支持自由放球、多层叠放、墙壁、锥口球洞及固定 +5 m/s 定向加速方块 - 保存 Blender 源资产、模型导出、资源制作脚本和关卡编辑存档逻辑 - 按七类目录归档工程,集中 zsh 启动入口并补充 AGENTS.md 文件索引 - 同步设计规则、依赖锁定、验证报告和目录迁移记录 验证:目录迁移后的资源导入与四个场景加载通过;本次提交前检查暂存内容,未重复运行整套物理测试。
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# 底部通孔连续路线验证
|
||||
|
||||
2026-11-16。结论:现有直槽和两种弯槽的底孔能够连接成固定路线,球可以依靠真实碰撞通过两个弯道。水平通孔不会自行提供前进动力;坡道的底孔还不能直接按同底面高度接入这条路线。
|
||||
|
||||
## 打开与操作
|
||||
|
||||
双击项目根目录的 [scripts/Underpass.command](../../scripts/Underpass.command),或运行:
|
||||
|
||||
```sh
|
||||
./scripts/underpass.zsh
|
||||
```
|
||||
|
||||
Godot 原生场景是 [underpass.tscn](scenes/underpass.tscn)。点击“同时释放”或按空格启动;再次按空格暂停/继续,`T` 重置,`X` 切换实体/透视,右键拖动旋转,中键平移,滚轮缩放,`F` 回到全景。重置后可调初速度,范围 0–5 m/s,默认 2.4 m/s。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## 路线与验证边界
|
||||
|
||||
- 下层球从入口孔口内侧出发,沿“直行 → 交叉块底孔 → 转弯 → 两段直行 → 反向转弯 → 出口直行”经过 7 块滑槽,最后进入下层球洞。
|
||||
- 上层球沿另外一条直槽路线横穿同一块交叉积木,再进入上层球洞。两球同时释放,交叉块有一段时间同时容纳两球。
|
||||
- 两端使用现有锥口球洞与可见实心墙收球。滑槽、铁球、摩擦、滚动阻力、空气阻力、重力和碰撞网格直接复用现有独立美术副本。没有新增承托平台、隐藏碰撞体、沿路径移动或运行中的速度修正;初速度只在释放时赋予一次,初始角速度为 0。
|
||||
- 透视开关只替换渲染材质;蓝线为孔道中心线,橙线为上层方向标记,两者均无碰撞。球运动轨迹来自物理计算,检测点只记录通过情况。
|
||||
- 水平底孔半径 0.32 m,铁球半径 0.30 m,径向余量只有 0.02 m。当前测试保留原尺寸,不代表任意错位连接或任意长路线都能通过。
|
||||
|
||||
布局保存在 [underpass_validation.json](data/underpass_validation.json),可从工坊存档列表载入继续编辑。**工坊从静止释放,不使用此独立实验场景的初速度滑块**;单纯载入工坊后,水平孔内的球不会自行走完路线。重复本验证请使用专用入口。
|
||||
|
||||
## 真实物理结果
|
||||
|
||||
```sh
|
||||
./scripts/run.zsh test-underpass
|
||||
```
|
||||
|
||||
Godot 4.7.2、Jolt Physics、120 Hz。完整结果、每段出口时刻、实际接触记录与采样轨迹见 [underpass_report.json](../artifacts/styled/underpass_report.json)。
|
||||
|
||||
21 项检查通过:真实三角面碰撞体的 707 个球体净空采样均无阻挡;6 处接口吻合;默认 2.4 m/s 的 12 次完整试跑全部进入各自球洞,下层依序通过 7 个出口并实际接触全部 7 块滑槽。重复试跑包括球心横向偏移 0、−0.008、+0.008 m。测试还检查上下球同时占据交叉块且不接触、透视不改变碰撞体、重置、暂停与继续。
|
||||
|
||||
初速度扫描的结果如下。这是本布局的离散采样,不是求出的精确最低通行速度,也不代表表中每个速度都做了重复稳定性验证。
|
||||
|
||||
| 初速度 | 下层结果 |
|
||||
| --- | --- |
|
||||
| 0 m/s | 留在入口,水平孔不会自行驱动小球 |
|
||||
| 0.8 m/s | 通过 1 段后停下 |
|
||||
| 1.2 m/s | 通过 3 段后停下 |
|
||||
| 1.6 m/s | 通过 6 段,在末端直孔内停下 |
|
||||
| 2.0、2.4、2.8、3.2、4.0、5.0 m/s | 全部 7 段通过并入洞 |
|
||||
|
||||
默认速度的完成时间约 5.6–5.8 秒。物理运行有小幅差异,以每次报告为准。速度不足时显示停球提示;可以直接重置调整初速度对照。
|
||||
|
||||
## 坡道为何不能直接串进来
|
||||
|
||||
资产目录中,相对各自底面原点的孔心高度为:直槽/弯槽/Y 汇流 0.340 m,缓坡约 0.052 m,陡坡约 0.207 m。后两者底孔还向底面外开放;同高摆放会产生约 0.288 m、0.133 m 的接口错位,远大于本球的径向余量。
|
||||
|
||||
本场景因此只证明同高的直槽与弯槽可以组成连续下层路线。若后续要把缓坡、陡坡接入同一底层路线,需要另行解决孔心高度、开放底部的承托和接口过渡,再做组合试跑。当前水平结构在上槽底与孔顶之间只有约 0.02 m 实体厚度,这也是继续调整球径、孔径或槽深时需要复核的尺寸约束。
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"assetFamily": "railbound_inspired",
|
||||
"title": "底部通孔 · 连续转弯验证",
|
||||
"pieces": [
|
||||
{"id":"lower_entry","kind":"straight","position":[0,0,2],"quarter":0},
|
||||
{"id":"crossing","kind":"straight","position":[0,0,1],"quarter":0},
|
||||
{"id":"lower_turn_a","kind":"turn_ccw","position":[0,0,0],"quarter":0},
|
||||
{"id":"lower_middle_a","kind":"straight","position":[1,0,0],"quarter":1},
|
||||
{"id":"lower_middle_b","kind":"straight","position":[2,0,0],"quarter":1},
|
||||
{"id":"lower_turn_b","kind":"turn_cw","position":[3,0,0],"quarter":1},
|
||||
{"id":"lower_exit","kind":"straight","position":[3,0,-1],"quarter":0},
|
||||
{"id":"upper_entry","kind":"straight","position":[-1,0,1],"quarter":0},
|
||||
{"id":"upper_exit","kind":"straight","position":[1,0,1],"quarter":0}
|
||||
],
|
||||
"entities": [
|
||||
{"id":"lower_goal","kind":"goal_hole","position":[3,0.02,-2],"quarter":0},
|
||||
{"id":"lower_stop","kind":"wall","position":[3,0,-3],"quarter":0},
|
||||
{"id":"upper_goal","kind":"goal_hole","position":[2,0.68,1],"quarter":0},
|
||||
{"id":"upper_stop","kind":"wall","position":[3,0,1],"quarter":0}
|
||||
],
|
||||
"balls": [
|
||||
{"id":"lower_ball","ballTypeId":"iron_ball","position":[0,0.335,2.25],"launchDirection":[0,0,-1]},
|
||||
{"id":"upper_ball","ballTypeId":"iron_ball","position":[-1.25,0.998,1],"launchDirection":[1,0,0]}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://playtest/underpass/scripts/underpass.gd" id="1"]
|
||||
|
||||
[node name="UnderpassValidation" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
@@ -0,0 +1,144 @@
|
||||
extends "res://designer/scripts/studio.gd"
|
||||
|
||||
# Only the initial impulse is authored. Existing asset colliders and iron-ball
|
||||
# forces own all motion after release; guide lines have no physics bodies.
|
||||
const LEVEL = "res://playtest/underpass/data/underpass_validation.json"
|
||||
const LOWER_IDS = ["lower_entry", "crossing", "lower_turn_a", "lower_middle_a", "lower_middle_b", "lower_turn_b", "lower_exit"]
|
||||
const BLUE = Color("287ca0")
|
||||
const ORANGE = Color("d27c36")
|
||||
var speed_slider: HSlider
|
||||
var speed_label: Label
|
||||
var view_button: Button
|
||||
var route_label: Label
|
||||
var xray := false
|
||||
var guides := Node3D.new()
|
||||
var checkpoints: Array = []
|
||||
var passed_checkpoints: Array = []
|
||||
var route_contacts: Dictionary = {}
|
||||
var ball_contacts := 0
|
||||
var lower_trace: Array = []
|
||||
var stalled_time := 0.0
|
||||
var launch_speed := 2.4
|
||||
var snapshot_time := -1.0
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
get_window().title = "IntoHole · 底部通孔验证"
|
||||
for arg in OS.get_cmdline_user_args():
|
||||
if arg == "--xray": toggle_xray()
|
||||
if arg.begins_with("--snapshot-time="):
|
||||
snapshot_time = float(arg.trim_prefix("--snapshot-time=")); capture_count = -1
|
||||
|
||||
func setup_environment() -> void:
|
||||
super.setup_environment()
|
||||
camera.h_offset = -1.4
|
||||
yaw = 1.05; pitch = .74
|
||||
add_child(guides)
|
||||
|
||||
func setup_ui() -> void:
|
||||
var layer := CanvasLayer.new(); add_child(layer)
|
||||
var panel := PanelContainer.new(); panel.position = Vector2(20, 20); panel.custom_minimum_size.x = 288
|
||||
panel.add_theme_stylebox_override("panel", style(PAPER)); layer.add_child(panel)
|
||||
var col := VBoxContainer.new(); col.add_theme_constant_override("separation", 12); panel.add_child(col)
|
||||
col.add_child(label("INTO / HOLE", 27))
|
||||
col.add_child(label("底部通孔验证", 22))
|
||||
col.add_child(label("下层 7 块 · 2 次转弯\n上层横穿同一块滑槽", 16))
|
||||
run_button = button("▶ 同时释放", toggle_run, true); col.add_child(run_button)
|
||||
col.add_child(button("↺ 重置", reset_simulation))
|
||||
speed_label = label("初速度 2.4 m/s", 16); col.add_child(speed_label)
|
||||
speed_slider = HSlider.new(); speed_slider.min_value = 0; speed_slider.max_value = 5
|
||||
speed_slider.step = .1; speed_slider.value = launch_speed; speed_slider.custom_minimum_size = Vector2(260, 26)
|
||||
speed_slider.value_changed.connect(func(value): launch_speed = value; speed_label.text = "初速度 %.1f m/s" % value)
|
||||
col.add_child(speed_slider)
|
||||
view_button = button("观察方式:实体 → 透视", toggle_xray); col.add_child(view_button)
|
||||
col.add_child(label("蓝线 / 1 下层孔道\n橙线 / 2 上层滑槽", 16))
|
||||
count_label = label("", 19); col.add_child(count_label)
|
||||
route_label = label("", 15); col.add_child(route_label)
|
||||
status_label = label("", 15); status_label.custom_minimum_size.x = 260
|
||||
status_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART; col.add_child(status_label)
|
||||
col.add_child(label("空格 释放 / 暂停 T 重置\nX 实体 / 透视 F 全景\n右键旋转 · 中键平移 · 滚轮缩放", 13))
|
||||
col.add_child(label("水平通孔需要初始动能。\n调为 0 可观察静止对照。", 14, Color("7a7366")))
|
||||
|
||||
func initialize_level() -> void:
|
||||
apply_data(JSON.parse_string(FileAccess.get_file_as_string(LEVEL)))
|
||||
|
||||
func rebuild() -> void:
|
||||
super.rebuild()
|
||||
clear_children(guides); checkpoints.clear()
|
||||
for id in LOWER_IDS:
|
||||
var r: Dictionary = records[index_for(id)]
|
||||
var basis := Basis(Vector3.UP, -r.quarter * PI / 2)
|
||||
var points := PackedVector3Array()
|
||||
for p in lib.catalog[r.kind].lowerPaths[0]: points.append(lib.record_center(r) + basis * lib.vector(p))
|
||||
draw_path(points, BLUE)
|
||||
checkpoints.append({"id": id, "point": points[-1], "direction": (points[-1] - points[-2]).normalized()})
|
||||
draw_path(PackedVector3Array([Vector3(-1.5,1.025,1), Vector3(1.5,1.025,1)]), ORANGE)
|
||||
apply_view()
|
||||
|
||||
func draw_path(points: PackedVector3Array, color: Color) -> void:
|
||||
var mesh := ImmediateMesh.new(); mesh.surface_begin(Mesh.PRIMITIVE_LINE_STRIP)
|
||||
for point in points: mesh.surface_add_vertex(point)
|
||||
mesh.surface_end()
|
||||
var view := MeshInstance3D.new(); view.mesh = mesh
|
||||
var mat := material(color); mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED
|
||||
view.material_override = mat; guides.add_child(view)
|
||||
|
||||
func toggle_xray() -> void:
|
||||
xray = not xray; apply_view()
|
||||
view_button.text = "观察方式:透视 → 实体" if xray else "观察方式:实体 → 透视"
|
||||
|
||||
func apply_view() -> void:
|
||||
for piece in pieces:
|
||||
for node in piece.find_children("*", "MeshInstance3D", true, false):
|
||||
if str(node.name).begins_with("ink_"): node.visible = not xray; continue
|
||||
if xray:
|
||||
var mat := material(Color(.68,.75,.72,.19))
|
||||
mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
node.material_override = mat
|
||||
else: node.material_override = null
|
||||
guides.visible = xray
|
||||
|
||||
func reset_simulation() -> void:
|
||||
super.reset_simulation()
|
||||
passed_checkpoints.clear(); route_contacts.clear(); ball_contacts = 0; lower_trace.clear(); stalled_time = 0
|
||||
for i in range(tags.size()): tags[i].modulate = BLUE if i == 0 else ORANGE
|
||||
refresh_ui()
|
||||
|
||||
func initial_velocity(index: int) -> Vector3:
|
||||
return lib.vector(spawn_specs[index].launchDirection).normalized() * launch_speed
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
super._physics_process(delta)
|
||||
if not started or paused or balls.is_empty(): return
|
||||
var b = balls[0]
|
||||
if not entered.has(0) and not lost.has(0):
|
||||
if Engine.get_physics_frames() % 6 == 0: lower_trace.append({"time":elapsed,"position":codec.array_from(b.position),"speed":b.linear_velocity.length()})
|
||||
ball_contacts += b.ball_contact_count
|
||||
for collider in b.get_colliding_bodies():
|
||||
var node: Node = collider
|
||||
while node != null and not node.has_meta("record_id"): node = node.get_parent()
|
||||
if node != null: route_contacts[str(node.get_meta("record_id"))] = true
|
||||
if passed_checkpoints.size() < checkpoints.size():
|
||||
var gate: Dictionary = checkpoints[passed_checkpoints.size()]
|
||||
var offset: Vector3 = b.position - gate.point
|
||||
var axial: float = offset.dot(gate.direction)
|
||||
if axial > .015 and (offset - axial * gate.direction).length() < .09:
|
||||
passed_checkpoints.append({"id":gate.id,"time":elapsed})
|
||||
stalled_time = stalled_time + delta if b.linear_velocity.length() < .03 else 0.0
|
||||
if stalled_time > 2: status = "下层球已停下。当前动能不足以走完整条路线。"
|
||||
refresh_ui()
|
||||
|
||||
func refresh_ui() -> void:
|
||||
if status_label == null: return
|
||||
super.refresh_ui()
|
||||
speed_slider.editable = not started
|
||||
route_label.text = "下层出口检查 %d / 7\n上下球接触 %d" % [passed_checkpoints.size(), ball_contacts]
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed and not event.echo and event.keycode == KEY_X: toggle_xray(); return
|
||||
super._unhandled_input(event)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if snapshot_time >= 0 and elapsed >= snapshot_time:
|
||||
snapshot_time = -1; capture_count = 2
|
||||
super._process(delta)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dtaw8jwlui1sc
|
||||
Reference in New Issue
Block a user