Collisions - BadDogSkyrim/PyNifly GitHub Wiki

Much of this info comes from https://wiki.beyondskyrim.org/wiki/Arcane_University:Mesh_Collisions; more of it came from Candoran2.

Note the latest NifSkope will do some collision handling for you, for Skyrim and FO4 both. See here: https://github.com/eckserah/nifskope_updated/releases and the video here: https://www.youtube.com/watch?v=ISRcNifg_R8

pyNifly supports creating an object and exporting it to the nif as the video shows, so you can export it directly from Blender rather than creating it with NifSkope.

Skyrim

Skyrim collisions are structured as a:

  • Collision object, which owns a
  • Collision body, which owns a
  • Collision shape

The collision object represents the collision. It has a target, which the thing the collision affects and which it's attached to. It has a single child which is its body and defines how the collision behaves.

The collision body is a single node that mostly holds a mess of properties to define the collision behavior. It is the parent of a single Collision Shape object.

The collision shape can be one of a number of types--see below for supported collisions. Collision shapes have a "material", which is the material it mimics, and a "radius", which provides an extra margin around the collision object. So the actual collision is bigger than what you see by the radius amount.

Collision measurements are in Havoc units, which are meters. Skyrim units are 1/64 of a yard. So the havoc units will be much smaller than you expect. The collision shape does the translation so it reflects the actual collision, but any properties such as the radius are not converted.

Since collisions are meant to cover the actual mesh, they are imported as wireframes.

In Blender

Collision Target

The object which is supposed to have collisions is the collision target, but it doesn't actually have the collision info. Instead it is given a transform constraint so it follows the actual collision object. This is because you usually want a simpler collision geometry than your mesh, and you want control over how that geometry is represented in the nif (the collision shape).

Collision Object

The collision object overlays its target, so it's represented as a wireframe. It has actual Blender physics. The name of the collision object defines the type of collision shape--bhkBoxShape, for example. Note that any transform you put on the collision shape is going to change the collision target apparent location--go into edit mode and change the mesh if you want to adjust the shape relative to the target.

Havok properties that have Blender equivalents are translated into Blender physics properties. If there's no Blender equivalent, they are stored as custom properties on the Collision Object.

The Collision Object is not a child of the root node. Often the collision object provides physics for the root node, and Blender gets confused if the collision object tries to set the location of its own parent.

Types of Collision Objects

bhkBoxShape

  • Collision is a simple box, 6 sides, all right angles. As you adjust the box vertices to cover the shape make sure you keep it a rectilinear box.
  • The bhkMaterial property defines the type of material the collision mimics. See SkyrimHavokMaterial below.

bhkCapsuleShape

  • Collision is a pill shape implemented by a UV Sphere. Create the sphere at the origin with an odd number of rings, then in edit mode select all the vertices above the origin and move them in the Z direction until you get a capsule as long as you like. You must use a UV Sphere--the exporter finds the ends by identifying the top and bottom points.

bhkConvexVerticesShape

  • Collision is a convex hull shrink-wrapped around the Blender shape--so your shape doesn't actually need to be a convex hull. But remember, the shape is supposed to be simple.

bhkListShape

  • Collects a list of collision shapes as children. Allows you to build up a complex collision from a bunch of simpler shapes. See dlc01\weapons\falmerstaff\staff.nif for an example.
  • Blender requires the bhkListShape to be an actual mesh. The importer creates a small box for this. If you're creating the bhkListShape, put the box somewhere that it won't interfere with the collision behavior in Blender.

bhkConvexTransformShape

  • You don't need to create these directly. They are created on export of a bhkListShape to position the children.

bhkCOFlags

ACTIVE = 1
NOTIFY = 1 << 2
SET_LOCAL = 1 << 3
DBG_DISPLAY = 1 << 4
USE_VEL = 1 << 5
RESET = 1 << 6
SYNC_ON_UPDATE = 1 << 7
ANIM_TARGETED = 1 << 10
DISMEMBERED_LIMB = 1 << 11

bhkRigidBodyProps

collisionFilter_layer: SkyrimCollisionLayer
collisionFilter_flags
collisionFilter_group
broadPhaseType: BroadPhaseType
prop_data
prop_size
prop_flags
collisionResponse: hkResponseType
unusedByte1
processContactCallbackDelay
unkInt1
collisionFilterCopy_layer
collisionFilterCopy_flags
collisionFilterCopy_group
unkShorts2
translation
rotation
linearVelocity
angularVelocity
inertiaMatrix
center
mass
linearDamping
angularDamping
timeFactor
gravityFactor
friction
rollingFrictionMult
restitution
maxLinearVelocity
maxAngularVelocity
penetrationDepth
motionSystem: hkMotionType
deactivatorType: hkDeactivatorType
solverDeactivation: hkSolverDeactivation
qualityType: hkQualityType
autoRemoveLevel
responseModifierFlag
numShapeKeysInContactPointProps
forceCollideOntoPpu
unusedInts1_0
unusedInts1_1
unusedInts1_2
unusedBytes2_0
unusedBytes2_1
unusedBytes2_2
bodyFlagsInt
bodyFlags

SkyrimCollisionLayer

