Blender Tutorial for Physics
From Multiverse
| Creating and Importing Models |
|
Creating Assets • Creating Collision Volumes • Exporting Models to COLLADA • Targeting a Wide Range of Hardware • Model Conversion Tool • Creating Material Scripts |
| Using 3ds Max |
|
Using the 3ds Max Export Tool Creating Attachment Models Creating Morph Animations Transferring Biped Skeletons Implementing Vertex Lighting |
| Other Tools |
|
Blender: Static Model • Blender: Anim. Model • Blender Physics • DeleD: Static Model • DAZ Studio: Creating Characters • DAZ Studio: Avatars • Using Poser |
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.
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.
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.
This will give you further options for setting the physics. Select the Rigid Body and then accept the default values for everything else.
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.
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.
Choose to save the DAE file as shown in the following screen.
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.
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-".
- 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!
Revised Physics Edits Using Blender (as of 01/02/2010)
This info was provided for by Demi from the Multiverse Dev Forums and Project Planet Postmoderna.
The samples we used for our project were done using Blender v 2.49 beta.
Using the same direction given for 3dsMax Physics usage in the Multiverse Wiki Physics Tutorial, Creating Collision Volumes. DO NOT USE THE INTERNAL PHYSICS PARAMETERS/LOGIC IN BLENDER. YOU MUST CREATE VOLUMES MANUALLY.
edit: You need to make a cube for each block of collision. The reference or "dummy" cube can be nothing more than a 1×1x1 which can be hidden inside a wall. The cube can be placed anywhere on the model. Call these cubes dummy_0, dummy_1 and so on if you like just name them so the collision volumes reference the same name. Then make a rectangle around the area you want to have collision (I make them just sit on the outer surface and inner surface of a wall). Name them mvcv_obb_dummy_.
Example:
Place Dummy Object in Wall Segment and call it dummy_01. Name the Collision Volume in that same area as mvcv_obb_dummy_01
I moved the collision volume object to another layer for organization and assigned a red material color to them to see them better.
Scale the model up about 20x before export and align the model so the y-axis is pointing up. Export the whole object (model object, dummy objects and collision volume objects) using the current Collada Exporter (currently Collada 1.4).
Run the *.dae file through the Conversion Tool as per the Multiverse Documentation.
Sometimes the exported physics file (*.physics) leaves the prefix "mvcv_obb_" in the referenced object name and does not remove it (Dummy_1-geometry.0 would be named mvcv_obb_dummy_1-geometry.0). Just open the physics file in wordpad (or your favorite text editor) and remove the mvcv_obb_ in front of the reference collision volume object name(s). You may just want to do a "Replace All" function if you have a lot of them.
Import your *.mesh object and the associated *.physics file using the Asset Importer tool and you will have a successful "physics-enabled" model.
Test it out in model viewer and/or your world browser (using the Ctrl-H command so you can see the collision volumes). Don't forget to turn them off (CTRL-H again 2x).
Reference the Planet Postmoderna Project blog entry for further reference. Also, reference the thread discussing this on the Multiverse Forums.










