|
|
I have added another capability to my rounded corners idea, demonstrated by the
code below. (I intend to add a description of how this works to
http://www.john-greenwood.co.uk/PovRay/Rounded_Objects/Basics.html)
Designing objects like the one in this demo badly needs a fast display to check
the effect of changes to the controlling parameters.
I have used the isofunction for this development and have given priority to
clarity of working over speed of rendering. However I think the isofunction
approach is always going to be slow.
I am wondering if a better approach might be to realise the rounded object as a
mesh which, I understand, would render much faster. I have had a quick look at
meshes in the PovRay documentation but am not at all clear how it could be used
in this case.
Another option would to be to do the design with a separate app such as
Bishop3D. Currently this does not do isofunctions but I am trying to contact the
author to find out how the development is going.
// 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 {location <-30,10,-40> angle 9 look_at <0,0,0> }
light_source {<-5,20,-20> colour rgb<1,1,1>}
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.4;
#declare EyeBallRad = .5;
#macro Face(r) +R_Surface(.6,r,2,0,0,+1,x,y,z,
..4*R_Step(y,-.2,.2)-.2*R_Bend(y,0,2)-.2*R_Bend(x,0,.5)-.1*R_Ridge(x,0,1)*(R_Ridge(y,-.8,.1)+R_Ridge(y,-1,.1)))
#end
#declare Head = function(x,y,z){
R_Intersection(
Face(2)
+R_Surface(.6,3,2,0,+.3,-1,x,y,z,0)
+R_Surface(.6,1,2, +1, .15,0,x,y,z,-.2*R_Bend(y,0,1))
+R_Surface(.6,1,2, -1,+.15,0,x,y,z,-.2*R_Bend(y,0,1))
+R_Surface(.6,.7,3,0,+1,0,x,y,z,0)
+R_Surface( 1,3 ,2.7,0,-1,0,x,y,z,-.5*R_Bend(x,0,1))
+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,.3,.4, 0, +1, 0, x,y,z,0)
+R_Surface(.6,.4,.7, 0, 0, -1, x,y,z,0)
)
}
//Mouth----------------------------
isosurface {
function{
R_Intersection(
Face(.1)
+R_Surface(.6,.2,-.6, 0,+1,0,
x,y,z,+.5*(R_Step(x,+.5,.2)-R_Step(x,-.5,.2)+R_Step(z,+3,.2)-R_Step(z,1,.2)))
+R_Surface(.6,.2, .0, 0,-1,0, x,y,z,0)
)
}
threshold 1
max_gradient 25
contained_by { box {<-1,-.5, -1>, <1,.5,-3>} }
texture {pigment {color rgb < 1, .3,.3>}}
translate <0,-1.6,+.15> }
//------------------------------------------------------------------------------------------
isosurface {
function {
// start of rounded object ****************************************
R_Union(
Head(x,y,z)
+Nose(x,y+.8,z+EyeProtrude-.1)
)
// end of rounded object **************************
}
threshold 1
max_gradient 11
contained_by { box {<-2.5,-3.2, -2.5>, <2.5,3.2,2.5>} }
texture {pigment {color rgb < 1, 0.9, 0.65>}}
}
#declare EyeBall =
#union {
sphere {0,EyeBallRad pigment {color rgb < 1, 1, 1>}}
sphere {<0,0,-.05-.5*EyeBallRad>,.5*EyeBallRad pigment {color rgb < 0, 0,
..2>}}
finish {ambient .2 diffuse .6 specular 1 roughness .001 reflection {1}}
}
object {EyeBall translate < EyeSep,0,-EyeProtrude> }
object {EyeBall translate <-EyeSep,0,-EyeProtrude> }
Post a reply to this message
|
|