POV-Ray : Newsgroups : povray.windows : How to generate sphere and cylinder with csv file : Re: How to generate sphere and cylinder with csv file Server Time
21 Jun 2021 12:20:51 EDT (-0400)
  Re: How to generate sphere and cylinder with csv file  
From: Bald Eagle
Date: 28 Mar 2017 08:00:00
Message: <web.58da4fecae95604bc437ac910@news.povray.org>
"Jeff" <jef### [at] gmailcom> wrote:

> hi, if i open the .csv file , and save it as .txt file, will that do the
> conversion?

The .csv file is essentially a text file in exactly the format that POV-Ray
needs it to be in.  "Comma Separated Values" = CSV

> and i have like 1000+ sphere that i need to generate from the data,

Not a problem - I've made scenes with millions.

> is there any efficient way to do it, instead of write down the sphere position?

Yes, that's why you're automating the process by reading in the values from an
existing file.
I'd start with a small fragment of the file - say 10-50 entries or so, and
output all of the variables you read in and calculate to the #ebug stream so
that you're sure about what you're working with, and passing on to POV-Ray.

I generally define a Verbose variable, then use
#if (Verbose)
     #debug "Debugging on \n"
so that I'm not forever commenting and uncommenting debugging tools.

> #include "colors.inc"
> #declare myImage = image{ png "C:\\Users\\Jeff\\Desktop\\beijing.png" }

#declare myImage = pigment {image_map {png "C:/Users/Jeff/Desktop/beijing.png"
#declare Resolution = max_extent (myImage);
#declare ImageHeight = Resolution.y;
#declare ImageWidth = Resolution.x;

Then make a flat box:  box {0, 1, translate -0.5 pigment {myImage} scale
<Resolution.x, Resolution.y, 1>}

> #fopen nodesfile "nodes.txt" read
> #fopen linksfile "links.txt" read
>   #while (defined(nodesfile))
>     #read (nodesfile,Var1,Var2,Var3,Var4)
> #if (Var1 = "bus")
>     #declare Color = pigment {Red};
> #else if (Var2 = "subway")
>     #declare Color = pigment {Green};
> #else if (Var3 = "rail")
>     #declare Color = pigment {Blue};
> #else (Var4 = "tram")
>     #declare Color = pigment {Yellow};
> #end
> camera
> { location <0,0,-10>
>   look_at 0
>   rotate <0,clock*360,0>
> }

I'm not sure why you're using the Clock variable in your camera definition,
unless you plan on animating this later.
Probably gonna have to move that camera WAY back in the -z direction.
I'd also probably use an orthographic camera, and ambient_light to get aa pretty
flat, evenly lit scene, at least at the beginning.

> light_source    {
>                 <10,10,-10>
>                 color White
>                 }

Post a reply to this message

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