$y){ $sriver[$rcount]=$xcoord[$key]." ".($y-$rwidth)." 0.1\t#$rcount"; $rcount++; } foreach($ycoord as $key => $y){ $nriver[$rcount]=$xcoord[$key]." ".($y+$rwidth)." 0.1\t#$rcount"; $rcount++; } foreach($ycoord as $key => $y){ $sbank[$rcount]=$xcoord[$key]." ".($y-(1.25*$rwidth))." $groundheight\t#$rcount"; $rcount++; } foreach($ycoord as $key => $y){ $nbank[$rcount]=$xcoord[$key]." ".($y+(1.25*$rwidth))." $groundheight\t#$rcount"; $rcount++; } //hills $ang=deg2rad(15); $hycoord=array(); $hxcoord=array(); $hill=array(); for($i = 0; $i <= 23; $i++){ $hxcoord[]=(mt_rand(90,105)/100)*(100*cos($ang*$i)); $hycoord[]=(mt_rand(90,105)/100)*(100*sin($ang*$i)); } $hcount=0; foreach($hycoord as $key => $y){ $hill[$hcount]=$hxcoord[$hcount]." $y ".($groundheight+20)."\t#$hcount"; $hcount++; }unset($y); $hbase=array(); foreach($hycoord as $key => $y){ $hbase[$hcount]=(1.25*$hxcoord[$key])." ".(1.25*$y)." $groundheight\t$hcount"; $hcount++; } echo "world\n\tsize ".(.85*$worldsize)."\n\n#nowalls\nend\n"; echo "options\n\t-j\n\t-sb\n\t-fb\n\t-ms 4\n\t +f F{10} +f SW{5} +f CL{2} +f ST{30} +f L{5} +f QT{5} +f SE{10} +f GM{3}\n\t-set _reloadTime 5.0\n\t-set _shotSpeed 200\n\t-set _tankSpeed 45\n\t-set _wallHeight 0\n\t#-set _radarLimit 150\n\t-set _noClimb 0\n\t-set _shotsKeepVerticalVelocity 1\n\t-set _rFireAdVel 3\nend\n"; echo "textureMatrix\n\tname water\n\tshift 0 .2\nend\n"; echo "\nphysics\n\tname river\n\tlinear 5 0.0 0.0\nend\n"; echo "\nmaterial\n\tname water\n\ttexture wall\n\tdiffuse 0 .5 1 1\nend\n"; echo "material\n\tname watersurface\n\ttexture water\ndiffuse 0 .2 .25 .95\nnoradar\nend\n"; echo "material\n\tname bank\n\tdiffuse tan\n\ttexture roof\n\tnoradar\nend\n"; echo "material\n\tname ground\n\taddtexture std_ground\nnoradar\ndiffuse tan\nend\n"; echo "material\n\tname hill\n\taddtexture std_ground\ndiffuse tan\nend\n"; //Landscape echo "\nmesh\n"; echo "#bounds\n"; foreach($bound as $key => $bvert){ echo "\tvertex $bvert"; } echo "\n\t#south river vertices\n"; foreach($sriver as $key => $svert){ echo "\tvertex $svert\n"; } echo"\n\t#north river vertices\n"; foreach($nriver as $key => $vert){ echo "\tvertex $vert\n"; } echo"\n\t#south bank vertices\n"; foreach($sbank as $key => $vert){ echo "\tvertex $vert\n"; } echo"\n\t#north bank vertices\n"; foreach($nbank as $key => $vert){ echo "\tvertex $vert\n"; } echo "\tinside -100 200 2.5\n\tinside 100 200 2.5\n\tinside -100 -200 2.5\n\tinside 100 -200 2.5\n"; //water echo "\tmatref water\n\tface\nphydrv river\n\t\tvertices "; foreach($sriver as $key => $value){ echo "$key "; }unset($key); krsort($nriver); foreach($nriver as $key => $value){ echo "$key "; }unset($key); ksort($nriver); echo "\n\tendface"; //southbank echo "\n\tmatref bank"; for($i=4;$i<($rivercount+3);$i++){ echo "\n\tface\n\t\tvertices "; echo " ".($i+1)." ".($i)." ".($i+2*$rivercount)." ".($i+1+2*$rivercount)."\n"; echo "\tendface"; } //southbank echo "\n\tmatref bank"; for($i=(4+$rivercount);$i<(2*$rivercount+4);$i++){ echo "\n\tface\n\t\tvertices "; echo " ".($i)." ".($i+1)." ".($i+1+2*$rivercount)." ".($i+2*$rivercount)."\n"; echo "\tendface"; } //Ground echo "\n\tmatref ground\n\tface\n\t\tvertices "; echo "0 1 "; krsort($sbank); foreach($sbank as $key => $value){ echo "$key "; }unset($key); ksort($sbank); echo "\n\tendface"; //Northbank echo "\n\tmatref ground\n\tface\n\t\tvertices "; foreach($nbank as $key => $value){ echo "$key "; }unset($key); echo "3 2"; echo "\n\tendface"; echo "\nend #mesh\n"; //Water surface $waterdepth=1.25; $texcoordy=50; echo "mesh #water surface\n"; echo "\tvertex -1000 200 $waterdepth\n\tvertex -1000 -200 $waterdepth\n\tvertex 1000 -200 $waterdepth\n\tvertex 1000 200 $waterdepth\n"; echo "\n\ttexcoord 0 0\n\ttexcoord 3 0\n\ttexcoord 3 $texcoordy\n\ttexcoord 0 $texcoordy\n"; echo "\n\tmatref watersurface\n\ttexmat water\n\tdrivethrough\n"; echo "\nface\n\tvertices 0 1 2 3\n\ttexcoords 0 1 2 3\nendface\n"; echo "end #mesh\n"; //hills echo "\ndefine hill\nmesh\n"; foreach($hill as $key => $hvert){ echo "\tvertex $hvert\t#$key\n"; }unset($key); foreach($hbase as $key => $hvert){ echo "\tvertex $hvert\t#$key\n"; }unset($key); echo "inside 0 0 ".($groundheight+2)." \n"; echo "\n\tmatref hill\n\tface\n\t\tvertices "; foreach($hill as $key => $value){ echo "$key "; }unset($key); echo "\n\tendface"; echo "\n\tmatref hill\n\tface\n\t\tvertices "; foreach($hbase as $key => $value){ echo "$key "; }unset($key); for($i=0;$i < count($hbase); $i++){ echo "face\n\tvertices "." ".($i+24)." ".($i+25)." ".($i+1)." ".($i)."\nendface\n"; } echo "face\n\tvertices 47 24 0 23\nendface\nend #mesh\nenddef\n"; $circlecount=0; for ($i = 0; $i < 4; $i++){ $x = (mt_rand(0,1500))-750; $y = (mt_rand(300,775)); $xscale = (mt_rand(50,125))/100; $yscale = (mt_rand(50,125))/100; $zscale = (mt_rand(50,100))/100; $circleh[$circlecount] = $x; $circlek[$circlecount] = $y; $circlea[$circlecount] = 100*$xscale; $circleb[$circlecount] = 100*$yscale; $circlecount++; echo "group hill #north $i\n\tshift $x $y 0\n\tscale 1 1 $zscale\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;} echo "group hill #south $i\n\tshift $x -$y 0\n\tscale 1 1 $zscale\nend\n"; }; //// Field no trees allowed here $fieldh = (mt_rand(0, 1.5*$worldsize)-(.75*$worldsize)); $fieldk = (mt_rand(50,200)); $fieldr = 200; function checkField($x,$y){ global $fieldh, $fieldk, $fieldr; if((($x-$fieldh)*($x-$fieldh))+(($y-$fieldk)*($y-$fieldk)) < ($fieldr*$fieldr)){ return 1; } } //function function checkEx($x,$y){ global $circleh,$circlek,$circlea,$circleb; foreach($circleh as $key => $h){ if((($x-$h)*($x-$h))+(($y-$circlek[$key])*($y-$circlek[$key])) < (125*125)){ return 1; } /* if(((($x-$h)*($x-$h)))/($circlea[$key]*$circlea[$key])+(($y-$circlek[$key])*($y-$circlek[$key])/($circleb[$key]*$circleb[$key])) < (125*125)){ return 1; } */ } //foreach circleh } //function function checkRiver($x,$y){ if($y < 100*(.75*sin(($x)/200))+75)return 1; } // OBJECTS and TREES $scalepercent=25; $usedmat=array(); $materialcount=0; echo "############## Spruce pine1 trees ###############################\n"; $objects=$worldsize/16; $angle=45; //degrees $radius=16; //bzw units $height=35; //bzw units high $material="pine1"; $objectname=$material; $trunk=1; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand((.25*$worldsize),$worldsize)); $scale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## Spruce pine1 trees ###############################\n"; $objects=$worldsize/16; $angle=45; //degrees $radius=20; //bzw units $height=45; //bzw units high $material="pine1"; $objectname=$material; $trunk=1; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand((.5*$worldsize),$worldsize)); $scale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## needle pine ###############################\n"; $objects=$worldsize/16; $angle=60; //degrees $radius=7.5; //bzw units $height=16; //bzw units high $material="needle_pine"; $objectname=$material; $trunk=1; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(100,400)); $scale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## cypress oak? ###############################\n"; $objects=$worldsize/16; $angle=60; //degrees $radius=18; //bzw units $height=45; //bzw units high $material="cypress"; $objectname=$material; $trunk=1; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(400,$worldsize)); $scale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## laurel_cone ###############################\n"; $objects=$worldsize/16; $angle=60; //degrees $radius=7.5; //bzw units $height=16; //bzw units high $material="laurel_cone"; $objectname=$material; $trunk=1; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand((.25*$worldsize),(.75*$worldsize))); $scale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## japanese_maple ###############################\n"; $objects=$worldsize/10; $angle=60; //degrees $radius=12; //bzw units $height=25; //bzw units high $material="japanese_maple"; $objectname=$material; $trunk=1; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(400,$worldsize)); $scale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## Bamboo bushes ###############################\n"; $objects=$worldsize/16; $angle=60; //degrees $radius=3; //bzw units $height=4; //bzw units high $material="bamboo1"; $objectname=$material; $trunk=0; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(0,300)); $xscale = (mt_rand(50,150))/100; $yscale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## forsythia bushes ###############################\n"; $objects=$worldsize/4; $angle=60; //degrees $radius=2; //bzw units $height=3; //bzw units high $material="forsythia"; $objectname=$material; $trunk=0; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(0,(.5*$worldsize))); $xscale = (mt_rand(50,150))/100; $yscale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## phoenix_palm (Ferns) ###############################\n"; $objects=$worldsize/6; $angle=60; //degrees $radius=4; //bzw units $height=4; //bzw units high $material="phoenix_palm"; $objectname=$material; $trunk=0; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(0,200)); $xscale = (mt_rand(50,150))/100; $yscale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 3\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 3\n\tscale 1 1 1\nend\n"; $i++; } } echo "############## ground cover ###############################\n"; $objects=$worldsize/6; $angle=30; //degrees $radius=6; //bzw units $height=5; //bzw units high $material="bamboo1"; $objectname=$material; $trunk=0; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(0,800)); $xscale = (mt_rand(50,150))/100; $yscale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y)){ }elseif(checkField($x,$y)){ echo "group $objectname #$i north\n\tshift $x $y 3.3\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 3.5\n\tscale 1 1 1\nend\n"; $i++; }else{} } echo "############## palm2 bush ###############################\n"; $objects=$worldsize/10; $angle=60; //degrees $radius=5; //bzw units $height=8; //bzw units high $material="palm2"; $objectname=$material; $trunk=0; include "./foliagedI3.php"; for ($i = 0; $i <= $objects;){ $x = (mt_rand(0,(2*$worldsize)))-$worldsize; $y = (mt_rand(0,100)); $xscale = (mt_rand(50,150))/100; $yscale = (mt_rand(50,150))/100; if(checkEx($x,$y) || checkRiver($x,$y) ||checkField($x,$y)){ }else{ echo "group $objectname #$i north\n\tshift $x $y 5\n\tscale 1 1 1\nend\n"; if($x < 0){$x = sqrt($x*$x);}else{$x = -$x;}//flip the x coordinate echo "group $objectname #$i south\n\tshift $x -$y 5\n\tscale 1 1 1\nend\n"; $i++; } } ?>