Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure CopyCollision(aSource, aDestination: string);
- var
- SrcNif, DstNif: TwbNifFile;
- node, bhknp, bhk: TwbNifBlock;
- begin
- SrcNif := TwbNifFile.Create;
- DstNif := TwbNifFile.Create;
- try
- // load meshes
- SrcNif.LoadFromFile(aSource);
- DstNif.LoadFromFile(aDestination);
- // add NiNode as a child of the root node in destination mesh
- node := DstNif.Blocks[0].AddChild('NiNode');
- // copy NiNode data from source mesh
- node.Assign(SrcNif.Blocks[12]);
- // add bhkPhysicsSystem first because it must be before bhkNPCollisionObject
- bhk := DstNif.AddBlock('bhkPhysicsSystem');
- // copy bhkPhysicsSystem data from source mesh
- bhk.Assign(SrcNif.Blocks[3]);
- // add bhkNPCollisionObject
- bhknp := DstNif.AddBlock('bhkNPCollisionObject');
- // copy bhkNPCollisionObject data from source mesh
- bhknp.Assign(SrcNif.Blocks[13]);
- // set Target field pointing to NiNode
- bhknp.NativeValues['Target'] := node.Index;
- // set Data field pointing to bhkPhysicsSystem
- bhknp.NativeValues['Data'] := bhk.Index;
- // set it as a collision for NiNode
- node.NativeValues['Collision Object'] := bhknp.Index;
- // save destination mesh
- DstNif.SaveToFile(aDestination);
- finally
- SrcNif.Free;
- DstNif.Free;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement