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

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

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

#version 3.7 ;

#include "colors.inc"

camera {location <10,10,10> angle 30 look_at <0,0,0> }

  background { color rgb<0.2, 0.4, 0.8>  }
  light_source {<10,20,5> color White}
  global_settings {assumed_gamma 1.0 }

  #declare Corner_Profile = -.5;   // -.5 gives rounded bevel, 0 almost round,
+.5 Not noticebly sharper
  #declare Corner_round = 1;

  #declare R_plane = function( X,r,s){

select((X>r)-(X<-r),2*(r<0)-1,s*pow(X/r,5)-(2*s+.5)*pow(X/r,3)+(1.5+s)*X/r,1-2*(r<0))
                                     }
  isosurface {
     function {
               R_plane(x+1.5,-Corner_round,Corner_Profile)
              +R_plane(x-1.5,+Corner_round,Corner_Profile)
              +R_plane(y-1.5, Corner_round,Corner_Profile)
              +R_plane(y+1.5,-Corner_round,Corner_Profile)
              +R_plane(z-1.5,+Corner_round,Corner_Profile)
              +R_plane(z+1.5,-Corner_round,Corner_Profile)
              }
     threshold -5


      max_gradient 6
    contained_by { box { -2, 2 } }
 texture {
  pigment {color rgb < 1, 0.9, 0.65>}
  }
  }

/**
// Example 1. Notes: changing the threshold does have the effect of
shrinking/swelling the object. Corner_round = 1.5 Corner_Profile = -.5 gives a
rounded octrahedron
     function {
               R_plane(x+1.5,-Corner_round,Corner_Profile)
              +R_plane(x-1.5,+Corner_round,Corner_Profile)
              +R_plane(y-1.5, Corner_round,Corner_Profile)
              +R_plane(y+1.5,-Corner_round,Corner_Profile)
              +R_plane(z-1.5,+Corner_round,Corner_Profile)
              +R_plane(z+1.5,-Corner_round,Corner_Profile)
              }
     threshold -5
// Example 2. Demonstrates not all the same corner profile
     function {
               R_plane(x-1.5,+.5,0)
              +R_plane(x+1.5,-2,0)
              +R_plane(y-1.5, 1,-.5)
              +R_plane(y+1.5,-1,-.5)
              +R_plane(z-1.5,+1,-.5)
              +R_plane(z+1.5,-1,-.5)
              }
     threshold -5
//Example 3. Five planes, not all othogonal
     function {
               R_plane(x+1.5,-Corner_round,Corner_Profile)
              +R_plane(x-1.5,+Corner_round,Corner_Profile)
              +R_plane(y+1.5,-Corner_round,Corner_Profile)
              +R_plane(y+z-1,+Corner_round,Corner_Profile)
              +R_plane(z+1.5,-Corner_round,Corner_Profile)
              }
     threshold -4
//Example 4. Corner definitions can be variable: Round
     function {
               R_plane(x+1.5,-.5,Corner_Profile)
              +R_plane(x-1.5,+1.5,Corner_Profile)
              +R_plane(y-1.5, Corner_round+.5*x,Corner_Profile)
              +R_plane(y+1.5,-Corner_round-.5*x,Corner_Profile)
              +R_plane(z-1.5,+Corner_round+.5*x,Corner_Profile)
              +R_plane(z+1.5,-Corner_round-.5*x,Corner_Profile)
              }
     threshold -5

//Example 5. Corner definitions can be variable: profile
     function {
               R_plane(x+1.5,-.4,0)
              +R_plane(x-1.5,+.4,0)
              +R_plane(y-1.5, Corner_round,Corner_Profile*x)
              +R_plane(y+1.5,-Corner_round,Corner_Profile*x)
              +R_plane(z-1.5,+Corner_round,Corner_Profile*x)
              +R_plane(z+1.5,-Corner_round,Corner_Profile*x)
              }
     threshold -5

*/


Post a reply to this message

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