POV-Ray : Newsgroups : povray.newusers : how to make a screw object? : Re: how to make a screw object? Server Time
4 Nov 2024 13:58:11 EST (-0500)
  Re: how to make a screw object?  
From: BorisW37
Date: 30 Jul 2003 13:55:01
Message: <web.3f28056cb40ba1e0e8af727a0@news.povray.org>
I have worked out a vey nice screw, it follows the American screw standards
and actually looks like a real screw. All i need to do now is to make a
more realistic head. It takes a hell of a long time to render if doing good
quality. Here is the full scene text:

// ==== Standard POV-Ray Includes ====
/*#include "colors.inc"   // Standard Color definitions
#include "textures.inc"   // Standard Texture definitions
#include "functions.inc"  // internal functions usable in user defined
functions
#include "metals.inc"
*/
// perspective (default) camera
camera {
  location  <-2, 20, -22.0>
  look_at   <6, 5,  0>
  right     x*image_width/image_height
}

// An area light (creates soft shadows)
// WARNING: This special light can significantly slow down rendering times!
light_source {
  0*x                 // light's position (translated below)
  color rgb 1.2       // light's color
  area_light
  <8, 0, 0> <0, 0, 8> // lights spread out across this distance (x * z)
  4, 4                // total number of lights in grid (4x*4z = 16 lights)
  adaptive 0          // 0,1,2,3...
  jitter              // adds random softening of light
  circular            // make the shape of the light circular
  orient              // orient light
  translate <40, 60, -40>   // <x y z> position of light
}

#declare Gold_Nugget =
   material  // Gold_Nugget
   {
      texture
      {
         pigment
         {
            color rgb <0.5, 0.35, 0.25>
         }
         finish
         {
            ambient 0.1
            diffuse 0.65
            brilliance 1.5
            specular 0.85
            roughness 0.01
            reflection 0.45
         }
      }
   }


// An infinite planar surface
// plane {<A, B, C>, D } where: A*x + B*y + C*z = D
plane {
  y, // <X Y Z> unit surface normal, vector points "away from surface"
  -2 // distance from the origin in the direction of the surface normal
  hollow on // has an inside pigment?
  material {Gold_Nugget}
}
/*
cylinder {
        <0,100,0>,<0,-100,0>,0.05
        pigment {Red}
}
cylinder {
        <100,0,0>,<-100,0,0>,0.05
        pigment {Red}
}
cylinder {
        <0,0,100>,<0,0,-100>,0.05
        pigment {Red}
}
*/
//-------------------------------------------------------------------------------------
//   ALL SCREW DIMENSION GO HERE \/ \/ \/


#declare p=1;    //pitch (distance between same 2 points on the thread) 1
cycle or period
#declare md=8;   //major diameter of the screw
#declare len=25; //length of screw withou the cap
#declare qual=300;//quality of the screw (number of cones per one revolution
or one pitch)
//-------------------------------------------------------------------------------------
#declare d=(p*sqrt(3)/2);
#declare pv=(1/16)*p*cos(pi/6); //NOTE to Self, rotate in degrees BUT
sin,cos, etc.. in radians
#declare n_dies=(((len/p)-1/2)*qual); //total number of cones (dies) to be
added  from cylinder
#declare mid= md-2*(d-2*pv); //minor diameter of the screw, the diameter of
the center cylinder



#declare BLUE_METAL =
   material  // BLUE_METAL
   {
      texture
      {
         pigment
         {
            color rgb <0.0, 0.0, 0.61>
         }
         finish
         {
            ambient 0.1
            diffuse 0.8
            brilliance 6.0
            phong 1.0
            phong_size 80.0
            reflection 0.7
         }
      }
   }

#declare die=
        cone {
                <0,0,0>, (p*7/16)
                <(d-2*pv),0,0>, (p/16)
                translate <mid/2,0,0>

                //texture {Chrome_Metal}
        }
#declare die_set=
    union {
        #declare n_dies_con=n_dies;
        #while (n_dies>0)
          object { die
                rotate <0,((360/qual)*( n_dies_con-n_dies)),0>
                translate <0,((p/qual)*( n_dies_con-n_dies)),0>
        }
        #declare n_dies=(n_dies-1);
        #end


   }
#declare main =
        union {
                object {die_set }
                cylinder {
                                <0,0,0>,<0,len-1/2*p,0>,mid/2
                        }
                cylinder {<0,len-1/2*p,0>,<0,len,0>,md/2
                        }
                        rotate <0,0,0>
                        translate <0,0,0>

        }

#declare nl=(2*sqrt(3)*0.75*md)/3;

#declare head_hex=
                // extrude a closed 2-D shape along an axis
        prism {
          linear_sweep  // or conic_sweep for tapering to a point
          linear_spline // linear_spline | quadratic_spline | cubic_spline |
bezier_spline
           len,         // height 1
           len +2/3*md,         // height 2
          7,           // number of points
          // (--- the <u,v> points ---)
          <.5*nl,-0.75*md>,<nl,0>,<.5*nl,0.75*md>,
          <-.5*nl,0.75*md>,<-nl,0>,<-.5*nl,-0.75*md>,
          <.5*nl,-0.75*md>
          // , <0.2,   0.2> // match 2nd point, if quadratic_spline add this
          // , <0.2,  -1.0> // match 1st point, if cubic_spline add this as
well as the other
          // [open]
          // [sturm]
        }
#declare screw= union {object {main} object {head_hex}
                       // texture {Chrome_Metal}
                       material {BLUE_METAL}
                      }



object {screw rotate <0,20,-90> translate <-8,5,0>}



------------------------------------------


Try rendering with lower quality first, to see how it comes out. This is my
backround for my desktop and i used 25000 quality seting. It took around
4hrs to render on 2ghz Athlon xp.

Please tell me what you think of this screw...


Post a reply to this message

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