param( [string]$WorkspaceRoot = (Split-Path -Parent $PSScriptRoot) ) Add-Type -AssemblyName System.Drawing $characterRoot = Join-Path $WorkspaceRoot 'assets\images\2d-game-characters\02-xinyin' $partsDirectory = Join-Path $characterRoot 'parts\front-right\v1' $manifestPath = Join-Path $partsDirectory 'parts-manifest.json' $correctionDirectory = Join-Path $characterRoot 'parts\front-right\rig-corrections-v1' $correctionManifestPath = Join-Path $correctionDirectory 'rig-corrections-manifest.json' $referencePath = Join-Path $characterRoot 'reference\xinyin-front-right-assembled-reference-v1.png' $assembledDirectory = Join-Path $characterRoot 'assembled\front-right' $previewDirectory = Join-Path $characterRoot 'previews' $assemblyPath = Join-Path $assembledDirectory 'xinyin-front-right-neutral-assembly-v4.png' $layoutPath = Join-Path $assembledDirectory 'assembly-layout-v4.json' $previewPath = Join-Path $previewDirectory 'xinyin-front-right-assembly-validation-v4.png' New-Item -ItemType Directory -Force -Path $assembledDirectory, $previewDirectory | Out-Null $manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json $correctionManifest = Get-Content -LiteralPath $correctionManifestPath -Raw | ConvertFrom-Json $partByName = @{} foreach ($part in $manifest.parts) { $partByName[$part.name] = [pscustomobject]@{ ComponentId=$part.componentId; File=$part.file; PartSet='base-v1' AssetPath="assets/images/2d-game-characters/02-xinyin/parts/front-right/v1/$($part.file)" FullPath=(Join-Path $partsDirectory $part.file) PivotX=[double]$part.pivot.outputPixels.x; PivotY=[double]$part.pivot.outputPixels.y } } foreach ($part in $correctionManifest.parts) { $partByName[$part.name] = [pscustomobject]@{ ComponentId=$part.componentId; File=$part.file; PartSet='rig-corrections-v1' AssetPath="assets/images/2d-game-characters/02-xinyin/parts/front-right/rig-corrections-v1/$($part.file)" FullPath=(Join-Path $correctionDirectory $part.file) PivotX=[double]$part.rootPivot.outputPixels.x; PivotY=[double]$part.rootPivot.outputPixels.y } } # Target coordinates use a 500x760 authoring canvas. X/Y are the desired positions of # each part's manifest pivot. The initial arrangement deliberately uses only one of # several alternate hair/limb pieces so that unused variants stay visible in the report. $layout = @( @{ Name='ponytail-root'; X=215; Y=62; Rotation=0; Scale=.55; Group='base'; Note='三段马尾根部' }, @{ Name='ponytail-middle'; X=296; Y=94; Rotation=-12; Scale=.42; Group='base'; Note='三段马尾中段' }, @{ Name='ponytail-tip'; X=334; Y=258; Rotation=-6; Scale=.38; Group='base'; Note='三段马尾末端' }, @{ Name='coat-panel-01'; X=150; Y=318; Rotation=6; Scale=.92; Group='base'; Note='左外层候选' }, @{ Name='coat-panel-02'; X=176; Y=315; Rotation=3; Scale=.88; Group='base'; Note='左后层候选' }, @{ Name='coat-panel-03'; X=204; Y=319; Rotation=1; Scale=.88; Group='base'; Note='中左候选' }, @{ Name='coat-panel-04'; X=226; Y=320; Rotation=0; Scale=.90; Group='base'; Note='中层候选' }, @{ Name='coat-panel-05'; X=245; Y=320; Rotation=0; Scale=.90; Group='base'; Note='中层候选' }, @{ Name='coat-panel-06'; X=264; Y=319; Rotation=-1; Scale=.88; Group='base'; Note='中右候选' }, @{ Name='coat-panel-07'; X=286; Y=315; Rotation=-3; Scale=.88; Group='base'; Note='右后层候选' }, @{ Name='coat-panel-08'; X=316; Y=318; Rotation=-6; Scale=.92; Group='base'; Note='右外层候选' }, @{ Name='thigh-a'; X=195; Y=350; Rotation=7; Scale=.92; Group='base'; Note='画面左腿候选' }, @{ Name='shin-boot-a'; X=178; Y=480; Rotation=9; Scale=.88; Group='base'; Note='画面左小腿候选' }, @{ Name='thigh-b'; X=244; Y=350; Rotation=-5; Scale=.92; Group='base'; Note='画面右腿候选' }, @{ Name='shin-boot-b'; X=252; Y=487; Rotation=-3; Scale=.88; Group='base'; Note='画面右小腿候选' }, @{ Name='pelvis'; X=220; Y=350; Rotation=0; Scale=.88; Group='base'; Note='主根候选' }, @{ Name='torso-upper'; X=213; Y=318; Rotation=0; Scale=.92; Group='base'; Note='躯干' }, @{ Name='upper-arm-a'; X=146; Y=214; Rotation=10; Scale=.40; Group='base'; Note='独立上臂 A,肩到肘' }, @{ Name='forearm-a'; X=130; Y=307; Rotation=156; Scale=.38; Group='base'; Note='独立前臂 A,肘到腕' }, @{ Name='hand-fan-grip'; X=89; Y=214; Rotation=-8; Scale=.38; Group='base'; Note='独立持扇手' }, @{ Name='upper-arm-b'; X=276; Y=214; Rotation=-8; Scale=.40; Group='base'; Note='独立上臂 B,肩到肘' }, @{ Name='forearm-b'; X=289; Y=309; Rotation=-5; Scale=.30; Group='base'; Note='独立前臂 B,肘到腕' }, @{ Name='hand-relaxed-b'; X=296; Y=389; Rotation=-5; Scale=.25; Group='base'; Note='独立放松手 B' }, @{ Name='waist-guard'; X=217; Y=298; Rotation=0; Scale=.72; Group='overlay'; Note='覆盖骨盆和腿根' }, @{ Name='front-drape'; X=203; Y=305; Rotation=2; Scale=.75; Group='overlay'; Note='腰前垂布' }, @{ Name='waist-pouch'; X=270; Y=312; Rotation=-2; Scale=.58; Group='overlay'; Note='画面右侧腰包,v2 缩小' }, @{ Name='neck'; X=207; Y=187; Rotation=0; Scale=.90; Group='overlay'; Note='颈部' }, @{ Name='head-face'; X=205; Y=194; Rotation=0; Scale=1.00; Group='overlay'; Note='面部' }, @{ Name='hair-front'; X=204; Y=76; Rotation=0; Scale=1.00; Group='overlay'; Note='前发覆盖面部' }, @{ Name='shoulder-armor-a'; X=146; Y=207; Rotation=8; Scale=.65; Group='overlay'; Note='固定于躯干的独立肩甲 A' }, @{ Name='shoulder-armor-b'; X=276; Y=207; Rotation=-8; Scale=.65; Group='overlay'; Note='固定于躯干的独立肩甲 B' } ) function Draw-Part { param( [Drawing.Graphics]$Graphics, [Drawing.Image]$Image, [double]$PivotX, [double]$PivotY, [double]$TargetX, [double]$TargetY, [double]$Rotation, [double]$Scale ) $state = $Graphics.Save() $Graphics.TranslateTransform([single]$TargetX, [single]$TargetY) $Graphics.RotateTransform([single]$Rotation) $Graphics.ScaleTransform([single]$Scale, [single]$Scale) $Graphics.DrawImageUnscaled($Image, [int][Math]::Round(-$PivotX), [int][Math]::Round(-$PivotY)) $Graphics.Restore($state) } $images = @{} $assembly = [Drawing.Bitmap]::new(500, 760, [Drawing.Imaging.PixelFormat]::Format32bppArgb) $assemblyGraphics = [Drawing.Graphics]::FromImage($assembly) $assemblyGraphics.SmoothingMode = [Drawing.Drawing2D.SmoothingMode]::AntiAlias $assemblyGraphics.InterpolationMode = [Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic $assemblyGraphics.PixelOffsetMode = [Drawing.Drawing2D.PixelOffsetMode]::HighQuality $assemblyGraphics.Clear([Drawing.Color]::Transparent) try { foreach ($item in $layout) { $part = $partByName[$item.Name] if ($null -eq $part) { throw "Part not found in manifest: $($item.Name)" } if (-not $images.ContainsKey($item.Name)) { $images[$item.Name] = [Drawing.Bitmap]::new($part.FullPath) } Draw-Part -Graphics $assemblyGraphics -Image $images[$item.Name] ` -PivotX $part.PivotX -PivotY $part.PivotY ` -TargetX $item.X -TargetY $item.Y -Rotation $item.Rotation -Scale $item.Scale } $assembly.Save($assemblyPath, [Drawing.Imaging.ImageFormat]::Png) $layoutRecords = foreach ($item in $layout) { $part = $partByName[$item.Name] [ordered]@{ part = $item.Name componentId = $part.ComponentId partSet = $part.PartSet file = $part.AssetPath targetPivot = [ordered]@{ x=$item.X; y=$item.Y } rotationDegrees = $item.Rotation scale = $item.Scale group = $item.Group note = $item.Note } } [ordered]@{ characterId = '02-xinyin' direction = 'front-right' version = 4 status = 'art-assembly-validated' canvas = [ordered]@{ width=500; height=760; origin='top-left'; units='pixels' } sourceManifests = @( 'assets/images/2d-game-characters/02-xinyin/parts/front-right/v1/parts-manifest.json', 'assets/images/2d-game-characters/02-xinyin/parts/front-right/rig-corrections-v1/rig-corrections-manifest.json' ) warnings = @( 'This is an art-side assembly validation, not an engine rig.', 'A/B limb ownership and cloth ordering remain provisional until animation testing.', 'C01 is excluded because two alternate ponytail masses are connected by a thin strand.', 'C09 is excluded because the front-hair part already carries the visible long ornament.', 'C15/C17 and C18/C20 are replaced by independent arm, forearm, and hand correction parts.', 'C28/C29 are restored as torso-mounted shoulder armor because corrected upper arms do not contain armor.' ) items = $layoutRecords } | ConvertTo-Json -Depth 7 | Set-Content -LiteralPath $layoutPath -Encoding utf8 $board = [Drawing.Bitmap]::new(1800, 980, [Drawing.Imaging.PixelFormat]::Format32bppArgb) $g = [Drawing.Graphics]::FromImage($board) $g.SmoothingMode = [Drawing.Drawing2D.SmoothingMode]::AntiAlias $g.InterpolationMode = [Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic $g.PixelOffsetMode = [Drawing.Drawing2D.PixelOffsetMode]::HighQuality $g.Clear([Drawing.Color]::FromArgb(255, 17, 21, 30)) $titleBrush = [Drawing.SolidBrush]::new([Drawing.Color]::FromArgb(255, 240, 244, 252)) $mutedBrush = [Drawing.SolidBrush]::new([Drawing.Color]::FromArgb(255, 150, 169, 198)) $panelBrush = [Drawing.SolidBrush]::new([Drawing.Color]::FromArgb(255, 24, 30, 42)) $panelPen = [Drawing.Pen]::new([Drawing.Color]::FromArgb(255, 65, 82, 112), 2) $jointPen = [Drawing.Pen]::new([Drawing.Color]::FromArgb(255, 255, 94, 122), 3) $bonePen = [Drawing.Pen]::new([Drawing.Color]::FromArgb(210, 79, 211, 255), 4) $fontTitle = [Drawing.Font]::new('Segoe UI Semibold', 27) $fontPanel = [Drawing.Font]::new('Segoe UI Semibold', 18) $fontText = [Drawing.Font]::new('Segoe UI', 13) $g.DrawString('XIN YIN — FRONT-RIGHT ASSEMBLY VALIDATION V4', $fontTitle, $titleBrush, 42, 26) $g.DrawString('reference / extracted-part assembly / pivot and hierarchy check', $fontText, $mutedBrush, 45, 68) $panelXs = @(42, 624, 1206) foreach ($panelX in $panelXs) { $g.FillRectangle($panelBrush, $panelX, 112, 552, 820) $g.DrawRectangle($panelPen, $panelX, 112, 552, 820) } $g.DrawString('A ASSEMBLED REFERENCE', $fontPanel, $titleBrush, 62, 132) $g.DrawString('B PARTS RECONSTRUCTION', $fontPanel, $titleBrush, 644, 132) $g.DrawString('C PIVOT / HIERARCHY', $fontPanel, $titleBrush, 1226, 132) $reference = [Drawing.Bitmap]::new($referencePath) $g.DrawImage($reference, 112, 186, 414, 716) $g.DrawImage($assembly, 650, 172, 500, 760) $g.DrawImage($assembly, 1232, 172, 500, 760) $bones = @( @((215,62),(296,94),(334,258),(347,388)), @((205,194),(207,187),(213,260),(220,350)), @((213,220),(146,214),(130,307),(89,214)), @((213,220),(276,214),(289,309),(296,389)), @((220,350),(195,350),(178,480),(160,685)), @((220,350),(244,350),(252,487),(260,700)) ) foreach ($chain in $bones) { for ($i = 0; $i -lt $chain.Count - 1; $i++) { $x1 = 1232 + $chain[$i][0] $y1 = 172 + $chain[$i][1] $x2 = 1232 + $chain[$i + 1][0] $y2 = 172 + $chain[$i + 1][1] $g.DrawLine($bonePen, $x1, $y1, $x2, $y2) } foreach ($point in $chain) { $g.DrawEllipse($jointPen, 1232 + $point[0] - 6, 172 + $point[1] - 6, 12, 12) } } $g.DrawString('Corrected chain:', $fontText, $titleBrush, 1240, 862) $g.DrawString('separate upper arms / forearms / hands / three-part ponytail', $fontText, $mutedBrush, 1240, 888) $g.DrawString('C28/C29 restored as torso-mounted armor', $fontText, $mutedBrush, 1240, 912) $board.Save($previewPath, [Drawing.Imaging.ImageFormat]::Png) $reference.Dispose() $fontText.Dispose(); $fontPanel.Dispose(); $fontTitle.Dispose() $bonePen.Dispose(); $jointPen.Dispose(); $panelPen.Dispose() $panelBrush.Dispose(); $mutedBrush.Dispose(); $titleBrush.Dispose() $g.Dispose(); $board.Dispose() } finally { foreach ($image in $images.Values) { $image.Dispose() } $assemblyGraphics.Dispose() $assembly.Dispose() } Write-Output $assemblyPath Write-Output $layoutPath Write-Output $previewPath