Blender Model Compiler

BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
edited December 2016 in Modding
The day is finally here! I'm proud to finally be releasing a tool that allows you to compile .blend files directly into .model files for ns2. Unlike the previous release, this one is FULLY FEATURED -- that means animations and physics will properly export! Also unlike the previous release, this is not a script that will be run from within blender, but rather these scripts are designed to be run by builder.exe.

https://www.dropbox.com/s/k6r8z8uccdzig34/BlenderCompiler.exe?dl=1

Simply place that exe file in your Natural Selection 2 folder -- the same folder as Builder.exe -- and run it. You'll be prompted for the location of your blender executable.

The script will automatically make the necessary changes to builder_setup.xml so builder will run the program. It will also automatically copy the python scripts necessary to "Natural Selection 2/utils/blender_scripts"

To use the utility, simply start up a mod, and place a .blend file into the source directory. Builder will automatically find it, run the BlenderCompiler.exe file (it's not just an installer -- don't delete it!!!), which launches an instance of blender in the background that runs the scripts that do the exporting. Not any .blend will work, however. There is a small amount of prep that needs to be performed in the files to make the scripts accept them. See the "Spark Model Manual" for details (link in launchpad).

There's a feature in the blender compiler that allows you to output multiple .model files from a single .blend. This is useful for making different variations of a similar prop, or for breaking a prop into many pieces (eg catwalks). HOWEVER, what this means is that we're violating the assumption made by Builder.exe that every source file has exactly 1 output file. To deal with this, builder will always report a failed build when compiling blender files, but will also print out useful error text telling you what really happened, including if it was successful or not.

Long story short: do not trust builder when it says it failed. Read the error text and check your output to verify!.

I have tried to be thorough in the manual about how to use this tool, and I hope to have some quality example files for you to look at soon.

As usual, if you find any bugs please post here, and I'll get to them when I can. :)

Cheers!
Beige
Post edited by BeigeAlert on
NordicSupaFredSaffron_bakerFlaterectomy2coughUncleCrunchsXLg

Comments

  • UncleCrunchUncleCrunch Mayonnaise land Join Date: 2005-02-16 Member: 41365Members, Reinforced - Onos Posts: 1,542 Advanced user
    (Oh noooo; he posted!!!)

    Well...
    Building...
    1> Y:\Espace de travail - modder Jeux\Natural selection 2\Outer_rim_ark\output\models\ora\Test_FBX_builderEXE_direct.blend
    1> Executing '"C:\Program Files (x86)\Steam\steamapps\common\Natural Selection 2\BlenderCompiler" "Y:\Espace de travail - modder Jeux\Natural selection 2\Outer_rim_ark\source\models\ora\Test_FBX_builderEXE_direct.blend"'
    1> Exception in module register(): 'C:\\Users\\Tex\\AppData\\Roaming\\Blender Foundation\\Blender\\2.76\\scripts\\addons\\BoolTool.py'
    1> Exception in module register(): 'C:\\Users\\Tex\\AppData\\Roaming\\Blender Foundation\\Blender\\2.76\\scripts\\addons\\uv_squares.py'
    1> Traceback (most recent call last):
    1>   File "C:\Program Files\Blender Foundation\Blender\2.76\scripts\modules\addon_utils.py", line 343, in enable
    1>     mod.register()
    1>   File "C:\Users\Tex\AppData\Roaming\Blender Foundation\Blender\2.76\scripts\addons\BoolTool.py", line 1009, in register
    1>     km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
    1> AttributeError: 'NoneType' object has no attribute 'keymaps'
    1> Traceback (most recent call last):
    1>   File "C:\Program Files\Blender Foundation\Blender\2.76\scripts\modules\addon_utils.py", line 343, in enable
    1>     mod.register()
    1>   File "C:\Users\Tex\AppData\Roaming\Blender Foundation\Blender\2.76\scripts\addons\uv_squares.py", line 952, in register
    1>     km = wm.keyconfigs.addon.keymaps.new(name='UV Editor', space_type='EMPTY')
    1> AttributeError: 'NoneType' object has no attribute 'keymaps'
    1> Test_FBX_builderEXE_direct.blend: All 2 files successfully built.
    1> AL lib: (EE) UpdateDeviceParams: Failed to set 44100hz, got 96000hz instead
    -------------------------------------------------------------------------
    Build complete (10 seconds)
    0 succeeded, 1 failed, 76 up-to-date, 133 skipped
    

    Apparently it works.

    I say this:
    • Filenames : The filename given in the "model_compile_list" text block (in Blender) will be filtered. It will be in lower case. So this "TestCubeWithName01.model" will become this "testcubewithname01.model" for the filename. It's not a bug in itself. Just use underscores ("_") for better names.
    • The documentation should be providing an example file or be more like a tutorial. It may be out of reach for some people not really used to Blender (while they definitely should!!!).
    • The log in builder is quite unreadable. Maybe the line containing the final 'score' should be in bold font or inverted like if it was selected. if possible of course.
    • This little one should be documented (i may have missed it) : "1> AttributeError: 'NoneType' object has no attribute 'keymaps'" <- hmmm ok.</li>

    Shivers in the pants before clicking the spoiler button ??? ... Come on...

    File provided for dummies.
    ChubbChubbs ???

    Reach me on NS2 forums in :
    Map: Outer Rim Ark and Outer Rim Ark Edge
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    It doesn't seem to like some of the modules you've got enabled. Those errors are happening right at startup, it's not even getting to my scripts yet. :(
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    Update 1/24/16:
    _ Fixed a typo in the part of the program that inserts the new lines into the "builder_setup.xml" file. It would complain about a parsing error.

    To fix, all you have to do is re-download the EXE (same link), and replace the one in your Natural Selection 2 directory, and run it (I mean double click it, not run it through builder just yet). You'll be prompted for permission to "repair" the editor_setup.xml file. Utility will take care of all the changes that need to be made. :)
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    @UncleCrunch
    Unfortunately, there's no way for me to make bolded text in the error output. :(

    The keymaps thing I've never seen before... I think it my have something to do with an addon you're using? I certainly don't call to it in my scripts, so that's something else at work.

    I hope to have some good example assets ready soonish.

    I'm looking into the lowercase filenames problem now. You're right, it shouldn't be doing that. :)
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    Another quick update:
    The exporter will no longer force file names to lowercase... however I still recommend everybody follow the proper ns2 naming conventions and keep it lowercase anyways.
  • UncleCrunchUncleCrunch Mayonnaise land Join Date: 2005-02-16 Member: 41365Members, Reinforced - Onos Posts: 1,542 Advanced user
    About the builder log.
    Maybe a line of dashes would do it as a visual separator.

    Ex:
    All file blah blah success
    ChubbChubbs ???

    Reach me on NS2 forums in :
    Map: Outer Rim Ark and Outer Rim Ark Edge
  • RevanCoranaRevanCorana Join Date: 2015-08-14 Member: 207125Members Posts: 571 Advanced user
    Wow, so basically this tool allow modders to stop using 3DS Max 2009?
    Can it also be used for uncompiling a .model file into a .blend files or is the source file still needed in this case?
    For example a cosmetic mod that would replace the vanilla jump animation of marines.
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    edited January 2016
    Wow, so basically this tool allow modders to stop using 3DS Max 2009?
    Can it also be used for uncompiling a .model file into a .blend files or is the source file still needed in this case?
    For example a cosmetic mod that would replace the vanilla jump animation of marines.

    Yes! If you know how to use Blender, this tool does it all! :)
    Unfortunately it's not an importer. :( Though I have been playing around with the idea, just not really had the time to make anything with it yet.
    McGlaspie
  • RevanCoranaRevanCorana Join Date: 2015-08-14 Member: 207125Members Posts: 571 Advanced user
    Seems great for making modelling easier :smiley:
    Btw got any idea how mods like these managed to partially edit existing models?
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    edited January 2016
    Seems great for making modelling easier :smiley:
    Btw got any idea how mods like these managed to partially edit existing models?

    They probably just opened up the included example assets and made their changes there.

    If you look in your "Natural Selection 2" directory, you should see a folder called "assets", and in there are a bunch of the source assets from the game. There's one called "modelsrc/marine/rifle/" and in there are both the rifle model and rifle_view model source .max files. You'll need 3dsmax to do anything meaningful with the files though, and specifically 3dsmax 2009 if you want to do anything involving physics.
  • RevanCoranaRevanCorana Join Date: 2015-08-14 Member: 207125Members Posts: 571 Advanced user
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    2-16-16

    Bugfix update!

    Fixed a bug that made models fail to compile if a physics solid was parented to an empty object.
    Fixed a bug that made physics objects without parents be oriented incorrectly.

    To update, simply re-download the executable from the link on the first page, overwrite the one in your Natural Selection 2 directory, and run it. This will automatically copy out the fixed scripts to the proper directories. :)
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    2-19-16

    Fixed a small bug caused by the above bug, oops! (Collision solids were improperly transformed if they weren't parented to bones).
    Saffron_bakerArchie
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    7-25-16

    Fixed a bug where the exported normals/tangents/binormals wouldn't be correct if object had a transform.

    To update, simply re-download the executable from the link on the first page, overwrite the one in your Natural Selection 2 directory, and run it. This will automatically copy out the fixed scripts to the proper directories. :)
    UncleCrunch
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    edited August 2016
    8-7-16

    Fixed a bug where animations wouldn't export properly.
    Added a new feature to allow the compiler to use normal maps from pre-existing NS2 props: "flip_bitangent". Setting this flag in the model_compile text block flips the bitangent from what it is in Blender. (Meaning that normal maps from NS2 can be used in Blender-exported assets, otherwise you'd need to invert the y (green) component of the tangent space normal map).

    EDIT: Also fixed another issue that would cause some animations to either be too long, or have a negative length.
    Post edited by BeigeAlert on
  • ZdrytchXZdrytchX Australia Join Date: 2016-02-06 Member: 212662Members Posts: 101 Advanced user
  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts Posts: 2,829 admin
    Huh, sorry about that. Updated the link. I didn't remove it... I wonder if dropbox expires links... be a shame if they did... I send permalinks around a lot. :(

    @ZdrytchX
  • ZdrytchXZdrytchX Australia Join Date: 2016-02-06 Member: 212662Members Posts: 101 Advanced user
    edited December 2016
Sign In or Register to comment.