POV-Ray : Newsgroups : povray.binaries.images : Head produced by rounded objects method Server Time: 25 Feb 2017 14:03:32 GMT
  Head produced by rounded objects method (Message 1 to 1 of 1)  
From: John Greenwood
Subject: Head produced by rounded objects method
Date: 11 Dec 2016 11:15:01
Message: <web.584d34e77f9527eae15d43a80@news.povray.org>
This image was produced by the following scene:

// This work is licensed under the Creative Commons Attribution 3.0 Unported
License.
// To view a copy of this license, visit
http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain
View,
// California, 94041, USA.

// Rounded objects: Illustration of R_Surface

// Vers: 1.00
// Date: 30 Nov 2016
// Auth: John Greenwood

#version 3.7 ;
    global_settings {assumed_gamma 1.0 }
    camera {perspective location <0,0,-40> angle 22 look_at <0,0,0> }
    light_source {<-5,10,-20> colour rgb<1,1,1>* .5}
    light_source {<+20,3 ,-10> colour rgb<1,1,1>* .5}
    background { color rgb<0.2, 0.4, 0.8>  }

// The essential functions******************************************
  #declare R_function = function( p,F){
    select(-(p<=-1) , select((F>1)-(F<-1) , -1 , F , 1)+1
                 , select(-(p!=1) , select((F>1)-(F<-1) , -1 ,
..5*p*pow(F,5)-(p+.5)*pow(F,3)+(1.5+.5*p)*F , 1)+1
                               ,F/(sqrt(.17+pow(F,2))) +1
           ) )
                                 }

  #declare R_Intersection =
function(V){select((V>2)-(V<0),-1,-.5*pow(V-1,3)+1.5*(V-1),+1)+1}
  #declare R_Union =
function(V){select((V>4)-(V<2),-1,-.5*pow(V-3,3)+1.5*(V-3),+1)+1}
  #declare R_Unite =
function(n,V){select((V>(2*n))-(V<2*n-2),-1,-.5*pow(V+1-2*n,3)+1.5*(V+1-2*n),+1)+1}

  #declare R_S_function = function( p,x,y,z,F){
    select(-(p<=-1) , select((F>1)-(F<-1) , -1 , F , 1)+1
                 , select(-(p!=1) , select((F>1)-(F<-1) , -1 ,
..5*p*pow(F,5)-(p+.5)*pow(F,3)+(1.5+.5*p)*F , 1)+1
                               ,F/(sqrt(.17+pow(F,2))) +1
           ) )
                                 }


  #declare R_Ridge =function(Dim,Off,Width){1/(1+pow((Dim+Off)/Width,2))}
  #declare R_Step
=function(Dim,Off,Width){.5+.5*(Dim+Off)/(Width*sqrt(1+pow((Dim+Off)/Width,2)))}
  #declare R_Bend
=function(Dim,Off,Width){Width*(sqrt(1+pow((Dim+Off)/Width,2))-1)}
  #declare R_Surface =
function(p,r,L,xo,yo,zo,x,y,z,Fm){R_S_function(p,x,y,z,((x*xo+y*yo+z*zo)/sqrt(pow(xo,2)+pow(yo,2)+pow(zo,2))
+L+Fm) /-r)}
//**********************************************************************

  #declare R_Sphere =
function(p,r,L,x,y,z){R_function(p,(sqrt(pow(x,2)+pow(y,2)+pow(z,2))-L)/r) }


#ifndef(s) #local s = 0; #end

//Rounded object work
bench----------------------------------------------------------------

  #declare EyeSep =     .7;
  #declare EyeProtrude = 1.35;
  #declare EyeBallRad = .5;
  #macro Face(r) +R_Surface(.6,r,2,0,0,+1,x,y,z,
..3*R_Step(y,-.2,.3)-.2*R_Bend(y,0,2)-.2*R_Bend(x,0,.5)) #end

  #declare Head = function(x,y,z){
                               //
-.1*R_Ridge(x,0,1)*(R_Ridge(y,-.8,.1)+R_Ridge(y,-1,.1))
     R_Intersection(
                 Face(2)

+R_Surface(.6,4,2,0,+.2,-1,x,y,z,+.2*R_Bend(y+1.5,0,.5)-.3*R_Bend(y-0,0,2))
         //back

                +R_Surface(1,1,2,  +1, .15,0,x,y,z,-.2*R_Bend(y,0,1))   //side
                +R_Surface(1,1,2,  -1,+.15,0,x,y,z,-.2*R_Bend(y,0,1))   //side

                +R_Surface(.6,.7,3,0,+1,0,x,y,z,0)
//bottom
                +R_Surface( 1,3 ,2.7,0,-1,0,x,y,z,-.5*R_Bend(x,0,1))     //top


                +R_Sphere(.6,-.7,.12,x-EyeSep,y+.3 ,z+2)
                +R_Sphere(.6,-.7,.12,x+EyeSep,y+.3 ,z+2)
                     ) }

  #declare Nose =
     function(x,y,z){
     R_Intersection(
                +R_Surface(.6,.6,.5,  +1, -.25, +.4, x,y,z,0)
                +R_Surface(.6,.6,.5,  -1, -.25, +.4, x,y,z,0)

                +R_Surface(.6,.4,.4,   0,  +1,   0, x,y,z,0)
                +R_Surface(.6,.4,.7,   0,   0,   -1, x,y,z,0)
                    )
                     }
  #declare EyeLid =
     function(x,y,z){
     R_Intersection(
              +R_Sphere(.6,+.2,EyeBallRad+.05,x+EyeSep,y ,z+EyeProtrude)
              +R_Surface(.6,.2,EyeProtrude+EyeBallRad-.2,   0,   0,   +1,
x,y,z,R_Bend(y,0,.1))
                    )
                     }

#declare Fn = function { R_Unite( 4,
              Head(x,y,z)
              +Nose(x,y+.8,z+EyeProtrude-.1)
              +EyeLid(x,y ,z)
              +EyeLid(-x,y ,z)
              )  }

  #declare EyeBall =
    #union {
     sphere {0,EyeBallRad pigment {color rgb < 1, 1, 1>} finish {phong 0.9
phong_size 100 }}
     sphere {<0,0,-.05-.5*EyeBallRad>,.5*EyeBallRad pigment {color rgb < 0, 0,
..2>} finish {phong 0.9 phong_size 100 }}


            }


#declare isoThreshold = 1;

// Set to yes to produce the approximation
// or to no for the actual isosurface
#declare approximateIso = yes;

// Set to yes to produce a smooth_triangle approximation
// or to no ro produce a flat triangle approximation
#declare isoSmooth =no;

// Controls the size of the cube that is beeing sampled
#declare R = 3.0;

#declare isoMin = -<1, 1, 1>*R;
#declare isoMax = +<1, 1, 1>*R;

// The resolution of the sampling in the x, y and z directions
#declare Resolution = 50;

#if (approximateIso)

  #declare Depth = 0; // Set to 0 for no recursion
  #declare isoSegs = <1, 1, 1>*Resolution;
  #declare isoFileOption = 1;
  #declare isoFile = "triangles.inc";
  #declare isoName = "Surface";
  #include "isosurface_kl_jf_tok.inc"

  #declare Shape =
    #union{
    object {
      Surface
      pigment { color rgb < 1, 0.9, 0.65> }
      finish {
        phong 0.2
        phong_size 1
             }
           }
 object {EyeBall translate < EyeSep,0,-EyeProtrude> }
 object {EyeBall translate <-EyeSep,0,-EyeProtrude> }
       }

#else
  isosurface {
    function { Fn(x, y, z) }
    max_gradient 8.0
     threshold 1
    contained_by { box { isoMin, isoMax } }
    open
    pigment { color rgb < 1, 0.9, 0.65> }
    finish {
      phong 0.5
      phong_size 10
    }
  }
#end

// to see if there are any holes------------------
/*
  object{Shape  translate <-1.5,0,0>}
  object{Shape rotate <0,90,0> translate <3,0,0>}

 box{<4,4,+2>,<-4,-4,0> pigment { color rgb < 10,10, 0> } }
*/

object{Shape translate <-3,3,0>}
object{Shape rotate <0,90,0> translate <-3,-3,0>}
object{Shape rotate <90,0,0>  translate <+3,-3,0>}
object{Shape rotate <0,45,0> scale .5 translate <+3,+4,0>}
object{Shape rotate <0,45,0> scale .25 translate <+5,+2,0>}
object{Shape rotate <0,45,0>  scale .1 translate <+5,+4,0>}


Post a reply to this message


Attachments:
Download 'head.png' (103 KB)

Preview of image 'head.png'
head.png


 

Copyright 2003-2008 Persistence of Vision Raytracer Pty. Ltd.