Implement Mesh partitioning

This commit is contained in:
2026-09-27 17:48:22 +02:00
parent 11426fe8fb
commit 850a6f601b
21 changed files with 1146638 additions and 181 deletions

View File

@@ -0,0 +1,313 @@
# Blender MTL File: 'Audi_R8_2017.blend'
# Material Count: 31
newmtl AirBackOutput
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl AudiLogoChrome
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Axe
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl BlackGlossy
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.050000 0.050000 0.050000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl BodyMaterials(00297F)
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.160784 0.498039
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Bolt(Black)
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.050000 0.050000 0.050000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Brake
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.100000 0.100000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl BrakeDisc
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.100000 0.100000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl CarbonFibre
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.150000 0.150000 0.150000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Centre(Black)
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.050000 0.050000 0.050000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl FarLight
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl FrontHighlightChrome
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl GlassBackHighlight
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.100000 0.100000 0.120000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl GlassFrontHighlight
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.100000 0.100000 0.120000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Ground
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl HoneyComb
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.050000 0.050000 0.050000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl InteriorFrontHighlight
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl LightBackHighlight
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl LightFrontHighlight
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl LightSource
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Mirrors
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl MirrorsLightSouces
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl NumberPlateLight
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl NumbrePlateAudiR8
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd NumernSchildAudiR8.png
newmtl Ring(Light)
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl RoofCanvas
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Tyre
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.030000 0.030000 0.030000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl WheelsChrome
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl WindscreenGlassBlack
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.050000 0.050000 0.050000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl WindscreenGlassGrey
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.100000 0.100000 0.120000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl undercarriage
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.050000 0.050000 0.050000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

1145920
assets/audi_r8/Audi_R8_2017.obj Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

View File

@@ -0,0 +1,3 @@
Model by hermes25, from: https://free3d.com/3d-model/audi-r8-spyder-22646.html
Modified material for easier lighting and diffuse colors

76
assets/mtl_converter.py Normal file
View File

@@ -0,0 +1,76 @@
import argparse
import re
import os
import sys
COLOR_RULES = {
"black": "0.05 0.05 0.05", "dark": "0.15 0.15 0.15", "grey": "0.5 0.5 0.5",
"white": "0.9 0.9 0.9", "chrome": "0.8 0.8 0.8", "metal": "0.7 0.7 0.7",
"silver": "0.75 0.75 0.75", "gold": "0.8 0.7 0.2", "copper": "0.7 0.4 0.2",
"glass": "0.1 0.1 0.12", "window": "0.1 0.1 0.12", "mirror": "0.9 0.9 0.9",
"tyre": "0.03 0.03 0.03", "tire": "0.03 0.03 0.03", "rubber": "0.03 0.03 0.03",
"wood": "0.4 0.25 0.1", "carbon": "0.15 0.15 0.15", "plastic": "0.8 0.8 0.8",
"red": "0.8 0.1 0.1", "green": "0.1 0.8 0.1", "blue": "0.1 0.1 0.8",
"yellow": "0.8 0.8 0.1"
}
def hex_to_kd(hex_str):
r, g, b = int(hex_str[0:2], 16), int(hex_str[2:4], 16), int(hex_str[4:6], 16)
return f"{r/255.0:.6f} {g/255.0:.6f} {b/255.0:.6f}"
def get_color(name):
match = re.search(r'\(([A-Fa-f0-9]{6})\)', name)
if match:
return hex_to_kd(match.group(1))
name_lower = name.lower()
for kw, kd in COLOR_RULES.items():
if kw in name_lower: return kd
return None
def main():
parser = argparse.ArgumentParser(description="Auto-fix missing Kd colors in MTL files based on material names.")
parser.add_argument("input", help="Path to the input .mtl file")
parser.add_argument("-o", "--output", help="Path to output file (default: <input>_fixed.mtl)")
parser.add_argument("-w", "--overwrite", action="store_true", help="Overwrite the input file directly")
args = parser.parse_args()
if not os.path.exists(args.input):
print(f"Error: {args.input} not found.")
sys.exit(1)
with open(args.input, 'r') as f:
lines = f.readlines()
out_lines = []
current_mat = ""
changes = 0
for line in lines:
if line.startswith("newmtl "):
current_mat = line.split()[1].strip()
out_lines.append(line)
elif line.startswith("Kd ") and current_mat:
new_kd = get_color(current_mat)
if new_kd:
out_lines.append(f"Kd {new_kd}\n")
changes += 1
else:
out_lines.append(line)
else:
out_lines.append(line)
out_path = args.input if args.overwrite else (args.output or args.input.replace(".mtl", "_fixed.mtl"))
with open(out_path, 'w') as f:
f.writelines(out_lines)
print(f"Done! {changes} materials updated. Saved to {out_path}")
if __name__ == "__main__":
main()

View File

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View File

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 181 KiB

View File

Before

Width:  |  Height:  |  Size: 457 KiB

After

Width:  |  Height:  |  Size: 457 KiB

View File

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 141 KiB

View File

Before

Width:  |  Height:  |  Size: 231 B

After

Width:  |  Height:  |  Size: 231 B

View File

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 251 KiB