Collada Model cleanup scripts
by Jeff Yaskus · 07/17/2015 (11:53 am) · 4 comments
This resource is a follow up to my previous forum post, to address the NaN issues and other warning messages when using the stock assets.
Since the Collada files are simple XML format, it just requires a few edits to resolve the common issues. Besides NaN warnings, most art I've found also has hard coded paths to the source textures. When imported it to T3D, it causes failures until we open it in the Editor and correct the materials manually.
In fact, I've found that by editing the Collada files by hand -- its easily possible to correct the names used by the images for textures. In some cases this is required, like if they start the texture name with a number or include special characters in its name.
Original forum post
www.garagegames.com/community/forums/viewthread/132930
First, I wanted to eliminate any of the NaN warning messages. While just a warning, it was unnecessary clutter.
I placed this script in my cygwin home directory and called it simply: fixNaN
and then run it as:
Next, I created a similar script for the hard coded texture path and extensions.
I also placed it in my cygwin home directory and called this one: fixIt
To use this script requires passing a parameter.
Here are the (2) examples I use, to correct the hard coded paths and such.
Together that seems to clear up all the issues and spam I had come across.
And if you come up with a better solution, please let me know!
p.s. if you aren't google savvy ... let me help with the location of cygwin;
www.cygwin.com/
It downloads an installer, which then lets you select packages to download, etc.
For this effort the defaults are ok, just need to get a cygwin prompt.
Since the Collada files are simple XML format, it just requires a few edits to resolve the common issues. Besides NaN warnings, most art I've found also has hard coded paths to the source textures. When imported it to T3D, it causes failures until we open it in the Editor and correct the materials manually.
In fact, I've found that by editing the Collada files by hand -- its easily possible to correct the names used by the images for textures. In some cases this is required, like if they start the texture name with a number or include special characters in its name.
Original forum post
www.garagegames.com/community/forums/viewthread/132930
First, I wanted to eliminate any of the NaN warning messages. While just a warning, it was unnecessary clutter.
I placed this script in my cygwin home directory and called it simply: fixNaN
SEARCH="NaN"
echo "searching all DAE files for: ${SEARCH}"
#build file list
find . -name "*.dae" -print > file.list
find . -name "*.DAE" -print >> file.list
for FILE in `cat file.list`;
do
test=`grep ${SEARCH} $FILE | wc -l`;
if [ $test -gt 0 ]; then
printf "$FILE : $test issues found";
sed -i 's/NaN/0/g' $FILE
echo "... corrected $FILE"
else
echo " $FILE ok"
fi
doneTo use it
I cd into my game/art directory (under projects or simply the template)and then run it as:
~/fixNaN
searching all DAE files for: NaN
./shapes/actors/Soldier/Anims/PlayerAnim_Lurker_Back.dae ok
./shapes/actors/Soldier/Anims/PlayerAnim_Lurker_Celebrate_01.dae ok
./shapes/actors/Soldier/Anims/PlayerAnim_Lurker_Crouch_Backward.dae ok
...
./shapes/actors/Soldier/FP/FP_SoldierArms.DAE ok
./shapes/actors/Soldier/soldier_rigged.DAE : 8 issues found... corrected ./shapes/actors/Soldier/soldier_rigged.DAE
./shapes/Cheetah/Cheetah_Body.DAE ok
./shapes/Cheetah/Cheetah_Turret.DAE ok
./shapes/Cheetah/wheel.DAE ok
./shapes/Cheetah/wheelBack.DAE ok
./shapes/teleporter/teleporter.DAE ok
./shapes/trees/defaulttree/defaulttree.DAE ok
./shapes/weapons/Lurker/FP_Lurker.DAE : 2 issues found... corrected ./shapes/weapons/Lurker/FP_Lurker.DAE
./shapes/weapons/Lurker/TP_Lurker.DAE : 8 issues found... corrected ./shapes/weapons/Lurker/TP_Lurker.DAE
./shapes/weapons/ProxMine/FP_ProxMine.DAE : 2 issues found... corrected ./shapes/weapons/ProxMine/FP_ProxMine.DAE
./shapes/weapons/ProxMine/TP_ProxMine.DAE : 6 issues found... corrected ./shapes/weapons/ProxMine/TP_ProxMine.DAE
./shapes/weapons/Ryder/FP_Ryder.DAE : 2 issues found... corrected ./shapes/weapons/Ryder/FP_Ryder.DAE
./shapes/weapons/Ryder/TP_Ryder.DAE : 2 issues found... corrected ./shapes/weapons/Ryder/TP_Ryder.DAE
./shapes/weapons/shared/RifleShell.DAE : 4 issues found... corrected ./shapes/weapons/shared/RifleShell.DAE
./shapes/trees/defaulttree/defaulttree.DAE ok
./shapes/weapons/Lurker/FP_Lurker.DAE : 3 issues found
... corrected ./shapes/weapons/Lurker/FP_Lurker.DAE
./shapes/weapons/Lurker/TP_Lurker.DAE : 3 issues found
... corrected ./shapes/weapons/Lurker/TP_Lurker.DAE
./shapes/weapons/ProxMine/FP_ProxMine.DAE ok
./shapes/weapons/ProxMine/TP_ProxMine.DAE ok
./shapes/weapons/Ryder/FP_Ryder.DAE : 3 issues found
... corrected ./shapes/weapons/Ryder/FP_Ryder.DAE
./shapes/weapons/Turret/Turret_Head.DAE ok
./shapes/weapons/Turret/Turret_Legs.DAE ok(I chopped 90% of the output, to reduce clutter on this page ... but hopefully you get the idea)Next, I created a similar script for the hard coded texture path and extensions.
I also placed it in my cygwin home directory and called this one: fixIt
if [ $# -ne 1 ]; then
echo "ex. [[6288105ea991e]] String_to_remove"
exit
fi
SEARCH=
echo "searching all DAE files for: $SEARCH "
#build file list
find . -name "*.dae" -print > file.list
find . -name "*.DAE" -print >> file.list
for FILE in `cat file.list`;
do
test=`grep ${SEARCH} $FILE | wc -l`;
if [ $test -gt 0 ]; then
echo "$FILE : $test issues found";
cat $FILE | grep -v "${SEARCH}" > temp.$$
mv temp.$$ $FILE
echo "... corrected $FILE"
else
echo " $FILE ok"
fi
doneTo use this script requires passing a parameter.
Here are the (2) examples I use, to correct the hard coded paths and such.
~/fixIt "file:" ~/fixIt "\.psd"
Together that seems to clear up all the issues and spam I had come across.
And if you come up with a better solution, please let me know!
p.s. if you aren't google savvy ... let me help with the location of cygwin;
www.cygwin.com/
It downloads an installer, which then lets you select packages to download, etc.
For this effort the defaults are ok, just need to get a cygwin prompt.
About the author
Long time gamer, hacker and programmer. With dreams of making video games -
#2
07/17/2015 (12:04 pm)
correction: [[55a9518474b7c]] should be $0 but I wont edit it in fear of messing up the rest of the code.
#3
07/17/2015 (5:31 pm)
Tip : When you edit the post after the first time, it will mess up all quotes through the posting. I've learned that this week after at least a decade of posting here :)
#4
07/21/2015 (8:17 pm)
Cool! Thanks for sharing! 
Torque Owner Jeff Yaskus
jy games