POV-Ray : Newsgroups : povray.newusers : a simple surface : Re: a simple surface Server Time
2 Nov 2024 09:20:35 EDT (-0400)
  Re: a simple surface  
From: Phil Cook
Date: 24 Jun 2004 10:46:32
Message: <opr93snpswefp2ch@news.povray.org>

<fab### [at] icunicampbr> did spake, saying:

> Hi!
> I am trying to use povray to generate a 3d surface from a big matrix of  
> real
> numbers, which are the output of my program. I read a lot of things about
> povray, the documentation, etc, but i really don't know how i can do it.
> Everthing i need is a light_source, a camera and this surface. Nothing  
> more.
> Somebody may help me to make a simple .pov file, which my program will
> generate, only changing the parameters?
> (ps: if i did any mistake in my english, i'm sorry in advance!)
>
> Thanks

> ps:
> Examples:
> matrix file:
> http://www.ic.unicamp.br/~ra015988/lis/artigos/novo/superficie.dat
> (the sintax of this file may change as need)
> the target file, i made it in 3dmax
> http://www.ic.unicamp.br/~ra015988/lis/artigos/novo/superficie_saltoe.png

To get povray to read your superficie.dat file you need to add commas  
instead of spaces like:

0,0,1,
0,1,3,
0,2,0,
0,3,0,

Then try:

//start code

/*
Assume first value read is row(Z)
second value column (X)
third value height {Y)
*/

#fopen MyFile "superficie.dat" read
#while (defined(MyFile))
#read (MyFile,LastZ, LastX, DitchY)
#end
/*
The last values read should be the highest needed
DitchY is not needed to be kept
*/

/*
Remember to count the 0
*/

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

camera{
location <LastX/2,100,-100>
look_at  <LastX/2,0,LastZ/2>
}

light_source{<LastX/2,50,LastZ/2> rgb 1}

#declare MyArray= array[LastZ][LastX];

/*
Read the file again and put the values into an array
*/

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

#declare i=0;
#declare j=0;

/*
Draw a box of correct height and move it to the correct place
as the column(X) and row(Z) are the same as i and j use these to
translate the box
*/

#while(i<LastZ)

#while(j<LastX)
box{0,<1,MyArray[i][j],1> translate <j,0,i> pigment{rgb 1}}
#declare j=j+1;
#end

#declare i=i+1;
#declare j=0;
#end
//end code

Uses boxes rather than points and might be slow with a *lot* of data (this  
took 26 sec on my computer, 76800 objects) but I hope it helps.

--
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.