Blender/Custom Collision

From the Oblivion ConstructionSet Wiki
Revision as of 16:37, 5 August 2008 by imported>Morerunes (added to the advanced havok stuff)
Jump to navigation Jump to search


Alright, there's no good custom collision in Blender tutorial here, so here goes nothing.

Resource Pack for this Tutorial

About

What's a Collision Mesh?

It tells the game what to bump into (and also whether things can swing and bounce, or are like chains, but that's beyond the current scope of the tutorial), and whether to just sit there, or fall, or bounce, or float, etc. So basically, no collision, and you can walk through it, and it won't be affected by gravity, and nothing can touch it (kinda like a ghost, but it won't move, and you can't see through it).

Why Custom?

Why make custom collision you say? Well, the answer is simple. Because you don't want to walk through your mesh, or have your mesh bounce in mid-air or other weird problems. Sometimes it's ok to just use collision from another NIF file, but after following this tutorial, I think you'll be doing a lot more custom collision. I do it all the time, even when it isn't necessary, just because it's more accurate, and takes only about 1 minute to do, without any necessary NifSkope edits.


Starting Off

Have a Mesh

You can't really make your collision mesh until you have a regular mesh, so either make a mesh to use, or download the Tutorial Resources and use those.

First, decide what type of collision you want to use. If it's cylindrical, you want to make a Cylinder. If it's a rectangular prism (i.e. mostly squarish or rectangular), then use Box. If it's a sphere, use Sphere. If it's just some odd shape that needs accurate collision, then use either a Static TriangleMesh, or Convex Hull Polytope.

Making the Collision Mesh

If you downloaded my resource pack, open chapstick.blend, you want a cylinder.

Cylinder

Make a new cube, as a new object. When you make it, just know that the flat side is pointing toward your camera, so make sure that when you make the cube you are looking at the flat part of your cylinder, like this:

File:BlenderCollisionExample1.png

Then, fit the cube over your cylinder, stretching and scaling all you need, so that it covers it like this:

File:BlenderCollisionExample2.png

When it fits perfectly how you want it to, go to object mode, and go to object options. Change Draw Type to bounds. Then, go to Logic options, and click on bounds, and change it to cylinder. You should now see a wire cylinder over your cylinder mesh. There you go, you just made a collision mesh.

File:BlenderCollisionExample3.png File:BlenderCollisionExample4.png

Box

Same as cylinder, but without being round. No need to re-write it all. Just choose box instead of cylinder for bounds.

There is another way to do it, which I'll explain later.

Sphere

For this one, do the same as the cylinder, but don't stretch it. Just fit a cube over your sphere. Choose Sphere instead of Cylinder for bounds.

There is another way to do it, which I'll explain later.

Convex Hull Polytope

This is a bit different, but almost as easy. Basically, the idea is that you make a regular mesh (do it all in edit mode, makes it easier on you later), and then make it a Convex Hull Polytope, and oblivion recognizes it as collision. This is only for convex shapes, so you can't make something like a sphere with an inward dent, only an outward dent (and certainly not a Harvey Dent). Please note that this may not catch arrows, so if it needs to catch arrows use Static TriangleMesh instead. So, after you make the shape of it in edit mode, go to Object mode, and do set it to only display bounds, but under Draw Extra, also click Wire.

Then, go to Logic Options, and click bounds, and choose Convex Hull Polytope.

There is another way to do it, which I'll explain later.

Static TriangleMesh

This one works the same as the Convex Hull Polytope, except this one works for any shape. It does not have to be convex. Use this sparingly though, and keep the vertex count as low as possible, because it could slow down your game. The only thing you do differently, is choose Static TriangleMesh instead of Convex Hull Polytope for Bounds.

The "Other way to do it"

Make just the mesh shape, and then go to object mode and select it, then go to the scripts window.

File:BlenderCollisionExample5.png

Then go to Scripts>>Mesh>>Hull

Choose the appropriate option.

Then go back to the 3d window (the grid icon) and select JUST YOUR MESH. The script created a copy of the mesh on top of yours, that is already set up for you. So, once you are sure you have your mesh selected, delete it, and you should see a wire version of the mesh you made.

That's it. You're done. Give yourself a pat on the back.

I recommend saving the .blend file right now as a backup.

Export Options

*As of Nif Scripts ver. 2.3.5

When you export, make sure you've selected all of your mesh objects first.

Set up your export options like this:

File:BlenderCollisionExample6.png

Then, change settings according to this:

    • Click on clutter if it's something like a potion, or a bottle, or a food, or something else that just lies around and you can kick and throw and whatnot.
    • Click on weapon if it's a weapon.
    • Click on Static if it's something like a building, or a statue.
    • Click on Creature if it's a creature.
  1. Choose one of the materials (glass, wood, cloth, etc.). If you don't like those, then you have to change it in NifSkope.

Solid and Hollow determines how the physics settings are calculated, choose the one closest to your mesh.

Then just export!

Advanced NifSkope Physics

Don't like how much it bounces? Want it to never slide down a hill? Or never stop sliding down a hill? You'll have to use NifSkope, but don't worry, it's easy to do this part.

Just select the bhkRigidBody under the bhkCollisionObject, and there are settings in the setting list. I'm not going to explain all of this, because I don't know all of it, but here's a few.

File:BlenderCollisionExample7.png

Mass
Makes it heavy or light, big number = heavy. I think this affects how far it will fly through the air when you throw it, and maybe how fast it stops bouncing too.
Linear Damping
I think a higher number means that when it moves, a higher number will make it move slower.
Restitution
How bouncy it is. Values over about 3 don't seem to affect it. (i.e. 10,000,000 is no bouncier than 10)
Layer
What type of physics it is (weapon, clutter, etc.)

If you go into the bhkListShape (parented to the bhkCollisionObject), you can change the material. This will change the sounds that play when you hit it with a weapon, or throw it at something, or walk on it. You will also probably need to change it in each individual shape. (In 'ChapstickHavok.blend', there is only one, and it's a bhkCapsuleShape). This will allow you a wider selection of materials that aren't in the blender exporter.

Well, good luck making stuff, and I hope this helps.

See Also