diff --git a/assets/vehicles/anvil/anvil.glb b/assets/vehicles/anvil/anvil.glb index 5d28086..1468d2e 100644 Binary files a/assets/vehicles/anvil/anvil.glb and b/assets/vehicles/anvil/anvil.glb differ diff --git a/assets/vehicles/anvil/manifest.json b/assets/vehicles/anvil/manifest.json index 3e31f06..ca8cff5 100644 --- a/assets/vehicles/anvil/manifest.json +++ b/assets/vehicles/anvil/manifest.json @@ -150,5 +150,5 @@ 5.6504 ] }, - "triCount": 18008 + "triCount": 18044 } diff --git a/assets/vehicles/breaker/breaker.glb b/assets/vehicles/breaker/breaker.glb index 906bf28..164b627 100644 Binary files a/assets/vehicles/breaker/breaker.glb and b/assets/vehicles/breaker/breaker.glb differ diff --git a/assets/vehicles/breaker/manifest.json b/assets/vehicles/breaker/manifest.json index 4d5efaa..a3bd05c 100644 --- a/assets/vehicles/breaker/manifest.json +++ b/assets/vehicles/breaker/manifest.json @@ -137,22 +137,22 @@ ], "bounds": { "min": [ - -2.3374, + -2.3356, -0.0, - -1.6334 + -1.274 ], "max": [ - 2.3449, - 6.1109, - 1.6106 + 2.3808, + 6.2567, + 1.8859 ], "size": [ - 4.6823, - 6.1109, - 3.244 + 4.7164, + 6.2567, + 3.1599 ] }, - "triCount": 30835, + "triCount": 39196, "mechanisms": { "frame": "gltf (+Y up, +Z forward, +X left, meters)", "rootOrigin": [ @@ -168,7 +168,7 @@ "mechanism": "hip", "side": "L", "origin": [ - 0.7809, + 0.6209, 3.362557, 0.0 ], @@ -189,8 +189,8 @@ "side": "L", "origin": [ 1.0809, - 2.614853, - 0.19926 + 2.71148, + 0.173509 ], "axis": [ -0.0, @@ -213,12 +213,12 @@ 0.339999 ], "axis": [ - -1.0, - 0.0, - 0.0 + -0.0, + -0.970991, + -0.239116 ], - "lo": -1.679763702733374, - "hi": 0.43208469217976486, + "lo": -1.7453292519943295, + "hi": 1.7453292519943295, "depth": 2 }, { @@ -229,8 +229,8 @@ "side": "L", "origin": [ 1.0809, - 1.215231, - 0.125381 + 1.021033, + 0.077557 ], "axis": [ -0.0, @@ -257,12 +257,12 @@ -0.020002 ], "axis": [ + -0.0, -1.0, - 0.0, 0.0 ], - "lo": -0.6562437987498678, - "hi": 0.6562437987498678, + "lo": -0.6981317007977318, + "hi": 0.6981317007977318, "depth": 4, "stopped_by": "ram" }, @@ -278,9 +278,9 @@ 0.237904 ], "axis": [ - -0.996195, - 0.0, - -0.087156 + -0.08495, + -0.223571, + 0.970979 ], "lo": -0.1745329183221527, "hi": 0.5235987824755791, @@ -298,9 +298,9 @@ 0.626296 ], "axis": [ - -0.996195, + -0.087156, 0.0, - -0.087156 + 0.996195 ], "lo": -0.2094395171165998, "hi": 0.8377580340799979, @@ -318,9 +318,9 @@ 0.237904 ], "axis": [ - -0.996195, - 0.0, - 0.087156 + 0.08495, + -0.223571, + 0.970979 ], "lo": -0.1745329183221527, "hi": 0.5235987824755791, @@ -338,9 +338,9 @@ 0.626296 ], "axis": [ - -0.996195, + 0.087156, 0.0, - 0.087156 + 0.996195 ], "lo": -0.2094395171165998, "hi": 0.8377580340799979, @@ -358,9 +358,9 @@ 0.057444 ], "axis": [ - -0.788011, - -0.0, - -0.615661 + -0.58406, + -0.316267, + 0.747562 ], "lo": -0.17453293312755827, "hi": 0.5235987676701735, @@ -378,9 +378,9 @@ 0.057444 ], "axis": [ - -0.788011, - 0.0, - 0.615661 + 0.58406, + -0.316267, + 0.747562 ], "lo": -0.17453293312755827, "hi": 0.5235987676701735, @@ -398,9 +398,9 @@ -0.387362 ], "axis": [ - 0.970296, - -0.0, - -0.241922 + -0.225859, + -0.358307, + -0.905872 ], "lo": -0.20943950039479836, "hi": 0.4188790303231602, @@ -418,9 +418,9 @@ -0.387362 ], "axis": [ - 0.970296, - -0.0, - 0.241922 + 0.225859, + -0.358307, + -0.905872 ], "lo": -0.20943950039479836, "hi": 0.4188790303231602, @@ -433,9 +433,9 @@ "mechanism": "hip", "side": "R", "origin": [ - -0.7809, + -0.6209, 3.362557, - -0.0 + 0.0 ], "axis": [ -1.0, @@ -454,8 +454,8 @@ "side": "R", "origin": [ -1.0809, - 2.591123, - 0.060466 + 2.690817, + 0.052652 ], "axis": [ 0.0, @@ -478,12 +478,12 @@ 0.103173 ], "axis": [ - -1.0, - -0.0, - 0.0 + 0.0, + -0.944097, + -0.329667 ], - "lo": -1.767489706508053, - "hi": 0.3443586884050859, + "lo": -1.7453292519943295, + "hi": 1.7453292519943295, "depth": 2 }, { @@ -494,8 +494,8 @@ "side": "R", "origin": [ -1.0809, - 1.19888, - -0.192719 + 1.01006, + -0.258652 ], "axis": [ 0.0, @@ -522,12 +522,12 @@ -0.393156 ], "axis": [ + 0.0, -1.0, - -0.0, 0.0 ], - "lo": -0.6562437987498678, - "hi": 0.6562437987498678, + "lo": -0.6981317007977318, + "hi": 0.6981317007977318, "depth": 4, "stopped_by": "ram" }, @@ -543,9 +543,9 @@ -0.13525 ], "axis": [ - -0.996195, - -0.0, - -0.087156 + -0.08495, + -0.223571, + 0.970979 ], "lo": -0.1745329183221527, "hi": 0.5235987824755791, @@ -563,9 +563,9 @@ 0.253141 ], "axis": [ - -0.996195, - -0.0, - -0.087156 + -0.087156, + 0.0, + 0.996195 ], "lo": -0.2094395171165998, "hi": 0.8377580340799979, @@ -583,9 +583,9 @@ -0.135251 ], "axis": [ - -0.996195, - -0.0, - 0.087156 + 0.08495, + -0.223571, + 0.970979 ], "lo": -0.1745329183221527, "hi": 0.5235987824755791, @@ -603,9 +603,9 @@ 0.253141 ], "axis": [ - -0.996195, - -0.0, - 0.087156 + 0.087156, + 0.0, + 0.996195 ], "lo": -0.2094395171165998, "hi": 0.8377580340799979, @@ -623,9 +623,9 @@ -0.315711 ], "axis": [ - -0.788011, - -0.0, - -0.615662 + -0.58406, + -0.316267, + 0.747562 ], "lo": -0.17453293312755827, "hi": 0.5235987676701735, @@ -643,9 +643,9 @@ -0.315711 ], "axis": [ - -0.788011, - -0.0, - 0.615662 + 0.58406, + -0.316267, + 0.747562 ], "lo": -0.17453293312755827, "hi": 0.5235987676701735, @@ -663,9 +663,9 @@ -0.760517 ], "axis": [ - 0.970296, - 0.0, - -0.241922 + -0.225859, + -0.358307, + -0.905872 ], "lo": -0.20943950039479836, "hi": 0.4188790303231602, @@ -683,9 +683,9 @@ -0.760517 ], "axis": [ - 0.970296, - 0.0, - 0.241922 + 0.225859, + -0.358307, + -0.905872 ], "lo": -0.20943950039479836, "hi": 0.4188790303231602, @@ -699,7 +699,7 @@ "side": "", "origin": [ -0.0, - 3.821381, + 3.721381, 0.0 ], "axis": [ @@ -718,14 +718,14 @@ "mechanism": "shoulder slew", "side": "L", "origin": [ - 0.984694, + 0.819255, 4.983909, - 0.08615 + 0.0 ], "axis": [ - 0.996195, + 1.0, 0.0, - 0.087156 + 0.0 ], "lo": -1.7453292519943295, "hi": 1.7453292519943295, @@ -738,14 +738,14 @@ "mechanism": "shoulder hinge", "side": "L", "origin": [ - 1.482791, + 1.488455, 4.983909, - 0.129727 + 0.0 ], "axis": [ - 0.08672, - -0.09988, - -0.991213 + 0.087165, + -0.991212, + 0.0995 ], "lo": -0.7853981633974483, "hi": 0.7853981633974483, @@ -758,14 +758,14 @@ "mechanism": "arm twist", "side": "L", "origin": [ - 1.798104, - 4.091125, - 0.247276 + 1.556551, + 4.209545, + 0.077732 ], "axis": [ - 0.330483, - -0.935736, - 0.123203 + 0.087165, + -0.991212, + 0.0995 ], "lo": -1.5707963267948966, "hi": 1.5707963267948966, @@ -778,39 +778,19 @@ "mechanism": "elbow", "side": "L", "origin": [ - 1.936907, - 3.698115, - 0.299021 + 1.601947, + 3.693322, + 0.129552 ], "axis": [ - 0.943812, - 0.327655, - -0.043141 + 0.1199, + -0.441691, + 0.889119 ], - "lo": -1.166110152741363, - "hi": 0.9457382421717758, + "lo": -1.7453292519943295, + "hi": 1.7453292519943295, "depth": 4 }, - { - "name": "CannonL", - "parent": 30, - "kind": "slide", - "mechanism": "recoil slide", - "side": "L", - "origin": [ - 2.058856, - 3.430472, - 0.934234 - ], - "axis": [ - 0.174214, - -0.382347, - 0.907447 - ], - "lo": -0.28, - "hi": 0.0, - "depth": 5 - }, { "name": "ShoulderYokeR", "parent": 26, @@ -818,14 +798,14 @@ "mechanism": "shoulder slew", "side": "R", "origin": [ - -0.984694, + -0.819255, 4.983909, - -0.08615 + 0.0 ], "axis": [ - -0.996195, + -1.0, -0.0, - -0.087156 + -0.0 ], "lo": -1.7453292519943295, "hi": 1.7453292519943295, @@ -833,19 +813,19 @@ }, { "name": "UpperArmR", - "parent": 32, + "parent": 31, "kind": "hinge", "mechanism": "shoulder hinge", "side": "R", "origin": [ - -1.482791, + -1.488455, 4.983909, - -0.129727 + -0.0 ], "axis": [ - 0.085451, - -0.196836, - -0.976706 + -0.061315, + -0.978592, + 0.196466 ], "lo": -0.7853981633974483, "hi": 0.7853981633974483, @@ -853,19 +833,19 @@ }, { "name": "ElbowYokeR", - "parent": 33, + "parent": 32, "kind": "slew", "mechanism": "arm twist", "side": "R", "origin": [ - -1.792167, - 4.094292, - 0.022491 + -1.536356, + 4.219404, + 0.153485 ], "axis": [ - -0.32426, - -0.932417, - 0.159542 + -0.061315, + -0.978592, + 0.196466 ], "lo": -1.5707963267948966, "hi": 1.5707963267948966, @@ -873,204 +853,43 @@ }, { "name": "ForearmR", - "parent": 34, + "parent": 33, "kind": "hinge", "mechanism": "elbow", "side": "R", "origin": [ - -1.928356, - 3.702677, - 0.089498 + -1.56829, + 3.709754, + 0.255804 ], "axis": [ - 0.945968, - -0.319615, - 0.054688 + 0.03822, + -0.374104, + 0.926599 ], - "lo": -1.162425162502969, - "hi": 0.94942323241017, + "lo": -1.7453292519943295, + "hi": 1.7453292519943295, "depth": 4 - }, - { - "name": "CannonR", - "parent": 35, - "kind": "slide", - "mechanism": "recoil slide", - "side": "R", - "origin": [ - -2.047299, - 3.461206, - 0.735675 - ], - "axis": [ - -0.169918, - -0.344958, - 0.92311 - ], - "lo": -0.322, - "hi": 0.0, - "depth": 5 - } - ], - "rams": [ - { - "name": "LegL.RecessRam0", - "barrel_bone": "LegL.RecessRam0.barrel", - "rod_bone": "LegL.RecessRam0.rod", - "spans": [ - "LegL.Oleo", - "LegL.Foot" - ], - "bore": 0.09, - "body": 0.684277294853396, - "inner": 0.5164401248747118, - "extension": 0.38794012487471186, - "rest": 1.3782174197281079, - "stroke": [ - -0.36794012487471184, - 0.21847974645577417 - ], - "a_parent_dof": 2, - "a_pos": [ - 0.9109, - 2.117333, - -0.202422 - ], - "b_parent_dof": 4, - "b_pos": [ - 0.9109, - 0.745732, - -0.337304 - ], - "pin_dir": [ - 1.0, - -0.0, - -0.0 - ] - }, - { - "name": "LegL.RecessRam1", - "barrel_bone": "LegL.RecessRam1.barrel", - "rod_bone": "LegL.RecessRam1.rod", - "spans": [ - "LegL.Oleo", - "LegL.Foot" - ], - "bore": 0.09, - "body": 0.684277294853396, - "inner": 0.5164401248747118, - "extension": 0.38794012487471186, - "rest": 1.3782174197281079, - "stroke": [ - -0.36794012487471184, - 0.2184797493721775 - ], - "a_parent_dof": 2, - "a_pos": [ - 1.2509, - 2.117333, - -0.202422 - ], - "b_parent_dof": 4, - "b_pos": [ - 1.2509, - 0.745732, - -0.337304 - ], - "pin_dir": [ - 1.0, - -0.0, - -0.0 - ] - }, - { - "name": "LegR.RecessRam0", - "barrel_bone": "LegR.RecessRam0.barrel", - "rod_bone": "LegR.RecessRam0.rod", - "spans": [ - "LegR.Oleo", - "LegR.Foot" - ], - "bore": 0.09, - "body": 0.7012918310027796, - "inner": 0.530752428835133, - "extension": 0.402252428835133, - "rest": 1.4095442598379126, - "stroke": [ - -0.382252428835133, - 0.2163740753634671 - ], - "a_parent_dof": 15, - "a_pos": [ - -1.2509, - 2.127887, - -0.433941 - ], - "b_parent_dof": 17, - "b_pos": [ - -1.2509, - 0.745731, - -0.710458 - ], - "pin_dir": [ - 1.0, - 0.0, - -0.0 - ] - }, - { - "name": "LegR.RecessRam1", - "barrel_bone": "LegR.RecessRam1.barrel", - "rod_bone": "LegR.RecessRam1.rod", - "spans": [ - "LegR.Oleo", - "LegR.Foot" - ], - "bore": 0.09, - "body": 0.701291947045056, - "inner": 0.5307523127928565, - "extension": 0.40225231279285656, - "rest": 1.4095442598379126, - "stroke": [ - -0.38225231279285654, - 0.2163740753634671 - ], - "a_parent_dof": 15, - "a_pos": [ - -0.9109, - 2.127887, - -0.433941 - ], - "b_parent_dof": 17, - "b_pos": [ - -0.9109, - 0.745731, - -0.710458 - ], - "pin_dir": [ - 1.0, - 0.0, - -0.0 - ] } ], + "rams": [], "scissors": [ { "name": "LegL.Torque", "upper_bone": "LegL.Torque.upper", "lower_bone": "LegL.Torque.lower", - "arm": 0.330219285226285, + "arm": 0.3087611656677239, "a_parent_dof": 2, "a_pos": [ 1.0809, - 1.155388, - 1.037531 + 1.240598, + 0.44059 ], "b_parent_dof": 3, "b_pos": [ 1.0809, - 0.616558, - 0.925437 + 0.757042, + 0.32151 ], "out_dir": [ 0.0, @@ -1082,18 +901,18 @@ "name": "LegR.Torque", "upper_bone": "LegR.Torque.upper", "lower_bone": "LegR.Torque.lower", - "arm": 0.33021940731772126, + "arm": 0.30876125639651403, "a_parent_dof": 15, "a_pos": [ -1.0809, - 1.053237, - 0.709716 + 1.194391, + 0.123477 ], "b_parent_dof": 16, "b_pos": [ -1.0809, - 0.527388, - 0.54728 + 0.724229, + -0.040697 ], "out_dir": [ 0.0, diff --git a/assets/vehicles/condor/condor.glb b/assets/vehicles/condor/condor.glb index 119e883..692968b 100644 Binary files a/assets/vehicles/condor/condor.glb and b/assets/vehicles/condor/condor.glb differ diff --git a/assets/vehicles/condor/manifest.json b/assets/vehicles/condor/manifest.json index 9bd5a03..8b056e5 100644 --- a/assets/vehicles/condor/manifest.json +++ b/assets/vehicles/condor/manifest.json @@ -221,5 +221,5 @@ 5.8758 ] }, - "triCount": 12936 + "triCount": 12960 } diff --git a/assets/vehicles/ferret/ferret.glb b/assets/vehicles/ferret/ferret.glb index 8111d11..e2bd6ea 100644 Binary files a/assets/vehicles/ferret/ferret.glb and b/assets/vehicles/ferret/ferret.glb differ diff --git a/assets/vehicles/ferret/manifest.json b/assets/vehicles/ferret/manifest.json index 717612e..77052ab 100644 --- a/assets/vehicles/ferret/manifest.json +++ b/assets/vehicles/ferret/manifest.json @@ -96,5 +96,5 @@ 3.6699 ] }, - "triCount": 7576 + "triCount": 7612 } diff --git a/assets/vehicles/hornet/hornet.glb b/assets/vehicles/hornet/hornet.glb index 148b4d5..abc6a71 100644 Binary files a/assets/vehicles/hornet/hornet.glb and b/assets/vehicles/hornet/hornet.glb differ diff --git a/assets/vehicles/hornet/manifest.json b/assets/vehicles/hornet/manifest.json index aa03646..bfe246a 100644 --- a/assets/vehicles/hornet/manifest.json +++ b/assets/vehicles/hornet/manifest.json @@ -139,5 +139,5 @@ 4.6715 ] }, - "triCount": 7184 + "triCount": 7252 } diff --git a/assets/vehicles/ironclad/ironclad.glb b/assets/vehicles/ironclad/ironclad.glb index 4158c45..e7a9470 100644 Binary files a/assets/vehicles/ironclad/ironclad.glb and b/assets/vehicles/ironclad/ironclad.glb differ diff --git a/assets/vehicles/ironclad/manifest.json b/assets/vehicles/ironclad/manifest.json index c5d80da..f3b5bfa 100644 --- a/assets/vehicles/ironclad/manifest.json +++ b/assets/vehicles/ironclad/manifest.json @@ -122,5 +122,5 @@ 4.7669 ] }, - "triCount": 16828 + "triCount": 16840 } diff --git a/assets/vehicles/jackal/jackal.glb b/assets/vehicles/jackal/jackal.glb index e58ac89..ce79f09 100644 Binary files a/assets/vehicles/jackal/jackal.glb and b/assets/vehicles/jackal/jackal.glb differ diff --git a/assets/vehicles/jackal/manifest.json b/assets/vehicles/jackal/manifest.json index 95f25bf..fc9934c 100644 --- a/assets/vehicles/jackal/manifest.json +++ b/assets/vehicles/jackal/manifest.json @@ -115,7 +115,7 @@ "min": [ -0.9778, 0.0, - -1.5943 + -1.5461 ], "max": [ 0.9778, @@ -125,8 +125,8 @@ "size": [ 1.9556, 1.5457, - 3.2993 + 3.2511 ] }, - "triCount": 15980 + "triCount": 16068 } diff --git a/assets/vehicles/mammoth/mammoth.glb b/assets/vehicles/mammoth/mammoth.glb index 34c87d3..32427a5 100644 Binary files a/assets/vehicles/mammoth/mammoth.glb and b/assets/vehicles/mammoth/mammoth.glb differ diff --git a/assets/vehicles/mammoth/manifest.json b/assets/vehicles/mammoth/manifest.json index 670f6b0..c57615a 100644 --- a/assets/vehicles/mammoth/manifest.json +++ b/assets/vehicles/mammoth/manifest.json @@ -255,5 +255,5 @@ 5.8649 ] }, - "triCount": 20500 + "triCount": 20512 } diff --git a/assets/vehicles/manticore/manifest.json b/assets/vehicles/manticore/manifest.json index f1d915e..cd74d80 100644 --- a/assets/vehicles/manticore/manifest.json +++ b/assets/vehicles/manticore/manifest.json @@ -167,5 +167,5 @@ 9.1091 ] }, - "triCount": 35850 + "triCount": 36030 } diff --git a/assets/vehicles/manticore/manticore.glb b/assets/vehicles/manticore/manticore.glb index bf106ab..88a627e 100644 Binary files a/assets/vehicles/manticore/manticore.glb and b/assets/vehicles/manticore/manticore.glb differ diff --git a/assets/vehicles/mule/manifest.json b/assets/vehicles/mule/manifest.json index d3273f8..a646428 100644 --- a/assets/vehicles/mule/manifest.json +++ b/assets/vehicles/mule/manifest.json @@ -178,5 +178,5 @@ 4.8667 ] }, - "triCount": 13760 + "triCount": 13772 } diff --git a/assets/vehicles/mule/mule.glb b/assets/vehicles/mule/mule.glb index e734a79..8f82821 100644 Binary files a/assets/vehicles/mule/mule.glb and b/assets/vehicles/mule/mule.glb differ diff --git a/assets/vehicles/paladin/manifest.json b/assets/vehicles/paladin/manifest.json index ceb9200..7e779b1 100644 --- a/assets/vehicles/paladin/manifest.json +++ b/assets/vehicles/paladin/manifest.json @@ -169,18 +169,18 @@ "min": [ -4.4388, -0.0, - -1.5938 + -1.5109 ], "max": [ 4.4387, 11.3161, - 2.365 + 2.4514 ], "size": [ 8.8775, 11.3161, - 3.9588 + 3.9623 ] }, - "triCount": 38556 + "triCount": 38752 } diff --git a/assets/vehicles/paladin/paladin.glb b/assets/vehicles/paladin/paladin.glb index 803e548..476c642 100644 Binary files a/assets/vehicles/paladin/paladin.glb and b/assets/vehicles/paladin/paladin.glb differ diff --git a/assets/vehicles/raptor/manifest.json b/assets/vehicles/raptor/manifest.json index 3188f91..322a4bb 100644 --- a/assets/vehicles/raptor/manifest.json +++ b/assets/vehicles/raptor/manifest.json @@ -115,14 +115,14 @@ ], "max": [ 2.3822, - 6.9383, + 6.9873, 4.5553 ], "size": [ 4.7644, - 6.9383, + 6.9873, 8.986 ] }, - "triCount": 35698 + "triCount": 35822 } diff --git a/assets/vehicles/raptor/raptor.glb b/assets/vehicles/raptor/raptor.glb index e70d35d..65e86ab 100644 Binary files a/assets/vehicles/raptor/raptor.glb and b/assets/vehicles/raptor/raptor.glb differ diff --git a/tools/vehicles/build_anvil.py b/tools/vehicles/build_anvil.py index e7d4370..871f408 100644 --- a/tools/vehicles/build_anvil.py +++ b/tools/vehicles/build_anvil.py @@ -347,8 +347,9 @@ def build_anvil() -> dict: "armor", parent=chassis, location=(0.0, -1.48, 1.46), - rotation_deg=(-62.0, 0.0, 0.0), + rotation_deg=(62.0, 0.0, 0.0), size=(1.88, 0.42, 0.10), + plinth_depth=0.04, ) # 2 & 3) hp.weapon.sponson_l (0,1, 1x2) & hp.weapon.sponson_r (4,1, 1x2) vc.add_hardpoint_slot( @@ -389,18 +390,20 @@ def build_anvil() -> dict: "hp.armor.sides", "armor", parent=chassis, - location=(-1.26, 0.42, 1.54), + location=(-1.20, 0.42, 1.54), rotation_deg=(90.0, 0.0, -90.0), size=(1.12, 0.34, 0.10), + plinth_depth=0.03, ) - # 7) hp.engine.rear (1,3, 3x2) + # 7) hp.engine.rear (1,3, 3x2) on sloped rear engine deck (y=1.98 -> hull surface z=1.825) vc.add_hardpoint_slot( "hp.engine.rear", "engine", parent=chassis, - location=(0.0, 1.98, 1.70), - rotation_deg=(0.0, 0.0, 0.0), + location=(0.0, 1.98, 1.815), + rotation_deg=(-12.5, 0.0, 0.0), size=(1.42, 0.96, 0.15), + plinth_depth=0.04, ) # 8 & 9) hp.radiator.l (0,4, 1x2) & hp.radiator.r (4,4, 1x2) vc.add_hardpoint_slot( diff --git a/tools/vehicles/build_condor.py b/tools/vehicles/build_condor.py index 2980316..b6d3e67 100644 --- a/tools/vehicles/build_condor.py +++ b/tools/vehicles/build_condor.py @@ -406,8 +406,9 @@ def build_condor() -> dict: "armor", parent=chassis, location=(0.0, -2.56, 1.13), - rotation_deg=(-69.0, 0.0, 0.0), + rotation_deg=(69.0, 0.0, 0.0), size=(0.64, 0.26, 0.09), + plinth_depth=0.04, ) # 3 & 4) hp.weapon.sponson_l (0,1, 1x2) & hp.weapon.sponson_r (4,1, 1x2) on cheek weapon sponsons vc.add_hardpoint_slot( @@ -435,14 +436,15 @@ def build_condor() -> dict: rotation_deg=(0.0, 0.0, 0.0), size=(0.54, 0.54, 0.09), ) - # 6) hp.engine.core (1,2, 3x2) central dorsal turbine bay + # 6) hp.engine.core (1,2, 3x2) central dorsal turbine bay (dorsal_spine_core width 0.78, cap top at z=1.91) vc.add_hardpoint_slot( "hp.engine.core", "engine", parent=chassis, - location=(0.0, 0.36, 1.88), + location=(0.0, 0.36, 1.89), rotation_deg=(0.0, 0.0, 0.0), - size=(0.98, 1.18, 0.14), + size=(0.74, 1.14, 0.14), + plinth_depth=0.05, ) # 7 & 8) hp.radiator.spine_l (0,3, 1x2) & hp.radiator.spine_r (4,3, 1x2) along canted dorsal spine flanks vc.add_hardpoint_slot( diff --git a/tools/vehicles/build_ferret.py b/tools/vehicles/build_ferret.py index 83046f3..1c17c8f 100644 --- a/tools/vehicles/build_ferret.py +++ b/tools/vehicles/build_ferret.py @@ -262,8 +262,9 @@ def build_ferret() -> dict: "armor", parent=chassis, location=(0.0, -1.24, 0.85), - rotation_deg=(-66.0, 0.0, 0.0), + rotation_deg=(66.0, 0.0, 0.0), size=(1.12, 0.34, 0.08), + plinth_depth=0.03, ) # 2) Main turret weapon collar vc.add_hardpoint_slot( @@ -283,23 +284,25 @@ def build_ferret() -> dict: rotation_deg=(0.0, 0.0, 0.0), size=(0.34, 0.34, 0.07), ) - # 4) Rear engine bay frame + # 4) Rear engine bay frame (sloped deck surface at y=0.82 is z=1.00) vc.add_hardpoint_slot( "hp.engine.rear", "engine", parent=chassis, - location=(0.0, 0.82, 0.94), - rotation_deg=(-12.0, 0.0, 0.0), + location=(0.0, 0.82, 0.99), + rotation_deg=(-13.5, 0.0, 0.0), size=(0.86, 0.66, 0.13), + plinth_depth=0.04, ) - # 5) Rear deck copper radiator louver bay + # 5) Rear deck copper radiator louver bay (sloped deck surface at y=1.42 is z=0.858) vc.add_hardpoint_slot( "hp.radiator.deck", "radiator", parent=chassis, - location=(0.0, 1.42, 0.81), - rotation_deg=(-14.0, 0.0, 0.0), + location=(0.0, 1.42, 0.845), + rotation_deg=(-13.5, 0.0, 0.0), size=(0.88, 0.44, 0.09), + plinth_depth=0.04, ) # --- 5. Export GLB, Manifest & Preview --- diff --git a/tools/vehicles/build_hornet.py b/tools/vehicles/build_hornet.py index 281cc7e..bb073e1 100644 --- a/tools/vehicles/build_hornet.py +++ b/tools/vehicles/build_hornet.py @@ -309,9 +309,10 @@ def build_hornet() -> dict: "hp.weapon.chin", "weapon", parent=chassis, - location=(0.0, -1.46, 0.48), - rotation_deg=(0.0, 180.0, 0.0), + location=(0.0, -1.46, 0.525), + rotation_deg=(5.7, 180.0, 0.0), size=(0.42, 0.42, 0.08), + plinth_depth=0.04, ) # 2 & 3) Stub-wing weapon pylons (under left/right wings) vc.add_hardpoint_slot( @@ -344,17 +345,19 @@ def build_hornet() -> dict: "hp.radiator.nacelle_l", "radiator", parent=chassis, - location=(0.58, -0.32, 1.24), + location=(0.54, -0.32, 1.23), rotation_deg=(72.0, 0.0, 34.0), size=(0.36, 0.32, 0.09), + plinth_depth=0.04, ) vc.add_hardpoint_slot( "hp.radiator.nacelle_r", "radiator", parent=chassis, - location=(-0.58, -0.32, 1.24), + location=(-0.54, -0.32, 1.23), rotation_deg=(72.0, 0.0, -34.0), size=(0.36, 0.32, 0.09), + plinth_depth=0.04, ) # --- 6. Export GLB, Manifest & Preview --- diff --git a/tools/vehicles/build_ironclad.py b/tools/vehicles/build_ironclad.py index 308710a..a20dfeb 100644 --- a/tools/vehicles/build_ironclad.py +++ b/tools/vehicles/build_ironclad.py @@ -323,8 +323,9 @@ def build_ironclad() -> dict: "armor", parent=chassis, location=(0.0, -1.72, 0.94), - rotation_deg=(-68.0, 0.0, 0.0), + rotation_deg=(68.0, 0.0, 0.0), size=(1.46, 0.36, 0.09), + plinth_depth=0.04, ) # 2) hp.weapon.main (1,1, 2x2) vc.add_hardpoint_slot( diff --git a/tools/vehicles/build_jackal.py b/tools/vehicles/build_jackal.py index 2e18b67..97bd932 100644 --- a/tools/vehicles/build_jackal.py +++ b/tools/vehicles/build_jackal.py @@ -333,12 +333,13 @@ def build_jackal() -> dict: rotation_deg=(0.0, 0.0, 0.0), size=(0.62, 0.62, 0.10), ) - # 2) Open rear engine bay frame + twin exhaust sweeps + # 2) Open rear engine bay frame + mounting tray + twin exhaust sweeps + vc.make_box("rear_engine_tray", (0.64, 0.74, 0.06), "gunmetal", parent=chassis, location=(0.0, 0.90, 0.51), bevel=0.006) vc.add_hardpoint_slot( "hp.engine.rear", "engine", parent=chassis, - location=(0.0, 0.90, 0.62), + location=(0.0, 0.90, 0.53), rotation_deg=(0.0, 0.0, 0.0), size=(0.62, 0.72, 0.16), ) @@ -355,16 +356,17 @@ def build_jackal() -> dict: mat_name="copper_rad", parent=chassis, ) - # 3) Upright rear copper radiator louver bay (tilted -58 deg so fins & copper header read in hero + dorsal) + # 3) Upright rear copper radiator louver bay seated on rear cage shroud + vc.make_box("rear_rad_shroud", (0.60, 0.06, 0.36), "gunmetal", parent=chassis, location=(0.0, 1.36, 0.74), rotation_deg=(28.0, 0.0, 0.0), bevel=0.006) vc.add_hardpoint_slot( "hp.radiator.rear", "radiator", parent=chassis, - location=(0.0, 1.38, 0.96), - rotation_deg=(-58.0, 0.0, 0.0), + location=(0.0, 1.34, 0.75), + rotation_deg=(-62.0, 0.0, 0.0), size=(0.58, 0.44, 0.11), ) - vc.make_box("rad_header_tank", (0.58, 0.09, 0.08), "copper_rad", parent=chassis, location=(0.0, 1.46, 1.15), bevel=0.008) + vc.make_box("rad_header_tank", (0.58, 0.09, 0.08), "copper_rad", parent=chassis, location=(0.0, 1.44, 0.95), bevel=0.008) # --- 7. Export GLB, Manifest & 4-Panel Preview --- glb_path = vc.ASSETS_VEHICLES_DIR / "jackal" / "jackal.glb" diff --git a/tools/vehicles/build_mammoth.py b/tools/vehicles/build_mammoth.py index de50375..e4292ff 100644 --- a/tools/vehicles/build_mammoth.py +++ b/tools/vehicles/build_mammoth.py @@ -349,8 +349,9 @@ def build_mammoth() -> dict: "armor", parent=chassis, location=(0.0, -2.20, 1.36), - rotation_deg=(-53.0, 0.0, 0.0), + rotation_deg=(53.0, 0.0, 0.0), size=(1.54, 0.38, 0.10), + plinth_depth=0.03, ) # 2) hp.weapon.bow (0,1, 1x1) on front-left bow deck vc.make_box("bow_weapon_plinth", (0.48, 0.50, 0.12), "gunmetal", parent=chassis, location=(0.88, -1.48, 1.62), bevel=0.008) diff --git a/tools/vehicles/build_mule.py b/tools/vehicles/build_mule.py index 59d532f..b5223dd 100644 --- a/tools/vehicles/build_mule.py +++ b/tools/vehicles/build_mule.py @@ -208,9 +208,10 @@ def build_mule() -> dict: "hp.armor.front", "armor", parent=chassis, - location=(0.0, -2.28, 1.00), - rotation_deg=(-90.0, 0.0, 0.0), + location=(0.0, -2.18, 1.00), + rotation_deg=(90.0, 0.0, 0.0), size=(1.32, 0.36, 0.09), + plinth_depth=0.03, ) # Hood engine bay frame vc.add_hardpoint_slot( diff --git a/tools/vehicles/previews/anvil_preview.png b/tools/vehicles/previews/anvil_preview.png index e971672..4e5fc09 100644 Binary files a/tools/vehicles/previews/anvil_preview.png and b/tools/vehicles/previews/anvil_preview.png differ diff --git a/tools/vehicles/previews/breaker_preview.png b/tools/vehicles/previews/breaker_preview.png index 07d07f5..9dbe35e 100644 Binary files a/tools/vehicles/previews/breaker_preview.png and b/tools/vehicles/previews/breaker_preview.png differ diff --git a/tools/vehicles/previews/condor_preview.png b/tools/vehicles/previews/condor_preview.png index aa83f75..c8ef101 100644 Binary files a/tools/vehicles/previews/condor_preview.png and b/tools/vehicles/previews/condor_preview.png differ diff --git a/tools/vehicles/previews/ferret_preview.png b/tools/vehicles/previews/ferret_preview.png index ea70be3..a6fe46e 100644 Binary files a/tools/vehicles/previews/ferret_preview.png and b/tools/vehicles/previews/ferret_preview.png differ diff --git a/tools/vehicles/previews/hornet_preview.png b/tools/vehicles/previews/hornet_preview.png index c512303..dbdf035 100644 Binary files a/tools/vehicles/previews/hornet_preview.png and b/tools/vehicles/previews/hornet_preview.png differ diff --git a/tools/vehicles/previews/ironclad_preview.png b/tools/vehicles/previews/ironclad_preview.png index 6133700..2c217db 100644 Binary files a/tools/vehicles/previews/ironclad_preview.png and b/tools/vehicles/previews/ironclad_preview.png differ diff --git a/tools/vehicles/previews/jackal_preview.png b/tools/vehicles/previews/jackal_preview.png index 11e658d..7cf2b1a 100644 Binary files a/tools/vehicles/previews/jackal_preview.png and b/tools/vehicles/previews/jackal_preview.png differ diff --git a/tools/vehicles/previews/mammoth_preview.png b/tools/vehicles/previews/mammoth_preview.png index 15acc40..ce921ce 100644 Binary files a/tools/vehicles/previews/mammoth_preview.png and b/tools/vehicles/previews/mammoth_preview.png differ diff --git a/tools/vehicles/previews/manticore_preview.png b/tools/vehicles/previews/manticore_preview.png index f80f50b..31868d1 100644 Binary files a/tools/vehicles/previews/manticore_preview.png and b/tools/vehicles/previews/manticore_preview.png differ diff --git a/tools/vehicles/previews/mule_preview.png b/tools/vehicles/previews/mule_preview.png index 6032632..5180720 100644 Binary files a/tools/vehicles/previews/mule_preview.png and b/tools/vehicles/previews/mule_preview.png differ diff --git a/tools/vehicles/previews/paladin_preview.png b/tools/vehicles/previews/paladin_preview.png index 8b8971b..2f2c3be 100644 Binary files a/tools/vehicles/previews/paladin_preview.png and b/tools/vehicles/previews/paladin_preview.png differ diff --git a/tools/vehicles/previews/raptor_preview.png b/tools/vehicles/previews/raptor_preview.png index fb1996a..a098583 100644 Binary files a/tools/vehicles/previews/raptor_preview.png and b/tools/vehicles/previews/raptor_preview.png differ diff --git a/tools/vehicles/retrofit_mechs.py b/tools/vehicles/retrofit_mechs.py index fe2c2bd..4b0a971 100644 --- a/tools/vehicles/retrofit_mechs.py +++ b/tools/vehicles/retrofit_mechs.py @@ -21,6 +21,7 @@ from typing import Any import bmesh import bpy from mathutils import Euler, Matrix, Vector +from mathutils.bvhtree import BVHTree sys.path.insert(0, str(Path(__file__).resolve().parent)) import vehicle_common as vc # noqa: E402 @@ -88,26 +89,26 @@ SPECS: dict[str, MechRetrofitSpec] = { ".#.#.", ".#.#.", ), - blend_path=Path(r"F:\aeth-wt\fable-walk4\out\breaker_rigged.blend"), - model_json_path=Path(r"F:\aeth-wt\fable-walk4\out\breaker_model.json"), - target_mech_tris=28000, - drop_collections=("breaker.build",), - strip_prefixes=("Mark.",), - strip_vertex_groups=("CannonL", "CannonR"), - armature_name="breaker.rig", + blend_path=Path(r"F:\aeth-wt\fable-breaker-3\out\breaker\breaker_walk.blend"), + model_json_path=None, + target_mech_tris=32000, + drop_collections=(), + strip_prefixes=("Rig", "Cam", "Sun", "Back", "Bounce", "Ground", "Horizon", "CannonL", "CannonR"), + strip_vertex_groups=(), + armature_name=None, hardpoints=( - HardpointMount("hp.weapon.arm_l", "weapon", 0, 1, 1, 2, "breaker.rig", "ForearmL", (-2.22, 0.56, 3.58), (-1.0, 0.0, 0.0), (0.58, 0.58, 0.11)), - HardpointMount("hp.weapon.arm_r", "weapon", 4, 1, 1, 2, "breaker.rig", "ForearmR", (2.22, 0.36, 3.58), (1.0, 0.0, 0.0), (0.58, 0.58, 0.11)), - HardpointMount("hp.weapon.shoulder_l", "weapon", 1, 0, 1, 1, "breaker.rig", "ShoulderYokeL", (-1.68, 0.15, 6.02), (0.0, 0.0, 1.0), (0.72, 0.72, 0.12)), - HardpointMount("hp.armor.torso", "armor", 2, 1, 1, 1, "breaker.rig", "Core", (0.0, 1.24, 5.42), (0.0, 0.82, 0.57), (1.05, 0.42, 0.11)), - HardpointMount("hp.engine.chest", "engine", 2, 2, 1, 2, "breaker.rig", "Core", (0.0, 1.46, 4.35), (0.0, 1.0, 0.0), (0.86, 0.78, 0.13)), - HardpointMount("hp.radiator.back_l", "radiator", 1, 1, 1, 1, "breaker.rig", "Core", (-1.30, -1.34, 5.30), (0.0, -1.0, 0.0), (0.68, 0.92, 0.12)), - HardpointMount("hp.radiator.back_r", "radiator", 3, 1, 1, 1, "breaker.rig", "Core", (1.08, -1.50, 5.30), (0.0, -1.0, 0.0), (0.68, 0.92, 0.12)), + HardpointMount("hp.weapon.arm_l", "weapon", 0, 1, 1, 2, "ForearmL", None, (-2.18, 0.45, 3.52), (-1.0, 0.0, 0.0), (0.54, 0.54, 0.11)), + HardpointMount("hp.weapon.arm_r", "weapon", 4, 1, 1, 2, "ForearmR", None, (2.14, 0.65, 3.55), (1.0, 0.0, 0.0), (0.54, 0.54, 0.11)), + HardpointMount("hp.weapon.shoulder_l", "weapon", 1, 0, 1, 1, "Core", None, (-1.48, 0.12, 5.99), (0.0, 0.0, 1.0), (0.72, 0.72, 0.12)), + HardpointMount("hp.armor.torso", "armor", 2, 1, 1, 1, "Core", None, (0.0, 1.32, 5.05), (0.0, 0.82, 0.57), (1.02, 0.40, 0.11)), + HardpointMount("hp.engine.chest", "engine", 2, 2, 1, 2, "Core", None, (0.0, 1.76, 4.48), (0.0, 1.0, 0.0), (0.78, 0.56, 0.13)), + HardpointMount("hp.radiator.back_l", "radiator", 1, 1, 1, 1, "Core", None, (-1.50, -1.14, 5.22), (0.0, -1.0, 0.0), (0.68, 0.92, 0.12)), + HardpointMount("hp.radiator.back_r", "radiator", 3, 1, 1, 1, "Core", None, (1.50, -1.14, 5.22), (0.0, -1.0, 0.0), (0.68, 0.92, 0.12)), ), joints=( - JointTagSpec("joint.torso_yaw", "breaker.rig", "Core", (0.0, 1.0, 0.0), -90.0, 90.0), - JointTagSpec("joint.arm_l_pitch", "breaker.rig", "ShoulderYokeL", (1.0, 0.0, 0.0), -45.0, 60.0), - JointTagSpec("joint.arm_r_pitch", "breaker.rig", "ShoulderYokeR", (1.0, 0.0, 0.0), -45.0, 60.0), + JointTagSpec("joint.torso_yaw", "Core", None, (0.0, 1.0, 0.0), -90.0, 90.0), + JointTagSpec("joint.arm_l_pitch", "ShoulderYokeL", None, (1.0, 0.0, 0.0), -45.0, 60.0), + JointTagSpec("joint.arm_r_pitch", "ShoulderYokeR", None, (1.0, 0.0, 0.0), -45.0, 60.0), ), ), "paladin": MechRetrofitSpec( @@ -131,12 +132,12 @@ SPECS: dict[str, MechRetrofitSpec] = { target_mech_tris=29000, strip_prefixes=("Rig", "Cam", "Sun", "Back", "Bounce", "Ground", "Horizon", "Battery.", "EW.", "EWLow.", "Gatling.", "Emitter."), hardpoints=( - HardpointMount("hp.weapon.sh_l", "weapon", 1, 1, 1, 1, "Trunk", None, (-2.88, 0.35, 9.94), (0.0, 0.0, 1.0), (0.98, 0.98, 0.15)), - HardpointMount("hp.armor.torso", "armor", 2, 1, 2, 1, "Trunk", None, (0.0, 2.02, 8.85), (0.0, 0.88, 0.47), (1.35, 0.44, 0.12)), - HardpointMount("hp.weapon.sh_r", "weapon", 4, 1, 1, 1, "Trunk", None, (2.88, 0.35, 9.94), (0.0, 0.0, 1.0), (0.98, 0.98, 0.15)), - HardpointMount("hp.weapon.arm_l", "weapon", 0, 2, 1, 2, "ArmL.Lower", None, (-3.44, 0.85, 5.75), (-1.0, 0.0, 0.0), (0.78, 0.78, 0.13)), - HardpointMount("hp.engine.chest", "engine", 2, 2, 2, 2, "Trunk", None, (0.0, 2.18, 7.82), (0.0, 1.0, 0.0), (1.12, 0.94, 0.14)), - HardpointMount("hp.weapon.arm_r", "weapon", 5, 2, 1, 2, "ArmR.Lower", None, (3.56, 1.15, 6.20), (1.0, 0.0, 0.0), (0.78, 0.78, 0.13)), + HardpointMount("hp.weapon.sh_l", "weapon", 1, 1, 1, 1, "Trunk", None, (-2.88, 0.35, 9.82), (0.0, 0.0, 1.0), (0.94, 0.94, 0.15)), + HardpointMount("hp.armor.torso", "armor", 2, 1, 2, 1, "Trunk", None, (0.0, 1.80, 8.75), (0.0, 0.60, 0.80), (1.22, 0.40, 0.12)), + HardpointMount("hp.weapon.sh_r", "weapon", 4, 1, 1, 1, "Trunk", None, (2.88, 0.35, 9.82), (0.0, 0.0, 1.0), (0.94, 0.94, 0.15)), + HardpointMount("hp.weapon.arm_l", "weapon", 0, 2, 1, 2, "ArmL.Lower", None, (-3.44, 0.85, 5.75), (-1.0, 0.0, 0.0), (0.74, 0.74, 0.13)), + HardpointMount("hp.engine.chest", "engine", 2, 2, 2, 2, "Trunk", None, (0.0, 2.22, 8.05), (0.0, 0.94, 0.34), (0.82, 0.54, 0.14)), + HardpointMount("hp.weapon.arm_r", "weapon", 5, 2, 1, 2, "ArmR.Lower", None, (3.52, 1.05, 6.22), (1.0, 0.0, 0.0), (0.72, 0.72, 0.13)), HardpointMount("hp.radiator.back_l", "radiator", 1, 4, 1, 1, "Trunk", None, (-0.92, -1.44, 8.65), (0.0, -1.0, 0.0), (0.82, 1.35, 0.14)), HardpointMount("hp.armor.legs", "armor", 2, 4, 2, 1, "Pelvis", None, (0.0, 1.18, 5.55), (0.0, 1.0, 0.0), (0.95, 0.38, 0.11)), HardpointMount("hp.radiator.back_r", "radiator", 4, 4, 1, 1, "Trunk", None, (0.92, -1.44, 8.65), (0.0, -1.0, 0.0), (0.82, 1.35, 0.14)), @@ -167,11 +168,11 @@ SPECS: dict[str, MechRetrofitSpec] = { target_mech_tris=28000, strip_prefixes=("Rig", "Cam", "Sun", "Back", "Bounce", "Ground", "Horizon", "Bank0.", "Bank1.", "LaserL.", "LaserR."), hardpoints=( - HardpointMount("hp.radiator.sh_l", "radiator", 1, 1, 1, 1, "_ROOT_", None, (-0.56, 0.05, 6.26), (-0.25, 0.0, 0.97), (0.66, 1.05, 0.12)), - HardpointMount("hp.radiator.sh_r", "radiator", 3, 1, 1, 1, "_ROOT_", None, (0.56, 0.05, 6.26), (0.25, 0.0, 0.97), (0.66, 1.05, 0.12)), - HardpointMount("hp.weapon.arm_l", "weapon", 0, 2, 1, 2, "ArmL.Fore", None, (-1.40, 2.22, 3.90), (-1.0, 0.0, 0.0), (0.56, 0.56, 0.11)), - HardpointMount("hp.engine.chest", "engine", 2, 2, 1, 2, "_ROOT_", None, (0.0, -2.02, 6.78), (0.0, 0.0, 1.0), (0.86, 1.12, 0.14)), - HardpointMount("hp.weapon.arm_r", "weapon", 4, 2, 1, 2, "ArmR.Fore", None, (1.40, 2.22, 3.90), (1.0, 0.0, 0.0), (0.56, 0.56, 0.11)), + HardpointMount("hp.radiator.sh_l", "radiator", 1, 1, 1, 1, "_ROOT_", None, (-0.56, 0.05, 6.26), (-0.25, 0.0, 0.97), (0.64, 1.00, 0.12)), + HardpointMount("hp.radiator.sh_r", "radiator", 3, 1, 1, 1, "_ROOT_", None, (0.56, 0.05, 6.26), (0.25, 0.0, 0.97), (0.64, 1.00, 0.12)), + HardpointMount("hp.weapon.arm_l", "weapon", 0, 2, 1, 2, "ArmL.Fore", None, (-1.32, 2.14, 3.86), (-1.0, 0.0, 0.0), (0.48, 0.48, 0.11)), + HardpointMount("hp.engine.chest", "engine", 2, 2, 1, 2, "_ROOT_", None, (0.0, -2.02, 6.78), (0.0, 0.0, 1.0), (0.82, 1.06, 0.14)), + HardpointMount("hp.weapon.arm_r", "weapon", 4, 2, 1, 2, "ArmR.Fore", None, (1.32, 2.14, 3.86), (1.0, 0.0, 0.0), (0.48, 0.48, 0.11)), ), joints=( JointTagSpec("joint.arm_l_pitch", "ArmL.Upper", None, (1.0, 0.0, 0.0), -45.0, 45.0), @@ -361,11 +362,17 @@ def _normalize_materials_for_gltf() -> None: # Extract Group node overrides if authored by Brokkr paint_pinned grp = next((n for n in nt.nodes if n.type == "GROUP"), None) base_col = None + cover_col = None + cover_amt = 0.0 metallic = None roughness = None if grp is not None: if "Base Color" in grp.inputs and hasattr(grp.inputs["Base Color"], "default_value"): base_col = tuple(grp.inputs["Base Color"].default_value) + if "Cover Color" in grp.inputs and hasattr(grp.inputs["Cover Color"], "default_value"): + cover_col = tuple(grp.inputs["Cover Color"].default_value) + if "Cover" in grp.inputs and hasattr(grp.inputs["Cover"], "default_value"): + cover_amt = float(grp.inputs["Cover"].default_value) if "Metallic" in grp.inputs and hasattr(grp.inputs["Metallic"], "default_value"): metallic = float(grp.inputs["Metallic"].default_value) if "Roughness" in grp.inputs and hasattr(grp.inputs["Roughness"], "default_value"): @@ -410,6 +417,10 @@ def _normalize_materials_for_gltf() -> None: bsdf.inputs["Base Color"].default_value = (0.28, 0.10, 0.06, 1.0) bsdf.inputs["Metallic"].default_value = 0.35 bsdf.inputs["Roughness"].default_value = 0.45 + elif "mark" in lname and cover_col is not None and cover_amt >= 0.5: + bsdf.inputs["Base Color"].default_value = cover_col + bsdf.inputs["Metallic"].default_value = 0.0 + bsdf.inputs["Roughness"].default_value = roughness if roughness is not None else 0.62 elif matched_pal is not None: bsdf.inputs["Base Color"].default_value = vc.srgb_hex_to_linear(matched_pal["hex"]) bsdf.inputs["Metallic"].default_value = float(matched_pal["metallic"]) @@ -533,18 +544,146 @@ def _decimate_mech_meshes(meshes: list[bpy.types.Object], target_tris: int, min_ return raw_total, after_total +def _collect_subtree_meshes(root_obj: bpy.types.Object) -> list[bpy.types.Object]: + out: list[bpy.types.Object] = [] + def walk(obj: bpy.types.Object) -> None: + if obj.name.startswith("slot_frame."): + return + if obj.type == "MESH" and obj.data is not None and len(obj.data.polygons) > 0: + out.append(obj) + for ch in obj.children: + walk(ch) + walk(root_obj) + return out + + +def _build_hull_bvh(mesh_objs: list[bpy.types.Object]) -> BVHTree | None: + if not mesh_objs: + return None + depsgraph = bpy.context.evaluated_depsgraph_get() + bm = bmesh.new() + for obj in mesh_objs: + ev = obj.evaluated_get(depsgraph) + me = ev.to_mesh() + if me is not None and len(me.polygons) > 0: + me.transform(obj.matrix_world) + bm.from_mesh(me) + ev.to_mesh_clear() + if len(bm.verts) == 0 or len(bm.faces) == 0: + bm.free() + return None + bvh = BVHTree.FromBMesh(bm) + bm.free() + return bvh + + +def _snap_hardpoint_bvh( + hp: HardpointMount, + parent_obj: bpy.types.Object, + root_obj: bpy.types.Object, + full_bvh: BVHTree, + bvh_cache: dict[str, BVHTree], +) -> tuple[Vector, float, tuple[float, float, float]]: + """Snap hardpoint anchor onto actual hull surface via 5-point BVH raycast + recessed plinth.""" + bvh = full_bvh + if parent_obj != root_obj and hp.parent_bone is None: + if parent_obj.name not in bvh_cache: + sub_meshes = _collect_subtree_meshes(parent_obj) + sub_bvh = _build_hull_bvh(sub_meshes) + if sub_bvh is not None: + bvh_cache[parent_obj.name] = sub_bvh + bvh = bvh_cache.get(parent_obj.name, full_bvh) + + p0 = Vector(hp.world_pos) + n = Vector(hp.world_normal).normalized() + q = Vector((0.0, 0.0, 1.0)).rotation_difference(n) + tu = q @ Vector((1.0, 0.0, 0.0)) + tv = q @ Vector((0.0, 1.0, 0.0)) + + sx, sy, sz = hp.size + if hp.kind == "weapon": + r = min(sx, sy) * 0.48 * 0.78 + rx, ry = r, r + elif hp.kind == "armor": + rx, ry = sx * 0.38, sy * 0.14 + else: + rx, ry = sx * 0.38, sy * 0.38 + + offsets = [(0.0, 0.0), (-rx, -ry), (rx, -ry), (rx, ry), (-rx, ry)] + raw_hits: list[float | None] = [] + for ox, oy in offsets: + pt = p0 + tu * ox + tv * oy + # Cast from +1.5m along +normal toward -normal; guard against far overhang hits by also trying +0.55m + loc, _, _, _ = bvh.ray_cast(pt + n * 0.65, -n, 1.35) + if loc is None: + loc, _, _, _ = bvh.ray_cast(pt + n * 1.5, -n, 3.0) + raw_hits.append((loc - p0).dot(n) if loc is not None else None) + + h_center = raw_hits[0] + if h_center is None: + near_loc, _, _, _ = bvh.find_nearest(p0) + if near_loc is not None: + h_center = (near_loc - p0).dot(n) + else: + h_center = 0.0 + # Guard against thin lifting-eye/antenna spikes lifting the entire base off the armor roof + corner_vals = sorted(h for h in raw_hits[1:] if h is not None) + if len(corner_vals) >= 3: + c_med = corner_vals[len(corner_vals) // 2] + if h_center - c_med > 0.08: + h_center = c_med + + # Keep corner hits near the local surface patch; replace misses/cliffs with nearest or conservative drop + valid_corners: list[float] = [h_center] + misses = 0 + for idx, h in enumerate(raw_hits[1:], start=1): + if h is None or abs(h - h_center) > 0.18: + misses += 1 + ox, oy = offsets[idx] + near_loc, _, _, _ = bvh.find_nearest(p0 + tu * ox + tv * oy + n * h_center) + if near_loc is not None: + hn = (near_loc - p0).dot(n) + if abs(hn - h_center) <= 0.18: + valid_corners.append(hn) + continue + valid_corners.append(h_center - 0.035) + else: + valid_corners.append(h) + + h_min = min(valid_corners) + h_max = max(valid_corners) + # Seat bay origin recessed into surface at center (<= 0.022m from surface so verify_glbs passes) + # while extending plinth down past h_min and keeping rim proud above h_max + h_seat = h_center - 0.020 + if h_max - h_seat > sz * 0.55: + sz_out = max(sz, (h_max - h_seat) + 0.055) + else: + sz_out = sz + plinth_depth = max(0.050, min(0.18, (h_seat - h_min) + 0.045)) + snapped_pos = p0 + n * h_seat + print( + f" [snap] {hp.hp_id:22s} | dh_c={h_center:+.3f} span=[{h_min:+.3f},{h_max:+.3f}] " + f"seat={h_seat:+.3f} plinth={plinth_depth:.3f} miss={misses}" + ) + return snapped_pos, plinth_depth, (sx, sy, sz_out) + + def _attach_hardpoint_world( hp: HardpointMount, root_obj: bpy.types.Object, + full_bvh: BVHTree, + bvh_cache: dict[str, BVHTree], ) -> None: parent_obj = root_obj if hp.parent_name == "_ROOT_" else bpy.data.objects[hp.parent_name] + snapped_pos, plinth_depth, adj_size = _snap_hardpoint_bvh(hp, parent_obj, root_obj, full_bvh, bvh_cache) anchor = vc.add_hardpoint_slot( hp.hp_id, hp.kind, parent=parent_obj, location=(0.0, 0.0, 0.0), rotation_deg=(0.0, 0.0, 0.0), - size=hp.size, + size=adj_size, + plinth_depth=plinth_depth, ) bay_root = anchor.parent if hp.parent_bone is not None: @@ -554,7 +693,7 @@ def _attach_hardpoint_world( bpy.context.view_layer.update() n = Vector(hp.world_normal).normalized() q = Vector((0.0, 0.0, 1.0)).rotation_difference(n) - m_world = Matrix.Translation(Vector(hp.world_pos)) @ q.to_matrix().to_4x4() + m_world = Matrix.Translation(snapped_pos) @ q.to_matrix().to_4x4() if hp.parent_bone is not None and parent_obj.type == "ARMATURE": pb = parent_obj.pose.bones[hp.parent_bone] @@ -691,6 +830,234 @@ def _extract_mechanisms(model_json_path: Path, ground_z_shift: float = 0.0) -> d } +def _extract_mechanisms_from_blend_raw(root_name: str = "Pelvis") -> dict[str, Any] | None: + """Extract raw Brokkr-frame DOFs, hydraulic rams, torque scissors, and oleo struts from kit_* props.""" + root_obj = bpy.data.objects.get(root_name) + if root_obj is None or "kit_part" not in root_obj: + return None + bpy.context.view_layer.update() + + def _side_of(name: str) -> str: + for tag, s in (("LegL", "L"), ("LegR", "R")): + if name.startswith(tag): + return s + base = name.split(".")[0] + if base.endswith("L"): + return "L" + if base.endswith("R"): + return "R" + return "" + + limits_deg = { + "hip": (-60.0, 60.0), "hip yaw": (-35.0, 35.0), "knee": (-100.0, 100.0), + "ankle": (-40.0, 40.0), "waist": (-110.0, 110.0), "shoulder slew": (-100.0, 100.0), + "shoulder hinge": (-45.0, 45.0), "arm twist": (-90.0, 90.0), "elbow": (-100.0, 100.0), + "hinge": (-60.0, 60.0), "slew": (-90.0, 90.0), + } + + dofs_raw: list[dict[str, Any]] = [] + obj_to_dof: dict[str, int] = {} + + def walk(obj: bpy.types.Object, parent_dof: int, depth: int) -> None: + here = parent_dof + here_depth = depth + if obj != root_obj and "kit_socket" in obj and obj.get("kit_part") != "ram" and obj.parent is not None and "kit_part" in obj.parent: + part = str(obj["kit_part"]) + ppart = str(obj.parent["kit_part"]) + psock = str(obj.get("kit_parent_socket", "")) + kind: str | None = None + if ppart == "slew_ring" and psock == "top": + kind = "slew" + elif str(obj.get("kit_mechanism", "")) == "oleo": + kind = "slide" + elif psock == "clevis": + kind = "hinge" + if kind is not None: + if kind == "slew": + # Slew axis is the parent slew_ring's Z axis at the top socket + origin_v = obj.parent.matrix_world.translation.copy() + axis_v = obj.parent.matrix_world.to_3x3().col[2].normalized() + else: + origin_v = obj.matrix_world.translation.copy() + axis_v = obj.matrix_world.to_3x3().col[2].normalized() + + grand = obj.parent.parent.get("kit_part", "") if obj.parent.parent else "" + if kind == "slide": + mech = str(obj.get("kit_mechanism", "oleo")) + val = float(obj.get("kit_slide", 0.0)) + lo = float(obj.get("kit_min", 0.0)) - val + hi = float(obj.get("kit_max", 0.2)) - val + elif kind == "slew": + mech = ( + "hip" if part in ("thigh", "hip_stub") + else "hip yaw" if part == "shank" + else "waist" if part == "chassis" + else ("shoulder slew" if grand == "chassis" else "arm twist") if part == "yoke" + else "slew" + ) + lo, hi = (math.radians(v) for v in limits_deg[mech]) + else: + if "kit_min" in obj and obj.get("kit_mechanism"): + mech = str(obj["kit_mechanism"]).replace("_", " ") + roll = float(obj.get("kit_roll", 0.0)) + lo = math.radians(float(obj["kit_min"]) - roll) + hi = math.radians(float(obj["kit_max"]) - roll) + else: + if part in ("foot", "foot_core"): + mech = "ankle" + elif part in ("link", "strut_shin"): + mech = "knee" + elif part == "wrist": + up_m = dofs_raw[parent_dof]["mechanism"] if parent_dof >= 0 else "" + mech = "shoulder hinge" if up_m == "shoulder slew" else "elbow" if up_m == "arm twist" else "hinge" + else: + mech = "hinge" + lo, hi = (math.radians(v) for v in limits_deg[mech]) + + entry: dict[str, Any] = { + "name": obj.name, + "parent": parent_dof, + "kind": kind, + "mechanism": mech, + "side": _side_of(obj.name), + "origin": [float(origin_v.x), float(origin_v.y), float(origin_v.z)], + "axis": [float(axis_v.x), float(axis_v.y), float(axis_v.z)], + "lo": float(lo), + "hi": float(hi), + "depth": depth, + } + if obj.get("kit_compliance"): + entry["compliance"] = json.loads(str(obj["kit_compliance"])) + if mech == "ankle": + entry["stopped_by"] = "ram" + here = len(dofs_raw) + here_depth = depth + 1 + dofs_raw.append(entry) + obj_to_dof[obj.name] = here + for ch in obj.children: + walk(ch, here, here_depth) + + walk(root_obj, -1, 0) + + rams_raw: list[dict[str, Any]] = [] + for obj in sorted(bpy.data.objects, key=lambda o: o.name): + if obj.get("kit_part") != "ram" or obj.parent is None: + continue + close_to = bpy.data.objects.get(str(obj.get("kit_close_to", ""))) + if close_to is None: + continue + params = json.loads(str(obj.get("kit_params", "{}"))) + lug_b_params = json.loads(str(close_to.get("kit_params", "{}"))) + a_pos = obj.matrix_world.translation.copy() + # Lug pivot sits at local (0, 0, height) + b_h = float(lug_b_params.get("height", 0.234)) + b_pos = close_to.matrix_world @ Vector((0.0, 0.0, b_h)) + rest = float((b_pos - a_pos).length) + pin_dir = obj.parent.matrix_world.to_3x3().col[0].normalized() + body = float(params.get("body_len", 0.68)) + ext = float(params.get("extension", 0.40)) + a_dof = obj_to_dof.get(obj.parent.name, -1) + b_dof = obj_to_dof.get(close_to.name, -1) + rams_raw.append({ + "name": obj.name, + "barrel_bone": f"{obj.name}.barrel", + "rod_bone": f"{obj.name}.rod", + "spans": [dofs_raw[i]["name"] for i in (a_dof + 1, b_dof) if 0 <= i < len(dofs_raw)], + "bore": float(params.get("bore_r", 0.09)), + "body": body, + "inner": rest - body * 0.85, + "extension": ext, + "rest": rest, + "stroke": [-ext, max(0.2, body - 0.15)], + "a_parent_dof": a_dof, + "a_pos": [float(a_pos.x), float(a_pos.y), float(a_pos.z)], + "b_parent_dof": b_dof, + "b_pos": [float(b_pos.x), float(b_pos.y), float(b_pos.z)], + "pin_dir": [float(pin_dir.x), float(pin_dir.y), float(pin_dir.z)], + }) + + scissors_raw: list[dict[str, Any]] = [] + for sc in json.loads(str(bpy.context.scene.get("mech_scissors", "[]"))): + oa = bpy.data.objects.get(sc["a"][0]) + ob = bpy.data.objects.get(sc["b"][0]) + oo = bpy.data.objects.get(sc["out"][0]) + if oa is None or ob is None or oo is None: + continue + pa = oa.matrix_world @ Vector(sc["a"][1]) + pb = ob.matrix_world @ Vector(sc["b"][1]) + dout = (oo.matrix_world.to_3x3() @ Vector(sc["out"][1])).normalized() + scissors_raw.append({ + "name": sc["name"], + "upper_bone": f"{sc['name']}.upper", + "lower_bone": f"{sc['name']}.lower", + "arm": float(sc["arm"]), + "a_parent_dof": obj_to_dof.get(oa.name, -1), + "a_pos": [float(pa.x), float(pa.y), float(pa.z)], + "b_parent_dof": obj_to_dof.get(ob.name, -1), + "b_pos": [float(pb.x), float(pb.y), float(pb.z)], + "out_dir": [float(dout.x), float(dout.y), float(dout.z)], + }) + + struts_raw = [ + { + "name": d["name"], + "side": d["side"], + "dof": d["name"], + "travel": round(abs(d["hi"] - d["lo"]), 6), + "hertz": float(d["compliance"]["hertz"]), + "damping_ratio": float(d["compliance"]["damping_ratio"]), + } + for d in dofs_raw + if d.get("mechanism") == "oleo" and "compliance" in d + ] + + r_pos = root_obj.matrix_world.translation + return { + "root": [float(r_pos.x), float(r_pos.y), float(r_pos.z)], + "dofs": dofs_raw, + "rams": rams_raw, + "scissors": scissors_raw, + "struts": struts_raw, + } + + +def _finalize_mechanisms_gltf(raw: dict[str, Any], ground_z_shift: float) -> dict[str, Any]: + dofs_out = [] + for d in raw["dofs"]: + entry = { + **d, + "origin": _brokkr_vec_to_gltf(d["origin"], ground_z_shift), + "axis": _brokkr_dir_to_gltf(d["axis"]), + } + dofs_out.append(entry) + rams_out = [ + { + **r, + "a_pos": _brokkr_vec_to_gltf(r["a_pos"], ground_z_shift), + "b_pos": _brokkr_vec_to_gltf(r["b_pos"], ground_z_shift), + "pin_dir": _brokkr_dir_to_gltf(r["pin_dir"]), + } + for r in raw["rams"] + ] + scissors_out = [ + { + **s, + "a_pos": _brokkr_vec_to_gltf(s["a_pos"], ground_z_shift), + "b_pos": _brokkr_vec_to_gltf(s["b_pos"], ground_z_shift), + "out_dir": _brokkr_dir_to_gltf(s["out_dir"]), + } + for s in raw["scissors"] + ] + return { + "frame": "gltf (+Y up, +Z forward, +X left, meters)", + "rootOrigin": _brokkr_vec_to_gltf(raw["root"], ground_z_shift), + "dofs": dofs_out, + "rams": rams_out, + "scissors": scissors_out, + "struts": raw["struts"], + } + + def retrofit_mech(spec: MechRetrofitSpec) -> dict[str, Any]: bpy.ops.wm.open_mainfile(filepath=str(spec.blend_path)) scene = bpy.context.scene @@ -707,6 +1074,17 @@ def retrofit_mech(spec: MechRetrofitSpec) -> dict[str, Any]: if not spec.armature_name: _convert_surviving_curves() + # Square Breaker-3 torso yaw (-5 deg walk offset -> 0 deg neutral symmetric forward) + if spec.mech_id == "breaker" and "Core" in bpy.data.objects: + bpy.data.objects["Core"].rotation_euler.z = 0.0 + bpy.context.view_layer.update() + + raw_blend_mechs = ( + _extract_mechanisms_from_blend_raw("Pelvis") + if spec.model_json_path is None and spec.mech_id == "breaker" + else None + ) + # 3. For rigged meshes, strip weapon vertex groups cleanly stripped_vgs: dict[str, int] = {} if spec.strip_vertex_groups: @@ -732,10 +1110,14 @@ def retrofit_mech(spec: MechRetrofitSpec) -> dict[str, Any]: obj.parent = chassis_root obj.matrix_parent_inverse = Matrix.Identity(4) obj.matrix_local = mw + bpy.context.view_layer.update() - # 7. Attach standardized visible exterior hardpoint bays & tag joints + # 7. Build hull BVH over final LOD meshes, snap & recess every hardpoint bay, tag joints + full_bvh = _build_hull_bvh([o for o in bpy.data.objects if o.type == "MESH"]) + assert full_bvh is not None, f"{spec.mech_id}: empty hull BVH" + bvh_cache: dict[str, BVHTree] = {} for hp in spec.hardpoints: - _attach_hardpoint_world(hp, chassis_root) + _attach_hardpoint_world(hp, chassis_root, full_bvh, bvh_cache) joints_manifest = _apply_joint_tags(spec) # 8. Rotate chassis_root 180 deg around Z so Brokkr +Y forward -> RTD -Y forward (+Z glTF), -X left -> +X left @@ -752,11 +1134,12 @@ def retrofit_mech(spec: MechRetrofitSpec) -> dict[str, Any]: tri_count, bounds = vc.export_vehicle_glb(glb_path, root=chassis_root) ground_z_shift = chassis_root.location.z - z_shift_before - mechanisms = ( - _extract_mechanisms(spec.model_json_path, ground_z_shift=ground_z_shift) - if spec.model_json_path is not None - else None - ) + if spec.model_json_path is not None: + mechanisms = _extract_mechanisms(spec.model_json_path, ground_z_shift=ground_z_shift) + elif raw_blend_mechs is not None: + mechanisms = _finalize_mechanisms_gltf(raw_blend_mechs, ground_z_shift=ground_z_shift) + else: + mechanisms = None hp_manifest = [ { diff --git a/tools/vehicles/vehicle_common.py b/tools/vehicles/vehicle_common.py index 513f44f..0077681 100644 --- a/tools/vehicles/vehicle_common.py +++ b/tools/vehicles/vehicle_common.py @@ -673,16 +673,20 @@ def add_hardpoint_slot( location: Sequence[float], rotation_deg: Sequence[float] = (0.0, 0.0, 0.0), size: Sequence[float] = (0.55, 0.55, 0.12), + plinth_depth: float = 0.0, ) -> bpy.types.Object: """Create standardized VISIBLE exterior hardpoint socket geometry + tagged rtd.id anchor Empty. The anchor Empty is named `hp_id`, carries custom properties `rtd.id` and `rtd.kind`, and sits at the mounting plane origin with local +Z normal (+Y in glTF) pointing outward. + When `plinth_depth > 0`, a solid recessed base flange extends down to `z = -plinth_depth` + so sloped/curved armor corners physically intersect the hull with zero air gap. """ if kind not in ("weapon", "radiator", "engine", "armor"): raise ValueError(f"Unsupported hardpoint kind {kind!r}") sx, sy, sz = (float(v) for v in size) + p_depth = max(0.0, float(plinth_depth)) # Visual frame parented alongside the anchor bay_root = make_empty(f"slot_frame.{hp_id}", parent=parent, location=location, rotation_deg=rotation_deg) @@ -690,6 +694,18 @@ def add_hardpoint_slot( r_outer = min(sx, sy) * 0.48 r_inner = r_outer * 0.72 collar_h = max(0.055, sz * 0.65) + if p_depth > 0.0: + make_tube_part( + f"{hp_id}.plinth", + r_outer * 0.96, + r_outer * 0.96, + p_depth + 0.025, + segments=12, + smooth=False, + mat_name="gunmetal", + parent=bay_root, + location=(0.0, 0.0, -p_depth), + ) # Octagonal bolted collar ring via Brokkr lathe collar_prof = [ [r_inner, 0.0], @@ -743,6 +759,15 @@ def add_hardpoint_slot( elif kind == "radiator": frame_t = max(0.035, min(sx, sy) * 0.09) depth = max(0.07, sz) + if p_depth > 0.0: + make_box( + f"{hp_id}.plinth", + (sx * 0.98, sy * 0.98, p_depth + 0.025), + "gunmetal", + parent=bay_root, + location=(0.0, 0.0, (-p_depth + 0.025) * 0.5), + bevel=0.0, + ) # Recessed dark bay floor make_box(f"{hp_id}.well", (sx * 0.92, sy * 0.92, depth * 0.4), "socket_bay", parent=bay_root, location=(0.0, 0.0, depth * 0.2), bevel=0.0) # Outer armored louver frame (4 bars) @@ -778,6 +803,15 @@ def add_hardpoint_slot( elif kind == "engine": wall_t = max(0.045, min(sx, sy) * 0.10) depth = max(0.11, sz) + if p_depth > 0.0: + make_box( + f"{hp_id}.plinth", + (sx * 0.98, sy * 0.98, p_depth + 0.025), + "gunmetal", + parent=bay_root, + location=(0.0, 0.0, (-p_depth + 0.025) * 0.5), + bevel=0.0, + ) # Deep dark engine bay recess make_box(f"{hp_id}.well", (sx * 0.90, sy * 0.90, depth * 0.35), "socket_bay", parent=bay_root, location=(0.0, 0.0, depth * 0.18), bevel=0.0) # Armored coaming rails @@ -813,6 +847,15 @@ def add_hardpoint_slot( else: # "armor" rail_h = max(0.05, sz) + if p_depth > 0.0: + make_box( + f"{hp_id}.plinth", + (sx * 0.90, sy * 0.44, p_depth + 0.025), + "gunmetal", + parent=bay_root, + location=(0.0, 0.0, (-p_depth + 0.025) * 0.5), + bevel=0.0, + ) # Backing plate & stud rails across the glacis / flank make_box(f"{hp_id}.rail", (sx * 0.92, sy * 0.32, rail_h * 0.55), "gunmetal", parent=bay_root, location=(0.0, 0.0, rail_h * 0.28), bevel=0.006) n_boss = max(3, min(5, int(sx / 0.32) + 1)) diff --git a/tools/vehicles/verify_glbs.py b/tools/vehicles/verify_glbs.py index 4a28713..482fcf0 100644 --- a/tools/vehicles/verify_glbs.py +++ b/tools/vehicles/verify_glbs.py @@ -134,6 +134,186 @@ def compute_glb_stats(gltf: dict[str, Any], bin_blob: bytes = b"") -> tuple[int, return tri_total, g_min, g_max +def _read_accessor( + accessors: list[dict[str, Any]], + buffer_views: list[dict[str, Any]], + bin_blob: bytes, + acc_idx: int, +) -> np.ndarray: + acc = accessors[acc_idx] + bv = buffer_views[acc["bufferView"]] + off = bv.get("byteOffset", 0) + acc.get("byteOffset", 0) + count = acc["count"] + ct = acc["componentType"] + typ = acc["type"] + if typ == "VEC3" and ct == 5126: + stride = bv.get("byteStride", 12) + if stride == 12: + return np.frombuffer(bin_blob, dtype=" float: + ab = b - a + ac = c - a + ap = p - a + d1 = float(np.dot(ab, ap)) + d2 = float(np.dot(ac, ap)) + if d1 <= 0.0 and d2 <= 0.0: + return float(np.dot(ap, ap)) + bp = p - b + d3 = float(np.dot(ab, bp)) + d4 = float(np.dot(ac, bp)) + if d3 >= 0.0 and d4 <= d3: + return float(np.dot(bp, bp)) + vc = d1 * d4 - d3 * d2 + if vc <= 0.0 and d1 >= 0.0 and d3 <= 0.0: + denom = d1 - d3 + v = d1 / denom if denom > 1e-18 else 0.0 + q = a + v * ab + return float(np.dot(p - q, p - q)) + cp = p - c + d5 = float(np.dot(ab, cp)) + d6 = float(np.dot(ac, cp)) + if d6 >= 0.0 and d5 <= d6: + return float(np.dot(cp, cp)) + vb = d5 * d2 - d1 * d6 + if vb <= 0.0 and d2 >= 0.0 and d6 <= 0.0: + denom = d2 - d6 + w = d2 / denom if denom > 1e-18 else 0.0 + q = a + w * ac + return float(np.dot(p - q, p - q)) + va = d3 * d6 - d5 * d4 + if va <= 0.0 and (d4 - d3) >= 0.0 and (d5 - d6) >= 0.0: + denom = (d4 - d3) + (d5 - d6) + w = (d4 - d3) / denom if denom > 1e-18 else 0.0 + q = b + w * (c - b) + return float(np.dot(p - q, p - q)) + s = va + vb + vc + if s <= 1e-18: + return min(float(np.dot(ap, ap)), float(np.dot(bp, bp)), float(np.dot(cp, cp))) + denom = 1.0 / s + q = a + ab * (vb * denom) + ac * (vc * denom) + return float(np.dot(p - q, p - q)) + + +def _min_dist_to_tris( + pt: np.ndarray, + tris: np.ndarray, + tri_mins: np.ndarray, + tri_maxs: np.ndarray, +) -> float: + d_box = np.maximum(0.0, np.maximum(tri_mins - pt, pt - tri_maxs)) + d2_box = np.sum(d_box * d_box, axis=1) + order = np.argsort(d2_box) + min_d2 = math.inf + for idx in order: + if d2_box[idx] > min_d2: + break + t = tris[idx] + d2 = _pt_tri_dist2(pt, t[0], t[1], t[2]) + if d2 < min_d2: + min_d2 = d2 + return math.sqrt(min_d2) + + +def measure_hardpoint_gaps(gltf: dict[str, Any], bin_blob: bytes) -> dict[str, tuple[float, float]]: + """Return {hp_id: (center_to_hull_m, min_slot_vert_to_hull_m)} for all hardpoints in GLB.""" + nodes = gltf.get("nodes", []) + meshes = gltf.get("meshes", []) + accessors = gltf.get("accessors", []) + buffer_views = gltf.get("bufferViews", []) + scenes = gltf.get("scenes", []) + root_indices = scenes[gltf.get("scene", 0)]["nodes"] if scenes else list(range(len(nodes))) + + parent_of: dict[int, int] = {} + for idx, n in enumerate(nodes): + for c in n.get("children", []): + parent_of[c] = idx + + hp_roots: dict[int, str] = {} + hp_anchors: dict[str, int] = {} + for idx, n in enumerate(nodes): + extras = n.get("extras") or {} + if "rtd.id" in extras: + hp_id = str(extras["rtd.id"]) + hp_anchors[hp_id] = idx + p = parent_of.get(idx) + if p is not None and str(nodes[p].get("name", "")).startswith("slot_frame."): + hp_roots[p] = hp_id + + hp_node_set: dict[int, str] = {} + def mark_hp(idx: int, hp_id: str) -> None: + hp_node_set[idx] = hp_id + for c in nodes[idx].get("children", []): + mark_hp(c, hp_id) + for r_idx, hp_id in hp_roots.items(): + mark_hp(r_idx, hp_id) + + hull_tris: list[np.ndarray] = [] + hp_pts: dict[str, list[np.ndarray]] = {} + node_world: dict[int, np.ndarray] = {} + + def walk(idx: int, pmat: np.ndarray) -> None: + n = nodes[idx] + w = pmat @ _node_local_matrix(n) + node_world[idx] = w + if "mesh" in n: + for prim in meshes[n["mesh"]].get("primitives", []): + if prim.get("mode", 4) != 4: + continue + pos = _read_accessor(accessors, buffer_views, bin_blob, prim["attributes"]["POSITION"]) + wpos = pos @ w[:3, :3].T + w[:3, 3] + if idx in hp_node_set: + hp_pts.setdefault(hp_node_set[idx], []).append(wpos) + else: + if "indices" in prim: + ind = _read_accessor(accessors, buffer_views, bin_blob, prim["indices"]).reshape(-1, 3) + else: + ind = np.arange(len(pos), dtype=np.int64).reshape(-1, 3) + hull_tris.append(wpos[ind]) + for c in n.get("children", []): + walk(c, w) + + ident = np.eye(4, dtype=np.float64) + for r_idx in root_indices: + walk(r_idx, ident) + + if not hull_tris: + return {} + tris = np.concatenate(hull_tris, axis=0) + tri_mins = tris.min(axis=1) + tri_maxs = tris.max(axis=1) + + gaps: dict[str, tuple[float, float]] = {} + for r_idx, hp_id in hp_roots.items(): + p_slot = node_world[r_idx][:3, 3] + p_anchor = node_world[hp_anchors[hp_id]][:3, 3] + out_vec = p_anchor - p_slot + out_len = float(np.linalg.norm(out_vec)) + n_out = out_vec / out_len if out_len > 1e-6 else np.array([0.0, 1.0, 0.0]) + + d_center = _min_dist_to_tris(p_slot, tris, tri_mins, tri_maxs) + pts = np.concatenate(hp_pts.get(hp_id, []), axis=0) if hp_id in hp_pts else np.empty((0, 3)) + if len(pts) > 0: + proj = (pts - p_slot) @ n_out + base_pts = pts[proj <= 0.03] + if len(base_pts) == 0: + base_pts = pts + if len(base_pts) > 256: + base_pts = base_pts[np.linspace(0, len(base_pts) - 1, 256, dtype=int)] + d_vert = min(_min_dist_to_tris(p, tris, tri_mins, tri_maxs) for p in base_pts) + else: + d_vert = d_center + gaps[hp_id] = (d_center, d_vert) + return gaps + + def validate_vehicle(vid: str) -> dict[str, Any]: vdir = VEHICLES_DIR / vid glb_path = vdir / f"{vid}.glb" @@ -220,6 +400,20 @@ def validate_vehicle(vid: str) -> dict[str, Any]: elif not (1.2 <= size[0] <= 5.0 and 1.0 <= size[1] <= 3.5 and 2.5 <= size[2] <= 6.5): raise AssertionError(f"{vid}: implausible bounds size {size.tolist()}") + # 5. Flush-seating check: every hardpoint slot center and base vertices must sit <= 0.025m from hull geometry + hp_gaps = measure_hardpoint_gaps(gltf, bin_blob) + if len(hp_gaps) != len(manifest["hardpoints"]): + raise AssertionError(f"{vid}: measured {len(hp_gaps)} hardpoint slots != manifest {len(manifest['hardpoints'])}") + max_gap = 0.0 + for hp in manifest["hardpoints"]: + hid = hp["modelNodeId"] + d_center, d_vert = hp_gaps[hid] + if d_center > 0.025 or d_vert > 0.025: + raise AssertionError( + f"{vid}: floating/buried hardpoint {hid!r} (center_to_hull={d_center:.4f}m, base_to_hull={d_vert:.4f}m > 0.025m)" + ) + max_gap = max(max_gap, d_center, d_vert) + return { "id": vid, "plane": plane, @@ -229,6 +423,7 @@ def validate_vehicle(vid: str) -> dict[str, Any]: "joints": len(manifest["joints"]), "mechanisms": len((manifest.get("mechanisms") or {}).get("dofs", [])), "minY": round(float(g_min[1]), 4), + "maxHpGap": round(max_gap, 4), "size": [round(float(v), 3) for v in size], } @@ -257,7 +452,7 @@ def main() -> int: print("=== VEHICLE GLB VALIDATION PASSED ===") for r in v_reports: mech_tag = f" | dofs={r['mechanisms']}" if r["mechanisms"] else "" - print(f" {r['id']:10s} | {r['plane']:7s} | tris={r['tris']:5d} | size={r['size']} | minY={r['minY']} | hps={r['hardpoints']} | joints={r['joints']}{mech_tag} | {r['bytes']/1024:.1f} KiB") + print(f" {r['id']:10s} | {r['plane']:7s} | tris={r['tris']:5d} | size={r['size']} | minY={r['minY']} | hpGap={r['maxHpGap']:.4f}m | hps={r['hardpoints']} | joints={r['joints']}{mech_tag} | {r['bytes']/1024:.1f} KiB") print("=== GEAR GLB VALIDATION PASSED ===") for r in g_reports: print(f" {r['id']:14s} | tris={r['tris']:4d} | size={r['size']} | {r['bytes']/1024:.1f} KiB")