#!/usr/local/bin/perl open(INPUT, "temp.wrl"); $counter=0; print OUTPUT "#VRML V2.0 utf8\n"; print OUTPUT "Background { \n"; print OUTPUT "skyColor [\n"; print OUTPUT " 0.4 0.6 1,\n"; print OUTPUT " 0.4 0.6 1,\n"; print OUTPUT " 0.8 0.8 1,\n"; print OUTPUT " 0.1 0.1 0.82,\n"; print OUTPUT " ]\n"; print OUTPUT " skyAngle [ 1.47, 1.6, 1.62 ]\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 42 18 22\n"; print OUTPUT " description \"Entry View\"\n"; print OUTPUT " orientation 1 0 0 -0.5\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 42 18 12\n"; print OUTPUT " description \"Closer View1\"\n"; print OUTPUT " orientation 1 0 0 -0.5\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 42 18 2\n"; print OUTPUT " description \"Closer View2\"\n"; print OUTPUT " orientation 1 0 0 -0.5\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 42 18 -10\n"; print OUTPUT " description \"Closer View3\"\n"; print OUTPUT " orientation 1 0 0 -0.5\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 42 18 -25\n"; print OUTPUT " description \"Closer View4\"\n"; print OUTPUT " orientation 1 0 0 -0.5\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 42 18 -42\n"; print OUTPUT " description \"Closer View5\"\n"; print OUTPUT " orientation 1 0 0 -0.5\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 42 18 -59\n"; print OUTPUT " description \"Closer View6\"\n"; print OUTPUT " orientation 1 0 0 -0.5\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 50 150 -70\n"; print OUTPUT " description \"Top View\"\n"; print OUTPUT " orientation 1 0 0 -1.57\n"; print OUTPUT "}\n"; print OUTPUT "Viewpoint { position 140 25 -50\n"; print OUTPUT " description \"Side View\"\n"; print OUTPUT " orientation 0 1 0 1.57\n"; print OUTPUT "}\n"; print OUTPUT "Transform {\n"; print OUTPUT " translation -30 -1.5 0\n"; print OUTPUT " children [\n"; print OUTPUT " Shape {\n"; print OUTPUT " appearance Appearance {\n"; print OUTPUT " material Material {\n"; print OUTPUT " diffuseColor 0 0.6 0.5\n"; print OUTPUT " }\n"; print OUTPUT " }\n"; print OUTPUT " geometry Box { size 120 0.05 1000 }\n"; print OUTPUT " }\n"; print OUTPUT " ]\n"; print OUTPUT " }\n"; print OUTPUT "Transform {\n"; print OUTPUT " translation 95 -1.5 0\n"; print OUTPUT " children [\n"; print OUTPUT " Shape {\n"; print OUTPUT " appearance Appearance {\n"; print OUTPUT " material Material {\n"; print OUTPUT " diffuseColor 0 0.6 0.5\n"; print OUTPUT " }\n"; print OUTPUT " }\n"; print OUTPUT " geometry Box { size 80 0.05 1000 }\n"; print OUTPUT " }\n"; print OUTPUT " ]\n"; print OUTPUT " }\n\n\n"; while($line = ) { if ($line =~ /^object(..*?)$/) { @lines = split /,\s/, $1; $text_z=@lines[3]+@lines[7]*.5+.1; if(@lines[0]=~/box/) { $var = "Box"; } if(@lines[8]=~/blue/) { $color= "0 0 1" ; } if(@lines[8]=~/red/) { $color= "1 0 0" ; } if(@lines[8]=~/green/) { $color= "0 1 0" ; } if(@lines[8]=~/orange/) { $color= "1 1 0" ; }if(@lines[8]=~/pink/) { $color= ".5 .5 0" ; } if(@lines[8]=~/yellow/) { $color= "1 .5 .5" ; } if(@lines[8]=~/gray/) { $color= ".5 .5 .5" ; } print OUTPUT " Transform{\n"; print OUTPUT " children Shape {\n"; print OUTPUT " appearance Appearance {\n"; print OUTPUT " material Material {\n"; print OUTPUT " ambientIntensity 0.186667\n"; print OUTPUT " diffuseColor $color\n"; print OUTPUT " specularColor 0.1 0.28 0.17\n"; print OUTPUT " emissiveColor 0 0 0\n"; print OUTPUT " shininess 0.4\n"; print OUTPUT " transparency .2\n"; print OUTPUT " }\n"; print OUTPUT " }\n"; print OUTPUT " geometry $var {size @lines[5] @lines[6] @lines[7]}\n"; print OUTPUT " }\n"; print OUTPUT " translation @lines[2] @lines[4] @lines[3]\n"; print OUTPUT " }\n"; print OUTPUT " Transform {\n"; print OUTPUT " children Shape {\n"; print OUTPUT " geometry Text {\n"; print OUTPUT " string \"@lines[1]\"\n"; print OUTPUT " fontStyle FontStyle {\n"; print OUTPUT " size 1.0\n"; print OUTPUT " family [ \"SANS\" ]\n"; print OUTPUT " style \"PLAIN\"\n"; print OUTPUT " horizontal TRUE #SFBool\n"; print OUTPUT " leftToRight TRUE #SFBool\n"; print OUTPUT " topToBottom TRUE #SFBool\n"; print OUTPUT " justify [ \"BEGIN\" ]\n"; print OUTPUT " spacing 1.0 }\n"; print OUTPUT " }\n"; print OUTPUT " }\n"; print OUTPUT " translation @lines[2] @lines[4] $text_z\n"; print OUTPUT "}\n"; } #object loop } # while for object close(INPUT); open(INPUT, ") { if ($line =~ /^backtracking-object(..*?)$/) { $counter++; @lines1 = split /,\s/, $1; if(@lines1[0]=~/box/) { $var1 = "Box"; } if(@lines1[8]=~/blue/) { $color1= "0 0 1" ; } if(@lines1[8]=~/red/) { $color1= "1 0 0" ; } if(@lines1[8]=~/green/) { $color1= "0 1 0" ; } if(@lines1[8]=~/orange/) { $color1= "1 1 0" ; }if(@lines1[8]=~/pink/) { $color1= ".5 .5 0" ; } if(@lines1[8]=~/yellow/) { $color1= "1 .5 .5" ; } if(@lines1[8]=~/gray/) { $color1= ".5 .5 .5" ; } $count=$counter-1; print OUTPUT "DEF BK$count Switch{\n"; print OUTPUT "whichChoice 1\n"; print OUTPUT "choice[\n"; print OUTPUT " Transform{\n"; print OUTPUT " children Shape {\n"; print OUTPUT " appearance Appearance {\n"; print OUTPUT " material Material {\n"; print OUTPUT " ambientIntensity 0.186667\n"; print OUTPUT " diffuseColor $color1\n"; print OUTPUT " specularColor 0.1 0.28 0.17\n"; print OUTPUT " emissiveColor 0 0 0\n"; print OUTPUT " shininess 0.4\n"; print OUTPUT " transparency 0.5\n"; print OUTPUT " }\n"; print OUTPUT " }\n"; print OUTPUT " geometry $var1 {size @lines1[5] @lines1[6] @lines1[7]}\n"; print OUTPUT " }\n"; print OUTPUT " translation @lines1[2] @lines1[4] @lines1[3]\n"; print OUTPUT " }\n"; print OUTPUT "]}\n"; } #backtracking if } #while for backtracking print OUTPUT "DEF myScript Script{\n"; print OUTPUT "eventIn SFBool touched\n"; print OUTPUT "field SFBool lastValue FALSE\n"; print OUTPUT "eventOut SFInt32 choice\n"; print OUTPUT "url [ \"javascript:\n"; print OUTPUT "function touched(value) {\n"; print OUTPUT "if (value){\n"; print OUTPUT "lastValue=!lastValue;\n"; print OUTPUT "if (lastValue)\n"; print OUTPUT "choice=0\;\n"; print OUTPUT "else\n"; print OUTPUT "choice=1\;\n"; print OUTPUT "}}\n"; print OUTPUT "\"]\n"; print OUTPUT "}\n"; print OUTPUT "Group {\n"; print OUTPUT "children [\n"; print OUTPUT "DEF HudGroup Collision {\n"; print OUTPUT "children [\n"; print OUTPUT "DEF HudProx2 ProximitySensor {\n"; print OUTPUT "center 0 1.8 30\n"; print OUTPUT "size 200 200 200\n"; print OUTPUT " }\n"; print OUTPUT " DEF HudXform2 Transform {\n"; print OUTPUT " children [\n"; print OUTPUT "Transform {\n"; print OUTPUT "translation -15 -7.0 -19\n"; print OUTPUT "children[\n"; print OUTPUT "Shape {\n"; print OUTPUT "geometry Text {\n"; print OUTPUT "string [\" Show\",\" Backtracking\"]\n"; print OUTPUT "fontStyle FontStyle {\n"; print OUTPUT "size 0.6\n"; print OUTPUT "}\n"; print OUTPUT "}\n"; print OUTPUT "}\n"; print OUTPUT "]\n"; print OUTPUT "}\n"; print OUTPUT "Transform {\n"; print OUTPUT "translation -14 -7.5 -20\n"; print OUTPUT "children [\n"; for($m=0;$m<$counter;$m++) { print OUTPUT "DEF ShowTouch$m TouchSensor{}\n"; } print OUTPUT "Shape {\n"; print OUTPUT "appearance Appearance {\n"; print OUTPUT "material Material {\n"; print OUTPUT "diffuseColor 5 2 1\n"; print OUTPUT "}\n"; print OUTPUT "}\n"; print OUTPUT "geometry Box {size 3 1.5 .5}\n"; print OUTPUT "appearance Appearance {\n"; print OUTPUT "material Material {\n"; print OUTPUT "diffuseColor 1 .5 .5 }\n"; print OUTPUT "}\n"; print OUTPUT "}\n"; print OUTPUT "]\n"; print OUTPUT "}\n"; print OUTPUT "]\n"; print OUTPUT "}\n"; print OUTPUT "]\n"; print OUTPUT "ROUTE HudProx2.position_changed TO HudProx2.center\n"; print OUTPUT "ROUTE HudProx2.orientation_changed TO HudXform2.rotation\n"; print OUTPUT "ROUTE HudProx2.position_changed TO HudXform2.translation\n"; print OUTPUT "}\n"; print OUTPUT "]\n"; print OUTPUT "}\n"; for($n=0;$n<$counter;$n++) { print OUTPUT "ROUTE ShowTouch$n.isActive TO myScript.touched\n"; print OUTPUT "ROUTE myScript.choice TO BK$n.set_whichChoice\n"; } close(INPUT); close(OUTPUT);