Convert .vert/.tri pairs into obj with simple bash script

Alec Jacobson

May 13, 2011

weblog/

Here's a tiny bash script you can save in verttri2obj.sh to convert .vert/.tri pairs like those of the TOSCA mesh repository:
#!/bin/bash
cat $1 | sed -e "s/^/v /g" > $3
cat $2 | sed -e "s/^/f /g" >> $3
And call it with:
./verttri2obj.sh mesh.vert mesh.tri mesh.obj
Update: Here's a little bash oneliner that uses the script above to convert all the .vert/.tri pairs in a directory to objs:
ls -1 *.vert | sed -e "s/\(.*\).vert/~\/path\/to\/verttri2obj.sh \1.vert \1.tri \1.obj/g" | bash
Converting the entire TASCO repository above took about a minute and a half on my computer.