Blender Tutorial for Physics

From Multiverse

Jump to: navigation, search

Blender is an open source 3D modeling and animation tool. This tutorial explains how to to create a simple mesh in Blender, attach a bounding box to the mesh and then how to export it and get it to work in Multiverse. The techniques offered here can be automated and I probably will, but, I just wanted to let everyone know how to do it with "brute force". For this tutorial, Blender 2.45, Python 2.5 and the COLLADA 1.4 Blender plugin were utilized. This tutorial will build on the excellent tutorial that Matro put together on creating static meshes in Blender, see Exporting a Static Mesh from Blender.

This tutorial assumes you have some familiarity with the Blender interface.

This tutorial was written by Multiverse Developer LightninBoySnook.

Contents

Prerequisite

The Blender COLLADA plugin requires you to install Python. Download Python version 2.5 and install it on your system before you start Blender.

Note: You must install a standalone version of Python even if you have installed Cygwin's Python module.

Create a static model in Blender

First create a static model as described in the Exporting a Static Mesh from Blender tutorial. For this tutorial, the goal was to make a stage for a Multiverse concert. So you could start with a simple cube and then flatten it along the Z axis. The texture was added and then the mesh was converted to triangles as per the static mesh tutorial. The following is the mesh model as it existed in Blender before trying to apply the physics.

Image:Image23.jpg

Create a Bounding Box Physical Model

In world building an important concept is known as collision volumes. This is a specific type of physics that is applied by the game engine to ensure that you can't walk through buildings or other characters in a game. A very good tutorial on collision volumes in Multiverse and how the conversion tool treats the Collada models can be found at Creating Collision Volumes. Unfortunately, Blender does not handle them as elegantly as Max 3DS or Maya. But, what the heck, Blender is free!

In Blender, go to the logic button within the button's window and click it. This will put you into the logic for the game engine. This is where Blender handles physics as it is assuming you are building a scene that you want to play in their game engine. This will bring up the physics panel. We will be interested in only the Actor and Bounds buttons for this tutorial.

Image:Image22.jpg


Click on the Actor button and two more buttons will show up. Since we want this to be a physical object in our virtual world, we will select the Dynamic button and not the Ghost button.

Image:Image20.jpg


This will give you further options for setting the physics. Select the Rigid Body and then accept the default values for everything else.

Image:Image18.jpg


Next you need to identify what kind of object to use to wrap the collision volume around the mesh. You do this by first clicking the Bounds button. this will add further buttons. Select the button that says box to see what kind of bounding objects you can use. In this case, since it is a stage we are building which is basically a box, choose box for the type of bounding object.

Image:Image16.jpg


Save the Model and Export the Collada XML

You have done all the work you need to do in Blender at this point. Save the Blender model and then go to the Export option and choose Collada 1.4.

Image:Image14.jpg


Choose to save the DAE file as shown in the following screen.

Image:Image26.jpg


Create The Mesh and Material Files

When you have run the exporter. It will create a DAE file. For this tutorial, the name of the DAE XML file as newstage.dae. Now run the Multiverse Conversion Tool against the DAE file. It will create a mesh and a material file.

Image:Image13.jpg


The Big Fix Up

If you are saying, wait where is the physics file here is the trick. This doesn't create the physics file because the conversion tool is looking for unique names for the objects. They must start with a specific prefix as described in the tutorial - Creating Collision Volumes. In this case since it is a bounding box, the objects must start with mvcv_obb_.

  • So, copy the DAE file to a new name, for example newstage2.dae.
  • The get in edit on the file (Wordpad works just fine for Windows).
    • Find the name of the mesh you want to change by paging down and finding the mesh source id name.
    • In this case it was Cube-Geometry-Position. The naming convention Blender uses is the primitive before the first "-".
    • Now replace all the "Cube-" with "mvcv_obb_Cube-".

Image:Image12.jpg


  • Save the File
  • Run the Conversion Tool against the new DAE file (i.e. newstage2.dae)
    • This creates a physics file. We have fooled the conversion tool.
  • Delete the mesh and materials files created with this conversion (i.e. newstage2.mesh & newstage2.material)
  • Get in Edit on the physics file just created (newstage2.physics)
    • Change back to the name to the original name so it matches up with the mesh file (i.e. replace all the "mvcv_obb_Cube-" with "Cube-")
    • Save the File
    • Rename the file back to match the original mesh and material file names (i.e. newstage.physics)

You now have everything you need to create the mesh in your world.


Import Assets

Import the mesh and material files using the asset importer and copy the physics file to the physics directory in the client physics folder of your world. Then put the asset in your world and go stand on your stage!

Image:Image24.jpg

Personal tools