(* txt2pov.sml *) (* Tuesday, 7 December 1999 *) fun TextToPOV (infilename,outfilename) = let open TextIO Int val instr = openIn infilename val outstr = openOut outfilename val prologue = [ "\n", "#declare T =\n", " texture {\n", " pigment {\n", " color rgb <0.6,1,1>\n", " }\n", " finish {\n", " refraction on\n", " ior 1.2\n", " }\n", " }\n", "\n", "camera {\n", " location <-100,10,-200>\n", " look_at <0,15,0>\n", " angle 12\n", "}\n", "\n", "light_source {\n", " <0,0,-1000>\n", " color rgb <1,1,1>\n", "}\n", "\n", "light_source {\n", " <-1000,0,-100>\n", " color rgb <1,1,1>\n", "}\n", "\n", "light_source {\n", " <0,1000,-100>\n", " color rgb <1,1,1>\n", "}\n", "\n" ] val prefix = [ "object {\n", " text {\n", " ttf \"cyrvetic.ttf\",\n", " \"" ] fun postfix (y,z) = [ " \",1,0\n", " }\n", " texture { T }\n", " translate <0,", toString y, "," , toString z, ">\n", "}\n" ] fun outputList [] = () | outputList (x::xs) = ( output (outstr,x); outputList xs ) val cr = ref #" " val line = ref 0 val page = ref 0 in outputList prologue; outputList prefix; while not (endOfStream instr) do ( cr := valOf (input1 instr); case !cr of #"\n" => ( line := !line + 1; if !line=30 then ( page := !page + 1; line := 0 ) else (); outputList (postfix (30-(!line),!page*5)); outputList prefix ) | #"\"" => output (outstr,"\\\"") | #"\\" => output (outstr,"\\\\") | _ => output1 (outstr,!cr) ); outputList (postfix (30-(!line),!page*5)); output1 (outstr,#"\n"); closeIn instr; closeOut outstr end