|
|
scott <sco### [at] scottcom> wrote:
> >>> If you're on to something then some working
> >>> example code will go *far* further than just a text description.
> >>
> >> Totally agree, I am working on it.
> >
> > And here it is:
>
> A good start!
>
> How would you go about doing the union (or difference) of two rounded
> cubes? I tried to modify the code to do this but couldn't get it to
> work. If that works nicely then I think you're on to something...
>
> BTW you could always use a macro for each element, that depending on
> some global switch, either used the standard POV non-rounded primitive
> (for speed of setting up the scene) or the isosurface variant (for final
> render).
Excellent idea.
And here are unions:
// 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.
// Demonstration of nion for rounded objects
// Vers: 1.00
// Date: 20 Sept 2016
// Auth: John Greenwood
#version 3.7 ;
#include "colors.inc"
camera {location <10,7,30> angle 12 look_at <0,0,0> }
background { color rgb<0.2, 0.4, 0.8> }
light_source {<10,5,10> color White}
global_settings {assumed_gamma 1.0 }
#declare R_function = function( F,q,p,n){
select((F>q)-(F<-q),2*(q<0)-1,p*pow(F/q,5)-(2*p+.5)*pow(F/q,3)+(1.5+p)*F/q,1-2*(q<0))+n
}
#declare Vo =1;
#declare R_limit = function(V){select((V+1>Vo)-(V+1<-Vo),
-1,-.5*pow((V+1)/Vo,3)+1.5*(V+1)/Vo,+1)-1}
#declare Corner_Profile = -0; // -.5 gives rounded bevel, 0 almost round,
+.5 Not noticebly sharper
#declare Corner_round = .3;
isosurface {
function {
R_function(-sqrt(pow(x-1,2)+pow(y,2)+pow(z,2))+1,-1,0,-1)
+R_limit(
R_function(x+1.5,-Corner_round,Corner_Profile,1)
+R_function(x-.5,+Corner_round,Corner_Profile,1)
+R_function(y-.5, Corner_round,Corner_Profile,1)
+R_function(y+1.5,-Corner_round,Corner_Profile,1)
+R_function(z-1.5,+Corner_round,Corner_Profile,1)
+R_function(z+.5,-Corner_round,Corner_Profile,1)-2 )
+1
}
threshold 0
max_gradient 20
contained_by { box { -2, 2 } }
texture {pigment {color rgb < 1, 0.9, 0.65>}}
translate < 0,1.4,0>
}
isosurface {
function {
R_limit( R_function(-sqrt(pow(y-.5,2)+pow(z,2))+.5,-.3,0,-1)
+R_function(x+.5 ,-.3,0,1)
+R_function(x-1.5,+.3,0,1))
+R_limit( R_function(-sqrt(pow(y+.5,2)+pow(z,2))+.5,-.3,0,-1)
+R_function(x+1.5,-.3,0,1)
+R_function(x-.5,+.3,0,1))
+1
}
threshold 0
max_gradient 20
contained_by { box { -2, 2 } }
texture {pigment {color rgb < 1, 0.9, 0.65>}}
translate < 0,-1.5,0>
}
Post a reply to this message
|
|