POV-Ray : Newsgroups : povray.text.scene-files : Problem with #read Server Time
1 Nov 2024 01:21:49 EDT (-0400)
  Problem with #read (Message 1 to 2 of 2)  
From: Dave Brickell
Subject: Problem with #read
Date: 14 Mar 2002 07:49:44
Message: <3c909c68@news.povray.org>
#declare max_particles = 0;
        #declare step_size = 0;
        #declare grav_const = 0;
        #declare perimeter = 0;
        #declare frames = 0;


        #fopen particle_text "particle.txt" read
        #read (particle_text
,max_particles,step_size,grav_const,perimeter,frames)



        #declare alive = array[max_particles];
        #declare xvec = array[max_particles];
        #declare yvec = array[max_particles];
        #declare xpos = array[max_particles];
        #declare ypos = array[max_particles];
        #declare mass = array[max_particles];
        #declare rad = array[max_particles];


        #declare read_part = 1;
        #while (read_part < max_particles)
                #read
(particle_text,ralive,rxvec,ryvec,rxpos,rypos,rmass,rrad)
                #declare alive[read_part] = ralive;
                #declare xvec[read_part] = rxvec;
                #declare yvec[read_part] = ryvec;
                #declare xpos[read_part] = rxpos;
                #declare ypos[read_part] = rypos;
                #declare mass[read_part] = rmass;
                #declare rad[read_part] = rrad;
                #declare read_part = read_part + 1;
                #declare ralive = 0;
                #declare rxvec = 0;
                #declare ryvec = 0;
                #declare rxpos = 0;
                #declare rypos = 0;
                #declare rmass = 0;
                #declare rrad = 0;

        #end
        #fclose particle_text


Post a reply to this message

From: Dave Brickell
Subject: Re: The writing bit
Date: 14 Mar 2002 08:14:02
Message: <3c90a21a$1@news.povray.org>
#declare max_particles = 25;
        #declare space = 20;
        #declare setup = 1;
        #declare xstart = 0-(sqrt(max_particles)/2)*space;
        #declare ystart = xstart;
        #declare num = 0;
        #declare step_size = 0.3;
        #declare grav_const = 1;
        #declare perimeter = 10000;
        #declare frames = 50;
        #declare alive = array[max_particles+1]
        #declare xvec = array[max_particles+1]
        #declare yvec = array[max_particles+1]
        #declare xpos = array[max_particles+1]
        #declare ypos = array[max_particles+1]
        #declare mass = array[max_particles+1]
        #declare rad = array[max_particles+1]

        #declare rdm = seed(12345);

        #while (num < max_particles)


                        #declare alive[num] = 1;
                        #declare xpos[num] = xstart;
                        #declare ypos[num] = ystart;
                        #declare xvec[num] = (rand(rdm)*100)-50;
                        #declare yvec[num] = (rand(rdm)*100)-50;
                        #declare mass[num] = 10;
                        #declare rad[num] = 1;


                        #declare setup = setup + 1;
                        #declare ystart = ystart + space;

                        #if (setup > sqrt(max_particles))
                                #declare ystart =
0-(sqrt(max_particles)/2)*space;
                                #declare xstart = xstart + space;
                                #declare setup = 1;
                        #end



                        #declare num = num + 1;




        #end

        #declare write_part = 1;

        #fopen particle_text "particle.txt" write
        #write (particle_text ,max_particles,"\n",)
        #write (particle_text ,step_size,"\n",)
        #write (particle_text ,grav_const,"\n",)
        #write (particle_text ,perimeter,"\n",)
        #write (particle_text ,frames,"\n",)
        #while (write_part < max_particles)

                #write (particle_text ,alive[write_part],"\n",)
                #write (particle_text ,xvec[write_part],"\n",)
                #write (particle_text ,yvec[write_part],"\n",)
                #write (particle_text ,xpos[write_part],"\n",)
                #write (particle_text ,ypos[write_part],"\n",)
                #write (particle_text ,mass[write_part],"\n",)
                #write (particle_text ,rad[write_part],"\n",)

                #declare write_part = write_part + 1;

        #end

        #fclose particle_text


Post a reply to this message

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