UNIDENTIFIED = 0
STATIC = 1
ANIMSTATIC = 2
TRANSPARENT = 3
CLUTTER = 4
WEAPON = 5
PROJECTILE = 6
SPELL = 7
BIPED = 8
TREES = 9
PROPS = 10
WATER = 11
TRIGGER = 12
TERRAIN = 13
TRAP = 14
NONCOLLIDABLE = 15
CLOUD_TRAP = 16
GROUND = 17
PORTAL = 18
DEBRIS_SMALL = 19
DEBRIS_LARGE = 20
ACOUSTIC_SPACE = 21
ACTORZONE = 22
PROJECTILEZONE = 23
GASTRAP = 24
SHELLCASING = 25
TRANSPARENT_SMALL = 26
INVISIBLE_WALL = 27
TRANSPARENT_SMALL_ANIM = 28
WARD = 29
CHARCONTROLLER = 30
STAIRHELPER = 31
DEADBIP = 32
BIPED_NO_CC = 33
AVOIDBOX = 34
COLLISIONBOX = 35
CAMERASHPERE = 36
DOORDETECTION = 37
CONEPROJECTILE = 38
CAMERAPICK = 39
ITEMPICK = 40
LINEOFSIGHT = 41
PATHPICK = 42
CUSTOMPICK1 = 43
CUSTOMPICK2 = 44
SPELLEXPLOSION = 45
DROPPINGPICK = 46
NULL = 47

BroadPhaseType

INVALID = 0
ENTITY =  1
PHANTOM = 2
BORDER = 3

hkResponseType

INVALID = 0
SIMPLE_CONTACT = 1
REPORTING = 2
NONE = 3

hkMotionType

INVALID = 0,
DYNAMIC = 1,
SPHERE_INERTIA = 2,
SPHERE_STABILIZED = 3,
BOX_INERTIA = 4,
BOX_STABILIZED = 5, 
KEYFRAMED = 6,
FIXED = 7,
THIN_BOX = 8,
CHARACTER = 9

hkDeactivatorType

INVALID = 0
NEVER = 1
SPATIAL = 2

hkSolverDeactivation

INVALID = 0
OFF = 1
LOW = 2
MEDIUM = 3
HIGH = 4
MAX = 5

hkQualityType

INVALID = 0
FIXED = 1
KEYFRAMED = 2
DEBRIS = 3
MOVING = 4
CRITICAL = 5
BULLET = 6
USER = 7
CHARACTER = 8
KEYFRAMED_REPORT = 9

SkyrimHavocMaterial

BROKEN_STONE = 131151687
LIGHT_WOOD = 365420259
SNOW = 398949039
GRAVEL = 428587608
MATERIAL_CHAIN_METAL = 438912228
BOTTLE = 493553910
WOOD = 500811281
SKIN = 591247106
UNKNOWN_617099282 = 617099282
BARREL = 732141076
MATERIAL_CERAMIC_MEDIUM = 781661019
MATERIAL_BASKET = 790784366
ICE = 873356572
STAIRS_STONE = 899511101
WATER = 1024582599
UNKNOWN_1028101969 = 1028101969
MATERIAL_BLADE_1HAND = 1060167844
MATERIAL_BOOK = 1264672850
MATERIAL_CARPET = 1286705471
SOLID_METAL = 1288358971
MATERIAL_AXE_1HAND = 1305674443
UNKNOWN_1440721808 = 1440721808
STAIRS_WOOD = 1461712277
MUD = 1486385281
MATERIAL_BOULDER_SMALL = 1550912982
STAIRS_SNOW = 1560365355
HEAVY_STONE = 1570821952
UNKNOWN_1574477864 = 1574477864
UNKNOWN_1591009235 = 1591009235
MATERIAL_BOWS_STAVES = 1607128641
MATERIAL_WOOD_AS_STAIRS = 1803571212
GRASS = 1848600814
MATERIAL_BOULDER_LARGE = 1885326971
MATERIAL_STONE_AS_STAIRS = 1886078335
MATERIAL_BLADE_2HAND = 2022742644
MATERIAL_BOTTLE_SMALL = 2025794648
SAND = 2168343821
HEAVY_METAL = 2229413539
UNKNOWN_2290050264 = 2290050264
DRAGON = 2518321175
MATERIAL_BLADE_1HAND_SMALL = 2617944780
MATERIAL_SKIN_SMALL = 2632367422
STAIRS_BROKEN_STONE = 2892392795
MATERIAL_SKIN_LARGE = 2965929619
ORGANIC = 2974920155
MATERIAL_BONE = 3049421844
HEAVY_WOOD = 3070783559
MATERIAL_CHAIN = 3074114406
DIRT = 3106094762
MATERIAL_ARMOR_LIGHT = 3424720541
MATERIAL_SHIELD_LIGHT = 3448167928
MATERIAL_COIN = 3589100606
MATERIAL_SHIELD_HEAVY = 3702389584
MATERIAL_ARMOR_HEAVY = 3708432437
MATERIAL_ARROW = 3725505938
GLASS = 3739830338
STONE = 3741512247
CLOTH = 3839073443
MATERIAL_BLUNT_2HAND = 3969592277
UNKNOWN_4239621792 = 4239621792
MATERIAL_BOULDER_MEDIUM = 4283869410