February 9, 2012 3 Responses

Export Characters to Sprites with 3ds Max

One big issue of my last 2D and 2.5D game projects was to automate and optimize the character’s export process. For that I’ve developed a small exporter tool for 3ds Max written in MAXScript which could render your frames in a batch.
So, if you are working with 3ds Max and are building 2D or 2.5D (isometric) games e.g. with Starling or ND2D, than this script might be useful.

To get started please download the source files // CharacterExporter

After unzipping the ZIP file launch 3ds Max and install the exporter script by either selecting MAXScript / Run Script…

and then select “CharacterExporter.mzp” from the source files and click open

or just dragging the mzp file right into the 3ds Max application. Max will install all needed files automatically into the right places.

Next step is to add the exporter tool to a toolbar by opening the Customize User Interface Panel (Customize / Customize User Interface).
Click the  ”Toolbars” tab and choose “Electronauts” as the category. Finally drag the “Character Exporter” icon to a toolbar of your choice.

Now you are ready to go. Click the icon to open up the CharacterExporter panel.

The exporter provides you the following options:

  1. Select your “RenderStage”
    When exporting the characters will be loaded into the render stage and rendered with the provided settings.
    I’ve included a sample render stage which contains the must have elements. It’s a base for modifications e.g. different light settings or different renderers like VRay. It’s  mandatory that there’s a camera named “Camera”.
  2. Adjust how many directions or different angles shall be rendered
  3. Export

After pressing the “Export” button the exporter will ask you for the source and the target folder to export the images into.

It’s important to maintain the source folder structure (please also see the “source” folder in the archive):
Every character must have its own folder. Inside this folder the different animation types like “idle”, “walk” or “attack” have to be setup in different .max files.
The exporter will now scan the source folder and render all files in a batch. It will adopt the animation length and the render dimensions defined in the files.

One of the best tools to create sprite sheets out of all those frames is TexturePacker.

Now some slightly more advanced stuff:
Sometimes it is important to attach e.g. a flash animation to the character’s weapon muzzle which is moving in space frame by frame. To handle this you can define dummy objects, put them in the right place and attach them to your character. Just prefix them with “pivot_” e.g. “pivot_muzzle” and the exporter stores the offsets of the according pivot frame by frame in a JSON file (if you’re using Chrome this extension for formatting JSON files is quite handy).

The offset defines the x and y distance from the image’s center to the pivot’s transformed 2D postion, e.g. the x/y offset of “pivot_muzzle_left” in the first frame of the provided “die” animation example  is -56/-55, which is defined in the “pivot_muzzle_left” array of the “die” object:

1
2
"pivot_muzzle_left": [
     {"x": -56,"y": -55},
"pivot_muzzle_left": [
     {"x": -56,"y": -55},

To grab the the right offset object out of the array you can use this formula:

1
index = (currentDirection - 1) * numberOfAnimationFrames + currentFrame
index = (currentDirection - 1) * numberOfAnimationFrames + currentFrame

 

Filed in 3ds Max

3 Responses

  1. Peter Strømberg on February 12, 2012, 4:45 pm Reply

    Great stuff, thanks for sharing :O)

    After seeing Dungeon King, and having pulled my hair out attempting realitme animation, I’m tempted to give this approach a go, ignoring the fact that I’m actually not a games programmer.
    http://bulletproofarcade.com/games/DungeonKing

    Inspiring

  2. Pingback:Export Characters to Sprites with 3ds Max – BJÖRN ACKER | Interactive Media | Everything about Flash | Scoop.it

  3. 3d max kursu on March 11, 2012, 10:05 pm Reply

    lol. thanks for this article.

Leave a Reply

Your address will not be published.


+ 6 = 8