Serious Sam 2 AMF format Plugin

WOOT! It’s done! :smiley:

Project Goals:
My goal is to develop a plugin for Blender that will read and write to the AMF format used by the 3D game Serious Sam 2. (Note that this is not the same thing as the Flash AMF format.) Actually, the true goal of my project is to be able to generate normal maps in Blender and then export to SED2. Serious Editor 2 can handle animation and modelling; everything except UVmap baking. (This is normally done using Lightwave, which is what Croteam used but which very few Serious Sam fans can afford.) If I can construct and normal-map a highpoly mesh onto a lowpoly mesh in Blender, and then I still have to do rigging and animation in Serious Editor, I’ll be satisfied.

Serious Engine Model Formats (zipped html files)

AMF format Specifications (HTML… sorta)

Example of AMF format:
This is a simple cube, created in Serious Editor 2 and exported to AMF format, and then opened with Notepad. As you can see, it is a very human-readable format. Whitespace and parenthesis will have to be navigated and things in quotes will have to be parsed… I assume that other formats exist like this and that other plugins have been devised to address this. Hopefully I will be able to apply techniques pioneered by other plugin writers to get the job done.


SE_MESH 1.01
LAYERS 1
{
  LAYER_NAME "Undefined"
  LAYER_INDEX 0
  {
    VERTEX_MAPS 2
    {
      VERTEX_MAP "morph.position"
      {
        ELEMENTS 8
        {
          { -1, 1, -1; }
          { 1, 1, -1; }
          { -1, 1, 1; }
          { 1, 1, 1; }
          { -1, -1, 1; }
          { 1, -1, 1; }
          { -1, -1, -1; }
          { 1, -1, -1; }
        }
      }
      VERTEX_MAP "texcoord.Default"
      {
        ELEMENTS 24
        {
          { 0, 0; }
          { 0, 1; }
          { 1, 0; }
          { 1, 1; }
          { 0, 0; }
          { 0, 1; }
          { 1, 0; }
          { 1, 1; }
          { 0, 0; }
          { 0, 1; }
          { 1, 0; }
          { 1, 1; }
          { 0, 0; }
          { 0, 1; }
          { 1, 0; }
          { 1, 1; }
          { 0, 0; }
          { 0, 1; }
          { 1, 0; }
          { 1, 1; }
          { 0, 0; }
          { 0, 1; }
          { 1, 0; }
          { 1, 1; }
        }
      }
    }
    VERTICES 24
    {
      { 2: 0[0], 1[0]; }
      { 2: 0[1], 1[1]; }
      { 2: 0[2], 1[2]; }
      { 2: 0[3], 1[3]; }
      { 2: 0[4], 1[4]; }
      { 2: 0[5], 1[5]; }
      { 2: 0[6], 1[6]; }
      { 2: 0[7], 1[7]; }
      { 2: 0[3], 1[8]; }
      { 2: 0[1], 1[9]; }
      { 2: 0[5], 1[10]; }
      { 2: 0[7], 1[11]; }
      { 2: 0[0], 1[12]; }
      { 2: 0[2], 1[13]; }
      { 2: 0[6], 1[14]; }
      { 2: 0[4], 1[15]; }
      { 2: 0[2], 1[16]; }
      { 2: 0[3], 1[17]; }
      { 2: 0[4], 1[18]; }
      { 2: 0[5], 1[19]; }
      { 2: 0[1], 1[20]; }
      { 2: 0[0], 1[21]; }
      { 2: 0[7], 1[22]; }
      { 2: 0[6], 1[23]; }
    }
    POLYGONS 6
    {
      { 4: 0, 2, 3, 1; }
      { 4: 4, 6, 7, 5; }
      { 4: 8, 10, 11, 9; }
      { 4: 12, 14, 15, 13; }
      { 4: 16, 18, 19, 17; }
      { 4: 20, 22, 23, 21; }
    }
    POLYGON_MAPS 1
    {
      POLYGON_MAP_NAME "surface.Default"
      POLYGON_MAP_SMOOTHING_ANGLE 89
      POLYGONS_COUNT 6
      {
        0;
        1;
        2;
        3;
        4;
        5;
      }
    }
  }
}
 

Challenges:
I am not a python scripter, nor a Blender expert. I should be able to get help from the Blender community in learning how to express my ideas as python code and help from Croteam/Serious Sam 2 community in understanding the (largely self-explainatory) file format. The code will probabaly be buggy at first, and who knows how hard the development process actually is on something like this? None of the people currently working with Serious Sam 2 content seem interested in Blender, and vice-versa, so I’ll have to bridge the gap bewteen communities while learning all about python, blender plugins, and the AMF format.

Project Resources:
Serious Engine Model Formats (zipped)
Pastebin for this exporter (W.I.P.)
Serious Editor 2 (for testing the AMF files generated by this plugin)

Blender/Python coding Resources:
Blender-Python Export Tutorial
Python Docs
Introduction to Python
Blender API docs
Import/Export python scripts for various file formats
Optimization (exporter-specific notes!)

Communities:
Serious Sam Community Forums
Blender Artist Community Forums
#Blender at Freenode

Old News:

I’ve found out that absolutely anyone can download the 2.070 patch for Serious Sam 2, which includes the fully-functional Serious Editor 2. This means that you don’t need to own a copy of Serious Sam 2 in order to help debug the exporter! :smiley:

The Serious Spoon over at Seriously! has spoken up with some insight into our error message.

ShortWave attempted to beat knowlege into my head with a stick over IRC, and also severely corrected my approach. If this project ever gets finished, it will be because of ShortWave. Seriously. Send money and babes to ShortWave’s house. He did all the work.

Alen Ladavac from Croteam was kind enough to send me the Specifications for all of Croteam’s proprietary file formats, including AMF.

Code and output has been moved further down due to character-per-post limitations

Current Status:
DONE.
Extra-special thanks to ShortWave for making this plugin possible. :smiley:

CALLING ALL BLENDERHEADS:
Thanks for all your support! If you’d like to take things a step further and help develop a full-fledged 2-way pipeline, the tools are right here.

Serious Engine Model Formats (zipped) (information on Croteam’s proprietary formats)
Serious Editor 2 (for testing output)

Thank you and happy Blending! :slight_smile: