POV-Ray : Newsgroups : povray.windows : How to generate sphere and cylinder with csv file Server Time
29 Mar 2024 10:56:54 EDT (-0400)
  How to generate sphere and cylinder with csv file (Message 21 to 30 of 31)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 1 Messages >>>
From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 02:15:01
Message: <web.58e5dcc7ae95604b653b97b10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> So you want to render not to a static image, but rather to /some/ output
> file format that allows for free manipulation of the camera angle?
 movie, and letting the user jog forward and
> backward through the movie.

-- yes , i want to use my .png file , as the layer , and the nodes and the links
will be on the top of the layer(.png* file).
and i want the camera to rotate horizontal 360*, but i if i could rotate the
camera the way i want it after i render it would be better.


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 02:20:00
Message: <web.58e5dd82ae95604b653b97b10@news.povray.org>
Stephen <mca### [at] aolcom> wrote:
> On 4/1/2017 6:47 AM, Jeff wrote:
> > example picture:
> >
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTs
Q_AU

> I use a very thin box instead of a plane and an image_map.
>
> Or you can use a polygon. (From help file)
>
>
> polygon {
>    4,
>    <0, 0>, <0, 1>, <1, 1>, <1, 0>
>    texture {
>      finish { ambient 1 diffuse 0 }
>      pigment { image_map { gif "test.gif"  } }
>      }
>    //scale and rotate as needed here
>    }
>
>
> --
>
> Regards
>      Stephen

hi, thanks for answering. however, i want the picture to be normal square that
is adjustable in size. i try it to use the polygon , but i dont think its what i
want to do. i want 4 same pictures stack on the top of each other with a little
bit of distance. :)


Post a reply to this message

From: Stephen
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 03:05:11
Message: <58e5e8a7$1@news.povray.org>
On 4/6/2017 7:17 AM, Jeff wrote:
> Stephen <mca### [at] aolcom> wrote:
>> On 4/1/2017 6:47 AM, Jeff wrote:
>>> example picture:
>>>
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTs
> Q_AU
>
>> I use a very thin box instead of a plane and an image_map.
>>
>> Or you can use a polygon. (From help file)
>>
>>
>> polygon {
>>     4,
>>     <0, 0>, <0, 1>, <1, 1>, <1, 0>
>>     texture {
>>       finish { ambient 1 diffuse 0 }
>>       pigment { image_map { gif "test.gif"  } }
>>       }
>>     //scale and rotate as needed here
>>     }
>>
>>
>> --
>>
>> Regards
>>       Stephen
>
> hi, thanks for answering. however, i want the picture to be normal square that
> is adjustable in size. i try it to use the polygon ,

A box would have been better. Once you have the image in the box, the 
way you want it. Scale and translate the box. The image follows. :)

> but i dont think its what i
> want to do. i want 4 same pictures stack on the top of each other with a little
> bit of distance. :)
>

I would use four boxes for simplicity.
I can think of a couple of ways of making one object that has four 
images stacked.
Create a mesh and uv map the images in layers.
Create a density map with the images in layers and use media.

Four boxes in a union would be the simplest and easiest way to do it.


-- 

Regards
     Stephen


Post a reply to this message

From: clipka
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 04:19:36
Message: <58e5fa18$1@news.povray.org>
Am 06.04.2017 um 07:03 schrieb Jeff:

> Hi, when i try to run the code it says "Parse Error: Expected'float,vector,or
> string literal', string identifier found instead".
> 
> do you know what cause the problem?

My guess would be that you have arbitrary text in the CSV file; in that
case, you'll need to make sure it is enclosed in double quotes, e.g.

    "Foo"

instead of

    Foo


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 09:05:00
Message: <web.58e63ca1ae95604b80403a200@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> My guess would be that you have arbitrary text in the CSV file; in that
> case, you'll need to make sure it is enclosed in double quotes, e.g.
>
>     "Foo"
>
> instead of
>
>     Foo

Correct.
Jeff, look at the comment in the code:
//  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
//    etc.

That's exactly how it all will need to be formatted.
I'd probably use a spreadsheet, "copy" the data into an adjacent set of cells,
by using a formula that surrounds the relevant data with double quotes (the
String Literal POV-Ray is wanting for the #read directive) and commas and then
copying and pasting that into a text document, or displaying the data on a
separate spreadsheet and saving it to CSV format that way.

="\""&A1&"\", "&"\""&A2&"\", "&A3&"\", "&A4&"\", "&A5&"\","
or something like that

POV-Ray is a raytracer that generates 2D static images.  It can't render a 3D
model that you can then move around and inspect on-the-fly.
You can make an animation from a large series of static images sequentially
arranged, but it's as interactive as a VHS movie.

It seems like you have a fair amount of stuff you want to do - so for now, I'd
step back for a sec, write up some simple scenes from scratch, "wrap your head
around" POV-Ray's syntax, error messages, definitions, and other things peculiar
to it, and just get your 4 image layers working all by themselves.
You will have to use "transmit all 0.9" (or some other value) for the top 3
layers, so that you can see through them.


My standard bit of saved code for Image Mapping a box is:

#declare Feet = 12;
//  Sized image Map - 1 unit thick box
#declare XSize = 4*Feet;
#declare ImageMap = pigment {image_map {png "MyImage.png" once} };
#declare Resolution = max_extent (ImageMap);
#declare Resolution = Resolution + <0, 0, 1>;


#declare ImageMappedBox =
 box {0, 1
  texture {
   pigment {ImageMap}
  }
  translate <-0.5, -0.5, -0.5>
  scale Resolution*(1/Resolution.x)*XSize
  //translate y*(Resolution.y / Resolution.x)*XSize/2
 }

object {ImageMappedBox translate <0, 0, 0>}

Set yourself up some visible axes, and maybe a grid to give yourself some
orientation in the scene and maybe a sphere at the origin for a reference
marker.  (AT the beginning, it's easy to forget to include a camera, a light
source, get you axes mixed up, use right-hand rule instead of left hand rule,
etc)

You're going to need all these skills once you start creating a scene that's set
up for rendering frames for an animation - because you're going to need to
understand how the guts of the code works when you write the formulas with the
clock variable to control how everything is rendered in each successive frame.

Do everything stepwise, and save a working result with a different filename, so
that as you progressive, you don't overwrite your Last-Known-Good scene.

1. make a basic scene with axes
2. add a grid to give a sense of scale
3. add 4 layered boxes
4. move you camera around by editing the code and rerendering
4a. save as a different filename
5. add image_map textures
6. adjust transmit and scaling
..
..
..
N. add point and lines from the first scene code
..
..
..
N++. define the formulas to create a series of renders for animating
N++1.  Run you .ini animation file and let it churn them all out
N++2. Use a 3rd party software (VideoMach, etc) to make the static images into a
video file

and then tweak, tweak, tweak, rewrite and debug   ;)

There are plenty of example scenes, Lohmueller's site, the standard include
drop-down menu, and the POV-Ray scene files sections of the forum.

Only you will know exactly what you want, and we can't write it all for you -
you're best served by spending a few hours ( ;) ) grappling with what we all
struggled with when we first started doing this.

But we are here to help  :)


Post a reply to this message

From: Alain
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 11:33:44
Message: <58e65fd8@news.povray.org>

> Stephen <mca### [at] aolcom> wrote:
>> On 4/1/2017 6:47 AM, Jeff wrote:
>>> example picture:
>>>
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTs
> Q_AU
>
>> I use a very thin box instead of a plane and an image_map.
>>
>> Or you can use a polygon. (From help file)
>>
>>
>> polygon {
>>    4,
>>    <0, 0>, <0, 1>, <1, 1>, <1, 0>
>>    texture {
>>      finish { ambient 1 diffuse 0 }
>>      pigment { image_map { gif "test.gif"  } }
>>      }
>>    //scale and rotate as needed here
>>    }
>>
>>
>> --
>>
>> Regards
>>      Stephen
>
> hi, thanks for answering. however, i want the picture to be normal square that
> is adjustable in size. i try it to use the polygon , but i dont think its what i
> want to do. i want 4 same pictures stack on the top of each other with a little
> bit of distance. :)
>


