If you’re as lazy as me you want to be able to press one button (or run one .bat file) to get your game sprites rendered and processed right into the final format and directory, so you can see them in the game.
First, you need a model with animations. In this example, I’m using “Male NPC Pack” from Cubix Studio.
They make excellent stuff, easy to work with and very reasonably priced to boot.
Next, get Sprite Render Tool. It’s a neat little max script utility that automates the rendering of different angles.
I made a few additions to the script for my specific needs:
- Always renders 0,1,2 etc even with frame skipping
- Restores default settings upon most errors now (how they were before the script was run)
- Added direction in text option (uses “left” in filename instead of the degrees)
- Added “ignore directions that can be mirrored” option
- Added way to reverse the rotation
- Added “set_target_dir” command to batch commands
- Add batch commands to change directions, nth frames, etc flexibly for certain anims
- Automatically sets up batch.txt as the batchfile if found in the same dir as the model
- Added dos_command_in_target_dir batch command, so I can do various dos-things on the fly
Here is my hacked up version if you want it: spriterendertool091r4_with_seths_hacks.zip
Here is the Sprite Tool batch file used to render our three animations (walk, attack, idle) in all directions (actually 5, because we mirror some of them):
#help_batchfile usage: (outputfile) (startframe) (endframe) set_target_dir "../../../bin/worlds/RT_TopViewRPGTest/script/char/man/art" #Sure, I could just do *.png but who knows when a dir won't exist or something and it will run this in the #wrong place Safety first. dos_command_in_target_dir "del walk*.png" dos_command_in_target_dir "del idle*.png" dos_command_in_target_dir "del attack*.png" dos_command_in_target_dir "del die*.png" nth_frame 13 directions 8 idle_$.png 6 65 dos_command_in_target_dir "smartcropper idle" nth_frame 3 directions 8 walk_$.png 67 99 dos_command_in_target_dir "smartcropper walk" nth_frame 3 directions 8 attack_$.png 406 424 dos_command_in_target_dir "smartcropper attack"
Now, one issue with my particular game engine is all the sprites in a single animation should all be the same size, yet be small as possible.
In the example batch file above, the “smartcropper attack” command does this.
SmartCropper is a tiny command-line utility that scans a sequence of images, then crops them all at the smallest combined enclosing rectangle.
That way, you don’t have to worry about making the camera tightly fit the subject in Max.
Looking at the output, you can see it cropped the images to the best fit per sequence.
Here is SmartCropper with source (with a MSVS 2005 project), you’d need ClanLib if you wanted to modify/compile it.
And here they are in the test RPG level, “Smart shadows” have been enabled for them.