Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param(
- #path to the voxel data - use http://drububu.com/miscellaneous/voxelizer/index.html?out=xml to generate *OUTPUT AS XML*
- [Parameter(Mandatory=$True)][string]$voxelPath,
- #name of the resulting craft file
- [Parameter(Mandatory=$True)][string]$craftName,
- #optional output path - try stormworks data dir
- [string]$outputPath = '.\'
- )
- $path = '.\torus.xml'
- #just use hardcoded strings for basic stuff we don't need because I'm lazy
- $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>'
- $footer = '</components></body></bodies><logic_node_links/></vehicle>'
- $voxHeader = '<c d="01_block" t="0"><o r="1,0,0,0,1,0,0,0,1" bc="FFFFFFFF" ac="FFFFFFFF" sc="6">'
- $voxFooter = '</o></c>'
- [xml]$voxelData = Get-Content $voxelPath
- $content = $header
- foreach ($voxel in $voxelData.content.voxels.voxel){
- #shove the actual vox coords in with all this other messy crap
- $content = $content + $voxHeader + "<vp x=`"$($voxel.position.x)`" y=`"$($voxel.position.y)`" z=`"$($voxel.position.z)`"/>" + $voxFooter
- }
- $content = $content + $footer
- $filename = $craftName + '.xml'
- New-Item -Path $outputPath -Name $fileName -ItemType "file" -Value $content
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement