Difference between revisions of "NifSkope: Adding Collision Model"

formatting...
imported>Entim
m (ouch this article is a mess when I open it with Firefox)
imported>Entim
(formatting...)
Line 18: Line 18:
*Make your model in your 3D modeller application.
*Make your model in your 3D modeller application.
*Create the low-poly version of the model without any texturing or material settings.
*Create the low-poly version of the model without any texturing or material settings.
*Export these models in NIF or OBJ format.
*Export these models in NIF or OBJ format. Pay attention to remove duplicated vertices before exporting!
**See [[NIF Importers and Exporters]] for import and export plugins.
**See [[NIF Importers and Exporters]] for import and export plugins.
**See [http://www.niftools.org/wiki/index.php/NifSkope/Mesh_import_export NifTools.org: Mesh import export] for OBJ exporting help.
**See [http://www.niftools.org/wiki/index.php/NifSkope/Mesh_import_export NifTools.org: Mesh import export] for OBJ exporting help.
Line 40: Line 40:


In every instance of NifSkope you should see the appropriate model in the render window, a Block List window, and a Block Details window.
In every instance of NifSkope you should see the appropriate model in the render window, a Block List window, and a Block Details window.


===Preparing the arstatue01 model===
===Preparing the arstatue01 model===
Line 45: Line 47:
The ''arstatue01.nif'' was chosen becouse it's collision geometry data format allows importing custom made models' geometry. You are going to import your high-poly and low-poly models' data into this file, but first the unneccessary data need to be removed.
The ''arstatue01.nif'' was chosen becouse it's collision geometry data format allows importing custom made models' geometry. You are going to import your high-poly and low-poly models' data into this file, but first the unneccessary data need to be removed.


*Swich to the instance of NifSkope where ''arstatue01.nif'' was loaded. This will be your final model at the end of the process, so save it with a different name.
{|
[[image:CollTut01.gif|100px|right|thumb]]
|-
*Expand '''0 NiNode''' block on the Block List window, and right-click on '''7 NiTriStrips'''. Choose '''Block -> Remove Branch''' from the pop-up menu. The 7 NiTriStrips block should be gone. Remove the remaining four NiTriStrips blocks. These blocks contained every information of the model (geometry, textures, material properties), except the collision data. The remaining red wireframe represents the collision geometry. Enable '''Draw Havok''' in the '''Render''' menu if you can't see it.
|valign="top"|<font size=2>'''1.''' </font>Swich to the instance of NifSkope where ''arstatue01.nif'' was loaded. This will be your final model at the end of the process, so save it with a different name.
[[Image:CollTut06.gif|100px|right|thumb]]
|-
*Navigate to the '''3 NiTriStripsData''' block, and choose '''Block -> Remove''' after right-clicking. This block contains the collision geometry data. The render window should be empty now.
|valign="top"|<font size=2>'''2.''' </font>Expand '''0 NiNode''' block on the Block List window, and right-click on '''7 NiTriStrips'''. Choose '''Block -> Remove Branch''' from the pop-up menu. The 7 NiTriStrips block should be gone. Remove the remaining four NiTriStrips blocks. These blocks contained every information of the model (geometry, textures, material properties), except the collision data. The remaining red wireframe represents the collision geometry. Enable '''Draw Havok''' in the '''Render''' menu if you can't see it.
[[Image:CollTut02.gif|100px|right|thumb]]
|[[image:CollTut01.gif|thumb|100px]]
*Select '''5 bhkRigidBodyT''' block in the '''Block List''' window, and double-click on the '''Value''' of the '''Translation''' in the '''Block Details''' window. Set x, y, and z to zero. This positions the collision geometry to the origo.
|-
 
|valign="top"|<font size=2>'''3.''' </font>Navigate to the '''3 NiTriStripsData''' block, and choose '''Block -> Remove''' after right-clicking. This block contains the collision geometry data. The render window should be empty now.
 
|[[Image:CollTut06.gif|thumb|100px]]
 
|-
|valign="top"|<font size=2>'''4.''' </font>Select '''5 bhkRigidBodyT''' block in the '''Block List''' window, and double-click on the '''Value''' of the '''Translation''' in the '''Block Details''' window. Set x, y, and z to zero. This positions the collision geometry to the origo.
|[[Image:CollTut02.gif|thumb|100px]]
|}




Line 63: Line 68:
Instead of the low-poly model, you can use a '''NiTriShape''' or '''NiTriStrips''' block from any NIF (including the high-poly model!).
Instead of the low-poly model, you can use a '''NiTriShape''' or '''NiTriStrips''' block from any NIF (including the high-poly model!).


*Switch to the instance of NifSkope where you loaded your low-poly model.
{|
[[Image:CollTut07.gif|100px|right|thumb]]
|-
*Expand the '''0 NiNode''' block. If you exported only the geometry of the model, it contains one '''NiTriShape''' and one '''NiTriShapeData''' block. Right-click on the '''NiTriShape''' block, and choose '''Mesh -> Face Normals''' from the menu. (Before NifSkope version 0.9.4: '''Make Normals'''.)
|valign="top"|<font size=2>'''1.''' </font>Switch to the instance of NifSkope where you loaded your low-poly model.
[[Image:CollTut08.gif|100px|right|thumb]]
|-
*Right-click on the '''NiTriShape''' block again, and choose '''Mesh -> Strippify''' from the menu. This converts the the geometry from triangles to strips. Strippifying is needed becouse the collision geometry of ''arstatue01.nif'' was built from strips, and the low-poly model's geometry is going to replace it.
|valign="top"|<font size=2>'''2.''' </font>Expand the '''0 NiNode''' block. If you exported only the geometry of the model, it contains one '''NiTriShape''' and one '''NiTriShapeData''' block. Right-click on the '''NiTriShape''' block, and choose '''Mesh -> Face Normals''' from the menu. (Before NifSkope version 0.9.4: '''Make Normals'''.)
*Reset the '''Translation''' in the '''Block Details''' window if it is not zero.
|[[Image:CollTut07.gif|100px|thumb]]
|-
|valign="top"|<font size=2>'''3.''' </font>Right-click on the '''NiTriShape''' block again, and choose '''Mesh -> Strippify''' from the menu. This converts the the geometry from triangles to strips. Strippifying is needed becouse the collision geometry of ''arstatue01.nif'' was built from strips, and the low-poly model's geometry is going to replace it.
|[[Image:CollTut08.gif|100px|thumb]]
|-
|valign="top"|<font size=2>'''4.''' </font>Reset the '''Translation''' in the '''Block Details''' window if it is not zero.
|}
 
 


===Importing the new data===
===Importing the new data===


[[Image:CollTut03.gif|100px|right|thumb]]
{|
*Switch to your high-poly model. Select the '''NiTriShape''' block. Reset the '''Translation''' in the '''Block Details''' window if it is not zero. Right-click on the '''NiTriShape''' block, and choose '''Block -> Copy Branch''' from the menu.
|-
[[Image:CollTut04.gif|100px|right|thumb]]
|valign="top"|<font size=2>'''1.''' </font>Switch to your high-poly model. Select the '''NiTriShape''' block. Reset the '''Translation''' in the '''Block Details''' window if it is not zero. Right-click on the '''NiTriShape''' block, and choose '''Block -> Copy Branch''' from the menu.
[[Image:CollTut05.gif|100px|right|thumb]]
|[[Image:CollTut03.gif|100px|right|thumb]]
*Switch back to the cleaned NIF (which was ''arstatue01.nif''). Right-click on '''0 NiNode''' and choose '''Block -> Paste Branch'''. NifSkope will probably argue about NIF versions, choose '''Continue'''. The high-poly model's NiTriShape, which contains geometry, texture, material data, is pasted in now.
|-
[[Image:CollTut14.gif|100px|right|thumb]]
|valign="top"|<font size=2>'''2.''' </font>Switch back to the cleaned NIF (which was ''arstatue01.nif''). Right-click on '''0 NiNode''' and choose '''Block -> Paste Branch'''. NifSkope will probably argue about NIF versions, choose '''Continue'''. The high-poly model's NiTriShape, which contains geometry, texture, material data, is pasted in now.
*Double-click on the '''Value''' of '''Num Children''' attribute in the '''Block Details''' window. This number controls how many child objects the NiNode has. Set it to 1. Expand '''Children'''. The list of the NiNode's children is not updated automatically, it still contains six references. The five Children with ''None'' value were the NiTriShapes you have removed, the sixth is the NiTriShape you have just pasted.
|[[Image:CollTut04.gif|100px|right|thumb]]
[[Image:CollTut16.gif|100px|right|thumb]]
|-
*Right click on the '''Children''' attribute, and choose '''Array -> Update'''. This updates the size of the Children list according to Num Children.
|
[[Image:CollTut17.gif|100px|right|thumb]]
|[[Image:CollTut05.gif|100px|right|thumb]]
*Expand '''Children''', and set its child's '''Value''' to the reference number of your NiTriShape ('''6'''). The high-poly model's NiTriShape is linked correctly to the NiNode now.
|-
[[Image:CollTut09.gif|100px|right|thumb]]
|valign="top"|<font size=2>'''3.''' </font>Double-click on the '''Value''' of '''Num Children''' attribute in the '''Block Details''' window. This number controls how many child objects the NiNode has. Set it to 1. Expand '''Children'''. The list of the NiNode's children is not updated automatically, it still contains six references. The five Children with ''None'' value were the NiTriShapes you have removed, the sixth is the NiTriShape you have just pasted.
*Switch to your low-poly model. Right-click on the '''NiTriStripsData''' block, and choose '''Block -> Copy'''.
|[[Image:CollTut14.gif|100px|right|thumb]]
[[Image:CollTut10.gif|100px|right|thumb]]
|-
*Switch back to the cleaned NIF. Right-click on the '''0 NiNode''' block, and choose '''Block -> Paste'''. Choose Continue again if NifSkope argues about the NIF version.
|valign="top"|<font size=2>'''4.''' </font>Right click on the '''Children''' attribute, and choose '''Array -> Update'''. This updates the size of the Children list according to Num Children.
[[Image:CollTut11.gif|100px|right|thumb]]
|[[Image:CollTut16.gif|100px|right|thumb]]
*Select the '''4 bhkNiTriStripsShape'''. Double-click on the '''Value''' of the '''Strips Data''' entry in the '''Block Details''' window, and enter the reference number of the new NiTriStripsData ('''1'''). The low-poly model's geometry data is now linked to the collision shape.
|-
[[Image:CollTut15.gif|100px|right|thumb]]
|valign="top"|<font size=2>'''5.''' </font>Expand '''Children''', and set its child's '''Value''' to the reference number of your NiTriShape ('''6'''). The high-poly model's NiTriShape is linked correctly to the NiNode now.
*The collision data blocks must be in a specific order, which the NiTriStripsData doesn't fit in yet. Choose '''Reorder Havok Blocks''' from the '''Spells''' -> '''Sanitize''' menu. To reorder the blocks manually, right-click on the '''1 NiTriStripsData''' block, and choose '''Block -> Move Down'''. Notice the reference number has changed to '''2'''. Repeat the '''Move Down''', so the number becomes '''3'''.
|[[Image:CollTut17.gif|100px|right|thumb]]
*Save the NIF.
|-
 
|valign="top"|<font size=2>'''6.''' </font>Switch to your low-poly model. Right-click on the '''NiTriStripsData''' block, and choose '''Block -> Copy'''.
|[[Image:CollTut09.gif|100px|right|thumb]]
|-
|valign="top"|<font size=2>'''7.''' </font>Switch back to the cleaned NIF. Right-click on the '''0 NiNode''' block, and choose '''Block -> Paste'''. Choose Continue again if NifSkope argues about the NIF version.
|[[Image:CollTut10.gif|100px|right|thumb]]
|-
|valign="top"|<font size=2>'''8.''' </font>Select the '''4 bhkNiTriStripsShape'''. Double-click on the '''Value''' of the '''Strips Data''' entry in the '''Block Details''' window, and enter the reference number of the new NiTriStripsData ('''1'''). The low-poly model's geometry data is now linked to the collision shape.
|[[Image:CollTut11.gif|100px|right|thumb]]
|-
|valign="top"|<font size=2>'''9.''' </font>The collision data blocks must be in a specific order, which the NiTriStripsData doesn't fit in yet. Choose '''Reorder Havok Blocks''' from the '''Spells''' -> '''Sanitize''' menu. To reorder the blocks manually, right-click on the '''1 NiTriStripsData''' block, and choose '''Block -> Move Down'''. Notice the reference number has changed to '''2'''. Repeat the '''Move Down''', so the number becomes '''3'''.
|[[Image:CollTut15.gif|100px|right|thumb]]
|-
|valign="top"|<font size=2>'''10.''' </font>Save the NIF.
|}




Line 98: Line 124:
===Fixing up===
===Fixing up===


NIFs created by this method appearanly always act like stone, no matter what their
NIFs created by this method appearanly always act like stone, no matter what their Material property is set to.
Material property is set to.


You have to insert a bhkListShape to solve this problem.
You have to insert a bhkListShape to solve this problem.
*Right-click on the '''5 bhkRigidBodyT''' block. Choose '''Block''' -> '''Insert''' -> '''BHK''' -> '''bhkListShape'''.
*Right-click in the Block List window, and choose '''Block''' -> '''Insert''' -> '''BHK''' -> '''bhkListShape'''.
*Set the '''bhkRigidBodyT''' block's '''Shape''' property to the reference number of the new bhkLishShape ('''6''') in the '''Block Details''' window. The bhkListShape is now linked to the bhkRigidBodyT block.
*Set the '''bhkRigidBodyT''' block's '''Shape''' property to the reference number of the new bhkLishShape in the '''Block Details''' window. The bhkListShape is now linked to the bhkRigidBodyT block.
*Set the '''bhkListShape''' block's '''Num Sub Shapes''' property to 1. Update the '''Sub Shapes''' array, just as you did when linked the high-poly model's NiTriShape to the NiNode.
*Set the '''bhkListShape''' block's '''Num Sub Shapes''' property to 1. Update the '''Sub Shapes''' array, just as you did when linked the high-poly model's NiTriShape to the NiNode.
*Expand the '''Sub Shapes''' array, and enter the reference number of the bhkNiTriStripsShape ('''4''').
*Expand the '''Sub Shapes''' array, and enter the reference number of the bhkNiTriStripsShape.
*Reorder the havok blocks.
*Reorder the havok blocks.
  Example of the result NIF is [http://www4.rapidupload.com/d.php?file=dl&filepath=27622 here].
  Example of the result NIF is [http://www4.rapidupload.com/d.php?file=dl&filepath=27622 here].


==Refining Collision Properties==
==Refining Collision Properties==
Line 118: Line 145:
*Select '''4 bhkNiTriStripsShape''' block. Double-click on the '''Value''' of the '''Material''' property (currently '''HAV_MAT_STONE'''). You get a drop-down list of available materials. This list with some explanation is available as tooltip (hold your mouse over the '''Type''' field of the Material property). Choose the material from the dropdown list, or enter the appropriate number which can be found [http://niftools.sourceforge.net/docsys/index.php?mode=list&table=attr&block_id=383&version=335544325 here] as well. This setting controls the hit sound, step sound, arrow penetrability, and particle effect of the surface.
*Select '''4 bhkNiTriStripsShape''' block. Double-click on the '''Value''' of the '''Material''' property (currently '''HAV_MAT_STONE'''). You get a drop-down list of available materials. This list with some explanation is available as tooltip (hold your mouse over the '''Type''' field of the Material property). Choose the material from the dropdown list, or enter the appropriate number which can be found [http://niftools.sourceforge.net/docsys/index.php?mode=list&table=attr&block_id=383&version=335544325 here] as well. This setting controls the hit sound, step sound, arrow penetrability, and particle effect of the surface.
*If you inserted a '''bhkListShape''' block, click on it, and notice that it also has a '''Material''' property. You can tweak the arrow penetration, particle effect, and sound by the material settings of the bhkListShape and the bhkNiTriStripsShape blocks. Arrows will only penetrate if both block's material is penetrable.
*If you inserted a '''bhkListShape''' block, click on it, and notice that it also has a '''Material''' property. You can tweak the arrow penetration, particle effect, and sound by the material settings of the bhkListShape and the bhkNiTriStripsShape blocks. Arrows will only penetrate if both block's material is penetrable.


===Collision properties===
===Collision properties===
Line 127: Line 153:
Most important properties:
Most important properties:
*The '''layer''' settings control the mesh color in '''CS''', wheather it behaves like a harvestable object like plants (no collision, but the activator icon shows up), and arrow penetrability. The list of layers with some explanation is also available as tooltip.
*The '''layer''' settings control the mesh color in '''CS''', wheather it behaves like a harvestable object like plants (no collision, but the activator icon shows up), and arrow penetrability. The list of layers with some explanation is also available as tooltip.
*'''Motion System''', '''Unknown Byte 1''' and '''2''', '''Quality Type''' controls wheather the object is static or mobile.
*'''Motion System''', '''Unknown Byte 1''' and '''2''', '''Quality Type''' controls wheather the object is static or mobile. See [[Finessing_Physics#The_Main_Blocks|Finessing Physics]] tutorial's bhkRigidBody explanation.


Compare these properties to other NIFs, and change them accordingly.
Compare these properties to other NIFs, and change them accordingly.


Further information about the NIF format and NifSkope can be found at [http://www.niftools.org NifTools.org]. Information about NIF format/Havok system is [http://www.niftools.org/wiki/index.php/Category:NIF_Format here].
Further information about the NIF format and NifSkope can be found at [http://www.niftools.org NifTools.org]. Information about NIF format/Havok system is [http://www.niftools.org/wiki/index.php/Category:NIF_Format here].


==Troubleshoot==
==Troubleshoot==
Anonymous user