Advertisement
krail

stormworks importer

Nov 12th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Param(
  2.     #path to the voxel data - use http://drububu.com/miscellaneous/voxelizer/index.html?out=xml to generate *OUTPUT AS XML*
  3.     [Parameter(Mandatory=$True)][string]$voxelPath,
  4.     #name of the resulting craft file
  5.     [Parameter(Mandatory=$True)][string]$craftName,
  6.     #optional output path - try stormworks data dir
  7.     [string]$outputPath = '.\'
  8. )
  9.  
  10. $path = '.\torus.xml'
  11.  
  12. #just use hardcoded strings for basic stuff we don't need because I'm lazy
  13. $header = '<?xml version="1.0" encoding="UTF-8"?><vehicle data_version="2" is_static="false" bodies_id="2"><editor_placement_offset x="0" y="0" z="0"/><authors/><bodies><body unique_id="2"><initial_local_transform 00="1" 01="0" 02="0" 03="0" 10="0" 11="1" 12="0" 13="0" 20="0" 21="0" 22="1" 23="0" 30="0" 31="0" 32="0" 33="1"/><local_transform 00="1" 01="0" 02="0" 03="0" 10="0" 11="1" 12="0" 13="0" 20="0" 21="0" 22="1" 23="0" 30="0" 31="0" 32="0" 33="1"/><components>'
  14. $footer = '</components></body></bodies><logic_node_links/></vehicle>'
  15.  
  16. $voxHeader = '<c d="01_block" t="0"><o r="1,0,0,0,1,0,0,0,1" bc="FFFFFFFF" ac="FFFFFFFF" sc="6">'
  17. $voxFooter = '</o></c>'
  18.  
  19. [xml]$voxelData = Get-Content $voxelPath
  20.  
  21. $content = $header
  22.  
  23. foreach ($voxel in $voxelData.content.voxels.voxel){
  24.    
  25.     #shove the actual vox coords in with all this other messy crap
  26.     $content = $content + $voxHeader + "<vp x=`"$($voxel.position.x)`" y=`"$($voxel.position.y)`" z=`"$($voxel.position.z)`"/>" + $voxFooter
  27.        
  28. }
  29.  
  30. $content = $content + $footer
  31.  
  32. $filename = $craftName + '.xml'
  33.  
  34. New-Item -Path $outputPath -Name $fileName -ItemType "file" -Value $content
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement