Jump to content

GUIDE 2018 - Creating collisions for LE & SE


ruddy88

Recommended Posts




---COLLISION TUTORIAL---

[LE AND SE collisions. This is more so for Weapon collisions but will work for statics and can probably be modified for any other collisions. The only exception may be soft body collisions]

I've been working on weapons lately and decided to add custom collisions to them rather than copying collisions from vanilla.

Here's a quick guide on how I managed to get it to work as I found a lot of info is outdated.


TOOLS YOU WILL NEED:

Blender/3DMax + required NIF scripts for exporting (for exporting your nif collision shapes)

NifUtilsSuite (For ChunkMerge) - https://github.com/skyfox69/NifUtilsSuite

Vanilla Barrel01.nif (To use as a template nif)

NifSkope (Im using the latest alpha release) - https://github.com/niftools/nifskope/releases

SE NIF OPTIMISER TOOL (For SE Users, we will be creating an LE mesh that can then be converted at the end) - https://www.nexusmods.com/skyrimspecialedition/mods/4089/


SETUP:

Blender/3DMax -

I wont be going through the blender setup, for this I recommend just following the Dark Creations Blender 2.7 tutorial for creating static NIFs. There are similar guides for using 3DS.

Essentially you just need to be at the stage of being able to export a NIF with a trishape and shader properties, the rest of the blocks we can make ourselves (for weapons, I added in some extra info at the end).


This site explains how to export static nifs and works fine.

It also explains how to export collisions, however the information is not complete for havok collisions and doesnt explain the setup requirements for NifUtilsSuite (which I have included in the very next section).

NifSkope - Just download and extract the archive to wherever you want.

NifUtilsSuite -

This is the complicated bit.

First things first, download and extract the archive to wherever you want it installed.

I keep all my Nif programs in one folder in my program files so everything is close by.

Before we set our preferences in NifUtilsSuite, we are going to create a template NIF to use.

For this, the Barrel01.nif seems to be the best as it has all the blocks we need.

So, your first step is to obtain the vanilla Barrel01.nif. If you are following this guide you should know how to extract vanilla meshes.

This HAS to be the LE version of the mesh so if you do not have LE installed, an alternative is to grab a barrel replacer mod (one that includes a mesh), just be sure to check permissions, even though you wont be including it in your mesh you are still using its collision settings so be safe, and use open permission assets.

Open the barrel01.nif in NifSkope, expand the 0BSFadeNode block.

Now, right click on EACH block and select Remove Branch, EXCEPT for the bhkCollisionObject (and its sub blocks).

So, You want to delete any NiNodes, NiTriShapes, NiControllerManager.

You should be left with the following:

0BSFadeNode

bhkCollisionObject

bhkRigidBody

bhkMoppBvTreeShape

bhkCompressedMeshShape

bhkCompressedMeshShapeData

Save As and just name it BarrelTEMPLATE.nif.

Navigate to your NifUtilsSuite installation folder, make a new folder inside it, name it "Templates" and copy your BarrelTEMPLATE.nif file in to this folder.

Thats it for the reference NIF.


The first time you run NifUtilsSuite it will prompt you with a setup screen.

If not, go to Options/Edit and click the general tab.

The first thing we need to do is set the nif.xml.

Click on the folder, navigate to wherever you have NifSkope installed and select the Nif.XML file.

For textures, just navigate to your Skyrim Data directory.

Now for templates, navigate to your NifUtilsSuite folder and select the Template folder you just made.

You can skip the next two sections and leave them blank.

Lastly, for the NifSkope field just navigate to your NifSkope.exe file (wherever its installed).


Thats it for our setup, just go through and make sure any other required programs are installed.



MAKING COLLISIONS:

First create you actual object mesh.

Ignore collisions for now, and just focus on getting a working NIF in the game.

Make sure your Blender file (or 3DS file) is sized correctly already and is not relying on transforms applied in NifSkope.

This is important as collision meshes are not easily transformed in NifSkope.

