Editing Arcane University:Mesh Collisions

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
{{Trail|Implementation|Nif Implementation}}
+
'''Collision''' is an attribute of [[Arcane University:NIF Data Format|NIF files]] which makes objects solid in the Creation Engine. When an object has collision, it cannot be walked through, fall through the ground or walls, and also determines what parts of the object are interactable. It can also be used to create non-collidable "phantom collision," to detect when an object enters the collision bounds and then call an event. This article will cover the different types of collision shapes and their uses, as well as the physics settings that affect how the object moves in the world.
'''Collision''' is an attribute of [[Arcane University:NIF Data Format|NIF files]] which makes objects solid in the Creation Engine. When an object has collision, it cannot be walked through, fall through the ground or walls, and also determines what parts of the object are interactable. It can also be used to create non-collidable "phantom collision," to detect when an object enters the collision bounds and then call an event. This article will cover the different types of collision shapes and their uses, as well as the physics settings that affect how the object moves in the world. It is by no means exhaustive—these are just the most commonly used features of collision in Skyrim.
 
  
{{note|Many problems are avoidable by copying the collision from a similar vanilla nif. This will save you the hassle of setting all the values by hand. Just make sure to use NifSkope's "Reorder Blocks" spell afterwards, otherwise the nif will crash the game/CK.}}
+
==Common Shapes==
 
 
==Common Shape Types==
 
 
[[File:WRjaildoor.png|350px|thumb|right|The Whiterun jail door uses a box primitive.]]
 
[[File:WRjaildoor.png|350px|thumb|right|The Whiterun jail door uses a box primitive.]]
There are three main types of collision meshes: '''Primitives''', '''Convex Shapes''', and '''Compressed Mesh Shapes'''. Primitives are the simplest, and compressed mesh shapes are the most complex. The CPU usage required to simulate physics, therefore, is lowest for primitives, slightly higher for convex shapes, and much higher for compressed mesh shapes. For this reason, primitives and convex shapes are preferred, and are the only viable option for moving objects (weapons, clutter that you can pick up, etc.). Compressed mesh shapes are reserved for static objects only (architecture, furniture, etc.).
+
There are three main types of collision meshes: '''Primitives''', '''Convex Shapes''', and '''Compressed MOPP Shapes'''. Primitives are the simplest, and MOPP shapes are the most complex. The CPU usage required to simulate physics, therefore, is lowest for primitives, slightly higher for convex shapes, and much higher for MOPP shapes. For this reason, primitives and convex shapes are preferred, and are the only viable option for moving objects (weapons, clutter that you can pick up, etc.). MOPP shapes are reserved for static objects only (architecture, furniture, etc.).
  
 
===Primitives===
 
===Primitives===
Line 14: Line 11:
 
Convex shapes are the easiest to create, and are extremely common for clutter items and simple furniture. Simply right-click the mesh in NifSkope, and select ''Havok > Create Convex Shape''. Adjust the roundoff error value if you need more or fewer vertices. The collision radius is an invisible shell around the collision shape, and may need to be adjusted later after testing. Smaller values result in a thinner shell. Generally, if the object is very small, it will likely need a smaller radius.
 
Convex shapes are the easiest to create, and are extremely common for clutter items and simple furniture. Simply right-click the mesh in NifSkope, and select ''Havok > Create Convex Shape''. Adjust the roundoff error value if you need more or fewer vertices. The collision radius is an invisible shell around the collision shape, and may need to be adjusted later after testing. Smaller values result in a thinner shell. Generally, if the object is very small, it will likely need a smaller radius.
  
Convex shapes necessarily can not have concave areas, or "indents." For an object that needs this, use either a compressed mesh shape (if it's a static) or a [[#List Shapes|list shape]], if it is dynamic.
+
Convex shapes necessarily can not have concave areas, or "indents." For an object that needs this, use either a MOPP shape (if it's a static) or a [[#List Shapes|list shape]], if it is dynamic.
  
===Compressed Mesh Shapes===
+
===MOPP Shapes===
Compressed mesh shapes are created in [[AU:Software#3D|3D software]] such as Blender, 3ds Max, or Maya. They are typically much simpler (i.e. fewer vertices) than the visible mesh. This can be done either by decimating a copy of the visible mesh, or removing edge loops manually for a higher quality collision mesh. Compressed meshes can also contain multiple collision materials. They can be exported to nif format using either [[Arcane University:CK-CMD for Skyrim#Including Collision Mesh|ck-cmd]] or [[Arcane University:Niftools/Chunkmerge for Skyrim|ChunkMerge]].
+
MOPP shapes are created in 3D software such as Blender, 3ds Max, or Maya. They are typically much simpler (i.e. fewer vertices) than the visible mesh. This can be done either by decimating a copy of the visible mesh, or removing edge loops manually for a higher quality collision mesh. MOPP meshes can also contain multiple collision materials. They can be exported to nif format using either [[Arcane University:CK-CMD for Skyrim#Including Collision Mesh|ck-cmd]] (single material only) or [[Arcane University:Niftools/Chunkmerge for Skyrim|ChunkMerge]].
  
 
==Special Cases==
 
==Special Cases==
[[File:Woodenbowl_collision.png|400px|thumb|right|The wooden bowl from vanilla Skyrim, showing a list shape collision.]]
+
[[File:Woodenbowl_collision.png|300px|thumb|right|The wooden bowl from vanilla Skyrim, showing a list shape collision.]]
 
===List Shapes===
 
===List Shapes===
List shapes are collections of convex shapes or primitives. They are often used for bowls, that need to have dynamic collision, but cannot use convex shapes, as well as many weapons. These are most easily made in NifSkope by copying a bhkCollisionObject from a similar nif and adjusting it to fit, or making the list shape by hand in NifSkope. Lists of convex shapes can also be made using [[AU:Nifskope for Skyrim#Forks|Spectral's NifSkope fork]].
+
List shapes are collections of convex shapes or primitives. They are often used for bowls, that need to have dynamic collision, but cannot use convex shapes, as well as many weapons. These are most easily made in NifSkope by copying a bhkCollisionObject from a similar nif and adjusting it to fit, or making the list shape by hand in NifSkope.
 
 
List shapes can use different collision materials, as long as the material is specified on the shape itself. Materials on the transform shapes or the list shape are ignored.
 
  
 
===Constraints===
 
===Constraints===
Line 43: Line 38:
 
*Quality Type: MO_QUAL_FIXED
 
*Quality Type: MO_QUAL_FIXED
  
The animated bhkCollisionObject should also have the SET_LOCAL flag, in addition to the usual ACTIVE and SYNC_ON_UPDATE flags. Lastly, make sure the [[Arcane University:NIF Data Format#BSXFlags node|BSXFlags]] of the nif are correct.
+
In addition, the animated bhkCollisionObject should have the SET_LOCAL flag, in addition to the usual ACTIVE and SYNC_ON_UPDATE. Lastly, make sure the [[Arcane University:NIF Data Format#BSXFlags node|BSXFlags]] of the nif are correct.
  
 
==Physics Settings==
 
==Physics Settings==
Physics settings are contained in the bhkRigidBody or bhkRigidBodyT. The only difference between these two blocks is that bhkRigidBodyT has translation enabled—the translation fields in a bhkRigidBody have no effect.
+
Physics settings are contained in the bhkRigidBody or bhkRigidBodyT. The only difference between these two blocks is that bhkRigidBodyT has translation enabled—regardless of what NifSkope shows, the translation fields in a bhkRigidBody have no effect.
  
 
*'''Layer:''' The layer the collision object belongs to. Some layers don't collide with certain other layers. The most common are Static, Animstatic, Clutter, and Weapon. There is also a copy of this field in the "Havok Filter Copy" group which must match.
 
*'''Layer:''' The layer the collision object belongs to. Some layers don't collide with certain other layers. The most common are Static, Animstatic, Clutter, and Weapon. There is also a copy of this field in the "Havok Filter Copy" group which must match.
Line 52: Line 47:
 
*'''Collision Response:''' Determines what to do when collision is detected. Typically always RESPONSE_SIMPLE_CONTACT, unless it is a phantom collision (sensor). There is a copy called "Collision Response 2" which must match.
 
*'''Collision Response:''' Determines what to do when collision is detected. Typically always RESPONSE_SIMPLE_CONTACT, unless it is a phantom collision (sensor). There is a copy called "Collision Response 2" which must match.
 
*'''Translation/Rotation:''' Translates and rotates the collision mesh. Only enabled in bhkRigidBodyT blocks.
 
*'''Translation/Rotation:''' Translates and rotates the collision mesh. Only enabled in bhkRigidBodyT blocks.
*'''<span id="inertia tensors"></span>Inertia Tensors:''' Determines the force necessary to rotate an object around each axis. Ideally would be calculated based on the mass and dimensions of the object, but can be copied from a similar vanilla object, or tweaked until it looks right in game. m11 corresponds to the X-axis, m22 to the y-axis, and m33 to the z-axis. Higher values make the object turn more slowly around that axis. Importantly, if a clutter object lacks inertia tensors, it will slide or float away when Havoked, carrying other nearby clutter with it. Conversely, if a static object has inertia tensors, it will move around when Havok simmed in CK, when it should not.
+
*'''Inertia Tensors:''' Determines the force necessary to rotate an object around each axis. Ideally would be calculated based on the mass and dimensions of the object, but can be copied from a similar vanilla object, or tweaked until it looks right in game. m11 corresponds to the X-axis, m22 to the y-axis, and m33 to the z-axis. Higher values make the object turn more slowly around that axis. Importantly, if a clutter object lacks inertia tensors, it will float away when havoked, carrying other nearby clutter with it. Conversely, if a static object has inertia tensors, it will move around when Havok simmed in CK, when it should not.
*'''Center:''' The center of mass. May not be where the object is held when picked up, since that is determined by the origin point of the nif. If the center of mass is not <tt>0,0,0</tt> in the rigid body, the object will turn over when picked up. If the center of mass is below z=0, the object will right itself when picked up. If the center of mass is above z=0, it will flip upside down.
+
*'''Center:''' The center of mass. May not be where the object is held when picked up, since that is determined by the origin point of the nif.
 
*'''Mass:''' Mass in kg.  
 
*'''Mass:''' Mass in kg.  
 
*'''Linear Damping:''' How much the object's linear velocity is slowed over time. Typically 0.1.
 
*'''Linear Damping:''' How much the object's linear velocity is slowed over time. Typically 0.1.
Line 66: Line 61:
  
 
===Collision Material===
 
===Collision Material===
Collision material is set in each shape. It determines the sound and visual effect when the player strikes it with a weapon, as well as whether arrows stick in it or bounce off, whether it bleeds, and what sound it makes when walked on. Stair materials are used to keep the player from getting stuck when walking up stairs. Compressed meshes can have multiple materials per shape.
+
Collision material is set in each shape. It determines the sound and visual effect when the player strikes it with a weapon, as well as whether arrows stick in it or bounce off, whether it bleeds, and what sound it makes when walked on. Stair materials are necessary on stairs to keep the player from getting stuck when walking up stairs. MOPP meshes can have multiple materials per shape.
 
 
==Troubleshooting==
 
; The nif has collision, but it doesn't seem to in game. : It is likely missing [[AU:NIF Data Format#BSXFlags node|BSXFlags]].
 
; The object slides away when it or a nearby clutter item is touched. : It is missing [[#inertia tensors|inertia tensors]]. Copy them from a vanilla object with similar shape and size.
 
; The nif looks fine, but it crashes the game/CK. : Make sure the blocks are in the proper order (use ''Spells > Reorder Blocks'' in NifSkope). Collision blocks must be in '''descending''' order.
 
; The object floats slightly above the surface it is placed on. : Decrease the radius value of the shape. Default is 0.05. Try 0.01 or 0.005. Very small objects like forks, spoons, or lockpicks may need an even smaller radius.
 
  
 
==Further Reading==
 
==Further Reading==
 
*[https://cgl.ethz.ch/Downloads/Seminar_Arbeiten/2002_03/Havok_Overview.pdf Havok Game Dynamics SDK - Product Overview]
 
*[https://cgl.ethz.ch/Downloads/Seminar_Arbeiten/2002_03/Havok_Overview.pdf Havok Game Dynamics SDK - Product Overview]
* [https://youtube.com/watch?v=Ammbvh0PbKM 'Types of Collision' Arcane University Lecture on collisions by teacher Candoran]
+
 
 
[[Category:Arcane University-3D Art]] [[Category:Arcane University-Method]] [[Category:Arcane University-Implementation]]
 
[[Category:Arcane University-3D Art]] [[Category:Arcane University-Method]] [[Category:Arcane University-Implementation]]

Please note that all contributions to Beyond Skyrim are considered to be released under the Creative Commons Attribution-ShareAlike (see Beyond Skyrim Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)

Templates used on this page: