Live-command corrections (atlas corridor-status, real body-ID naming), failure-proofed glb-gen/sprite-gen render scripts, Trellis API reference extracted. image-gen: fixed the output-path bug and de-forked the local image_connector.py to the canonical tooling/db/ copy. ticket skill consolidated to point at ticket-cli.md (setparent-none fix applied there too). Part of T-1099. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
72 lines
2.4 KiB
Bash
Executable File
72 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Render a 3D model to 2D sprites at 3 resolutions from 4 cardinal directions.
|
|
# Usage: render.sh <model_name> [godot_path]
|
|
# Example: render.sh wall_structural
|
|
set -euo pipefail
|
|
|
|
MODEL_NAME="${1:?Usage: render.sh <model_name> [godot_path]}"
|
|
GODOT="${2:-$HOME/bin/godot}"
|
|
REPO_ROOT="$(cd "$(dirname "$0")" && git rev-parse --show-toplevel)"
|
|
PROJECT="$REPO_ROOT/renderer"
|
|
SCENE="res://render_scene.tscn"
|
|
OUTPUT="$PROJECT/output"
|
|
|
|
# Verify model exists
|
|
MODEL_FILE="$PROJECT/models/${MODEL_NAME}.tscn"
|
|
if [ ! -f "$MODEL_FILE" ]; then
|
|
echo "ERROR: Model not found: $MODEL_FILE"
|
|
echo "Available models:"
|
|
ls "$PROJECT/models/"*.tscn 2>/dev/null | xargs -I{} basename {} .tscn
|
|
exit 1
|
|
fi
|
|
|
|
echo "Rendering: $MODEL_NAME"
|
|
echo "Godot: $GODOT"
|
|
echo "Project: $PROJECT"
|
|
|
|
# The render step (unlike --import) needs a display. Fail fast with a clear
|
|
# remedy instead of letting Godot die on a cryptic low-level GL/X error.
|
|
if [ -z "${DISPLAY:-}" ]; then
|
|
if command -v xvfb-run >/dev/null 2>&1; then
|
|
echo "No DISPLAY set — re-run under xvfb-run, e.g.:"
|
|
echo " xvfb-run -a $0 $MODEL_NAME${2:+ $2}"
|
|
exit 1
|
|
else
|
|
echo "ERROR: No DISPLAY set and xvfb-run is not installed."
|
|
echo " Install it (e.g. 'xorg-x11-server-Xvfb' on Fedora/RHEL, 'xvfb' on"
|
|
echo " Debian/Ubuntu), then re-run under xvfb-run -a."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Ensure resources are imported (headless, no display needed)
|
|
echo "Importing resources..."
|
|
"$GODOT" --path "$PROJECT" --headless --import 2>&1 || echo "Warning: import step had errors (may be non-fatal)"
|
|
|
|
# Clear stale output from any previous run of this model first, so a failed
|
|
# render can't be masked by leftover files from an earlier successful run.
|
|
rm -f "$OUTPUT/${MODEL_NAME}"_*.png
|
|
|
|
# Run Godot with the render scene, passing model name as user arg
|
|
"$GODOT" --path "$PROJECT" "$SCENE" -- "$MODEL_NAME" 2>&1
|
|
|
|
# Check output
|
|
FOUND_FILES=0
|
|
for dir in north east south west; do
|
|
for res in 1024 256 64; do
|
|
f="$OUTPUT/${MODEL_NAME}_${dir}_${res}.png"
|
|
if [ -f "$f" ]; then
|
|
FOUND_FILES=$((FOUND_FILES + 1))
|
|
fi
|
|
done
|
|
done
|
|
|
|
echo ""
|
|
echo "Generated $FOUND_FILES/12 files in $OUTPUT/"
|
|
ls -la "$OUTPUT/${MODEL_NAME}"_*.png 2>/dev/null || echo "No output files found."
|
|
|
|
if [ "$FOUND_FILES" -eq 0 ]; then
|
|
echo "ERROR: Godot produced no output files — render failed." >&2
|
|
exit 1
|
|
fi
|