Initial Unity project import

This commit is contained in:
Netherwarlord
2026-11-20 10:52:58 -05:00
commit 136065772b
254 changed files with 54630 additions and 0 deletions
@@ -0,0 +1,131 @@
fileFormatVersion: 2
guid: 79a0797c1cb950729a55e4d61fede3ec
ModelImporter:
serializedVersion: 24300
internalIDToNameTable: []
externalObjects:
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: M_L230SR_Display
second: {fileID: 2100000, guid: b930e4cae98d0b30cbfe4a5177465fb6, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: M_L230SR_Housing_Black
second: {fileID: 2100000, guid: 013e851e97983c16ba9af46ac7393091, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: M_L230SR_Lens
second: {fileID: 2100000, guid: 26976361ba24f0d66840a49e28ab6cf5, type: 2}
- first:
type: UnityEngine:Material
assembly: UnityEngine.CoreModule
name: M_L230SR_Trim_DarkMetal
second: {fileID: 2100000, guid: 496a6fb5c97740261afde8b2eadb290e, type: 2}
materials:
materialImportMode: 1
materialName: 0
materialSearch: 1
materialLocation: 1
searchTexturesGlobally: 0
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
removeConstantScaleCurves: 0
motionNodeName:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 0
meshes:
lODScreenPercentages: []
globalScale: 1
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
sortHierarchyByName: 1
importPhysicalCameras: 1
importVisibility: 0
importBlendShapes: 0
importCameras: 0
importLights: 0
nodeNameCollisionStrategy: 1
fileIdsGeneration: 2
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
keepQuads: 0
weldVertices: 1
bakeAxisConversion: 1
preserveHierarchy: 1
skinWeightsMode: 0
maxBonesPerVertex: 4
minBoneWeight: 0.001
optimizeBones: 1
generateMeshLods: 0
meshLodGenerationFlags: 0
maximumMeshLod: -1
meshOptimizationFlags: -1
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVMarginMethod: 1
secondaryUVMinLightmapResolution: 40
secondaryUVMinObjectScale: 1
secondaryUVPackMargin: 4
useFileScale: 1
strictVertexDataChecks: 0
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
referencedClips: []
importAnimation: 0
humanDescription:
serializedVersion: 3
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
globalScale: 1
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
autoGenerateAvatarMappingIfUnspecified: 1
animationType: 0
humanoidOversampling: 1
avatarSetup: 0
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
importBlendShapeDeformPercent: 1
remapMaterialsIfMaterialImportModeIsNone: 0
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,713 @@
"""
Build script: Chauvet Professional Legend 230SR Beam (game-ready fixture model)
==========================================================================
Run headless:
blender --background --factory-startup --python build_chauvet_legend_230sr_beam.py -- \
--out-blend <path.blend> --out-fbx <path.fbx> --report <path.json>
Coordinate system (Blender): metres, +Z up, fixture FRONT (control panel) faces -Y,
+X is the fixture's right-hand side when you look at the front.
Rest pose == DMX centre (pan 50 %, tilt 50 %): yoke arms on +/-X, head pointing
straight up (+Z, beam leaves the lens along +Z).
Hierarchy and pivots (object origins sit exactly on the mechanical axes):
Base origin (0, 0, 0) floor contact plane, centre of the base footprint
Yoke origin (0, 0, 0.1352) PAN axis = Yoke local +Z through (x=0, y=0)
Head origin (0, 0, 0.3735) TILT axis = Head local +X through (y=0, z=0.3735)
Lens origin (0, 0, 0.4855) optical axis = Lens local +Z
All dimensions trace to the Legend 230SR Beam User Manual Rev. 5 "Product Dimensions"
drawing (see Documentation/Chauvet_Legend_230SR_Beam_Fixture.md). Values that were
scaled from the raster drawing rather than printed are marked "scaled" below.
"""
import bpy
import bmesh
import json
import math
import os
import sys
from mathutils import Matrix, Vector
import numpy as np
# ---------------------------------------------------------------------------
# Dimensions (metres)
# ---------------------------------------------------------------------------
D = dict(
# printed on the manufacturer drawing
overall_height_head_up=0.4975, # 19.59 in / 497.5 mm
overall_width_handles=0.415, # 16.34 in / 415 mm
overall_length=0.3434, # 13.52 in / 343.4 mm (base depth)
yoke_width=0.3668, # 14.44 in / 366.8 mm
head_face_width=0.229, # 9.02 in / 229 mm
head_body_width=0.2214, # 8.72 in / 221.4 mm
head_depth=0.2059, # 8.11 in / 205.9 mm
head_length=0.2845, # 11.20 in / 284.5 mm
yoke_arm_depth=0.124, # 4.88 in / 124 mm
yoke_top=0.4353, # 17.14 in / 435.3 mm (head up)
base_height=0.122, # 4.80 in / 122 mm
yoke_bottom=0.1352, # 5.32 in / 135.2 mm
head_underside_horizontal=0.271, # 10.67 in / 271 mm (head horizontal)
# derived / scaled from the raster drawing (documented as estimates)
tilt_axis_z=0.3735, # 497.5 - 124 (front of head from axis), cross-checked 271 + 205.9/2
head_front_from_axis=0.124, # = arm radius; scaled 123-124 mm from side view
base_width=0.3056, # scaled 305-306 mm (front view)
lens_glass_diameter=0.133, # scaled ~130-135 mm
bezel_outer_diameter=0.178, # scaled ~178 mm
)
TZ = D["tilt_axis_z"]
YB = D["yoke_bottom"]
A_FRONT = D["head_front_from_axis"] # 0.124
A_REAR = A_FRONT - D["head_length"] # -0.1605
ARM_R = D["yoke_arm_depth"] / 2.0 # 0.062
ARM_IN = 0.1175 # inner face of each arm (3 mm clearance to the 229 mm face)
ARM_OUT = D["yoke_width"] / 2.0 # 0.1834
BX = D["base_width"] / 2.0 # 0.1528
BY = D["overall_length"] / 2.0 # 0.1717 overall (front panel details included)
BY_BODY = 0.16995 # housing half-depth (339.9 mm; scaled ~338 mm in side view) so
# housing + 3.5 mm front-panel relief = 343.4 mm overall
HX = D["head_body_width"] / 2.0 # 0.1107
HFX = D["head_face_width"] / 2.0 # 0.1145
HY = D["head_depth"] / 2.0 # 0.10295
LENS_A = 0.112 # lens centre along optical axis (from tilt axis)
LENS_R = D["lens_glass_diameter"] / 2.0
BEZ_RO = D["bezel_outer_diameter"] / 2.0
BEZ_RI = 0.072
WEB_HALF_DEPTH = 0.055 # V-web / pan block half depth (Y)
TILT_RANGE_DEG = 270.0
PAN_RANGE_DEG = 540.0
CLEARANCE = 0.005
MAT_NAMES = {
"housing": "M_L230SR_Housing_Black",
"trim": "M_L230SR_Trim_DarkMetal",
"display": "M_L230SR_Display",
"lens": "M_L230SR_Lens",
}
# ---------------------------------------------------------------------------
# small mesh-building toolkit (all geometry is accumulated per object)
# ---------------------------------------------------------------------------
class Part:
"""Geometry accumulator; each part keeps its material slot index."""
def __init__(self):
self.verts = []
self.faces = [] # (tuple(vertex indices), material index)
def add(self, verts, faces, mat):
base = len(self.verts)
self.verts.extend([tuple(v) for v in verts])
self.faces.extend([(tuple(i + base for i in f), mat) for f in faces])
def add_bm(self, bm, mat):
bm.verts.index_update()
verts = [v.co.copy() for v in bm.verts]
faces = [tuple(v.index for v in f.verts) for f in bm.faces]
self.add(verts, faces, mat)
bm.free()
def bm_box(size, center, bevel=0.0, segments=1):
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=1.0)
for v in bm.verts:
v.co = Vector((v.co.x * size[0], v.co.y * size[1], v.co.z * size[2])) + Vector(center)
if bevel > 0:
bmesh.ops.bevel(bm, geom=list(bm.edges), offset=bevel, offset_type='OFFSET',
segments=segments, profile=0.5, affect='EDGES', clamp_overlap=True)
return bm
def bm_cylinder(radius, depth, center, axis='Z', segments=16, radius2=None, bevel=0.0):
bm = bmesh.new()
bmesh.ops.create_cone(bm, cap_ends=True, cap_tris=False, segments=segments,
radius1=radius, radius2=radius if radius2 is None else radius2, depth=depth)
rot = {
'Z': Matrix.Identity(4),
'X': Matrix.Rotation(math.radians(90), 4, 'Y'),
'Y': Matrix.Rotation(math.radians(-90), 4, 'X'),
}[axis]
bmesh.ops.transform(bm, matrix=Matrix.Translation(Vector(center)) @ rot, verts=bm.verts)
if bevel > 0:
bmesh.ops.bevel(bm, geom=list(bm.edges), offset=bevel, offset_type='OFFSET',
segments=1, profile=0.5, affect='EDGES', clamp_overlap=True)
return bm
def bm_extrude_polygon(poly2d, plane, depth_from, depth_to, bevel=0.0):
"""poly2d: CCW list of (u,v). plane 'XZ' (extrude along Y), 'YZ' (along X), 'XY' (along Z)."""
bm = bmesh.new()
def to3(u, v, w):
if plane == 'XZ':
return Vector((u, w, v))
if plane == 'YZ':
return Vector((w, u, v))
return Vector((u, v, w))
lo = [bm.verts.new(to3(u, v, depth_from)) for (u, v) in poly2d]
hi = [bm.verts.new(to3(u, v, depth_to)) for (u, v) in poly2d]
n = len(poly2d)
bm.faces.new(list(reversed(lo)))
bm.faces.new(hi)
for i in range(n):
j = (i + 1) % n
bm.faces.new((lo[i], lo[j], hi[j], hi[i]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
if bevel > 0:
bmesh.ops.bevel(bm, geom=list(bm.edges), offset=bevel, offset_type='OFFSET',
segments=1, profile=0.5, affect='EDGES', clamp_overlap=True)
return bm
def bm_loft_rects(rect_a, rect_b, za, zb, bevel=0.0):
"""Frustum between two axis-aligned rectangles (half-sizes) at heights za/zb (local Z)."""
bm = bmesh.new()
(ax, ay), (bx, by) = rect_a, rect_b
ra = [bm.verts.new(Vector(p)) for p in ((-ax, -ay, za), (ax, -ay, za), (ax, ay, za), (-ax, ay, za))]
rb = [bm.verts.new(Vector(p)) for p in ((-bx, -by, zb), (bx, -by, zb), (bx, by, zb), (-bx, by, zb))]
bm.faces.new(ra)
bm.faces.new(list(reversed(rb)))
for i in range(4):
j = (i + 1) % 4
bm.faces.new((ra[i], rb[i], rb[j], ra[j]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
if bevel > 0:
bmesh.ops.bevel(bm, geom=list(bm.edges), offset=bevel, offset_type='OFFSET',
segments=2, profile=0.5, affect='EDGES', clamp_overlap=True)
return bm
def bm_tube(r_out, r_in, z0, z1, segments=32):
"""Hollow cylinder along local Z (open bore)."""
bm = bmesh.new()
rings = []
for (r, z) in ((r_out, z0), (r_out, z1), (r_in, z1), (r_in, z0)):
ring = []
for k in range(segments):
t = 2 * math.pi * k / segments
ring.append(bm.verts.new((r * math.cos(t), r * math.sin(t), z)))
rings.append(ring)
for a in range(4):
b = (a + 1) % 4
for k in range(segments):
k2 = (k + 1) % segments
bm.faces.new((rings[a][k], rings[a][k2], rings[b][k2], rings[b][k]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
return bm
def bm_lens_dome(radius, sag, z0, rings=3, segments=32):
"""Shallow spherical-cap lens with planar UVs centred at (0.5, 0.5)."""
bm = bmesh.new()
center = bm.verts.new((0, 0, z0 + sag))
prev = None
ring_list = []
for r_i in range(1, rings + 1):
rr = radius * r_i / rings
zz = z0 + sag * (1 - (rr / radius) ** 2)
ring = [bm.verts.new((rr * math.cos(2 * math.pi * k / segments),
rr * math.sin(2 * math.pi * k / segments), zz)) for k in range(segments)]
ring_list.append(ring)
for k in range(segments):
k2 = (k + 1) % segments
bm.faces.new((center, ring_list[0][k], ring_list[0][k2]))
for a in range(len(ring_list) - 1):
for k in range(segments):
k2 = (k + 1) % segments
bm.faces.new((ring_list[a][k], ring_list[a + 1][k], ring_list[a + 1][k2], ring_list[a][k2]))
# flat back so the lens is a closed, thin solid
back = [bm.verts.new((v.co.x, v.co.y, z0 - 0.003)) for v in ring_list[-1]]
for k in range(segments):
k2 = (k + 1) % segments
bm.faces.new((ring_list[-1][k], back[k], back[k2], ring_list[-1][k2]))
bm.faces.new(list(reversed(back)))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
return bm
def bm_handle(side):
"""Side carrying handle: an arched grip bar with two stand-offs (sign = +/-X side)."""
bm = bmesh.new()
x_in, x_out = BX - 0.004, D["overall_width_handles"] / 2.0
grip_x0, grip_x1 = x_out - 0.016, x_out
y_half, n = 0.098, 10
z_c, sag, zt = 0.052, 0.010, 0.022 # grip centre height, arch, grip height (scaled)
lo, hi = [], []
for i in range(n + 1):
y = -y_half + 2 * y_half * i / n
zc = z_c + sag * (1 - (y / y_half) ** 2)
lo.append((y, zc - zt / 2))
hi.append((y, zc + zt / 2))
rows = []
for (x) in (grip_x0, grip_x1):
rows.append([bm.verts.new((x, y, z)) for (y, z) in lo] + [bm.verts.new((x, y, z)) for (y, z) in reversed(hi)])
m = len(rows[0])
bm.faces.new(rows[0])
bm.faces.new(list(reversed(rows[1])))
for k in range(m):
k2 = (k + 1) % m
bm.faces.new((rows[0][k], rows[0][k2], rows[1][k2], rows[1][k]))
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
for y in (-y_half + 0.011, y_half - 0.011):
bm_join(bm, bm_box((grip_x0 - x_in + 0.002, 0.022, zt), ((x_in + grip_x0) / 2, y, z_c + zt * 0.15), bevel=0.002))
if side < 0:
bmesh.ops.scale(bm, vec=(-1, 1, 1), verts=bm.verts)
bmesh.ops.reverse_faces(bm, faces=bm.faces)
return bm
def bm_join(dst, src):
vmap = {}
for v in src.verts:
vmap[v] = dst.verts.new(v.co)
for f in src.faces:
dst.faces.new([vmap[v] for v in f.verts])
src.free()
def make_object(name, part, materials, location, parent=None):
me = bpy.data.meshes.new(name)
me.from_pydata([Vector(v) - Vector(location) for v in part.verts], [], [f for f, _ in part.faces])
for poly, (_, m) in zip(me.polygons, part.faces): # assign before validate() can drop polygons
poly.material_index = m
me.validate(clean_customdata=False)
for mat in materials:
me.materials.append(mat)
for p in me.polygons:
p.use_smooth = True
me.set_sharp_from_angle(angle=math.radians(35.0))
me.update()
ob = bpy.data.objects.new(name, me)
bpy.context.scene.collection.objects.link(ob)
if parent is not None:
ob.parent = parent
ob.matrix_parent_inverse = Matrix.Identity(4)
ob.location = Vector(location) - parent.matrix_world.translation
else:
ob.location = Vector(location)
bpy.context.view_layer.update()
return ob
def ensure_material(key, color, metallic=0.0, roughness=0.5, specular=0.5):
mat = bpy.data.materials.new(MAT_NAMES[key])
mat.use_nodes = True
bsdf = mat.node_tree.nodes.get("Principled BSDF")
bsdf.inputs["Base Color"].default_value = (*color, 1.0)
bsdf.inputs["Metallic"].default_value = metallic
bsdf.inputs["Roughness"].default_value = roughness
if "Emission Strength" in bsdf.inputs:
bsdf.inputs["Emission Strength"].default_value = 0.0
mat.diffuse_color = (*color, 1.0)
return mat
def planar_uv(ob, axis_u=0, axis_v=1, center=(0.0, 0.0), scale=1.0):
me = ob.data
uv = me.uv_layers.new(name="UVMap")
for loop in me.loops:
co = me.vertices[loop.vertex_index].co
uv.data[loop.index].uv = (0.5 + (co[axis_u] - center[0]) * scale, 0.5 + (co[axis_v] - center[1]) * scale)
def box_uv(ob, scale=2.0):
"""Cheap world-space box projection: enough for flat/tiling materials and lightmap-free use."""
me = ob.data
uv = me.uv_layers.new(name="UVMap")
for poly in me.polygons:
n = poly.normal
ax = max(range(3), key=lambda i: abs(n[i]))
u_i, v_i = [(1, 2), (0, 2), (0, 1)][ax]
for li in poly.loop_indices:
co = me.vertices[me.loops[li].vertex_index].co
uv.data[li].uv = (co[u_i] * scale, co[v_i] * scale)
# ---------------------------------------------------------------------------
# geometry
# ---------------------------------------------------------------------------
def build_head_part():
"""Head in head-local coordinates (origin on the tilt axis, optical axis +Z)."""
p = Part()
H, T = 0, 1
# main body
p.add_bm(bm_box((2 * HX, 2 * HY, 0.170), (0, 0, -0.015), bevel=0.016, segments=2), H)
# front face plate (229 mm) with chamfered corners -> octagon extruded along the optical axis
c = 0.034
octa = [(-HFX + c, -HY), (HFX - c, -HY), (HFX, -HY + c), (HFX, HY - c),
(HFX - c, HY), (-HFX + c, HY), (-HFX, HY - c), (-HFX, -HY + c)]
p.add_bm(bm_extrude_polygon(octa, 'XY', 0.058, 0.097, bevel=0.004), H)
# corner brackets of the front frame (scaled from front view)
for sx in (-1, 1):
for sy in (-1, 1):
bm = bm_box((0.050, 0.012, 0.030), (0, 0, 0))
bmesh.ops.rotate(bm, verts=bm.verts, cent=(0, 0, 0),
matrix=Matrix.Rotation(math.radians(-45 * sx * sy), 3, 'Z'))
bmesh.ops.translate(bm, verts=bm.verts, vec=(sx * (HFX - 0.030), sy * (HY - 0.030), 0.098))
p.add_bm(bm, T)
# round lens bezel (tube) and inner lip
p.add_bm(bm_tube(BEZ_RO, BEZ_RI, 0.095, A_FRONT, segments=32), H)
p.add_bm(bm_tube(BEZ_RI + 0.0005, LENS_R - 0.001, LENS_A - 0.006, LENS_A - 0.002, segments=32), T)
# rear: tapered housing towards the lamp end, ending at the documented 284.5 mm length
p.add_bm(bm_loft_rects((HX, HY), (0.074, 0.055), -0.098, A_REAR, bevel=0.008), H)
# rear cooling fins on the +/-Y faces of the taper (approximation of the serrated edge)
for i in range(5):
a = -0.108 - i * 0.010
t = (a - (-0.098)) / (A_REAR - (-0.098))
hy = HY + (0.055 - HY) * t
hx = HX + (0.074 - HX) * t
for sy in (-1, 1):
p.add_bm(bm_box((2 * hx - 0.030, 0.006, 0.003), (0, sy * (hy + 0.001), a)), T)
# louvred vent + label plate + screws on the -Y face (as drawn in the head-up front view)
p.add_bm(bm_box((0.078, 0.004, 0.070), (0, -HY - 0.0005, -0.108)), T)
for i in range(7):
p.add_bm(bm_box((0.072, 0.004, 0.003), (0, -HY - 0.003, -0.140 + i * 0.0095)), H)
p.add_bm(bm_box((0.070, 0.003, 0.030), (0, -HY - 0.001, -0.040), bevel=0.002), T)
for (x, a) in ((-0.055, 0.042), (0.055, 0.042), (-0.068, -0.090), (0.068, -0.090)):
p.add_bm(bm_cylinder(0.006, 0.004, (x, -HY - 0.001, a), axis='Y', segments=8), T)
# quarter-turn fasteners on the +Y cover
for x in (-0.060, 0.060):
p.add_bm(bm_cylinder(0.008, 0.004, (x, HY + 0.001, -0.070), axis='Y', segments=10), T)
# tilt hub covers (rotate with the head), ending 0.5 mm short of the arm faces
for sx in (-1, 1):
p.add_bm(bm_cylinder(0.040, 0.0065, (sx * (HX + 0.0028), 0, 0), axis='X', segments=24), T)
return p
def head_sample_points(head_part, spacing=0.002, max_div=40):
"""Dense surface samples (fan-triangulated faces, barycentric grid) in head-local space."""
V = np.array(head_part.verts)
pts = [V]
for (f, _) in head_part.faces:
for i in range(1, len(f) - 1):
A, B, C = V[f[0]], V[f[i]], V[f[i + 1]]
L = max(np.linalg.norm(B - A), np.linalg.norm(C - B), np.linalg.norm(A - C))
k = int(min(max_div, max(1, math.ceil(L / spacing))))
ii, jj = np.meshgrid(np.arange(k + 1), np.arange(k + 1), indexing="ij")
m = (ii + jj) <= k
u, v = ii[m] / k, jj[m] / k
pts.append(A + np.outer(u, B - A) + np.outer(v, C - A))
return np.vstack(pts)
def swept_floor(points, x_bins, y_half, tilt_deg=TILT_RANGE_DEG / 2, step=0.5):
"""Lowest world-z reached inside |y|<=y_half by head points falling in each |x| bin."""
floor = np.full(len(x_bins) - 1, np.inf)
ax = np.abs(points[:, 0])
yv, av = points[:, 1], points[:, 2]
tol = 0.003 # each bin also sees samples within +/-3 mm in x (sample spacing <= ~2-4 mm)
members = [(ax >= x_bins[b] - tol) & (ax <= x_bins[b + 1] + tol) for b in range(len(floor))]
for th in np.radians(np.arange(-tilt_deg, tilt_deg + 1e-6, step)):
y = yv * math.cos(th) - av * math.sin(th)
z = TZ + yv * math.sin(th) + av * math.cos(th)
z = np.where(np.abs(y) <= y_half, z, np.inf)
for b in range(len(floor)):
zb = z[members[b]]
if zb.size:
floor[b] = min(floor[b], zb.min())
return floor
def build_yoke_part(head_part):
p = Part()
H, T = 0, 1
# --- V-web / pan block: drawn V (manual front view) clipped to the head's swept envelope
bins = np.linspace(0.0, ARM_IN, 48)
floor = swept_floor(head_sample_points(head_part), bins, WEB_HALF_DEPTH + 0.004, step=1.0)
allowed = floor - CLEARANCE
# make the envelope monotone outward-safe and fill empty bins conservatively
allowed = np.where(np.isfinite(allowed), allowed, 0.30)
xs = (bins[:-1] + bins[1:]) / 2
def drawn(x):
if x <= 0.0425:
return 0.200
return 0.200 + (x - 0.0425) / (ARM_IN - 0.0425) * (D["head_underside_horizontal"] - 0.200)
top = []
for i, x in enumerate(xs):
lo_i, hi_i = max(0, i - 1), min(len(xs), i + 2) # neighbours: protect bin edges
top.append(min(drawn(x), allowed[lo_i:hi_i].min()))
# CCW outline in (x, z): bottom edge, right arm overlap, V top (right->left), left arm overlap
poly = [(-(ARM_IN + 0.004), YB), (ARM_IN + 0.004, YB)] + \
[(ARM_IN + 0.004, top[-1])] + [(x, z) for x, z in zip(reversed(xs), reversed(top))] + \
[(-x, z) for x, z in zip(xs, top)] + [(-(ARM_IN + 0.004), top[-1])]
p.add_bm(bm_extrude_polygon(poly, 'XZ', -WEB_HALF_DEPTH, WEB_HALF_DEPTH, bevel=0.003), H)
web_info = dict(block_top=float(min(top[:12])), v_top_at_arm=float(top[-1]),
drawn_v_top_at_arm=D["head_underside_horizontal"], drawn_block_top=0.200)
# front/back screw plate on the pan block (photo/drawing detail)
for sy in (-1, 1):
p.add_bm(bm_box((0.080, 0.003, 0.050), (0, sy * (WEB_HALF_DEPTH + 0.0012), YB + 0.030)), T)
# pan neck (rotates with the yoke) - slightly sunk into the base turntable ring
p.add_bm(bm_cylinder(0.036, 0.022, (0, 0, YB - 0.009), segments=20), T)
# --- arms: side profile = rectangle + semicircle concentric with the tilt axis
prof = [(-ARM_R, YB), (ARM_R, YB), (ARM_R, TZ)]
for k in range(1, 12):
t = math.pi * k / 12
prof.append((ARM_R * math.cos(t), TZ + ARM_R * math.sin(t)))
prof.append((-ARM_R, TZ))
for sx in (-1, 1):
x0, x1 = sorted((sx * ARM_IN, sx * ARM_OUT))
bm = bm_extrude_polygon(prof, 'YZ', x0, x1, bevel=0.005)
# chamfer the outer-bottom corner (front view silhouette)
p.add_bm(bm, H)
# raised (logo-free) cover plate on the outer face
plate = [(-0.030, YB + 0.040), (0.030, YB + 0.040), (0.040, TZ - 0.010)]
for k in range(1, 8):
t = math.pi * k / 8
plate.append((0.040 * math.cos(t), TZ - 0.010 + 0.040 * math.sin(t)))
plate.append((-0.040, TZ - 0.010))
xo = sx * ARM_OUT
p.add_bm(bm_extrude_polygon(plate, 'YZ', min(xo, xo + sx * 0.004), max(xo, xo + sx * 0.004), bevel=0.0015), H)
# vent slot rows near the top and bottom of the arm cover
for z in (YB + 0.020, TZ + 0.040):
for k in range(5):
y = -0.040 + k * 0.020
p.add_bm(bm_box((0.003, 0.012, 0.008), (sx * (ARM_OUT + 0.0008), y, z)), T)
return p, web_info
def build_base_part():
p = Part()
H, T, DSP = 0, 1, 2
# feet + mounting plate
for sx in (-1, 1):
for sy in (-1, 1):
p.add_bm(bm_box((0.045, 0.050, 0.021), (sx * 0.112, sy * 0.132, 0.0105), bevel=0.004), T)
p.add_bm(bm_box((0.130, 0.220, 0.010), (0, 0, 0.016), bevel=0.002), T)
# main housing + top tier + turntable ring
p.add_bm(bm_box((2 * BX, 2 * BY_BODY, 0.092), (0, 0, 0.020 + 0.046), bevel=0.014, segments=2), H)
p.add_bm(bm_box((0.270, 0.300, 0.016), (0, 0, D["base_height"] - 0.008), bevel=0.006, segments=2), H)
p.add_bm(bm_cylinder(0.055, 0.008, (0, 0, D["base_height"] + 0.004), segments=24), T)
# front control panel (-Y): frame, LCD, LEDs, buttons, corner screws
fy = -BY_BODY
p.add_bm(bm_box((0.236, 0.004, 0.062), (0, fy, 0.066), bevel=0.0015), T) # front at fy-0.002
p.add_bm(bm_box((0.040, 0.002, 0.026), (-0.004, fy - 0.0015, 0.068)), DSP) # LCD
for k in range(4):
p.add_bm(bm_box((0.003, 0.002, 0.003), (-0.034, fy - 0.0015, 0.059 + k * 0.006)), DSP)
for (x, z) in ((0.030, 0.068), (0.046, 0.068), (0.038, 0.076), (0.038, 0.060)):
p.add_bm(bm_cylinder(0.0035, 0.002, (x, fy - 0.0025, z), axis='Y', segments=8), T) # front at -0.1725
for x in (-0.132, 0.132):
for z in (0.045, 0.087):
p.add_bm(bm_cylinder(0.006, 0.002, (x, fy - 0.002, z), axis='Y', segments=8), T)
# side vents (+/-X): two brick-pattern grilles per side
for sx in (-1, 1):
for gy in (-0.085, 0.085):
for row in range(4):
for col in range(2):
off = 0.009 if row % 2 else 0.0
y = gy - 0.018 + col * 0.036 + off - 0.0045
z = 0.073 + row * 0.0085
p.add_bm(bm_box((0.002, 0.030, 0.0045), (sx * (BX + 0.0006), y, z)), T)
p.add_bm(bm_handle(sx), T)
# rear power-cable boot (+Y). The cable itself is not modelled.
p.add_bm(bm_cylinder(0.011, 0.020, (-0.100, BY_BODY + 0.009, 0.056), axis='Y', segments=12), T)
return p
# ---------------------------------------------------------------------------
# build / validate / export
# ---------------------------------------------------------------------------
def clean_scene():
bpy.ops.wm.read_factory_settings(use_empty=True)
sc = bpy.context.scene
sc.name = "L230SR_Fixture"
sc.unit_settings.system = 'METRIC'
sc.unit_settings.scale_length = 1.0
sc.unit_settings.length_unit = 'METERS'
def build():
clean_scene()
mats = {
"housing": ensure_material("housing", (0.018, 0.018, 0.020), 0.0, 0.62),
"trim": ensure_material("trim", (0.045, 0.046, 0.050), 0.55, 0.42),
"display": ensure_material("display", (0.010, 0.020, 0.060), 0.0, 0.15),
"lens": ensure_material("lens", (0.30, 0.32, 0.35), 0.0, 0.04), # neutral glass grey, no emission
}
head_local = build_head_part()
yoke_world, web_info = build_yoke_part(head_local)
base_world = build_base_part()
lens = Part()
lens.add_bm(bm_lens_dome(LENS_R, 0.007, 0.0, rings=3, segments=32), 0)
base = make_object("Base", base_world, [mats["housing"], mats["trim"], mats["display"]], (0, 0, 0))
yoke = make_object("Yoke", yoke_world, [mats["housing"], mats["trim"]], (0, 0, YB), parent=base)
# head part is head-local: shift to world before make_object subtracts the origin again
head_world = Part()
head_world.verts = [(x, y, z + TZ) for (x, y, z) in head_local.verts]
head_world.faces = head_local.faces
head = make_object("Head", head_world, [mats["housing"], mats["trim"]], (0, 0, TZ), parent=yoke)
lens_world = Part()
lens_world.verts = [(x, y, z + TZ + LENS_A) for (x, y, z) in lens.verts]
lens_world.faces = lens.faces
lens_ob = make_object("Lens", lens_world, [mats["lens"]], (0, 0, TZ + LENS_A), parent=head)
for ob in (base, yoke, head):
box_uv(ob)
planar_uv(lens_ob, 0, 1, (0.0, 0.0), 1.0 / (2 * LENS_R))
# documentation as custom properties (kept in .blend; not exported to FBX)
base["fixture"] = "Chauvet Professional Legend 230SR Beam"
base["units"] = "metres, +Z up, front (control panel) faces -Y"
yoke["pan_axis"] = "Yoke local +Z through Base origin"
yoke["pan_range_deg"] = PAN_RANGE_DEG
yoke["rest_pose"] = "DMX pan 50% (centre). Arms on +/-X."
head["tilt_axis"] = "Head local +X through (0, 0, 0.3735)"
head["tilt_range_deg"] = TILT_RANGE_DEG
head["rest_pose"] = "DMX tilt 50% (centre). Beam points +Z (straight up from the base)."
lens_ob["role"] = "emitter surface; colour/dimmer are driven at runtime (no baked light colour)"
return dict(base=base, yoke=yoke, head=head, lens=lens_ob, mats=mats, web=web_info)
def eval_tris(ob):
dg = bpy.context.evaluated_depsgraph_get()
me = ob.evaluated_get(dg).to_mesh()
me.calc_loop_triangles()
n = len(me.loop_triangles)
ob.evaluated_get(dg).to_mesh_clear()
return n
def world_bbox(objs):
pts = []
for ob in objs:
pts.extend([ob.matrix_world @ v.co for v in ob.data.vertices])
a = np.array(pts)
return a.min(axis=0), a.max(axis=0)
def bvh_for(objs):
from mathutils.bvhtree import BVHTree
verts, polys = [], []
for ob in objs:
off = len(verts)
verts.extend([ob.matrix_world @ v.co for v in ob.data.vertices])
polys.extend([[i + off for i in p.vertices] for p in ob.data.polygons])
return BVHTree.FromPolygons(verts, polys)
def validate(o):
base, yoke, head, lens = o["base"], o["yoke"], o["head"], o["lens"]
allobs = [base, yoke, head, lens]
rep = {}
lo, hi = world_bbox(allobs)
lo_nc, hi_nc = world_bbox(allobs) # cable boot included; recompute below without
rep["bbox_min"], rep["bbox_max"] = lo.tolist(), hi.tolist()
rep["size_xyz_m"] = (hi - lo).tolist()
# footprint/housing without the rear cable boot
bverts = np.array([base.matrix_world @ v.co for v in base.data.vertices])
rep["base_y_extent_without_cable_boot_m"] = [float(bverts[:, 1].min()),
float(bverts[bverts[:, 1] < BY_BODY + 0.001][:, 1].max())]
allv = np.vstack([np.array([ob.matrix_world @ v.co for v in ob.data.vertices]) for ob in allobs])
nb = allv[allv[:, 1] <= BY_BODY + 0.001]
rep["size_xyz_without_cable_boot_m"] = (nb.max(axis=0) - nb.min(axis=0)).tolist()
rep["triangles"] = {ob.name: eval_tris(ob) for ob in allobs}
rep["triangles_total"] = sum(rep["triangles"].values())
rep["materials"] = sorted({m.name for ob in allobs for m in ob.data.materials})
rep["material_count"] = len(rep["materials"])
rep["material_slots"] = {ob.name: [m.name for m in ob.data.materials] for ob in allobs}
rep["hierarchy"] = {ob.name: (ob.parent.name if ob.parent else None) for ob in allobs}
rep["origins_world"] = {ob.name: list(ob.matrix_world.translation) for ob in allobs}
rep["local_rot_scale_identity"] = {ob.name: (tuple(ob.rotation_euler) == (0, 0, 0) and tuple(ob.scale) == (1, 1, 1)) for ob in allobs}
rep["lights_in_file"] = [ob.name for ob in bpy.data.objects if ob.type == 'LIGHT']
rep["yoke_web"] = o["web"]
# articulation tests -----------------------------------------------------
tests = []
lens_rest = lens.matrix_world.translation.copy()
def lens_axis():
return (lens.matrix_world.to_3x3() @ Vector((0, 0, 1))).normalized()
yoke.rotation_euler = (0, 0, math.radians(90))
bpy.context.view_layer.update()
tests.append(dict(name="pan +90 only: lens stays on the pan axis, head origin stays on pan axis",
lens_pos=list(lens.matrix_world.translation), head_pos=list(head.matrix_world.translation),
ok=(lens.matrix_world.translation - lens_rest).length < 1e-6))
head.rotation_euler = (math.radians(90), 0, 0)
bpy.context.view_layer.update()
# with pan +90 (CCW from above) and tilt +90 about head local +X, optical axis should point along world +X? compute expected
exp_axis = (Matrix.Rotation(math.radians(90), 3, 'Z') @ Matrix.Rotation(math.radians(90), 3, 'X') @ Vector((0, 0, 1)))
exp_pos = Vector((0, 0, TZ)) + exp_axis * LENS_A
tests.append(dict(name="pan +90 then tilt +90: lens carried by yoke and head",
lens_pos=list(lens.matrix_world.translation), expected=list(exp_pos),
lens_axis=list(lens_axis()), expected_axis=list(exp_axis),
ok=(lens.matrix_world.translation - exp_pos).length < 1e-5 and (lens_axis() - exp_axis).length < 1e-5))
yoke.rotation_euler = (0, 0, 0)
head.rotation_euler = (math.radians(-135), 0, 0)
bpy.context.view_layer.update()
tests.append(dict(name="tilt -135 alone: yoke and base unaffected", yoke_rot=list(yoke.matrix_world.to_euler()),
lens_pos=list(lens.matrix_world.translation),
ok=abs(yoke.matrix_world.to_euler().z) < 1e-9 and abs(lens.matrix_world.translation.z - (TZ + LENS_A * math.cos(math.radians(-135)))) < 1e-5))
head.rotation_euler = (0, 0, 0)
bpy.context.view_layer.update()
# swept-collision audit: head vs yoke + base, full tilt range at several pan angles
static = bvh_for([base])
collisions = []
for pan in (0, 90, 180, 270):
yoke.rotation_euler = (0, 0, math.radians(pan))
for tilt in range(-135, 136, 3):
head.rotation_euler = (math.radians(tilt), 0, 0)
bpy.context.view_layer.update()
hb = bvh_for([head, lens])
yb = bvh_for([yoke])
if hb.overlap(yb) or hb.overlap(static):
collisions.append((pan, tilt))
yoke.rotation_euler = (0, 0, 0)
head.rotation_euler = (0, 0, 0)
bpy.context.view_layer.update()
tests.append(dict(name="no head/lens intersection with yoke or base over tilt -135..+135 (3 deg steps) at pan 0/90/180/270",
collisions=collisions[:20], ok=not collisions))
rep["articulation_tests"] = tests
rep["all_tests_ok"] = all(t["ok"] for t in tests)
return rep
def export_fbx(o, path):
bpy.ops.object.select_all(action='DESELECT')
for k in ("base", "yoke", "head", "lens"):
o[k].select_set(True)
bpy.context.view_layer.objects.active = o["base"]
bpy.ops.export_scene.fbx(
filepath=path, use_selection=True, object_types={'MESH'},
global_scale=1.0, apply_unit_scale=True, apply_scale_options='FBX_SCALE_ALL',
axis_forward='Y', axis_up='Z', bake_space_transform=False,
use_mesh_modifiers=True, mesh_smooth_type='FACE', use_tspace=False,
use_custom_props=False, add_leaf_bones=False, bake_anim=False,
path_mode='STRIP', embed_textures=False)
def main():
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
args = dict(zip(argv[::2], argv[1::2]))
o = build()
rep = validate(o)
rep["dimensions_source"] = D
if "--out-fbx" in args:
export_fbx(o, args["--out-fbx"])
rep["fbx"] = args["--out-fbx"]
# embed this script in the .blend so the source stays self-describing
txt = bpy.data.texts.new("build_chauvet_legend_230sr_beam.py")
txt.from_string(open(__file__, encoding="utf-8").read())
if "--out-blend" in args:
bpy.ops.wm.save_as_mainfile(filepath=args["--out-blend"], compress=True)
rep["blend"] = args["--out-blend"]
if "--report" in args:
with open(args["--report"], "w", encoding="utf-8") as fh:
json.dump(rep, fh, indent=2, default=str)
print("L230SR_REPORT", json.dumps({k: rep[k] for k in ("size_xyz_m", "triangles_total", "material_count", "all_tests_ok")}))
for t in rep["articulation_tests"]:
print("TEST", t["ok"], t["name"], {k: v for k, v in t.items() if k not in ("name", "ok")})
print("WEB", rep["yoke_web"])
if __name__ == "__main__":
main()
@@ -0,0 +1,61 @@
import bpy, math, sys, os
from mathutils import Vector
argv = sys.argv[sys.argv.index("--") + 1:]
outdir = argv[0]
os.makedirs(outdir, exist_ok=True)
sc = bpy.context.scene
sc.render.engine = 'CYCLES'
sc.cycles.device = 'CPU'
sc.cycles.samples = 48
try:
sc.cycles.use_denoising = True
except Exception:
pass
sc.render.film_transparent = False
sc.view_settings.view_transform = 'Standard'
world = bpy.data.worlds.new("PreviewWorld"); sc.world = world
world.use_nodes = True
world.node_tree.nodes["Background"].inputs[0].default_value = (0.55, 0.57, 0.60, 1)
world.node_tree.nodes["Background"].inputs[1].default_value = 0.9
def add_light(name, loc, rot, energy, kind='AREA', size=1.0):
ld = bpy.data.lights.new(name, kind); ld.energy = energy
if kind == 'AREA': ld.size = size
ob = bpy.data.objects.new(name, ld); sc.collection.objects.link(ob)
ob.location = loc; ob.rotation_euler = [math.radians(a) for a in rot]
add_light("PV_Key", (1.2, -1.4, 1.6), (55, 0, 40), 220, size=1.2)
add_light("PV_Fill", (-1.4, -0.8, 0.9), (70, 0, -60), 90, size=1.5)
add_light("PV_Rim", (0.2, 1.5, 1.4), (-60, 0, 180), 120, size=1.0)
yoke, head = bpy.data.objects["Yoke"], bpy.data.objects["Head"]
cam_d = bpy.data.cameras.new("PV_Cam"); cam = bpy.data.objects.new("PV_Cam", cam_d); sc.collection.objects.link(cam); sc.camera = cam
def look(cam, loc, target):
cam.location = loc
d = Vector(target) - Vector(loc)
cam.rotation_euler = d.to_track_quat('-Z', 'Y').to_euler()
def shot(name, loc, target, ortho=None, pan=0, tilt=0, res=(1200, 1200)):
yoke.rotation_euler = (0, 0, math.radians(pan)); head.rotation_euler = (math.radians(tilt), 0, 0)
bpy.context.view_layer.update()
if ortho:
cam_d.type = 'ORTHO'; cam_d.ortho_scale = ortho
else:
cam_d.type = 'PERSP'; cam_d.lens = 70
look(cam, loc, target)
sc.render.resolution_x, sc.render.resolution_y = res
sc.render.filepath = os.path.join(outdir, name + ".png")
bpy.ops.render.render(write_still=True)
print("RENDERED", sc.render.filepath)
C = (0, 0, 0.25)
# matched-scale orthographic views: 0.6 m across 1200 px = 2 px/mm; floor at image row 1100
sc.render.resolution_x = 1200
def ortho_center(z_floor_px=1100, res=1200, scale=0.6):
# camera centre height so that z=0 lands on row z_floor_px
return (res / 2 - (res - z_floor_px)) / (res / scale) * -1 + 0 # metres above floor of image centre
zc = (1100 - 600) / 2000.0 # image centre is 0.25 m above the floor
shot("ortho_front_head_horizontal", (0, -3, zc), (0, 0, zc), ortho=0.6, tilt=90)
shot("ortho_side_right_head_horizontal", (3, 0, zc), (0, 0, zc), ortho=0.6, tilt=90)
shot("ortho_front_head_up", (0, -3, zc), (0, 0, zc), ortho=0.6, tilt=0)
shot("ortho_side_right_head_up", (3, 0, zc), (0, 0, zc), ortho=0.6, tilt=0)
shot("ortho_top_head_up", (0, 0, 3), (0, 0.0001, 0), ortho=0.6, tilt=0)
shot("persp_three_quarter_rest", (1.25, -1.45, 0.95), C, tilt=0)
shot("persp_three_quarter_pan30_tilt60", (1.25, -1.45, 0.95), C, pan=30, tilt=60)
shot("persp_rear_low_pan-40_tilt-110", (-1.2, 1.5, 0.45), C, pan=-40, tilt=-110)
@@ -0,0 +1,41 @@
"""Round-trip check: import the exported FBX into an empty Blender scene and compare hierarchy/pivots."""
import bpy, json, math, sys
from mathutils import Vector
argv = sys.argv[sys.argv.index("--") + 1:]
fbx, out = argv[0], argv[1]
bpy.ops.wm.read_factory_settings(use_empty=True)
bpy.ops.import_scene.fbx(filepath=fbx) # importer reads the axis/unit info written in the file
bpy.context.view_layer.update()
exp = {"Base": ((0, 0, 0), None), "Yoke": ((0, 0, 0.1352), "Base"),
"Head": ((0, 0, 0.3735), "Yoke"), "Lens": ((0, 0, 0.4855), "Head")}
rep = {"objects": {}, "ok": True}
for name, (pos, parent) in exp.items():
ob = bpy.data.objects.get(name)
if ob is None:
rep["objects"][name] = "MISSING"; rep["ok"] = False; continue
w = ob.matrix_world
rot = w.to_euler()
scl = w.to_scale()
d = (w.translation - Vector(pos)).length
ok = (d < 1e-4 and (ob.parent.name if ob.parent else None) == parent
and all(abs(a) < 1e-4 for a in rot) and all(abs(s - 1) < 1e-4 for s in scl))
rep["objects"][name] = dict(type=ob.type, parent=ob.parent.name if ob.parent else None,
world_origin=list(w.translation), world_rot_deg=[math.degrees(a) for a in rot],
world_scale=list(scl), origin_error_m=d, ok=ok,
materials=[m.name for m in ob.data.materials] if ob.type == 'MESH' else [])
rep["ok"] &= ok
pts = [ob.matrix_world @ v.co for ob in bpy.data.objects if ob.type == 'MESH' for v in ob.data.vertices]
mn = [min(p[i] for p in pts) for i in range(3)]; mx = [max(p[i] for p in pts) for i in range(3)]
rep["bbox_size_m"] = [mx[i] - mn[i] for i in range(3)]
rep["bbox_min"], rep["bbox_max"] = mn, mx
rep["non_mesh_objects"] = [o.name + ":" + o.type for o in bpy.data.objects if o.type != 'MESH']
# articulation after import: pan 90 then tilt 90 must carry the lens like in the source file
y, h, l = (bpy.data.objects[n] for n in ("Yoke", "Head", "Lens"))
y.rotation_euler.rotate_axis('Z', math.radians(90)); bpy.context.view_layer.update()
h.rotation_euler.rotate_axis('X', math.radians(90)); bpy.context.view_layer.update()
rep["lens_after_pan90_tilt90"] = list(l.matrix_world.translation)
rep["lens_after_ok"] = (l.matrix_world.translation - Vector((0.112, 0, 0.3735))).length < 1e-4
rep["ok"] &= rep["lens_after_ok"]
json.dump(rep, open(out, "w"), indent=2)
print("ROUNDTRIP_OK", rep["ok"], rep["bbox_size_m"], rep["non_mesh_objects"])