Blender/Collision

From NifTools
Jump to: navigation, search


This article explains how you can export custom collision meshes for Morrowind and Oblivion.

Contents

Collision Objects

The type of collision objects that the Blender NIF Scripts can export are:

  • box
  • sphere
  • capsule
  • convex shape
  • arbitrary shape

How you can create these collision shapes in Blender is explained below.

Morrowind only supports the arbitrary shape collision type - you will get an error if you try to use anything else. Oblivion supports all of the above, so first you need to decide which of these categories suits best as a collision for your model. You can of course combine any of these collision objects to construct more complex objects.

In Oblivion, if you need to use an arbitrary shape, you should take care to make the collision mesh as simple as possible, because collisions of this type are computationally very demanding, and hence may have a huge impact on the frame rate. You should stick to the other primitives whenever possible.

Creating A Collision Mesh Using The Hull Script

With your mesh selected, open up the "Scripts" menu, and select Mesh -> Hull. You can choose between either "Box", "Sphere", or "Convex". If you need more control over the collision mesh, read on.

Creating A Custom Collision Mesh

Creating The Mesh

  • For the box, sphere, and capsule types, you can do everything with a simple cube. So, add a cube, and translate/scale this cube until it fits the size of your model (do not rotate it yet). Apply scale (CTRL-A) to your cube. Now rotate the shape so it fits your model. Note that if you do CTRL-A after a rotation then the bounding shape will not fit anymore since the bounding shape is axis aligned. If you need to tweak the scale after rotation, simply scale the object while in edit mode. For capsules, make sure the main axis runs along the local z-axis.
  • For convex shapes and arbitrary shapes, simply create a mesh as you would do usually. Make sure to remove duplicate vertices when you are done.

Settings for Collision Meshes

  • Go to object mode, to the object tab, and select "Bounds" for draw type. For convex shapes and arbitrary shapes, also select "Wire" under draw extra.

Screenshot-3.png

  • Next, select the actor tab, and click on "Bounds".

Screenshot-4.png

  • Now you can select the collision type:
    • Box: for boxes.
    • Sphere: for spheres.
    • Cylinder: for capsules (a cylinder with rounded ends). Again, for cylinders, make sure that the main axis corresponds to the local z-axis. If the cylinder's alignment looks alright then you do not need to worry further. If not, rotate your oblong cube in edit mode until the cylinder is displayed properly.
    • Convex Hull Polytope: for convex shapes.
    • Static Triangle Mesh: for arbitrary shapes.
    • Cones: exist in Blender but are not supported by the scripts; if you need them use the convex hull polytope or static triangle mesh.

Screenshot.png

  • Finally, you can set the material as a property. Click "Add Property", select "string" as property type, name it "HavokMaterial" and choose any of the material names from nif.xml [1], such as HAV_MAT_METAL, HAV_MAT_STONE, HAV_MAT_WOOD, etc. which suits your model best.

havokproperty.png

NifSkope Tweaking

Not all of the Oblivion collision parameters are well understood yet, so probably, after exporting your nif, you may still want to tweak the collision parameters of your exported collision geometries in NifSkope.

Screenshot-5.png

Constraints

The scripts also import and export hinge and ragdoll constraints. The following screenshot summarizes the meaning of the x, y, and z axis for each constraint. Note that the exporter writes default values for the angles; to have more control over the constraint, edit the constraint angle parameters with nifskope.

blenderconstraints.png

Known Issues

  • The convex hull shape (bhkConvexVerticesShape) may not catch arrows. If catching arrows is important for your model, use a static triangle mesh instead.
Personal tools