POV-Ray : Newsgroups : povray.general : How Do I... Server Time
17 Nov 2024 23:16:09 EST (-0500)
  How Do I... (Message 1 to 3 of 3)  
From: Timothy R  Cook
Subject: How Do I...
Date: 14 Dec 2002 05:23:39
Message: <3dfb06ab$1@news.povray.org>
I have an unspecified number of linear_spline prisms with unspecified
number of control points and unspecified colour.  Code for an individual
prism looks like

#declare Tile#### = prism{
   linear_sweep
   linear_spline -1.0, 0.0
   cp
   <x1, y1>,
   ..
   <xn, yn>
   rotate -x*90
   material{
     texture{
       pigment{ color rgbt<RRR, GGG, BBB, 0.5> }
       normal{ granite , 1.0 turbulence 1.0 ramp_wave }
       finish{ ambient 0.1 phong 1.0 phong_size 20.0 specular 1.0 }
     }
     interior{
       ior 2.0
       caustics 1.0
       media{
         intervals 1
         confidence 0.0001
         variance 1.0/1.0
         ratio 0.5
         emission rgb <RRR, GGG, BBB>
         scattering{ 5, rgb <0.2, 0.2, 0.2> eccentricity 0.0 }
       }
     }
   }
   hollow
   photons{ collect off }
}

where RRR, GGG, BBB are the red, green and blue values, cp the
number of control points, and Tile#### the prism in question.
I started doing the whole thing by hand in Moray, but I realised
that this is something that I ought to be able to do with a
fairly simple POV script.  I'd already started putting the colours
for the tiles into a CSV file (20 tiles so far).

The question is: how do I go about reading the appropriate elements
of the CSV into the appropriate variables in the prism object?  I
reckon I can figure out how to repeat it myself once I know how to
do one, but my programming experience doesn't include messing with
data files.

For reference, CSV would look like

Tile####,RRR,GGG,BBB,rrr,ggg,bbb,p, x1, y1, x2, y2, x3, y3, x4, y4
Tile0001,128,128,128,0.5,0.5,0.5,4,0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0
...
Tile0020,128,128,128,0.5,0.5,0.5,4,2.0,0.0,3.0,0.0,3.0,1.0,2.0,1.0
EOF

(probably can ditch the rrr, ggg, bbb values since I can do maths
inside POV, and they're RRR, GGG, and BBB divided by 255)
-- 
Tim Cook
http://empyrean.scifi-fantasy.com

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: cadman
Subject: Re: How Do I...
Date: 14 Dec 2002 08:43:30
Message: <3dfb3582$1@news.povray.org>
Perhaps, if I understand what you're trying...

Can you have the first element of the CSV file be the number of tiles?  Then
you can #read the first element into a viariable and delcare an array for
your tiles.  There is no way to dynamically change the name of a variable,
i.e. #declare Tile####.

#declare Tiles=array[number_of_tiles];

Then you can iterate through a loop that #reads all the subsequent values
and defines the next tile in your array.

#delcare Tiles[loop_counter]=prism { ... }

No doubt you've studied up on the file directives in the docs...;-)



"Timothy R. Cook" <tim### [at] scifi-fantasycom> wrote in message
news:3dfb06ab$1@news.povray.org...
> I have an unspecified number of linear_spline prisms with unspecified
> number of control points and unspecified colour.  Code for an individual
> prism looks like
>
> #declare Tile#### = prism{
>    linear_sweep
>    linear_spline -1.0, 0.0
>    cp
>    <x1, y1>,
>    ..
>    <xn, yn>
>    rotate -x*90
>    material{
>      texture{
>        pigment{ color rgbt<RRR, GGG, BBB, 0.5> }
>        normal{ granite , 1.0 turbulence 1.0 ramp_wave }
>        finish{ ambient 0.1 phong 1.0 phong_size 20.0 specular 1.0 }
>      }
>      interior{
>        ior 2.0
>        caustics 1.0
>        media{
>          intervals 1
>          confidence 0.0001
>          variance 1.0/1.0
>          ratio 0.5
>          emission rgb <RRR, GGG, BBB>
>          scattering{ 5, rgb <0.2, 0.2, 0.2> eccentricity 0.0 }
>        }
>      }
>    }
>    hollow
>    photons{ collect off }
> }
>
> where RRR, GGG, BBB are the red, green and blue values, cp the
> number of control points, and Tile#### the prism in question.
> I started doing the whole thing by hand in Moray, but I realised
> that this is something that I ought to be able to do with a
> fairly simple POV script.  I'd already started putting the colours
> for the tiles into a CSV file (20 tiles so far).
>
> The question is: how do I go about reading the appropriate elements
> of the CSV into the appropriate variables in the prism object?  I
> reckon I can figure out how to repeat it myself once I know how to
> do one, but my programming experience doesn't include messing with
> data files.
>
> For reference, CSV would look like
>
> Tile####,RRR,GGG,BBB,rrr,ggg,bbb,p, x1, y1, x2, y2, x3, y3, x4, y4
> Tile0001,128,128,128,0.5,0.5,0.5,4,0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0
> ...
> Tile0020,128,128,128,0.5,0.5,0.5,4,2.0,0.0,3.0,0.0,3.0,1.0,2.0,1.0
> EOF
>
> (probably can ditch the rrr, ggg, bbb values since I can do maths
> inside POV, and they're RRR, GGG, and BBB divided by 255)
> --
> Tim Cook
> http://empyrean.scifi-fantasy.com
>
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
> N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
> PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
> D++(---) G(++) e*>++ h+ !r--- !y--
> ------END GEEK CODE BLOCK------
>


Post a reply to this message

From: Timothy R  Cook
Subject: Re: How Do I...
Date: 14 Dec 2002 10:40:59
Message: <3dfb510b$1@news.povray.org>
cadman wrote:
> Can you have the first element of the CSV file be the number of tiles?

I don't yet know how many tiles I'll have, but once I do, I could do
that, I guess.

> No doubt you've studied up on the file directives in the docs...;-)

*cough*  *cough*
No doubt.

-- 
Tim Cook
http://empyrean.scifi-fantasy.com

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

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