gmzorz

objtocam.bat

Mar 13th, 2019
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.03 KB | None | 0 0
  1. @echo off
  2. setlocal Enabledelayedexpansion
  3.  
  4. :: .obj to cam converter
  5. ::
  6. ::  USAGE:
  7. :: Save this piece of text as *.bat and drag & drop .obj file
  8.  
  9. if [%1] == [] echo no file drop found & goto endMsg
  10. copy %1 %~n1_.txt
  11. set "file=%~n1_.txt"
  12. for /f "tokens=*" %%a in (%file%) do (
  13.     set line=%%a
  14.     if not "!line!"=="!line:v =!" (
  15.         echo !line! >> %~n1.txt"
  16.     )
  17. )
  18. del !file! /s /q >nul
  19. set /a "z=0" & for /f "tokens=2-4" %%a in (%~n1.txt) do (
  20.     set /a "numTicks+=10"
  21.     set /a "posX=%%a" 2>nul
  22.     set /a "posY=%%c" 2>nul
  23.     set /a "posZ=%%b" 2>nul
  24.     if !z! lss 1 (
  25.         set "campath=1_0/80/0/0/0/0/!posX!/!posY!/!posZ!;"
  26.         set /a "z+=1"
  27.     ) else (
  28.         set campath=!campath!!numTicks!/80/0/0/0/0/!posX!/!posY!/!posZ!;
  29.     )
  30. )
  31. echo !campath! > cam.tmp
  32. (
  33.     for /f "usebackqdelims=" %%a in (cam.tmp) do (
  34.         set "line=%%a"
  35.         set "line=!line:; =;!"
  36.         echo | set /p=!line!
  37.         )
  38. )>"%~n1.cam"
  39. del *.tmp /s /q >nul
  40. del %~n1.txt /s /q >nul
  41. goto eof
  42. :endMsg
  43. pause >nul
Advertisement
Add Comment
Please, Sign In to add comment