# runbatchscript 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 off

#lazy, working on the desktop is a bad idea!
!assetpath C:\Documents and Settings\NetYaroze\Desktop\out-h3d

#auto create a del folder and move all test files to it
mkdir del
move test* del

# export obj, H3D demo/viewer uses a few meters for world view by default, so have to make it small
!objexport NewObject(freeze) test.obj 0.0022
#assimp_viewer.exe test.obj

# if you don't see Assimp download it from:
# https://archive.org/details/assimp-master-build-21-jan-2023-winxp
# and add the location of the binary to your system envirnoment path variable.
assimp export test.obj test.dae
assimp_viewer.exe test.dae


# info on compiling Horde3D for windows XP with GL2+ https://github.com/horde3d/Horde3D/issues/213

# copy it to raw location for convertion, see h3d docs
copy /Y test.* C:\horde3d-assets\Raw

# clear folders
move /Y C:\horde3d-assets\Content\models\test C:\horde3d-assets\Content\models\test.del
mkdir C:\horde3d-assets\Content\models\test

#copy images to "game" location, should be converted to png or something
copy /Y *.bmp C:\horde3d-assets\Content\models\test


!assetpath  C:\horde3d-assets\Raw

#batch file wrapper for the converter exec to auto convert dae file into h3d format and puts it in my "game" scene location.
conv-model.bat test.dae

!assetpath  C:\horde3d-assets\Content\models\test

# overwrite created shader xml with correct one that includes normal mapping
# Case is important!

echo ^<Material^> > NewMaterial.material.xml
echo    ^<Shader source="shaders/model.shader" /^>  >> NewMaterial.material.xml
echo    ^<ShaderFlag name="_F02_NormalMapping" /^>  >> NewMaterial.material.xml
echo    ^<Sampler name="albedoMap" map="models/test/test0.bmp" /^>  >> NewMaterial.material.xml
echo    ^<Sampler name="normalMap" map="models/test/test1.bmp" /^>  >> NewMaterial.material.xml
echo ^</Material^>  >> NewMaterial.material.xml

 



!assetpath  C:\horde3d-assets\Content
h3dv.exe test