skyfox69 / NifUtilsSuite

Collection of NifUtils within one App
10 stars 2 forks source link

[ChunkExtract] Collision transform not inheriting parent node's transforms #57

Open hexabits opened 10 years ago

hexabits commented 10 years ago

I am using 1.2.2.978. When ChunkExtracting a collision from a NIF which has bhkCollisionObjects in sub-nodes i.e. not the parent BSFadeNode, the resulting NIF has transforms that are all zeroed even if the parent NiNode(s) had transform offsets.

Example: meshes\architecture\solitude\scastlewall04.nif

Structure:

0 BSFadeNode (X 0.0000 Y 0.0000 Z 0.0000)
    ...
    7 NiNode (X 380.0425 Y -69.5439 Z 91.8053)
        12 bhkCollisionObject

The NIF produced by ChunkExtract does not offset the collision into the correct position. It should either keep the same depth, and however deep replicate the parent NiNodes with their transforms intact, or it should condense all these transforms into one transform for one parent NiNode.

This makes importing the collision into 3ds Max a pain since the collision does not show up where it should, since the visible mesh and the collision no longer have the same origin/transform. Secondarily, there is a compounding issue with ChunkMerge and bhkCollisionObjects where sub-nodes aren't recognized by Templates, and also the bhkCO is unable to be inserted back into the mesh at the proper depth. (Issue #58)

hexabits commented 10 years ago

Primary Issue

Example non-working meshes

Including original NIF, original collision, modified collision, and template (which is just original NIF in this case). No output NIF, since ChunkMerge fails.

Example working meshes

These had to be done by hand.

  1. First "Crop to Branch" on the NiNode in the original NIF so that the collision object is right below the root. Save as TMPL NIF.
  2. Copy scastlewall04.nif, do same thing for INPUT NIF.
  3. Make copy of INPUT, rename to OUTPUT (only for the purposes of this example, since I need to show the pre-ChunkMerge input NIF)
  4. Run ChunkMerge using OUTPUT, EXPORT01, and TMPL NIFs.
  5. Copy scastlewall04.nif to FINAL NIF.
  6. Open FINAL and OUTPUT NIFs, delete bhkCollisionObject in destination NIF (FINAL) and copy/paste new bhkCO from OUTPUT > FINAL.
  7. Now finally you have a NIF with the new collision.

In case there is any confusion:

NIF Description
scastlewall04 Original NIF
scastlewall04_coll+ORIGINAL Original collision, from ChunkExtract
scastlewall04_coll+EXPORT01 Modified collision, exported from Max
scastlewall04+TMPL Modified NIF in order to avoid ChunkMerge error
scastlewall04+INPUT.nif Pre-ChunkMerge input NIF
scastlewall04+OUTPUT.nif Post-ChunkMerge output NIF
scastlewall04+FINAL.nif Original NIF with bhkCO from +OUTPUT

Secondary Issue

Importing scastlewall04.nif and scastlewall04_coll+ORIGINAL.nif into 3ds Max will give you two meshes in different locations.

The collision is "incorrectly" at the origin, whereas the visible part of the mesh is offset by its transform values, so to work on the collision at all, you need to move the visible mesh. This isn't a huge ordeal, but it can be very tricky. If you move the collision, you need to reset the transform before export, or manually zero out the transform in NifSkope.