POV-Ray : Newsgroups : povray.newusers : a simple surface : Re: a simple surface Server Time
30 Jul 2024 16:26:53 EDT (-0400)
  Re: a simple surface  
From: Phil Cook
Date: 29 Jun 2004 09:58:10
Message: <opsaczqjtqefp2ch@news.povray.org>
And lo on Fri, 25 Jun 2004 09:00:54 -0500, Christopher James Huff  
<cja### [at] earthlinknet> did spake, saying:

> In article <$O7jtAAKDo2AFws$@econym.demon.co.uk>,
>  Mike Williams <nos### [at] econymdemoncouk> wrote:
>
>> I did it by using a perl script to read your data file and write out an
>> image in PPM format. The little-known PPM format is useful for such
>> tasks because the data is represented by ascii strings rather than
>> binary values.
>
> The PGM variant would be more useful for this purpose. Just use P2
> instead of P3, and include each value only once. However, I don't know
> if POV will read this...I think it should, it's not exactly a difficult
> format.
>

Using a comma seperated dat file:

//start code
#fopen MyFile "superficie.dat" read
#while (defined(MyFile))
#read (MyFile,LastX, LastZ, DitchY)
#end

#declare LastX=LastX+1;
#declare LastZ=LastZ+1;

/*
This is to write put the pgm file
 from the comma seperated dat file
and can be commented out once generated
*/
#declare MyArray= array[LastX][LastZ];

#fopen MyFile "superficie.dat" read
#while (defined(MyFile))
#read (MyFile,MyX, MyZ, MyY)
#declare MyArray[MyX][MyZ]=MyY;
#end
#fclose MyFile
#declare i=0;
#declare j=0;

#fopen MyFile "super.pgm" write
#write(MyFile
"P2", "\n",
LastX," ", LastZ, "\n",
"255", "\n")

#while(j<LastZ)

#while(i<LastX)
#if (i=(LastX-1))
#write (MyFile, MyArray[i][j],"\n")
#else
#write (MyFile, MyArray[i][j]," ")
#end
#declare i=i+1;
#end
#declare j=j+1;
#declare i=0;
#end
#fclose MyFile
/*
Put the closing pgm comment here to stop generating the file
*/

camera{
location <-LastX/200,2.0,-1.5>
look_at  <-LastX/200,0,LastZ/200>
}

light_source{<-LastX/200,5,LastZ/200> rgb 1 shadowless}


height_field {pgm "super.pgm"
   pigment {green 0.5} finish{ambient 0.3}
   scale <-LastX/100, 2, LastZ/100>

}
//end code

Seems quicker

--
Phil Cook

-- 
All thoughts and comments are my own unless otherwise stated and I am  
happy to be proven wrong.


Post a reply to this message

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