POV-Ray : Newsgroups : povray.binaries.images : Mesh lathe : Mesh lathe Server Time
16 Aug 2024 08:18:43 EDT (-0400)
  Mesh lathe  
From: Warp
Date: 24 Feb 2002 06:55:45
Message: <3c78d4c0@news.povray.org>
I was experimenting with a small macro which creates a mesh shaped like
a lathe from a spline. (The advantage of meshes over lathes is speed. Another
one is that with lathes you sometimes get artifacts which you don't get with
meshes.)

  This should demonstrate what does the macro do:

----------8<------------8<-------------8<-------------8<-----------8<------
#macro MakeEvenSplinePoints(Points)
  #local Amnt = dimension_size(Points, 1)-1;
  #local Ind = 0;
  #while(Ind <= Amnt)
    Ind/Amnt, Points[Ind]
    #local Ind = Ind+1;
  #end
#end

#declare Points = array[18]
{ <0,.1>,<1,0>,<1.2,.05>,<1,.1>,<.2,.3>,
  <.25,.4>,<.1,.9>,<.1,2.5>,<.3,2.8>,<.3,3.1>,
  <1,3.25>,<1.25,4>,<1,5>,<.9,5>,<1.1,4.5>,
  <1.15,3.8>,<1,3.4>,<0,3.2>
}

#declare Spline = spline { cubic_spline MakeEvenSplinePoints(Points) }

camera { location -z*14 look_at 0 angle 35 orthographic translate y*2.5 }
light_source { <100,200,-300>, 1 }
light_source { <-100,20,-30>, <1,.5,0>*.5 }
plane { -z,0 pigment { checker rgb 1, rgb .5 } }

// Final mesh:
object
{ MeshLathe(Spline, 80, 20)
  no_shadow
  pigment { rgb 1 } finish { specular .5 }
  translate x*3
}

// Mesh with flat triangles:
#declare MeshLatheDebug=3;
object
{ MeshLathe(Spline, 80, 20)
  no_shadow
  pigment { rgb 1 } finish { specular .5 }
}

// Spline preview with normals:
#declare MeshLatheDebug=2;
#declare MeshLatheDebugNormalColor=x;
object
{ MeshLathe(Spline, 80, 20)
  no_shadow
  pigment { rgb x+y } finish { specular .5 }
  translate x*-3
}
----------8<------------8<-------------8<-------------8<-----------8<------


Post a reply to this message


Attachments:
Download 'MeshLatheDebug.jpg' (53 KB) Download 'MeshLatheExample.jpg' (23 KB)

Preview of image 'MeshLatheDebug.jpg'
MeshLatheDebug.jpg

Preview of image 'MeshLatheExample.jpg'
MeshLatheExample.jpg


 

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