POV-Ray : Newsgroups : povray.newusers : a simple surface : Re: a simple surface Server Time
2 Nov 2024 09:18:17 EDT (-0400)
  Re: a simple surface  
From: Mike Williams
Date: 24 Jun 2004 13:08:17
Message: <$O7jtAAKDo2AFws$@econym.demon.co.uk>
Wasn't it F?bio Dias who wrote:
>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!)

I don't think that there's anything like that which POV supports
directly. One thing you could do is to generate an image where the
brightness of the points corresponds to the heights, then use that image
as a Height_Field.

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.

A PPM file looks a bit like this

P3
240 240
255
1 1 1 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 20 20 20 0 0 0 0 0 0 0 0
0 0 0 0 20 20 20 1 1 1 1 1 1 5 5 5 5 5 5 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 3 3 3 0 0 0 0 0 0 1 1 1 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3
3 3 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 0
0 0 0 0 0 3 3 3 3 3 3 0 0 0 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 3 3 3 3 3 3 0 0 0 3 ...

The first line is "P3"

The second line is the numbers of pixels in the X and Y directions. Set
it to the dimensions of your matrix.

The third line is the number of shades per colour. Leave this as 255.

The remainder of the file is a sequence of R G B values. Use your data
to generate these entries. I suggest setting the three RGB values all
equal to the "height" value from your matrix. E.g.

Your data       PPM entry

  0 0 1         1 1 1
  0 1 3         3 3 3
  0 2 0         0 0 0
  0 3 0         0 0 0
  0 4 0         0 0 0
  0 5 0         0 0 0
  0 6 3         3 3 3
  0 7 1         1 1 1
  ...           ...

Then, in POV you can do something like

height_field {ppm "superficie.ppm"
  pigment {rgb <0,0.5,0>}
  translate <-0.5,0,-0.5>
  scale 2
}


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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