#declare Base_poly = polygon{5, <0,0>,<0,1>,<1,1>,<1,0>,<0,0>}
// a featureless 4 sided polygon

union{
#declare V_Pos = 0;
#while(V_Pos<4)
  object{ Base_poly translate 0.1*z}
  #declare Z_Pos = Z_Pos + 1;
#end
  texture{image_map{gif"test.gif"}} finish{emission 1 diffuse 0}}
// apply the texture to all polys at once
  scale Your_Scale
  rotate Rotation
  translate Somewhere
}


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 7 Apr 2017 13:00:01
Message: <web.58e7c48bae95604bb8de811f0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> clipka <ano### [at] anonymousorg> wrote:
>
> > My guess would be that you have arbitrary text in the CSV file; in that
> > case, you'll need to make sure it is enclosed in double quotes, e.g.
> >
> >     "Foo"
> >
> > instead of
> >
> >     Foo
>
> Correct.
> Jeff, look at the comment in the code:
> //  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
> //    etc.
>
> That's exactly how it all will need to be formatted.
> I'd probably use a spreadsheet, "copy" the data into an adjacent set of cells,
> by using a formula that surrounds the relevant data with double quotes (the
> String Literal POV-Ray is wanting for the #read directive) and commas and then
> copying and pasting that into a text document, or displaying the data on a
> separate spreadsheet and saving it to CSV format that way.
>
> ="\""&A1&"\", "&"\""&A2&"\", "&A3&"\", "&A4&"\", "&A5&"\","
> or something like that
>
> POV-Ray is a raytracer that generates 2D static images.  It can't render a 3D
> model that you can then move around and inspect on-the-fly.
> You can make an animation from a large series of static images sequentially
> arranged, but it's as interactive as a VHS movie.
>
> It seems like you have a fair amount of stuff you want to do - so for now, I'd
> step back for a sec, write up some simple scenes from scratch, "wrap your head
> around" POV-Ray's syntax, error messages, definitions, and other things peculiar
> to it, and just get your 4 image layers working all by themselves.
> You will have to use "transmit all 0.9" (or some other value) for the top 3
> layers, so that you can see through them.
>
>
> My standard bit of saved code for Image Mapping a box is:
>
> #declare Feet = 12;
> //  Sized image Map - 1 unit thick box
> #declare XSize = 4*Feet;
> #declare ImageMap = pigment {image_map {png "MyImage.png" once} };
> #declare Resolution = max_extent (ImageMap);
> #declare Resolution = Resolution + <0, 0, 1>;
>
>
> #declare ImageMappedBox =
>  box {0, 1
>   texture {
>    pigment {ImageMap}
>   }
>   translate <-0.5, -0.5, -0.5>
>   scale Resolution*(1/Resolution.x)*XSize
>   //translate y*(Resolution.y / Resolution.x)*XSize/2
>  }
>
> object {ImageMappedBox translate <0, 0, 0>}
>
> Set yourself up some visible axes, and maybe a grid to give yourself some
> orientation in the scene and maybe a sphere at the origin for a reference
> marker.  (AT the beginning, it's easy to forget to include a camera, a light
> source, get you axes mixed up, use right-hand rule instead of left hand rule,
> etc)
>
> You're going to need all these skills once you start creating a scene that's set
> up for rendering frames for an animation - because you're going to need to
> understand how the guts of the code works when you write the formulas with the
> clock variable to control how everything is rendered in each successive frame.
>
> Do everything stepwise, and save a working result with a different filename, so
> that as you progressive, you don't overwrite your Last-Known-Good scene.
>
> 1. make a basic scene with axes
> 2. add a grid to give a sense of scale
> 3. add 4 layered boxes
> 4. move you camera around by editing the code and rerendering
> 4a. save as a different filename
> 5. add image_map textures
> 6. adjust transmit and scaling
> ..
> ..
> ..
> N. add point and lines from the first scene code
> ..
> ..
> ..
> N++. define the formulas to create a series of renders for animating
> N++1.  Run you .ini animation file and let it churn them all out
> N++2. Use a 3rd party software (VideoMach, etc) to make the static images into a
> video file
>
> and then tweak, tweak, tweak, rewrite and debug   ;)
>
> There are plenty of example scenes, Lohmueller's site, the standard include
> drop-down menu, and the POV-Ray scene files sections of the forum.
>
> Only you will know exactly what you want, and we can't write it all for you -
> you're best served by spending a few hours ( ;) ) grappling with what we all
> struggled with when we first started doing this.
>
> But we are here to help  :)


hi, thank you so much. here is my code now. so, i have for layers , and a red
sphere.

#include "colors.inc"

camera {
       location <55,30,90>
       look_at <55,0,126>
       rotate <0,clock*360,0>
       }

light_source  {
              <55,30,75>
              color White
              }

global_settings {
 assumed_gamma 0.1
 #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
 ambient_light rgb <1, 1, 1> // <======== flat, even illumination
}

#declare EarthRadius = 6367*0.621371; //radius in m

#declare Feet = 12;
//  Sized image Map - 1 unit thick box
#declare XSize = 4*Feet;
#declare ImageMap = pigment {image_map {png "beijing.png" once} };
#declare Resolution = max_extent (ImageMap);
#declare Resolution = Resolution + <0, 0, 1>;
---------------------------------------------------------------------------
>>#macro S2C (Spherical)
 // input - 2d vector: <Latitude, Longitude>
 #local Lat = radians (Spherical.x);
 #local Lon = radians (Spherical.y);
 #local X = EarthRadius * cos(Lat) * cos(Lon);
 #local Y = EarthRadius * cos(Lat) * sin(Lon);
 #local Z = EarthRadius * sin(Lat);
>>#local Cartesian = <X

"" is there anything that i have to change in this part(above and below)? bcos i
just realized i gave the wrong questions, i said "use the
"lon" column as the Y position of the sphere, and "lat" column as the Z
position?" , but its actually use the "lon" column as the X position of the
sphere and "lat" as the Y positions of the sphere""

#macro C2S (Cartesian)

 #local R = sqrt(pow(Cartesian.x, 2) * pow(Cartesian.y, 2) * pow(Cartesian.z,
2));
 #local Lat = degrees (asin (Cartesian.z / R));
 #local Lon = degrees (atan2 (Cartesian.y, Cartesian.x));
 #local LatLon = <Lat, Lon>;
 LatLon;
#end // end macro C2S

"" HERE TOO ? ""
------------------------------------------------------------------------
#declare ImageMappedBox =
 box {0, 1
  texture {
   pigment {ImageMap}
  }
  translate <0, 0, 0>
  scale Resolution*(1/Resolution.x)*XSize
  rotate <90,0,0>
  //translate y*(Resolution.y / Resolution.x)*XSize/2
 }

object {ImageMappedBox translate <30,0,110>}
object {ImageMappedBox translate <30,5,110>}
object {ImageMappedBox translate <30,10,110>}
object {ImageMappedBox translate <30,15,110>}

sphere {
        <55,15,110>, 2
        pigment {Red}
}
--------------------------------------------------------
>>//  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
//    etc.
#declare Type = "";
#declare Location = "";
#declare ID = "";
#declare Latitude = 0;
#declare Longitude = 0;

""and this part, do i have to do it just one of 'em? or what? , i would like to
change it like this (below) ""

#declare Mode = "";
#declare City = "";
#declare ID = "";
#declare Latitude = 0;
#declare Longitude = 0;
------------------------------------------------
>>// count locations for sizing array
#declare Locations = 0;------> " what does this line do ? "
#fopen DataFile "LatLongData.txt" read
#while (defined (DataFile))
 #read (DataFile, Type, Location, ID, Latitude, Longitude)
 #declare Locations = Locations + 1;
#end
#fclose DataFile

"" this part, i would like to change it to like this (below)""

// count locations for sizing array
#declare Locations = 0; # i dont understand what is the "Locations" for????
#fopen Nodes "nodes.csv" read
#while (defined (Nodes))
 #read (Nodes, Mode, City, ID, Longitude, Latitude)
 #declare Locations = Locations + 1;
#end
#fclose Nodes
---------------------------------------------------
>>#declare _Type = array[Locations];
#declare _Location = array[Locations];
#declare _ID = array[Locations];
#declare _Latitude = array[Locations];
#declare _Longitude = array[Locations];
#declare _XYZ = array[Locations];

"" and i have problems to understand the block of codes above ""
-----------------------------------------------------------------


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 7 Apr 2017 15:30:01
Message: <web.58e7e830ae95604b80403a200@news.povray.org>
"Jeff" <jef### [at] gmailcom> wrote:

> >>#macro S2C (Spherical)
>  // input - 2d vector: <Latitude, Longitude>
>  #local Lat = radians (Spherical.x);
>  #local Lon = radians (Spherical.y);
>  #local X = EarthRadius * cos(Lat) * cos(Lon);
>  #local Y = EarthRadius * cos(Lat) * sin(Lon);
>  #local Z = EarthRadius * sin(Lat);
> >>#local Cartesian = <X
>
> "" is there anything that i have to change in this part(above and below)? bcos i
> just realized i gave the wrong questions, i said "use the
> "lon" column as the Y position of the sphere, and "lat" column as the Z
> position?" , but its actually use the "lon" column as the X position of the
> sphere and "lat" as the Y positions of the sphere""

Well, since there's x, y, AND z positions of a sphere, and from the above
formulae x and y are computed from BOTH the lat and lon, that's a hard question
to answer - maybe think on it some more.

> "" HERE TOO ? ""

vide supra.

> ""and this part, do i have to do it just one of 'em? or what? ,

I don't understand - one of WHAT?

> i would like to
> change it like this (below) ""
>
> #declare Mode = "";
> #declare City = "";
> #declare ID = "";
> #declare Latitude = 0;
> #declare Longitude = 0;

Sure, that's fine - you're just changing my variable names - it's just a name
internal to the code - otherwise it's irrelevant - it could be called Q or
hhfdiuahfishv for all the computer cares.


> #declare Locations = 0;------> " what does this line do ? "
When you're going to use a variable for something, it needs to be initialized.
So I give it a value of zero.

> #fopen DataFile "LatLongData.txt" read
> #while (defined (DataFile))
>  #read (DataFile, Type, Location, ID, Latitude, Longitude)
>  #declare Locations = Locations + 1;
> #end
> #fclose DataFile
>
> "" this part, i would like to change it to like this (below)""
>
> // count locations for sizing array
> #declare Locations = 0; # i dont understand what is the "Locations" for????
> #fopen Nodes "nodes.csv" read
> #while (defined (Nodes))
>  #read (Nodes, Mode, City, ID, Longitude, Latitude)
>  #declare Locations = Locations + 1;
> #end
> #fclose Nodes

Again, just names.

> ---------------------------------------------------
> >>#declare _Type = array[Locations];
> #declare _Location = array[Locations];
> #declare _ID = array[Locations];
> #declare _Latitude = array[Locations];
> #declare _Longitude = array[Locations];
> #declare _XYZ = array[Locations];
>
> "" and i have problems to understand the block of codes above ""
> -----------------------------------------------------------------
I'm making arrays of values - like a spreadsheet.
rows of values, each with a "header" - the name of the array variable.
Every time I read a line in from the "CSV" file, I increased the "Locations"
counter by one, thus counting how many places you have to plot points.
Then I use that final value of the counter to dimension the array - to give it
the right size.   If Locations = 25, then each array - each "column" of values
in my "spreadsheet" has 25 slots.

(Don't freak out - arrays are kind of a pita the work with at times, and macros
can get a bit hairy too, but using them can make other tasks easier in the long
run)

Move your cursor to "array" and hit F1, and it should bring up the array section
in the Help files...
Or just Google  POV-Ray array and see what pops up.
(be conscious of what version you're looking at the documentation for)
I think the wiki is the most up to date location for documentation.


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 8 Apr 2017 09:55:00
Message: <web.58e8eb3bae95604b4de507a60@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Jeff" <jef### [at] gmailcom> wrote:

here is my code now:

global_settings {
 assumed_gamma 1.0
 #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
 ambient_light rgb <1, 1, 1> // <======== flat, even illumination
}

#include "colors.inc"

camera {
 location <55,25,80>
 right    x*image_width/image_height
 look_at <55,0,126>
}

light_source{ <10,10,-10>  color rgb <1, 1, 1>}

#declare Feet = 12;
//  Sized image Map - 1 unit thick box
#declare XSize = 4*Feet;
#declare ImageMap = pigment {image_map {png "beijing.png" once} };
#declare Resolution = max_extent (ImageMap);
#declare Resolution = Resolution + <0, 0, 1>;

#declare ImageMappedBox =
 box {0, 1
  texture {
   pigment {ImageMap}
  }
  translate <0, 0, 0>
  scale Resolution*(1/Resolution.x)*XSize
  rotate <90,0,0>
  //translate y*(Resolution.y / Resolution.x)*XSize/2
 }
object {ImageMappedBox translate <31,0,115>}
object {ImageMappedBox translate <31,5,115>}
object {ImageMappedBox translate <31,10,115>}
object {ImageMappedBox translate <31,15,115>}

----------------what does the code blocks below
do?---------------------------#declare EarthRadius = 6367; //radius in km
#declare EarthRadius = 6367*0.621371; //radius in mi

#macro S2C (Spherical)
 // input - 2d vector: <Latitude, Longitude>
 #local Lat = radians (Spherical.x);
 #local Lon = radians (Spherical.y);
 #local X = EarthRadius * cos(Lat) * cos(Lon);
 #local Y = EarthRadius * cos(Lat) * sin(Lon);
 #local Z = EarthRadius * sin(Lat);
 #local Cartesian = <X, Y, Z>;
 Cartesian;
#end // end macro S2C

#macro C2S (Cartesian)

 #local R = sqrt(pow(Cartesian.x, 2) * pow(Cartesian.y, 2) * pow(Cartesian.z,
2));
 #local Lat = degrees (asin (Cartesian.z / R));
 #local Lon = degrees (atan2 (Cartesian.y, Cartesian.x));
 #local LatLon = <Lat, Lon>;
 LatLon;
#end // end macro C2S
------------------------------------------------------------------
//  data format: "bus", "CN/Beijing", "bus2382659521", 39.9067192, 116.4093833,
//    etc.
#declare Mode = "bus";
#declare City = "CN/Beijing";
#declare ID = "bus23822659521";
#declare Latitude = 39.9067192;
#declare Longitude = 116.4093833;

--------------------------------------------------------------
#declare modez = 'bus' = 0; 'subway' = 5; 'rail' = 10; 'tram = 15
here i try to declare different z position for different mode, so they are not
in the same height(layer of picture)
---------------------------------------------------------------
// count locations for sizing array
#declare Locations = 0;
#fopen nodes "nodes.csv" read
#while (defined (nodes))
 #read (nodes, mode, city, ID, Latitude, Longitude)
 #declare Locations = Locations + 1;
#end
#fclose nodes

#declare _mode = bus[Locations];
#declare _city = CN/Beijing[Locations];
#declare _ID = bus2382659521[Locations];
#declare _Latitude = 39.9067192[Locations];
#declare _Longitude = 116.4093833[Locations];
#declare _XYZ = Longitude[Locations];Latitude[Locations];modesz[Locations]

// input data into array
#declare Datapoint = 0;
#fopen links "links.csv" read
#while (defined (links))
 #read (links, Mode, Source, Target, Length)

 #declare _Mode [Datapoint] = Mode;
 #declare _Source [Datapoint] = Source;
 #declare _Target [Datapoint] = Target;
 #declare _Length [Datapoint] = Length;
 #declare _XYZ [Datapoint] = S2C (<_Longitude[Datapoint],
_Latitude[Datapoint,_XYZ[Datapoint]>);
 #declare Datapoint = Datapoint + 1;
#end
#fclose links

#declare Marker = 0.25;
#declare Line = 0.05;
#declare Linecolor = pigment {Magenta};

#for (Point, 0, Locations-1)

 #if (Mode = "bus")
  #declare Color = pigment {Red};
 #elseif (Mode = "subway")
  #declare Color = pigment {Green};
 #elseif (Mode = "rail")
  #declare Color = pigment {Blue};
 #elseif (Mode = "tram")
  #declare Color = pigment {Yellow};
 #else
  #debug "Unidentified Location Type.  \n"
  #declare Color = pigment {White};
 #end

 #declare S = 1; //<0.1, 0.1, 1/4000>;
 #declare T = <1350, 1130, -3500>;

 sphere {0.3, Marker pigment {Color} translate _XYZ[Point]*S translate T}

 #if (Point > 0)
  cylinder {LastPoint*S, _XYZ[Point]*S, Line pigment {Linecolor} translate T}
 #end // end if

 #debug concat( "Vector = ", vstr(3, _XYZ[Point]*S, ", ", 3, 0), " \n")

 #declare LastPoint = _XYZ[Point];

#end // end for Point


Post a reply to this message

From: Alain
Subject: Re: How to generate sphere and cylinder with csv file
Date: 9 Apr 2017 22:31:53
Message: <58eaee99$1@news.povray.org>

> "Bald Eagle" <cre### [at] netscapenet> wrote:
>> "Jeff" <jef### [at] gmailcom> wrote:
>
> here is my code now:
>
> global_settings {
>  assumed_gamma 1.0
>  #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
>  ambient_light rgb <1, 1, 1> // <======== flat, even illumination

WRONG !
ambient_light is multiplied with the ambient component of the finish. 
rgb<1,1,1> is the DEFAULT value.

By the way, it's bad practice to place the #default statement into the 
global_settings block. It have nothing to do in that location. Place it 
after.

global_settings{ assumed_gamma 1}
#default{ texture{ pigment{ rgb 1 } finish{ ambient 1 }}}


> }
>
> #include "colors.inc"
>
> camera {
>  location <55,25,80>
>  right    x*image_width/image_height
>  look_at <55,0,126>
> }
>
> light_source{ <10,10,-10>  color rgb <1, 1, 1>}
>
> #declare Feet = 12;
> //  Sized image Map - 1 unit thick box
> #declare XSize = 4*Feet;
> #declare ImageMap = pigment {image_map {png "beijing.png" once} };
> #declare Resolution = max_extent (ImageMap);
> #declare Resolution = Resolution + <0, 0, 1>;
>
> #declare ImageMappedBox =
>  box {0, 1
>   texture {
>    pigment {ImageMap}
>   }
>   translate <0, 0, 0>
>   scale Resolution*(1/Resolution.x)*XSize
>   rotate <90,0,0>
>   //translate y*(Resolution.y / Resolution.x)*XSize/2
>  }
> object {ImageMappedBox translate <31,0,115>}
> object {ImageMappedBox translate <31,5,115>}
> object {ImageMappedBox translate <31,10,115>}
> object {ImageMappedBox translate <31,15,115>}
>
> ----------------what does the code blocks below
> do?---------------------------#declare EarthRadius = 6367; //radius in km
> #declare EarthRadius = 6367*0.621371; //radius in mi

Nothing at all as those variables are never used.
In some other cases, those are usefull for some reason, like actually 
following Earth's curvature.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 1 Messages >>>

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