POV-Ray : Newsgroups : povray.general : supplying parameters dynamically : Re: supplying parameters dynamically Server Time
30 Jul 2024 12:27:28 EDT (-0400)
  Re: supplying parameters dynamically  
From: stbenge
Date: 4 Feb 2009 02:56:57
Message: <49894a49$1@news.povray.org>
stevenvh wrote:
> In my code I want to generate a series of prisms dynamically, where both the
> number of points and their coordinates are read from a file. I have no idea how
> to do this, so any hints be greatly appreciated.
> Regards,
> Steven

You could have an include file which contains an array:

#declare pn = pi*2/6;

#declare points=
array[7]{
  <sin(pn*0),cos(pn*0)>,
  <sin(pn*1),cos(pn*1)>,
  <sin(pn*2),cos(pn*2)>,
  <sin(pn*3),cos(pn*3)>,
  <sin(pn*4),cos(pn*4)>,
  <sin(pn*5),cos(pn*5)>,
  <sin(pn*0),cos(pn*0)>
}

Then you can #include the file into your scene and write something like 
this:

prism{
  -.5,.5,dimension_size(points,1)
  #declare V=0;
  #while(V<dimension_size(points,1))
   points[V]
   #declare V=V+1;
  #end
  pigment{rgb 1}
}

You'll probably want to generate the include file automatically. You 
should check into #fopen, #write and #fclose (3.2.2.3  File I/O 
Directives). You shouldn't have to #read a file to accomplish your goal. 
I hope this helps.

Sam


Post a reply to this message

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