// Vers: 3.6
// Auth: Leroy Whetstone Email lrwii@joplin.com
//  11:58:47 AM  Friday March 25,2011 

         RoundPrism.pov
         
 This makes a smooth Mesh2 out of an Prism
 It is meant to be used as a tool and shouldn't be
     called from another POV file.
 It can save The Mesh2 as 'Thing' that can be called from a POV file.    

 The Main idea of this is to grid off the prism and its surroundings
 and use trace to find out if a grid point is on the prism or not. 
 If a grid point is on then it gets a value(see 'Hav' below)
 otherewise gets another value(see 'Lav' below)
 Then we average the naboring grid points for each grid point and
 repeat averaging as many time as you want.(see 'Ave' below)
 When done averaging everything is scaled to a value(see 'Th' below).
 
 
 This Zip should have these files

      RoundPrism.pov// the engine
      ABstar.prm // the prism called 'Thing'
      Star.inc // Mesh2 created called 'Thing'
      Test.pov // show Mesh2 created
      ReadMe.txt
 
  A Quick review of the variable used in 'RoundPrism'
  There are 13 of them
//--------- changes -----------------
 Variable Default     Description
 PRISM="ABstar.prm"__(str) Prism include file  
                      NEED The Prism to be an object named 'Thing'
 Div=.02___________(float)<1  divide (rough triangle side)
 Ave= 2____________(int)>=0   Average map [Round factor]
 Th=0______________(float)>=0 triangle's max height 0= prism height
 Lav=.5____________(float) 0<Lav<Hav lower limit average
 Hav=1_____________(float) >Lav      upper limit average
 Gseed=0___________(int) base points jitter seed 0= no jitter
 Gval=.95__________(float) 0-1 % of jitter in cell
 Tpres=yes_________(yes/no) merg flat triangles where can 
 Smooth=yes________(yes/no) smooth triangles
 UV_on=1___________(int)uv mapping 0-off 1=map to point 2=map to grid
 UV_C=<1,1>________corners of uv map
 Save="Star.inc"___________(str) Save File Name: Thing=(mesh2)
//---------end of changes ----------------- 

 The 'changes' & 'end of changes' above are the same as RoundPrism.pov
 you find them you'll find the varaibles. 

 RoundPrism has a display and of course you can change that all ya want.
 It's at the end of the file under 'Show'.
 
 More on the variables and what they can do:

    Div: grid size(rough triangle side) the smaller the better
         and the bigger the Mesh2. And if you go to Big you'll
         get something Weird...

    Ave: number of times to average and also the number of naboring
         grids points to average. That is if you use Ave=2 then
         the first pass will average a square 5*5 to a point.
         The next  pass will average a square 3*3 to a point.
         Looking at it another way the averaging square is 
                     (2*Ave+1)^2
         It can get big real fast! And the bigger the square the
         more likely the average will be low.

     Th: This is the highest y point the mesh2 will have.                       
         RoundPrism uses the natural position of the prism with y being up.
         When Th=0 then Th=prism height. 

    Lav:
    Hav: These two varialbe work togather when averaging the grid points.
         Lav is the value of a grid point the is NOT ON the prism.
         Hav is the value of a grid point the is ON the prism.
         'Lav' should be lower than 'Hav' and zero or greater
         'Hav'can be any float > 'Lav'.
  
  Gseed: This is the Jitter seed. If this is 0 then NO Jitter
   Gval: If 'Gseed" then this is the percent of jitter for each Grid Point.
         The jitter take place after the average has been made.
         So trying to use triangle compression(Tpres) you'll have
         artifacts. As these two things hate each other. 
  
 Tpres: Turns on the triangle compression this is my attemp to reduce
        the triangle and point counts. It only works on points that are
        at the maximum height and close to each other. With some settings
        it is useless and RoundPrism will tell you about it.  
        
Smooth: This makes the Mesh2 smooth. That is it'll calc and place the
        normal_vectors for all the triangles.

 UV_on: This turns on uv mapping for the Mesh2. 
  UV_C: When 'UV_on' is on this 2 element vector helps set the uv values
        for each grid point. That was lame. Lets see, the elements should
        most always be positive. Think of the using a pigment image_map
        moved to <-.5,-.5,0>. To get that on your Mesh2 you'd could use
        'UV_C=<.5,.5>' or scale the pigment by 2 and use 'UV_C=<1,1>'.
        'UV_C' acts as an rectangle. So'UV_C=<1,1>'is equal to the area
        <-1,-1>,<1,-1>,<1,1>,<-1,1>.  

  Save= This string has the name of the file the Mesh2 is save to.
        The Mesh2 is name 'Thing' as in #declare Thing=Mesh2...
        You use it like this.
         #include"YourSavedMesh"
         Object(Thing...
        See the 'Test.Pov' file for a full example.
        
  Final Word:  I'm sure that I forgot something. But I hope this
              helps you make some smooth Prisms. Oh! by the way... 
                                                      
                 Have Fun!                                     