//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// bretzel
#declare R=function(u,v){cos(v)*2.0}
#declare F1= function(u,v){(4+R(u,v)*cos(u)+4*pow(cos(v*0.5),2))*cos(2*v)} 
#declare F2= function(u,v){(4+R(u,v)*cos(u)+4*pow(cos(v*0.5),2))*sin(2*v)} 
#declare F3= function(u,v){R(u,v)*sin(u)+(4*sin(v))}
//-------------------------------------------------------------------------------------------------
#include "meshmaker.inc"
//-------------------------------------------------------------------------------------------------
object{ // Parametric(Fx,Fy, Fz, <UVmin>, <UVmax>, Iter_U, Iter_V, FileName)
   Parametric( // Builds a parametric surface out of three given functions. 
               // The uv_coordinates for texturing the surface come from the square <0,0> - <1,1>. 
      F1, F2, F3, //three functions
      <0, FromV(0)>,< 2*pi, 2*pi>,// range within to calculate surface: <u min, v min>,<u max, v max>. 
      50,200, // resolution of the mesh in the u range and v range.
      "" // FileName: ""= non, "NAME.obj'= Wavefront objectfile, "NAME.pcm" compressed mesh file 
         // "NAME.arr" = include file with arrays to build a mesh2 from, 
         //  others: includefile with a mesh2 object 
   ) //---------------------------------------------------------------------------------------------
   /*
   interior_texture {  // inside texture
     uv_mapping
   //  pigment{ color rgb <1,1,1> }
     pigment{ checker color rgb <0.5,0.0,0.1> rgb <1,1,1> scale <0.02,0.025,0.01>}
     finish { specular 0.25}
   } // 
   */
   texture{            //  outside (interior_texture)
     //uv_mapping
     //pigment{ checker color rgb <0.0,0,0.0> rgb <1,0.9,0.9>  scale <0.015 ,0.035,1>}
     //finish { phong 0.5 }
   uv_mapping
      pigment {
         marble
         turbulence <0.3,0,0>
         translate <-0.5,0,0>
         scale <0.055,1,1>
         rotate <0,0,45>
         warp {repeat 0.5*x flip x}
         warp {repeat 0.5*y flip y}
         colour_map {
            [0, rgbf 0]
            [1, rgbf <1,1,1,0.6>]
         }
      }
      finish {
         specular 0.4
         roughness 0.05
         irid {
            0.3
            thickness 0.2
            turbulence 0.1
         }      
      }
   } // 
    
   scale< 1,1,1>*0.175
   rotate <90,0,0>
   translate< 0, 0, 0 >
} // end of object 
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
