POV-Ray : Newsgroups : povray.general : Spring is sprung. : Re: Spring is sprung. Server Time
4 Nov 2024 19:15:58 EST (-0500)
  Re: Spring is sprung.  
From: Warp
Date: 23 Sep 2003 11:09:40
Message: <3f706234@news.povray.org>
Stephen McAvoy <McA### [at] aolcom> wrote:
> Does any one have ideas for a compressible spring for an animation. I've tried a
> sphere_sweep but the rendering times are too long for me?

  There are basically to ways of making this (so that it will render with
an acceptable speed):

  1. Construct the spring with cylinders joined by spheres. Here is an
example of how it can be done:

camera { location -z*20 look_at 0 angle 35 }
light_source { -z*10, 1 }

#declare SpringHeight = 8;
#declare SpringMajorRadius = 1;
#declare SpringMinorRadius = .1;
#declare SpringRevolutions = 10;
#declare SpringSegments = 1000;

union
{
  #declare Ind = 0;
  #while(Ind <= SpringSegments)
    #declare Pos2 =
      vrotate(<SpringMajorRadius, SpringHeight*Ind/SpringSegments, 0>,
              y*360*SpringRevolutions*Ind/SpringSegments);
    #if(Ind > 0)
      cylinder { Pos1, Pos2, SpringMinorRadius }
      sphere { Pos2, SpringMinorRadius }
    #end
    #declare Pos1 = Pos2;
    #declare Ind = Ind+1;
  #end

  pigment { rgb 1 } finish { specular .5 }
  translate -y*4
}

box { <-2,-4,-2><2,-4.1,2> pigment { rgb <.8,.4,.2> } }


     The main problem is that you need a lot of segments to get a smooth
look.

  2. Construct the spring as a mesh. The advantage is that it renders
fast and it will look smooth even with fewer segments (because of
smooth triangles). The problem is that constructing it is a lot
more complicated (so complicated I'm not bothering doing it right now).

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

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