Now, you can use this same mesh shape for the collision if you want, or you can create a new simpler mesh for your collisions.

Either choice doesnt matter.

To export your collision mesh, just export the same way you did with your regular mesh, however, it is advised to give all faces a smooth shading (I read this in another guide, I am not sure if it is necessary, flat shaded faces may stil work fine aswell).

Export your mesh with a different file name to your original mesh (I just add _c to the end of the file name).


Now you should have two NIFs exported, your object mesh and your collision mesh.

Open your collision mesh, expand the BSFadeNode, expand the NiTriShape, right click on the BSLightingShaderProperty block and select remove branch.

Your collision mesh should only contain:

0BSFadeNode

NiTriShape

NiTriShapeData

If any other blocks were exported with it just delete them.

Click on the NiTriShape block.

In the Block Details window, left click on the 'txt' icon next to name (the actual icon).

In the popup window, type in "SKY_HAV_MAT_SOLID_METAL" and hit OK.

(You can change the material type later, you can type in the actual material type you want however the list of havok definitions on the NIFTOOLS wiki page is currently down so I am just using this one and changing it later).

Save the nif.


Now open NifUtilsSuite.

Click on the ChunkMerge tab.

For In-File, navigate to your object nif.

For the Out-File, navigate to your collision nif.

For the Template, it should already be pre-filled with your BarrelTEMPLATE.nif, if you have other templates saved then change it to the BarrelTEMPLATE.nif we made earlier by selecting it from the drop down list.

For Collision Source, select "Collision Fallback Mesh".

For Collision Material, select "Name of NiTriShape".

Click Add Collision.

You should get a notification in the bottom left saying collision data added.

Close NifUtilsSuite.


Open your object mesh, it should now have a bhkCollisionObject block (and its sub blocks).

Last thing you will need is a BSX flag.

Right click on the BSFadeNode, select NODE/Attach Extra Data and select BSX Flags.

Click on the new BSXFlags block, click the txt icon in the Block Details window and name it BSX

For the integer data, double click on the space next to the flag icon and type 194


For statics, that should be all you need to do.

The object will now have a complex collision added to it that will stop actors from passing through it.

However, it will not have gravity applied to it and will not react when something collides with it.


So, for the next step, you will need to find a similar NIF for what you want.

In my case, I was creating a weapon, so I opened up the Keening Dagger mesh.

Now, you will notice that some objects have a different shape type to them, we are using a bhkMoppBvTreeShape, whereas other weapions may use a boxtype, or a bhkConvexVertices blocks etc.

This doesnt matter, these sub blocks ONLY control the material types and the actual vertice positions.

All the actual havox physics are all controlled by the parent block which is the same for all types (that ive seen).

To clarify:

There are multiple TYPEs of collision shapes, but they are ALL contained within a bhkRigidBody (or bhkRigidBodyT) block, which is in turn contained in a bhkCollisionObject block.


Moving on,

Open your Object mesh with collision, and open your similar mesh.

Note: For SE users without LE, you currently have an LE mesh, but you CAN use an SE vanilla mesh as your reference, we wont be copying blocks over, we are only using it as a guide to change some values.


OK.

In your object mesh, expand BSFadeNode, expand bhkCollisionObject.

Its worth checking that the Target and Body fields are both assigned.

Target should be whatever node your trishape is in (usually BSFadeNode but may be a different node for some weapon setups such as maces).

Body should be assigned to bhkRigidBody.


Now, in your Block List window, expand the bhkCollisionObject block and select the bhkRigidBody block.

Expand the same blocks in your reference NIF as well.

It helps to put both copies of NIFSkope side by side for this.


The last thing we need to do is change a few fields on your object nif to reflect those on your reference nif.

Ill go through the main ones that I needed to change, you may run in to times when this is different though so be wary.

Shape - This will point to a bhjMoppBvTreeShape, this may be different in your reference NIF, but leave it as is.

