Model export from Blender

Return to content tutorials

Blender has a built-in OBJ and MD2 exporter which can be used to create suitable files for the metaio Mobile SDK. Important when exporting from Blender is the texture baking process as preparatory step.

Texture Baking in Blender

  • 1. Start Blender
  • 2. Import a model file via “File” => “Import”

image015.jpg

  • 3. Open the material panel (F5)

image016.jpg

  • 4. Make sure your materials were imported correct, otherwise set them up manually. If your mesh is not selected, select it with Right Mouse-Click. Then add a Material.

image017.jpg

  • 5. Add a texture.

image018.jpg

  • 6. In the same panel, flip from “Texture” to “Map Input” and check the UV-Button

image019.jpg

  • 7. Go to the Texture-Buttons (F6) and select Texture Type: Image

image020.jpg

  • 8. Click on “Load” and select the appropriate texture-file, then click “Select Image”

image021.jpg

  • 9. Next you need to have a look at the texture coordinates. To do so, change the Mode of your model from Object-Mode to Edit-Mode (Tab) by clicking the button marked.

image022.jpg

  • 10. If you don’t already have an UV/Image-Editor-Window ready, you can open a new window by right-clicking the line between two windows (when the cursor changes to a double-sided arrow), then select “Split area”. In the new Window click the Window-Type-Button and select “UV/Image-Editor”

image023.jpg

  • 11. You should now see the UV-Layout of your object.
    If you have a layout where multiple faces share the same texture space you have to make a new one before you can bake the texture, e.g. if two faces have the same texture space and one of them is full lit, and the other one should be in shadows the result will not be correct.

image024.jpg

  • 12. To create a new face-layout follow these steps:
    • Go to the Editing-Buttons-Window (F6)
    • Click on “New” next to UV Texture
    • + 4. This will add another UV-Layer

image025.jpg

  • 13. Move the mouse-pointer over the 3d-Window and press “U”.
    There are several different ways to generate the new layout. The easiest way is the option “Unwrap (smart projections)”.

image026.jpg

  • 14. In the following dialog-box you can make some adjustments, then click: “OK”

image027.jpg

  • 15. The new layout is displayed in the UV/Image-Editor. Before you continue, you have to set this new texture-layout also to “UV” in the Material-Buttons (see Step 17). Now you need to specify the image you want to bake: Select “Image” => “New”

image028.jpg

  • 16. In the dialog-box you can set:
    • the size of the baked texture
    • the background color
    • the transparency of the background color
    • a UV Test Grid, that shows you if your texture is laid out properly. (This will be overwritten when baked, so selecting this option will do no harm)

image029.jpg

  • 17. If you switch the draw type to Textured you can see how the Test Grid is applied to your model in the 3D-View

image030.jpg

  • 18. The last step before you can bake your texture is to build a light setup. Set your object back from Edit-Mode to Object-Mode (see Step 9), then click “Add” => “Lamp” => “Lamp“
    In the Lamp-Buttons you can adjust the settings for the selected light.

image031.jpg

  • 19. In the 3D-Window press “G” then move the mouse to place the lamp where you want it to be. With left click you confirm the transformation.
    If you want you can add more lights. You can also deselect the option to throw shadows for each light separately.
  • 20. In the World-Buttons (F8) you could also activate “Ambient Occlusion”, which will add some extra light from all sides your model, plus it darkens narrow corners. This will add very much to a good looking texture. The higher the sample rate, the better the result and the slower the calculation will be.

image032.jpg

  • 21. Now everything is ready to bake. Head over to the Render-Buttons (F10), make sure the object you want to bake is selected and the Ray-button is activated. Then hit “Bake”.

image033.jpg

  • 22. Save the result by clicking Image->Save as

image034.jpg

  • 23. Don’t forget to set the correct image-type, before you click “Save Image”

image035.jpg

  • 24. Now go back to the Texture-Buttons (F6) and select your newly generated file as the texture that should be used.

image036.jpg

  • 25. Additional step for shadow baking:
    If you want to bake a shadow that is cast to the floor, you have to add a plane (make sure it is big enough, so the shadow fits onto it) and place it below the box.
    Now all that you want to get is a shadow on the floor, but not the floor itself, that’s why you have to add a new material with exactly these settings to the shadow-plane.

image037.jpg

As before, save the image as a .png or any other format that supports an alpha channel.

Then delete the “Special-Material” and add a new standard one (see Step 4-8) and apply that saved image to the texture.

If you want textures that contain an alpha-channel to be displayed correctly in Blender, you have to go to the Editing-Panel (F9) and while your object is in edit-mode (see Step 9) click the “Alpha”-Button in the Texture Face-Panel.

image038.jpg

  • 26. Final Result in Blender:

image039.jpg

Export to Wavefront OBJ

  • 1. Select all objects you want to export, then click on “File” => “Export” => “Wavefront Obj”

image040.jpg

  • 2. You don’t have to edit the standard settings in the dialog box, just hit “Export”.

image041.jpg

Export to MD2

For Blender-Versions up to 2.49:

  • 1. Save your file with “File” => “Save” and close Blender.
  • 2. Copy the file “md2_export_new.py” into Blender’s script folder, then restart Blender.
  • 3. Reopen the file with File=>Open Recent, select your objects, then click “File” => “Export” => “MD2-new-“

For Blender-Versions 2.5 and above:

  • use this addon (install via File=>User Preferences=>Addons=>Install Addon and don't forget to activate it).

Export to MD2

image042.jpg

  • 4. In the dialog box you should disable the “Export animation”-button, if you don’t have one then click “Export to MD2…”

image043.jpg

Export animations to MD2

You can export nearly all kinds of animations from Blender to MD2, as long as you follow some rules.

  • The exporter exports all animations between Start (A) and End (B)-Frame.
  • You need to assign names to the animations so you can later trigger them from the MD2-File. To do so, you have to add markers (C) in the IPO-Window (D) with pressing “M”.
  • You can select a marker with right click move it with “STRG+G” and rename them with “STRG+M”(E). These shortcuts are also available through the Marker drop down menu (F)

image044.jpg

Model sizes

For visualization on the mobile phone it is important to verify reasonable model sizes. For Blender the units for modelling are usually millimetres. Thus, given a marker of 60mm size, the marker area will be occupied fully by a model of the same size.

For 3ds Max the unit can be set e.g. to millimetres or centimetres. When exporting your model, make sure to check the current unit settings.

Return to content tutorials

-- SupportMetaio - 2011-12-02

Topic revision: r3 - 2012-01-18 - 10:15:57 - SupportMetaio
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback