POV-Ray : Newsgroups : povray.general : rounded_objects: a new feature? : Re: rounded_objects: a new feature? Server Time
17 May 2024 17:38:00 EDT (-0400)
  Re: rounded_objects: a new feature?  
From: John Greenwood
Date: 19 Sep 2016 05:05:01
Message: <web.57dfaa2e696ad3a7cafab50@news.povray.org>
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).

I think I have a plan!

Meanwhile here are some cylinders:

// 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 Cylinder elements for rounded objects

// Vers: 1.00
// Date: 18 Sept 2016
// Auth: John Greenwood

#version 3.7 ;

#include "colors.inc"

camera {location <0,0,17> angle 25 look_at <0,-.30,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<5,10,20> 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
                                        }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-1,2)+pow(z,2))+.4-.1*x,-.5,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.3,0,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y,-.3,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,.7,0>  }


  isosurface {
     function    {
               R_function(-sqrt(pow(y-1,  2)+pow(z,2))+ .5,-.3,.2+.5*x,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.3,.2+.5*x,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y    ,-.5,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-1,0>  }

  isosurface {
     function    {
               R_function(-sqrt(pow(y-1  ,2)+pow(z,2))+ .4,-.5+.2*x,0,-1)
              +R_function(-sqrt(pow(y+1.5,2)+pow(z,2))+1.9,-.5+.2*x,0,-1)
              +R_function(x+1.5,-.3,0,1)
              +R_function(x-1.5,+.3,0,1)
              +R_function(y+1    ,-.5,0,1)
                }
     threshold -1
      max_gradient 6
     contained_by { box { -2, 2 } }
  texture {pigment {color rgb < 1, 0.9, 0.65>}}
            translate < 0,-2.7,0>  }


Post a reply to this message

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