#!/bin/sh #$Id: kaleidowrl2pov,v 1.4 2002/04/06 16:38:42 rl Exp $ # Convert a VRML file generated by Kaleido to POV-Ray scene description. # The polyhedra are resized to have a unit circumsphere. # # Usage: kaleidowrl2pov file.pov # # Note: The default 6 digit precision in Kaleido results in non-planarity # of faces to be detected by POV-Ray, so a 16 digits precision is used here # (and kaleido has to be run with a -d16 option). # # Author: Nadav Har'El # Adapted to VRML97 by Zvi Har'El cat < direction <0, 0, 1> up <0, 0.3, 0> right <0.3, 0, 0> look_at <0, 0, 0> } light_source {<10, 20, -30> color 1.5*White} sky_sphere { pigment { White } } #declare F_Face = finish { reflection 0.01 diffuse 0.4 ambient 0.3 phong 0.3 phong_size 5 } END_OF_PREAMBLE gawk ' BEGIN { state=0 maxrad=0 } /Color{/ {state=1; next} state==1 && /color\[/ { n=split($0,a,"[[,]") ncolors=n-2 # extra color[ and ] removed for(i=0;i" gsub(" ",",",colors[i]) } next } /Coordinate{/ {state=2; next} state==2 && /point\[/ {state=3; npoints=0; next} state==3 && /\]/ {state=5; next} state==3 && !/^[ ]*#/ { x[npoints]=$1 y[npoints]=$2 z[npoints]=$3 gsub(",","",z[npoints]) rad=sqrt(x[npoints]*x[npoints]+y[npoints]*y[npoints]+z[npoints]*z[npoints]) if(rad>maxrad)maxrad=rad npoints++ } state==5 && /coordIndex/ {state=6; nfaces=0; next} state==6 && /\]/ {state=7; next} state==6 { n=split($0,a,",") gsub("^[ \t]*","",a[1]) # remove leading spaces nedges[nfaces]=0 for(i=1;i,\n",x[polyg[i,j]]/maxrad,y[polyg[i,j]]/maxrad,z[polyg[i,j]]/maxrad) } printf("<%.16g,%.16g,%.16g>\n",x[polyg[i,0]]/maxrad,y[polyg[i,0]]/maxrad,z[polyg[i,0]]/maxrad) print "texture { T_Face_" colorIndex[i]+0 "}" print "}" } } '