Havok Col Filter / Layer - I had to change this from STATIC to WEAPON * Take note of what you select here.

Havok Col Filter Copy - Not sure why this is here again but make the same changes for this field.

Inertia - You will probably have all 0's in your nif, copy the values from your reference NIF if they are different.

Mass - This will be 0, change it as per your reference NIF, if you dont, your object will have no gravity applied to it.

* Copy any other values that are different from all fields from Linear Damping to Penetration Depth.

You can modify the value of penetration depth if you wish, this seems to cause the object to sink through the floor a little bit.

Motion System, Deatcivator Type, Solver Deactivation and Quality Type - Copy these fields to reflect your reference NIF, these seem to control the motion types of your object.


There will be other fields that are different, such as various INT fields and whatnot, these did not need to be modified in my case.


That should be it for the bhkRigidBody block.


The last steps:

Expand your bhkRigidBody block, expand bhkMoppBvTreeShape, expand bhkCompressedMeshShape and finally select the bhkCompressedMeshShapeData block.

In the Block Details tab, expand the Chunk Materials field twice.

Under Material, you can select the material type that best suits your object. I chose MAT_MATERIAL_BLADE_HAND.

For the Layer field, select the same option you chose earlier for Havok Col Filter.



And that should be it for your collisions. Save your object mesh, you can close your reference NIF now as well.



FURTHER NOTES:


Your collisions should be fine now, but if you ARE working on a weapon as well there may be some further adjustments to make.

This will differ depending on what kind of weapon you are making.

Open up a reference mesh again to see what block are required.

One of the first ones will be a NiStringExtraData block.

Right click on the BSFadeNode and choose Node, Attach Extra Data, and select NiStringExtra Data.

Select this new block.

Change the name to "Prn" by clicking the txt icon.

For the String Data, change it to "WeaponDagger" or "WeaponMace" etc, depending on the type of weapon you are using (see the correct spelling by comparing it to your reference nif).

You can also add a BSInvMarker if you want, this just lets you modify the placement of the displayed model when in the inventory. It isnt necessary but it can be useful if your mesh is displaying oddly in inventory.

To add one, right click on the BSFadeNode, select Block, Insert, and find the BSInvMarker block.

Select the new block.

Change the Name to "INV" (click the small txt icon).

Adjust the Rotations and Zoom however you want. I recommend leaving these as 0 then seeing how your inventory model displays, make adjustments from there.


You will also notice that weapons have two extra trishapes for the edgeblood.

I wont go in to full detail here but basically you just need to re-open your blender file, duplicate your object mesh, delete all vertices from handles and such so that only the blade is left, then increase the scale by a tiny amount (0.01 or something).

Export this as a trishape and just copy it in to your current object nif. Copy the BSLightingShader settings (important to have the Dynamic Decal shader flag set) from one of the edge blood blocks from your reference mesh. Also rename the EdgeBlood trishapes appropriately.

You will also see a trishape for the scabbard.

Again, you will need to export your scabbard mesh and copy it into your object mesh.

Rename the trishape to "Scb".

From what I can tell, this Name field is the only thing that stops the animation from taking the scabbard with the sword/dagger.


If you are creating a Mace then you will see some differences.

For whatever reason these weapons were created a little differently, basically the scabbard is attacked to the fade node, but the actual weapons shapes are all held in a seperate node. Youll need to make sure all your weapon trishapes and edge blood shapes are all kept in the same place IF you are using the same weapon type (so your NiStringExtraData will be called WeaponMace).


Anyway, that should be all you need for a working weapon nif.


For SE users following along, the last step for you is to run your nif through the SE Nif Optimiser tool, this is necessary as the NiTriShapeData block gets merged in to the NiTriShape block, which is also now changed to a BSTriShape block.


Try it out, hopefully it all works.



Ive tried to be thorough here, hopefully you can all follow along, if anyone has any questions just leave a comment and I'll help as much as I can!



Link to comment
Share on other sites

  • 1 year later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...