Native Mesh Format

Previously, NIF files were the only way to get models into the game. Unfortunately, the NIF format is proprietary, bloated, and the available exporters are not in a great shape. For example, the Blender NIF exporter currently only works with the very old Blender 2.4.

Starting with OpenMW version 0.38, we can utilize the OSG native model format. The OSG model format doesn't yet support all the features that NIF's support, but works for basic models. For more details on the format, refer to this forum post.

This article will explain how to export a model from Blender to OSG format and then load it into OpenMW.

= Prerequisites =


 * OpenMW commit e62470d67411c665231162959c764c27f4f19e2e or later
 * Blender 2.6x (any version of 2.6 should work)
 * A blender model you would like to export

= Install the exporter =


 * Download the osg export script: https://github.com/openmw/osgexport/blob/release/blender-2.5/build/osgexport-0.14.2.zip?raw=true
 * Open Blender and go to File -> User Preferences
 * Select Addons -> Install from File, then select the downloaded .zip
 * Enter "osg" into the search bar, then tick the checkbox next to the addon
 * Now click Save user setting so the exporter stays enabled when you re-start Blender

You can now export your model using the OSG model (osgt) entry in the File -> Export menu.

= Putting the model in-game =

Place the exported model in the Meshes sub-folder of a data folder recognized by the game, e.g. the Morrowind Data Files folder, or the local data folder ($HOME/.local/share/openmw/data on Linux). Place all required textures in the Textures sub-folder. Now start OpenMW-CS, create a new addon file and you should see your mesh in the Assets -> Meshes table. Go ahead and make some object use your mesh. You can now preview by right clicking on the object -> Preview to see what the mesh will look like.

= Converting the model to binary =

When the model behaves to our liking, we can think about converting it from the "osgt" text format to the "osgb" binary format so that it's smaller in size - and thus faster to load.

To do this, simply invoke the osgconv tool. This tool should be included with your distribution of OpensceneGraph.

osgconv -O WriteImageHint=UseExternal model.osgt model.osgb

Of course, you can convert the binary model back to text format as well: osgconv -O WriteImageHint=UseExternal model.osgb model.osgt

Note the use of -O WriteHint=UseExternal option. Enabling this option is desirable because it keeps the textures as external file references, rather than embedding the textures within the model file. Embedded textures have disadvantages such as being hard to inspect, and impossible to share between model files.

= Conclusion =

These are the basics of getting a textured, static model from Blender into the game. In the future, we will want a way to add bump maps, texture animations, skeletal animations, separate collision shapes, and some other features that are currently only available via NIF files. We will likely add these features to the native OSG format after OpenMW 1.0.