# C:\MarbleCLAY\Plugin\RunBatchScript.txt for MarbleClay PlayStation export.
# RSD Export/Obj batch script version 2 (May 2023)
# No warranty or liablity, very hacky stuff! Use at own risk.

# No defaulting of values below, all parameter values must appear!

# !assetpath C:\Documents and Settings\NetYaroze\Desktop
# This should be the first line executed!
# Spaces are fine in path, but dont put in quotes or a last back slash.
# Path can be change anytime, and the following commands will process in that folder.

# !rsdexport RootObjectName 1234567.rsd 1.0 0/1/2
# Names are Alphanumeric, no path included, no spaces, filename must be 7.3 formatted or less, 1.0 is the scale value, 0/1/2 can either be: 1:launch No$PSX,  0:Create TMD but skip No$PSX, or 2:ask
# See RSDExporter.txt for more information.
# !objexport is the same, except there is no launchpsx - note: no normals are exported.

#  !echo off / on
# Default is on, each DOS command's output will be displayed in a message popup, if off, it wont. 

# Everything else will be DOS commands and each passed to DOS, run in the current (!assetpath) location.
# Your commands can be log your output by >>file.log,  >NUL  2>NUL to null or everything will be displayed with !echo on.

#Recommendations :
# Using folders and files with no spaces, ASCII char's and DOS (or 7.3) filenames.
# Use echo on to see command and output when editing this script.
# You can not save this script while MarbleClay is running this script! Wait for it to end first.
# CD (chdir) will have no effect after that line has exectuted, you must use the !assetpath command.
# WARNING - strongly advise not deleting anything via this script, instead use move, if you have to run delete, always fully qualify individual files to avoid removing wrong files.
# Sometimes the message boxes from MarbleClay will be behind the application and it will look like it's locked up or crashed, it hasn't just hit Alt + Tab to find it, Also you'll see two MarbleClay windows in the toolbar, click the 2nd one.
# If you run a command and it's halted or pause (ie awaiting input), it will need to be killed via process explorer, for the script to finish.


#turn logging off  
@echo starting - wait a few seconds.
!echo off


# rm is from https://github.com/skeeto/w64devkit (busybox-w32 : standard unix utilities, including sh)
!assetpath C:\temp
rm -rf tmd
!assetpath C:\temp\tmd

!rsdexport F1 Left.rsd 10.0  0
!rsdexport F2 Center.rsd 10.0  0
!rsdexport F3 Right.rsd 10.0  0

!objexport F1 Left.obj 1.0  
!objexport F2 Center.obj 1.0  
!objexport F3 Right.obj 1.0  

rsd2tmd Left 1
rsd2tmd Center 1
rsd2tmd Right 1

#for backup
cp center.* C:\NY-WS\tmdanim\models\data
cp Left.* C:\NY-WS\tmdanim\models\data
cp Right.* C:\NY-WS\tmdanim\models\data


#create the frames to animate
cp center.tmd C:\NY-WS\tmdanim\tmd\F1.tmd
cp Left.tmd C:\NY-WS\tmdanim\tmd\F2.tmd
cp center.tmd C:\NY-WS\tmdanim\tmd\F3.tmd
cp Right.tmd C:\NY-WS\tmdanim\tmd\F4.tmd


#clearing past data
rm C:\NY-WS\tmdanim\tmd\*.pck
rm C:\NY-WS\tmdanim\tmd\*.mm
rm C:\NY-WS\tmdanim\tmd\*.txt


#running tmdanim - 2 frames per frame, loop, no normals, export MinMax
!assetpath C:\NY-WS\tmdanim\tmd
C:\NY-WS\tmdanim\tmd\tmdanim.exe -t3 -mm  -l

#running yarexe & no$psx
# make sure the NY main.exe and yarexe builds and runs

!assetpath C:\NY-WS\tmdanim
yarexe data.mak
wincmd no$psx C:\temp\run\psx.exe