Datasets:
Carpets: raise to 4 cm slabs with skirts (flat) / lift above floor (3D); stops floor z-fighting
Browse files- Bedroom1/Metascenes2_Spatiallm2_Solv3r2/scene_fixed.glb +2 -2
- Bedroom1/Metascenes2_Spatiallm2_Solv3r2/scene_physics.glb +2 -2
- I64/Metascenes1_Spatiallm1_RTABMAP1/scene_fixed.glb +2 -2
- I64/Metascenes1_Spatiallm1_RTABMAP1/scene_physics.glb +2 -2
- I87X/Metascenes3_Spatiallm3_Solv3r2/scene_fixed.glb +2 -2
- I87X/Metascenes3_Spatiallm3_Solv3r2/scene_physics.glb +2 -2
- P63/Metascenes1_Spatiallm1_MasterSlam1/scene_fixed.glb +2 -2
- P63/Metascenes1_Spatiallm1_MasterSlam1/scene_physics.glb +2 -2
- P64/Metascenes1_Spatiallm1_MasterSlam1/lift_carpets.py +11 -30
- P64/Metascenes1_Spatiallm1_MasterSlam1/rose_scan2sim.py +43 -3
Bedroom1/Metascenes2_Spatiallm2_Solv3r2/scene_fixed.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e5bbb9f94a59d8e2801b56361810e9ef6112ab10211521d60135d05045bced6c
|
| 3 |
+
size 24748460
|
Bedroom1/Metascenes2_Spatiallm2_Solv3r2/scene_physics.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f18e70c741727a8810878227668991c002bc3bda1b2920d73b3710c63735dd7b
|
| 3 |
+
size 24750624
|
I64/Metascenes1_Spatiallm1_RTABMAP1/scene_fixed.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0b588304d1325b8eab1d4fe751b1de610c479605bb300c7f205e4f5434a79788
|
| 3 |
+
size 20753424
|
I64/Metascenes1_Spatiallm1_RTABMAP1/scene_physics.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f4dbd599befee6d7a354b48d37aff3ab47483c5f2838eebc771fc744cb57142
|
| 3 |
+
size 20753672
|
I87X/Metascenes3_Spatiallm3_Solv3r2/scene_fixed.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0478471f7c40e7b7f5b5ea40fdc0970bb3591f3c8330731e339f0c7d57683cf1
|
| 3 |
+
size 26203604
|
I87X/Metascenes3_Spatiallm3_Solv3r2/scene_physics.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:93c0add47a2fdf02954f60416ede692ef37f54234f189e3498481b12745d13fc
|
| 3 |
+
size 26204440
|
P63/Metascenes1_Spatiallm1_MasterSlam1/scene_fixed.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:78d8a0a8dde74f11132b086ea7f402bcfb94c49063938287093ec6830f35b313
|
| 3 |
+
size 66896588
|
P63/Metascenes1_Spatiallm1_MasterSlam1/scene_physics.glb
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:07494fbd6de80599241ebd1e2feaa640e2dff8e930b7a9acd597336c296c8780
|
| 3 |
+
size 66897372
|
P64/Metascenes1_Spatiallm1_MasterSlam1/lift_carpets.py
CHANGED
|
@@ -1,30 +1,11 @@
|
|
| 1 |
-
"""
|
| 2 |
-
|
| 3 |
-
import sys,
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
if d > 1e-4: shifts[n] = d
|
| 13 |
-
if not shifts: return 0
|
| 14 |
-
b = open(path, "rb").read()
|
| 15 |
-
jl = struct.unpack("<I", b[12:16])[0]; j = json.loads(b[20:20+jl]); rest = b[20+jl:]
|
| 16 |
-
k = 0
|
| 17 |
-
for nd in j["nodes"]:
|
| 18 |
-
nm = nd.get("name", "")
|
| 19 |
-
if nm in shifts or nm.replace("/", "_") in shifts:
|
| 20 |
-
d = shifts.get(nm, shifts.get(nm.replace("/", "_")))
|
| 21 |
-
if "matrix" in nd: nd["matrix"][13] += d
|
| 22 |
-
else: nd["translation"] = [0, d, 0]
|
| 23 |
-
k += 1
|
| 24 |
-
js = json.dumps(j, separators=(",", ":")).encode(); js += b" " * (-len(js) % 4)
|
| 25 |
-
out = b[:8] + struct.pack("<I", 12 + 8 + len(js) + len(rest)) + struct.pack("<I", len(js)) + b"JSON" + js + rest
|
| 26 |
-
if not os.path.exists(path + ".prelift"): shutil.copy(path, path + ".prelift")
|
| 27 |
-
open(path, "wb").write(out)
|
| 28 |
-
return k
|
| 29 |
-
if __name__ == "__main__":
|
| 30 |
-
for p in sys.argv[1:]: print(p, fix(p))
|
|
|
|
| 1 |
+
"""Retro-fit carpet slabs (rose_scan2sim.carpet_slabs) to existing scene_fixed.glb / scene_physics.glb.
|
| 2 |
+
Always starts from <file>.prelift (the original, saved on first run), so it is safe to re-run."""
|
| 3 |
+
import sys, os, shutil, trimesh
|
| 4 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 5 |
+
from rose_scan2sim import carpet_slabs
|
| 6 |
+
for p in sys.argv[1:]:
|
| 7 |
+
bak = p + ".prelift"
|
| 8 |
+
if not os.path.exists(bak): shutil.copy(p, bak)
|
| 9 |
+
s = trimesh.load(bak, file_type="glb")
|
| 10 |
+
if not any("carpet" in n.lower() for n in s.graph.nodes_geometry): print(p, "no carpet"); continue
|
| 11 |
+
carpet_slabs(s).export(p); print(p, "ok")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
P64/Metascenes1_Spatiallm1_MasterSlam1/rose_scan2sim.py
CHANGED
|
@@ -370,18 +370,58 @@ def main():
|
|
| 370 |
print(f"done in {time.time() - t0:.0f} s -> {a.out}")
|
| 371 |
|
| 372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
def compose(room_glb, out, deltas, dst):
|
| 374 |
"""room.glb (glTF y-up, as written by export_3d.py) + objects/<name>.glb (layout z-up), each moved by deltas[name]."""
|
| 375 |
scene = trimesh.load(room_glb, force="scene") if room_glb else trimesh.Scene()
|
| 376 |
for name, D in deltas.items():
|
| 377 |
o = trimesh.load(os.path.join(out, "objects", name + ".glb"), force="scene", process=False)
|
| 378 |
o.apply_transform(ZUP2GLTF @ np.asarray(D))
|
| 379 |
-
if "carpet" in name.lower(): # flat carpets: keep >= 2 cm above the floor plane (y=0) so they do not z-fight with it
|
| 380 |
-
lift = 0.02 - o.bounds[0][1]
|
| 381 |
-
if lift > 0: o.apply_translation([0, lift, 0])
|
| 382 |
for node in o.graph.nodes_geometry:
|
| 383 |
T, g = o.graph[node]
|
| 384 |
scene.add_geometry(o.geometry[g].copy(), node_name=f"{name}/{node}", geom_name=f"{name}/{g}", transform=T)
|
|
|
|
| 385 |
scene.export(dst)
|
| 386 |
|
| 387 |
|
|
|
|
| 370 |
print(f"done in {time.time() - t0:.0f} s -> {a.out}")
|
| 371 |
|
| 372 |
|
| 373 |
+
CARPET_TOP = 0.04 # m: carpet top above the floor plane (y=0); sides are skirted down to the floor
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
def carpet_slabs(scene):
|
| 377 |
+
"""Flat carpet planes sit on the floor plane and z-fight with it. Raise each carpet so its top is CARPET_TOP above
|
| 378 |
+
the floor and close the gap with side skirts (same UVs): a thin rug slab with no coplanar surfaces.
|
| 379 |
+
Run it on the original scene (not on one already processed)."""
|
| 380 |
+
out = trimesh.Scene()
|
| 381 |
+
for n in scene.graph.nodes_geometry:
|
| 382 |
+
T, g = scene.graph[n]
|
| 383 |
+
m = scene.geometry[g]
|
| 384 |
+
if "carpet" not in n.lower() or not isinstance(m, trimesh.Trimesh):
|
| 385 |
+
out.add_geometry(m, node_name=n, geom_name=g, transform=T)
|
| 386 |
+
continue
|
| 387 |
+
m = m.copy(); m.apply_transform(T)
|
| 388 |
+
if np.ptp(m.vertices[:, 1]) > 0.01: # real 3D carpet mesh, not a flat plane: leave as is
|
| 389 |
+
m.apply_translation([0, max(0.0, 0.005 - m.bounds[0][1]), 0]) # keep it entirely above the floor plane
|
| 390 |
+
out.add_geometry(m, node_name=n, geom_name=g); continue
|
| 391 |
+
v = m.vertices.copy(); v[:, 1] += CARPET_TOP - v[:, 1].max()
|
| 392 |
+
uv = np.asarray(m.visual.uv); mat = m.visual.material
|
| 393 |
+
e = m.edges_sorted
|
| 394 |
+
_, inv, cnt = np.unique(e, axis=0, return_inverse=True, return_counts=True)
|
| 395 |
+
ed = m.edges[np.where(cnt[inv.ravel()] == 1)[0]] # boundary edges, directed as in the faces
|
| 396 |
+
low = {}
|
| 397 |
+
for a, b in ed:
|
| 398 |
+
for k in (a, b):
|
| 399 |
+
low.setdefault(int(k), len(v) + len(low))
|
| 400 |
+
vs, uvs, tris = [v], [uv], []
|
| 401 |
+
cen = v.mean(axis=0)
|
| 402 |
+
for k in low:
|
| 403 |
+
vs.append(np.array([[v[k][0], 0.0, v[k][2]]])); uvs.append(uv[k][None])
|
| 404 |
+
for a, b in ed:
|
| 405 |
+
A, B, A2, B2 = int(a), int(b), low[int(a)], low[int(b)]
|
| 406 |
+
nrm = np.cross(v[B] - v[A], np.array([0, -1.0, 0]))
|
| 407 |
+
if np.dot(nrm, (v[A] + v[B]) / 2 - cen) >= 0: tris += [[A, B, B2], [A, B2, A2]]
|
| 408 |
+
else: tris += [[A, B2, B], [A, A2, B2]]
|
| 409 |
+
V = np.vstack(vs); F = np.vstack([m.faces, np.array(tris, dtype=int).reshape(-1, 3)])
|
| 410 |
+
slab = trimesh.Trimesh(V, F, visual=trimesh.visual.TextureVisuals(uv=np.vstack(uvs), material=mat), process=False)
|
| 411 |
+
out.add_geometry(slab, node_name=n, geom_name=g)
|
| 412 |
+
return out
|
| 413 |
+
|
| 414 |
+
|
| 415 |
def compose(room_glb, out, deltas, dst):
|
| 416 |
"""room.glb (glTF y-up, as written by export_3d.py) + objects/<name>.glb (layout z-up), each moved by deltas[name]."""
|
| 417 |
scene = trimesh.load(room_glb, force="scene") if room_glb else trimesh.Scene()
|
| 418 |
for name, D in deltas.items():
|
| 419 |
o = trimesh.load(os.path.join(out, "objects", name + ".glb"), force="scene", process=False)
|
| 420 |
o.apply_transform(ZUP2GLTF @ np.asarray(D))
|
|
|
|
|
|
|
|
|
|
| 421 |
for node in o.graph.nodes_geometry:
|
| 422 |
T, g = o.graph[node]
|
| 423 |
scene.add_geometry(o.geometry[g].copy(), node_name=f"{name}/{node}", geom_name=f"{name}/{g}", transform=T)
|
| 424 |
+
scene = carpet_slabs(scene)
|
| 425 |
scene.export(dst)
|
| 426 |
|
| 427 |
|