87 lines
2.7 KiB
Batchfile
87 lines
2.7 KiB
Batchfile
@echo off
|
|
chcp 65001 >nul
|
|
setlocal
|
|
|
|
rem ==========================================================================
|
|
rem reexport_glb.bat - GLB re-export launcher (ASCII-only on purpose)
|
|
rem
|
|
rem Re-exports existing .glb files through Blender with the current export
|
|
rem settings. Originals are replaced IN PLACE and backed up first into
|
|
rem <input>\_glb_backup .
|
|
rem
|
|
rem Usage:
|
|
rem double-click -> re-export DEFAULT_DIR
|
|
rem drag a folder onto this bat -> re-export that folder
|
|
rem reexport_glb.bat "DIR" -> re-export DIR
|
|
rem reexport_glb.bat "DIR" --tex-format jpeg --tex-quality 85
|
|
rem
|
|
rem NOTE: do NOT add --draco here. Godot does not read Draco-compressed
|
|
rem glTF unless you install a decoder extension.
|
|
rem ==========================================================================
|
|
|
|
set "HERE=%~dp0"
|
|
set "SCRIPT=%HERE%convert_models.py"
|
|
|
|
rem ---------------------------- default folder ------------------------------
|
|
set "DEF_DIR=E:\Godot\agame\assets\GLB"
|
|
|
|
rem ---------------------------- target folder -------------------------------
|
|
set "TARGET=%~1"
|
|
if "%TARGET%"=="" set "TARGET=%DEF_DIR%"
|
|
if not exist "%TARGET%" set "TARGET=%DEF_DIR%"
|
|
if "%TARGET:~-1%"=="\" set "TARGET=%TARGET:~0,-1%"
|
|
|
|
rem ---------------------------- extra flags ---------------------------------
|
|
set "EXTRA="
|
|
if not "%~2"=="" set "EXTRA=%~2"
|
|
if not "%~3"=="" set "EXTRA=%EXTRA% %~3"
|
|
if not "%~4"=="" set "EXTRA=%EXTRA% %~4"
|
|
if not "%~5"=="" set "EXTRA=%EXTRA% %~5"
|
|
if not "%~6"=="" set "EXTRA=%EXTRA% %~6"
|
|
|
|
rem ---------------------------- find python ---------------------------------
|
|
set "PY="
|
|
|
|
where py.exe >nul 2>nul
|
|
if %errorlevel% equ 0 set "PY=py -3"
|
|
|
|
if not defined PY (
|
|
where python.exe >nul 2>nul
|
|
if not errorlevel 1 set "PY=python"
|
|
)
|
|
|
|
if not defined PY if exist "D:\dev\python\python3.13.7\python.exe" set "PY=D:\dev\python\python3.13.7\python.exe"
|
|
|
|
if not defined PY (
|
|
echo [ERROR] Python not found. Edit PY in this file.
|
|
echo.
|
|
pause
|
|
exit /b 2
|
|
)
|
|
|
|
if not exist "%SCRIPT%" (
|
|
echo [ERROR] convert_models.py not found next to this bat:
|
|
echo %SCRIPT%
|
|
echo.
|
|
pause
|
|
exit /b 2
|
|
)
|
|
|
|
echo ==========================================================
|
|
echo Re-export GLB (in place + backup)
|
|
echo Folder : %TARGET%
|
|
echo Backup : %TARGET%\_glb_backup
|
|
echo ==========================================================
|
|
echo.
|
|
|
|
%PY% "%SCRIPT%" --re-export --input "%TARGET%" %EXTRA%
|
|
set "RC=%errorlevel%"
|
|
|
|
echo.
|
|
echo ----------------------------------------------------------
|
|
if "%RC%"=="0" echo DONE.
|
|
if not "%RC%"=="0" echo FINISHED WITH ERRORS (exit code %RC%). See _glb_backup\_convert_report.txt
|
|
echo ----------------------------------------------------------
|
|
pause
|
|
endlocal & exit /b %RC%
|