#!/usr/bin/perl print "#VRML V2.0 utf8\n\n"; // Read the images numbers for basement reliefs // The images may not be in sequence open (IMGINFO, "Relief.Info"); $nimg = -1; do { $line = ; chomp $line; @pcs = split(' ',$line); if ($#pcs > 0) { $nimg ++; $Imgno[$nimg] = $pcs[0]; } } while $#pcs > 0 ; #print "\nNumber of Images $#Imgno \n"; $flnm = $ARGV[0]; open (SPINE, $flnm); $line = ; print "#$line"; $line = ; @pcs = split(' ',$line); $Section = $pcs[0]; $StepSize = $pcs[1]; $StartImg = $pcs[2]; $Decoration = $pcs[3]; #blank line $line = ; # first line gives first translation parameters $line = ; @pcs = split(' ',$line); $T1[0] = $pcs[0]; $T1[1] = $pcs[1]; $T1[2] = $pcs[2]; # second line gives second translation parameters $line = ; @pcs = split(' ',$line); $T2[0] = $pcs[0]; $T2[1] = $pcs[1]; $T2[2] = $pcs[2]; # blank Line $line = ; # Give initial translation $line = ; @pcs = split(' ',$line); $ti[0] = $pcs[0]; $ti[1] = $pcs[1]; # blank Line $line = ; # Height of relief $line = ; @pcs = split(' ',$line); $height = $pcs[0]; # blank Line $line = ; # Definition of outer spine $numele = -1; do { $line = ; chomp $line; @pcs = split(' ',$line); if ($#pcs > 0) { $numele ++; $spine[$numele][0] = $pcs[0]; $spine[$numele][1] = $pcs[1]; $numrelief[$numele] = $pcs[2]; } } while $#pcs > 0 ; #print "\nNumber of elements in outer spine $#spine \n"; close SPINE ; ######################################################### # reflect spine into four quadrants #print "Creating spine copies for remaining quadrants\n"; # Generate spines for each quadrant @first = &genquadrant(@spine,4); #@first = &genquadrant(@spine,$Section); #@second= &genquadrant(@spine,2); #@third = &genquadrant(@spine,3); #@fourth= &genquadrant(@spine,4); # Modulate using the initial translation parameters @firstex = &Modulate(@first,4); #@firstex = &Modulate(@first,$Section); #@secondex= &Modulate(@second,2); #@thirdex = &Modulate(@third,3); #@fourthex= &Modulate(@fourth,4); ######################################################### # Print cross with Modulated spine print "PROTO CORNICETEXTURE [ ] {\n"; print " Appearance {\n"; print " texture ImageTexture { url \"../../IMG/128/onecornice.jpg\" }\n"; print " textureTransform TextureTransform { scale 1 3}\n"; #print " material Material {\n"; #print " diffuseColor 0.5 0.5 0.4\n"; #print " emissiveColor 0.7 0.7 0.65\n"; #print " }\n"; print " }\n"; print "}\n"; print "\n\n#DEFINE CORNICE\n"; print "PROTO CORNICE [ ] {\n"; print " Shape {\n"; print " appearance CORNICETEXTURE { }\n"; print " geometry IndexedFaceSet {\n"; print " solid FALSE\n"; print " coord Coordinate {\n"; print " point [\n"; print " 0.0 0.0 0.0,\n"; print " $StepSize 0.0 0.0,\n"; print " $StepSize $height 0.0,\n"; print " 0.0 $height 0.0 \n"; print " ]\n"; print " }\n"; print " coordIndex [ 0, 1, 2, 3, -1 ]\n"; print " texCoord TextureCoordinate {\n"; print " point [ 0 0, 1 0, 1 1, 0 1 ]\n"; print " }\n"; print " }\n"; print " }\n"; print "}\n\n"; #if ($Section == 1){ # print "# Relief First quadrant\n"; # $t[0] = $T1[0]; # $t[1] = $T1[1]; # $t[2] = $T1[2]; #} #if ($Section == 2) { # print "# Relief Second quadrant\n"; # $t[0] = $T2[0]; # $t[1] = $T2[1]; # $t[2] = -$T2[2]; #} #if ($Section == 3) { # print "# Relief Third quadrant\n"; # $t[0] = -$T1[0]; # $t[1] = $T1[1]; # $t[2] = -$T1[2]; #} #if ($Section == 4) { print "# Relief Fourth quadrant\n"; $t[0] = -$T2[0]; $t[1] = $T2[1]; $t[2] = $T2[2]; #} &printRelief(@firstex,$Section); #&printRelief(@secondex,2); # #&printRelief(@thirdex,3); # #&printRelief(@fourthex,4); # ######################################################### # Generate Modulated spine sub Modulate { my @surface ; my $numele = $#_ - 1; my $flag = $_[$#_]; # print "Into Modulate with $numele $#cross and $flag\n"; for $i (0 .. $numele) { if ($flag == 1){ if ($i==0) { $dx = $_[0][0]-$_[1][0]; if ($dx != 0.0) { $facx = 0; $facz = 1; } else { $facx = 1; $facz = 0; } } else { if ($i==$numele) { $dx = $_[$numele-1][0]-$_[$numele][0]; if ($dx != 0.0) { $facx = 0; $facz = 1; } else { $facx = 1; $facz = 0; } } else { $facx = 1; $facz = 1; } } } if ($flag == 2){ if ($i==0) {$facx = 1; $facz = 0;} else { if ($i==$numele) {$facx = 0; $facz = -1;} else {$facx = 1; $facz = -1;} } } if ($flag == 3){ if ($i==0) {$facx = 0; $facz = -1;} else { if ($i==$numele) {$facx = -1; $facz = 0;} else {$facx = -1; $facz = -1;} } } if ($flag == 4){ if ($i==0) {$facx = -1; $facz = 0;} else { if ($i==$numele) {$facx = 0; $facz = 1;} else {$facx = -1; $facz = 1;} } } $surface[$i][0] = $_[$i][0] + $facx*$ti[1];; $surface[$i][1] = $_[$i][1] + $ti[0];; $surface[$i][2] = $_[$i][2] + $facz*$ti[1];; } @surface; } # ######################################################### # print VRML file sub printRelief { my @coord = @_; my $numele = $#_-2; my $tag = $coord[$#_]; my $len; my $reliefs; my $stepx; my $stepz; my $picture = $StartImg-1; $flnm = ">ViewPoints"; open (VP,$flnm); for $nsec (0 .. $numele) { $reliefs = $numrelief[$nsec]; $reliefSteps = $reliefs + 1; $lenx = abs($coord[$nsec+1][0] - $coord[$nsec][0]); $lenz = abs($coord[$nsec+1][2] - $coord[$nsec][2]); $Ulengthx = 0.0; $Ulengthz = 0.0; if ($lenx != 0.0) { $Ulengthx = $lenx - ($reliefSteps*$StepSize); } if ($lenz != 0.0) { $Ulengthz = $lenz - ($reliefSteps*$StepSize); } if ($lenx > $lenz) { $StepSizex = $StepSize; $StepSizez = 0.0; } else { $StepSizex = 0.0; $StepSizez = $StepSize; } $fracx = $Ulengthx / $reliefs; if ($coord[$nsec+1][0] < $coord[$nsec][0]) { $fracx = -$fracx; $StepSizex = -$StepSizex; } $fracz = $Ulengthz / $reliefs; if ($coord[$nsec+1][2] < $coord[$nsec][2]) { $fracz = -$fracz; $StepSizez = -$StepSizez; } $stepx = 0.0; $stepz = 0.0; for $nrel (0 .. (2*$reliefs) ) { $pstepx = $stepx; $pstepz = $stepz; if ($nrel%2 == 0) { $stepx += $StepSizex; $stepz += $StepSizez; } else { $stepx += $fracx; $stepz += $fracz; } $x0 = $coord[$nsec][0] + $pstepx; $y0 = $coord[$nsec][1]; $z0 = $coord[$nsec][2] + $pstepz; $x1 = $coord[$nsec][0] + $stepx; $y1 = $coord[$nsec][1]; $z1 = $coord[$nsec][2] + $stepz; $x2 = $coord[$nsec][0] + $stepx; $y2 = $coord[$nsec][1] + $height; $z2 = $coord[$nsec][2] + $stepz; $x3 = $coord[$nsec][0] + $pstepx; $y3 = $coord[$nsec][1] + $height; $z3 = $coord[$nsec][2] + $pstepz; if ($nrel%2 == 0) { print "Transform {\n"; $tx = $x0 + $t[0]; $ty = $y0 + $t[1]; $tz = $z0 + $t[2]; print " translation $tx $ty $tz\n"; $dz = $z0-$z1; if ($dz > 0.0) { print " rotation 0.0 1.0 0.0 1.57\n"; } else { if ($dz < 0.0) { print " rotation 0.0 1.0 0.0 -1.57\n"; } else { $dx = $x0-$x1; if ($dx > 0.0) { print " rotation 0.0 1.0 0.0 -3.14\n"; } } } print " children CORNICE { }\n"; print "}\n"; } else { $tx = $x0 + $t[0]; $ty = $y0 + $t[1]; $tz = $z0 + $t[2]; print "Transform {\n"; print " translation $tx $ty $tz\n"; print " children [\n"; print " Shape {\n"; print " appearance Appearance {\n"; print " texture ImageTexture { url \"../../IMG/128/onecornice.jpg\" }\n"; print " textureTransform TextureTransform { rotation 1.57 scale 1 7}\n"; print " }\n"; print " geometry IndexedFaceSet {\n"; print " solid FALSE\n"; print " coord Coordinate {\n"; print " point [\n"; $h0=$height/2.0-$Decoration; $h1=$height/2.0+$Decoration; print " 0.0 $h0 0.0\n"; print " $fracx $h0 $fracz\n"; print " $fracx $h1 $fracz\n"; print " 0.0 $h1 0.0\n"; print " ]\n"; print " }\n"; print " coordIndex [ 0, 1, 2, 3, -1 ]\n"; print " texCoord TextureCoordinate {\n"; print " point [ 0 0, 1 0, 1 1, 0 1 ]\n"; print " }\n"; print " }\n"; print " }\n"; print " ]\n"; print "}\n"; $picture ++; $pictureU = $Imgno[$picture]; $picture ++; $pictureL = $Imgno[$picture]; $wrlU = "a.wrl"; $wrlL = "b.wrl"; $htmlU= "a.html"; $htmlL= "b.html"; $jpg = ".jpg"; print "Transform {\n"; $tx = $x0 + $t[0]; $ty = $y0 + $t[1]; $tz = $z0 + $t[2]; print " translation $tx $ty $tz\n"; print " children [\n"; $flnm = "WRL/rel-$tag\.$nsec\.$nrel$wrlU"; print " Inline { url \"$flnm\" }\n"; $flnm = ">$flnm"; open (RELIEF,$flnm); $h0=$height/2.0+$Decoration; $h1=$h0+($height-$h0)/2.0; $fz=$fracz/3.0; $fx=$fracx/3.0; $fz2=$fracz/2.0; $fx2=$fracx/2.0; $fy2 = $ty+$h1; $flnm = "rel-$tag\.$nsec\.$nrel$htmlU"; open (HTML,">WRL/$flnm"); print HTML "\n"; print HTML " Jump directly to the corresponding gallery section\n"; print HTML "
\n\n\n\n"; close HTML ; print RELIEF "#VRML V2.0 utf8\n"; print VP "DEF U_$pictureU Viewpoint {\n"; print VP " description \"$pictureU\"\n"; if ($fz > 0.0) { $fx2 = $tx-2.0; $fz2 = $tz+$fz2; print VP " orientation 0 1 0 -1.57\n"; } else { $fz2 = $tz+2.0; $fx2 = $tx+$fx2; print VP " orientation 0 1 0 0.0\n"; } print VP " position $fx2 $fy2 $fz2\n"; print VP "}\n"; print RELIEF "Anchor {\n"; print RELIEF " url \"$flnm\"\n"; print RELIEF " parameter \"target=frame2\"\n"; print RELIEF " children [\n"; print RELIEF " Shape {\n"; print RELIEF " appearance Appearance { material Material {transparency 1.0} }\n"; print RELIEF " geometry IndexedFaceSet {\n"; print RELIEF " solid FALSE\n"; print RELIEF " coord Coordinate {\n"; print RELIEF " point [\n"; print RELIEF " 0.0 $h0 0.0,\n"; print RELIEF " $fx $h0 $fz,\n"; print RELIEF " $fx $h1 $fz,\n"; print RELIEF " 0.0 $h1 0.0 \n"; print RELIEF " ]\n"; print RELIEF " }\n"; print RELIEF " coordIndex [ 0, 1, 2, 3, -1 ]\n"; print RELIEF " texCoord TextureCoordinate {\n"; print RELIEF " point [ 0 0, 1 0, 1 1, 0 1 ]\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF " ]\n"; print RELIEF "}\n"; print RELIEF "Shape {\n"; print RELIEF " appearance Appearance { \n"; print RELIEF " texture ImageTexture {\n"; print RELIEF " url \"../512/$pictureU$jpg\"\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF " geometry IndexedFaceSet {\n"; print RELIEF " solid FALSE\n"; print RELIEF " coord Coordinate {\n"; print RELIEF " point [\n"; print RELIEF " 0.0 $h0 0.0,\n"; print RELIEF " $fracx $h0 $fracz,\n"; print RELIEF " $fracx $height $fracz,\n"; print RELIEF " 0.0 $height 0.0 \n"; print RELIEF " ]\n"; print RELIEF " }\n"; print RELIEF " coordIndex [ 0, 1, 2, 3, -1 ]\n"; print RELIEF " texCoord TextureCoordinate {\n"; print RELIEF " point [ 0 0, 1 0, 1 1, 0 1 ]\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF "}\n"; close RELIEF ; #PRINT Lower Portion $flnm = "WRL/rel-$tag\.$nsec\.$nrel$wrlL"; print " Inline { url \"$flnm\" }\n"; $flnm = ">$flnm"; open (RELIEF,$flnm); $h1=$height/2.0-$Decoration; $h0=$h1/2.0; $fz=$fracz/3.0; $fx=$fracx/3.0; $fz2=$fracz/2.0; $fx2=$fracx/2.0; $fy2=$ty+$h0; $flnm = "rel-$tag\.$nsec\.$nrel$htmlL"; open (HTML,">WRL/$flnm"); print HTML "\n"; print HTML " Jump directly to the corresponding gallery section\n"; print HTML "
\n\n\n\n"; close HTML ; print RELIEF "#VRML V2.0 utf8\n"; print VP "DEF L_$pictureL Viewpoint {\n"; print VP " description \"$pictureL\"\n"; if ($fz > 0.0) { $fx2 = $tx-2.0; $fz2 = $tz+$fz2; print VP " orientation 0 1 0 -1.57\n"; } else { $fz2 = $tz+2.0; $fx2 = $tx+$fx2; print VP " orientation 0 1 0 0.0\n"; } print VP " position $fx2 $fy2 $fz2\n"; print VP "}\n"; print RELIEF "Anchor {\n"; print RELIEF " url \"$flnm\"\n"; print RELIEF " parameter \"target=frame2\"\n"; print RELIEF " children [\n"; print RELIEF " Shape {\n"; print RELIEF " appearance Appearance { material Material {transparency 1.0} }\n"; print RELIEF " geometry IndexedFaceSet {\n"; print RELIEF " solid FALSE\n"; print RELIEF " coord Coordinate {\n"; print RELIEF " point [\n"; print RELIEF " 0.0 0.0 0.0,\n"; print RELIEF " $fx 0.0 $fz,\n"; print RELIEF " $fx $h0 $fz,\n"; print RELIEF " 0.0 $h0 0.0 \n"; print RELIEF " ]\n"; print RELIEF " }\n"; print RELIEF " coordIndex [ 0, 1, 2, 3, -1 ]\n"; print RELIEF " texCoord TextureCoordinate {\n"; print RELIEF " point [ 0 0, 1 0, 1 1, 0 1 ]\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF " ]\n"; print RELIEF "}\n"; print RELIEF "Shape {\n"; print RELIEF " appearance Appearance { \n"; print RELIEF " texture ImageTexture {\n"; print RELIEF " url \"../512/$pictureL$jpg\"\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF " geometry IndexedFaceSet {\n"; print RELIEF " solid FALSE\n"; print RELIEF " coord Coordinate {\n"; print RELIEF " point [\n"; print RELIEF " 0.0 0.0 0.0,\n"; print RELIEF " $fracx 0.0 $fracz,\n"; print RELIEF " $fracx $h1 $fracz,\n"; print RELIEF " 0.0 $h1 0.0 \n"; print RELIEF " ]\n"; print RELIEF " }\n"; print RELIEF " coordIndex [ 0, 1, 2, 3, -1 ]\n"; print RELIEF " texCoord TextureCoordinate {\n"; print RELIEF " point [ 0 0, 1 0, 1 1, 0 1 ]\n"; print RELIEF " }\n"; print RELIEF " }\n"; print RELIEF "}\n"; close RELIEF ; print " ]\n"; print "}\n"; } } } close VP; } # ######################################################### # Generate quadrants sub genquadrant { my @temp; my @spine; my $numele = $#_ - 1; my $flag = $_[$#_]; # print "Number of elements are $numele $flag\n"; # for $i (0 .. $numele) { # print "$i : $_[$i][0] $_[$i][1]\n"; # } $j = -1; for $i (0 .. $numele) { if ($flag == 1) { $x = $_[$i][0]; $y = $_[$i][1]; } if ($flag == 2) { $x = 0.0 - $_[$numele-$i][0]; $y = $_[$numele-$i][1]; } if ($flag == 3) { $x = 0.0 - $_[$i][0]; $y = 0.0 - $_[$i][1]; } if ($flag == 4) { $x = $_[$numele-$i][0]; $y = 0.0 - $_[$numele-$i][1]; } $j++; $temp[$j][0] = $x; $temp[$j][1] = $y; } @spine = genspine(@temp); } # ######################################################### # Generate spine sub genspine { my @spine ; my $numele = 0; $spine[0][0] = 0.0; $spine[0][1] = 0.0; $spine[0][2] = 0.0; for $i (0 .. $#_) { $numele ++; $spine[$numele][0] = $spine[$numele-1][0] + $_[$i][0]; $spine[$numele][1] = 0.0; $spine[$numele][2] = $spine[$numele-1][2] + $_[$i][1]; } @spine; } # #########################################################