SHARE
TWEET

Untitled

a guest Dec 31st, 2017 206 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. procedure CopyCollision(aSource, aDestination: string);
  2. var
  3.   SrcNif, DstNif: TwbNifFile;
  4.   node, bhknp, bhk: TwbNifBlock;
  5. begin
  6.   SrcNif := TwbNifFile.Create;
  7.   DstNif := TwbNifFile.Create;
  8.   try
  9.     // load meshes
  10.     SrcNif.LoadFromFile(aSource);
  11.     DstNif.LoadFromFile(aDestination);
  12.    
  13.     // add NiNode as a child of the root node in destination mesh
  14.     node := DstNif.Blocks[0].AddChild('NiNode');
  15.     // copy NiNode data from source mesh
  16.     node.Assign(SrcNif.Blocks[12]);
  17.    
  18.     // add bhkPhysicsSystem first because it must be before bhkNPCollisionObject
  19.     bhk := DstNif.AddBlock('bhkPhysicsSystem');
  20.     // copy bhkPhysicsSystem data from source mesh
  21.     bhk.Assign(SrcNif.Blocks[3]);
  22.  
  23.     // add bhkNPCollisionObject
  24.     bhknp := DstNif.AddBlock('bhkNPCollisionObject');
  25.     // copy bhkNPCollisionObject data from source mesh
  26.     bhknp.Assign(SrcNif.Blocks[13]);
  27.     // set Target field pointing to NiNode
  28.     bhknp.NativeValues['Target'] := node.Index;
  29.     // set Data field pointing to bhkPhysicsSystem
  30.     bhknp.NativeValues['Data'] := bhk.Index;
  31.     // set it as a collision for NiNode
  32.     node.NativeValues['Collision Object'] := bhknp.Index;
  33.  
  34.     // save destination mesh
  35.     DstNif.SaveToFile(aDestination);
  36.  
  37.   finally
  38.     SrcNif.Free;
  39.     DstNif.Free;
  40.   end;
  41. end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top