Sunday, November 28, 2010

Exporting to sauerbraten, using blender and the SMD format

For those of whom have traversed the Internet for free games you probably have at least heard of Sauerbraten http://sauerbraten.org/, which is the successor to the original Assault Cube http://assault.cubers.net/ which still is a pretty fun game to play. Anyway moving along as you might of heard from one of my other posts namely (and only) on my previous post you may of heard that I'm partaking in making of a game and for the mean time the cube II engine has taken our fancy to be the engine that we will build off.  Since I'm currently the only programmer/technical dev on the team it was up to me to get the environment setup. Because we plan to do all our modeling in blender more specific the development builds so 2.5 which has broken a few plug-ins that was needed for us to able to continue production. Namely the md3 exporter and i think the there was a md5 exporter as well which was mainly used in the original Sauerbraten game. Luckily for us the cube II engine supports a wide variety of formats for the models http://sauerbraten.org/docs/models.html in which i was quite delighted to see. So in the search to find a compatible export plug in for one of the supported formats other then obj which can only be used for static models so no animation nor rigging can be applied. I eventually came across the smd format, which you may of may not heard of but you would of defiantly heard of the games that uses it, its the format that valve games use, such as Half Life and Team Fortress. In general i was quite happy to see this this means that we would be able to use these models in the source engine as well, Gary's mod anyone?

Well anyway lets get back on topic, I discovered a smd import/export plug in that is compatible with blender 2.5.

here is the the projects page: https://code.google.com/p/blender-smd/

the smd format support in sauerbraten is from what i can tell is fully fleshed out and has all the same options as its support for MD5 which what i was originally going for. So lets take a look on the steps involved in exporting to a SMD and then the process of configuring and setting it up so that it is ready to be used in the cube II engine.


Step 1
First of we need to download and install the blender-smd plugin. go to https://code.google.com/p/blender-smd/ and download the latest version of the plugin(io_smd_tools). Then extract the zip folder to any temporary path. Open up blender and click "File" >> "User Preferences" (shortcut Ctrl + Alt U) to get into blender's application settings. Then navigate to the "Add-Ons" then click install select the extracted file from the download earlier. Once you go the plugin file selected click "Install Add-On". Then in the Import/Export section "Import/Export SMD Tools" and check it to enable the plug in. Remember to click "Save As Default" at the end so that this plug in is enabled by default each time you open up blender.






    Step 2
    Now its time for the easy part which is making model and exporting it, there is a few things that you will need to keep in mind in regarded to exporting you models in SMD for the cube II engine. The main thing you need to keep in mind is that name of the material you use for the model. Though the actual settings i believe don't get transported into the export, this is so when it comes to adding the color, normal(bump), spec maps that you know the name of the material to apply it to. When it comes to actually exporting the model you will find the SMD tools menu in the scene menu in the buttons panels, its a simple process of selecting the output folder for the project and the models that you wish to export.
     



    Step 3 
    Now move the model, and a copy of the textures you wish to apply to it in the game to sauerbraten's <base>/packages/model/<model's folder> so that the engine can find it when you call it. and now we need to create a file called "smd.cfg" inside the model's folder so that we configure the model for the game. here is an example of the "smd.cfg" and what it might look like.

    example configureation
    smdload crate02.smd // model no. 0
    smdskin crate02 skin.png

    mdlscale 1500
    end of example configuration

    The first line "smdload crate02.smd" tells  the cube II engine where the model file is located. the second line "smdskin crate02 skin.png" instructs the engine to apply the objects texture map or "skin" as it is referred too to the material. (note: "crate02" is the name of the material inside "crate02.smd" remember if you did not name the material in blender then "smdskin Material skin.png" would be what you would have to enter.)
    Lastly the "mdlscale 1500" this line is needed because blender units may look large in blender but the cube  II engine to treats 1 blender unit as like 1 inch in size the 1500 actually tells it to scale the object 1500% of it original size.

    (this is just a very basic configuration if you want to set things like the normal map (bump map) Look to the model documentation you may notice that the SMD section is not explained but that only because all the SMD options are identical to MD5 the only difference is that "md5" in all the commands is replaced with "smd" "md5load" = "smdload" etc.)


    Step 4
    now all that i s left is to import the model in the game engine to do so, in the command shell in the cube II engine whilst editing a map. Simply type "mmodel <model'd folder path>" eg. model's folder is in <base>/packages/models/crate02 then the command will be "mmodel crate02" to import the model. and the rest you should already know if you've messed around in the cube II map editor.

    The Greetings...

    Introduction  
    This would have to be my fourth attempt of setting up a blog for me, strangely enough I feel that this time i may just be keeping this one up and running. Why the sudden change in heart? well for many reasons first off i need to "get out there" and have my name seen without the silly alias and actually get a name for my self. Because of my many interests in life and a lot of it revolves around multimedia, programming and art in general i need a name and a home base to be found on. Secondly for the educational purposes more or less i want to sharpen my skills and lastly just for the fun of it.. ;)

    Site Layout
    For those whom end up reading my entries just to get the site layout stuff out of the way there are 3 main sections the first off is the "blog" section this is where I'll just be adding my general entries about things i feel like posting about. The "art" section this section will have all my art entries add too, I'll also be posting things like tutorials, tips and suggestions and all that other good stuff when i eventually get back into the swing of things. And lastly is the "dev" section, this is where all my project entries will be posted too. Just to give you an idea of the kind of stuff that will be going into there, me and a few comrades are making our own game... granted I already know how much of a challenge that is going to be but thats one of the reasons why I'm doing it i'll be posting more stuff about that later.

     Well I'll leave babbling on for later entries, lets see how this turns out.

    Getting back into the swing of things


    It feels like it's been a long time since I've put pencil to paper and draw, well that how the saying goes anyway. I can definitely see that my skills have gotten rusty from the past four months of negligence. Geez... Though I am partially satisfied with the way the last one came though it gave me the hardest time out of the lot. Probably not hat hard to tell but its actually a quick knock-up portrait of Misshannahminx one of those youtube girls that i so happen to come across whist searching for Japanese food X3.  
     

    Though admittedly I'm relatively frustrated about how I can never really seem to get anything more then a resemblance when i try and produce portraits of people. I think it's always the eyes that fail me I can never quite get them right when I'm drawing from a reference image. If i remember correctly I redrew her eyes 4-5 times before i was satisfied enough not to scrub them out again.

    Well i guess this counts as my first art blog post X3, hopefully with a bit of time i can get a bit of a portfolio happening.