#!/usr/bin/php This is a command line PHP script for processing newly exported .inc files Usage: is the filename of the include file to make a wireframe model of. --help, -help, -h, or -? displays this. <(-?[\d\.]{8}), (-?[\d\.]{8}), (-?[\d\.]{8})>/'; $offsetval = 0; $tri = 0; $edges=array(); $trivtx=array(); $vertices=array(); $vtx=array('x'=>0.0,'y'=>0.0,'z'=>0.0); while(preg_match($vertexpattern,$fcontents,$matches,PREG_OFFSET_CAPTURE,$offsetval)){ $vt = '<'.$matches[1][0].', '.$matches[2][0].', '.$matches[3][0].'>'; //$vtx['x']=(float)$matches[1][0]; //$vtx['y']=(float)$matches[2][0]; //$vtx['z']=(float)$matches[3][0]); //$norm = '<'.$matches[4][0].', '.$matches[5][0].', '.$matches[6][0].'>'; $offsetval = $matches[6][1]; $vertices[$vt]=true; $trivtx[$tri]=$vt; $tri++; if($tri>=3){ $tri=0; if(!in_array(array($trivtx[1],$trivtx[0]),$edges)) $edges[]=array($trivtx[0],$trivtx[1]); if(!in_array(array($trivtx[2],$trivtx[1]),$edges)) $edges[]=array($trivtx[1],$trivtx[2]); if(!in_array(array($trivtx[0],$trivtx[2]),$edges)) $edges[]=array($trivtx[2],$trivtx[0]); } } $outstring = << $exists){ $outstring .= "\tsphere{{$vertex}, vertex_radius}\n"; } $outstring .= "\ttexture{vertex_texture}\n}\n#end\n\n#macro {$basename}_edges(edge_radius,edge_texture)\nunion{\n"; foreach($edges as $edge){ $outstring .= "\tcylinder{{$edge[0]},{$edge[1]},edge_radius}\n"; } $outstring .= "\ttexture{edge_texture}\n}\n#end"; } file_put_contents($incname.'_wireframe.inc',$outstring); } ?>