Jump to content

Custom collision meshes/physics from scratch


Recommended Posts

When creating new weapon models, I have encountered a problem of them lacking physics and/or collision.

I have heard of the way where you'd replace a vanilla item mesh with the custom one via NifSkope, using existing collision model, but sometimes the collision just isn't accurate enough. Attempting to correct its model in Blender usually breaks physics, making the item float mid-air, but at least remaining collidable and pickable. My other attempts to correct this usually leave the mesh not only floating, but also disables collisions altogether.

Searching for solutions online, I've stumbled upon some old Fallout 4 forums, spotting mentions of using .obj files for that matter as an alternative, but, frankly speaking, I didn't catch much at the time, and perhaps misunderstood it as well.

So, my question is - what is a proper way to do custom collision meshes for new items? I've been battling this issue since my attempts at FNV modding as well, and it still hinders me in Oblivion.

Link to comment
Share on other sites

It seems that your exporter created right collision object (you can pick it up, but it's floating), but somewhat wrongly set up nif's BSX flags or simulation types in its bhkRigidBody part. In NifSkope I would check these things:

1. When you open your nif in NifSkope, check if BSX flag is set to 3 (zero bit (EnableHavok) and first bit (EnableCollision) must be set).

2. In bhkRigidBody check these: Layer - if it's set to OL_STATIC, change it. Motion system - change it if it's set to MO_SYS_FIXED. Quality Type - change it, if it's set to MO_QUAL_FIXED.

I learned this when I was trying to make Mysterium Xarxes book movable.  I'm not 3D artist of any sort, so I'm sorry I can't offer more help.

 

 

Link to comment
Share on other sites

Well, I have tried doing that just now, but something is off. Namely, the collision seems to only occur at the crossguard of the weapon, as if only one of the collision objects (bhkCapsuleShape, in this case) works properly, leading to geometry clipping. 

I am quite confident it's a problem caused by my attempts to adjust these capsules via Blender, which, as I've learned later, may cause such mishaps. The .nif structure also looked off, with two extra NiNodes containing collision objects within the "root" NiNode, which don't contribute to the collision even after setting proper Layer, Motion System and Quality Type. I've tried moving their contents (aforementioned bhkCapsuleShape) to this "root" NiNode, but they only seem to be pasted outside of it. Even setting their target as that "root" Node didn't seem to do much.

To be frank, I am not even sure what is the problem at this point. It's just becoming more and more frustrating. Right now, I have resorted for using existing collision models for my mod, but this issue really bothers me.

Link to comment
Share on other sites

Checking some weapons in NifSkope I see that weapons use two bhkCapsuleShape structures - one for crossguard and one for handle and blade. These two structures are referenced in bhkListShape structure. And then this bhkListShape is referenced in bhkRigidBody.

So the hieharchy goes like this for weapons: bhkCollisionObject -> bhkRigidBody ->bhkListShape -> bhkCapsuleShape(s). Perhaps there is a problem on last two levels - maybe one of CapsuleShapes is wrong or is not referenced in bhkListShape in Sub Shapes field.

Link to comment
Share on other sites

Yeah, that could be the reason. None of my bhkCapsuleShapes seem to have bhkListShape. However, one of them still works. Like I've said, the two other capsules, for some reason, are contained within extra NiNodes within the main NiNode which contains everything else. I just don't know how to extract them. Whenever I remove the two extra NiNodes, bhkCollisionObjects inside are put outside of the main NiNode, and I can't seem to figure out how to move them back inside. They aren't draggable and can't be copypasted or nested inside the main Node, only making copies outside of it. Here's how it looks like, before and after removing said extra nodes.

nodestuff.png.2299d3c2bddefba44706fd185321b4b2.png

 

Link to comment
Share on other sites

Ehm, no. The hieharchy I posted is from up to down, so bhkCapsuleShape as the last doesn't refer to another structure anymore. Also structure you posted seems really mismatched. As example I took look to random weapon I find, a claymore from Lost Paladins of the Divines mod: 

Claymore in NifSkope

And very first structure refers only to one bhkCollisionObject as seen on this picture. The rest is what I posted already - bhkCollisionObject will refer to bhkRigidBody and so on and last reference will be in bhkListShape, which will refer the bhkCapsuleShape structure(s). However, author used most simple method and CS Wiki mentions another one suited for Blender. Maybe this will help more:https://cs.uesp.net/wiki/Blender/Custom_Sword.

Link to comment
Share on other sites

Yeah, I get the part about hierarchy now, I must've meant a different bhk part, but I was up really late and mistook one for another.
And like I've said, export from Blender must've done something off to the nodes, hence why they all look terribly mismatched, as I took the collisions from an existing model (which, in a retrospect, I probably shouldn't have done).

At any rate, the link you gave me seems to have just what I need, and a little more. So, thank you, I'll look into it a bit later.

Link to comment
Share on other sites

I have attempted creating collision mesh in accordance with this specific article I've found in the article you linked to me. Unfortunately, something strange goes on with the exporter, as it skips rigid body export for all the capsules I've created, saying they have no rigid body. I must add that the article in question had extra instructions in images. However, said images are missing, since not everything was recovered from the original site. I also suspect that some of the export options are not accessible to me since I'm using Blender 3.6.1, and NifTools doesn't seem to be fully fitted for it. Perhaps, I'm missing something cruicial.

Right now I am attempting to get it working on older Blender versions. Not sure if it'll do the trick, but why not.

Link to comment
Share on other sites

Though quite outdated (from 2011) there is also offline backup of CS Wiki made by @LHammonds. Unfortunately a file size is quite big, because of photobucket junkie pictures embeeded in it (some tutorial pics come from this site). However part you're interested in has pictures embeeded in its base cs.elderscrolls.com directory, so all you propably need is to unpack only this one and index.html file to see whole article with pictures. 

Besides, there are also few tutorials in Modders Resources & Tutorials section.

  • Thanks 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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