POV-Ray : Newsgroups : povray.advanced-users : <no subject> Server Time
31 Oct 2024 14:11:43 EDT (-0400)
  <no subject> (Message 1 to 2 of 2)  
From: Antonio Ferrari
Subject: <no subject>
Date: 3 Nov 2005 08:40:00
Message: <web.436a12c8c23a6d9c93aff1a0@news.povray.org>
I'd like to apply media to a generic object, so that media
"intensity" is a function of the distance from the external
surface (for example decrease/increase linearly/exponentially
when distance grow up).

I don't know if this is a feature of Povray media. Is it
possible?

It seemed simple for spheres of cubes but I don't know if
it's the same thing for generic objects. For generic objects
df3 files can be used, but they must be generated ad hoc
for the media of the specific object.

First I thought to write a macro that calculate and generate
df3 entries, without using external generators or editors.

Follows the pseudo-code for my idea...

INPUT: object O, parameter E (I'll explain it later)
OUTPUT: container L (array, list, etc.)

01: calculate bounding box lengths (X,Y,Z) for axes x,y,z
02: i=0
03: while i<X begin
04:  j=0
05:  while j<Y begin
06:   k=0
07:   while k<Z begin
08:    if point <x,y,z> is internal to O, the add it to L
09:    k=k+E
10:   end
11:   j=j+E
12:  end
13:  i=i+E
14: end

After executing this procedure, L must contain all points
internal to O whose minum distance from each other is E,
that is a sort of grid of internal points. All the points
in L, placed in a 3D plane, approximate the object O.

The littler E is, the better the approximation will be.

Obviously value for E and intitial values (instead of 0)
for i,j,k can be optimized in order to better approximate
the object.

I know that 10^6 checks for internal points must be
performed when subdividing each axis in 100 parts, but
this is necessary in order to implement my idea...

Follows a 2D example, where X will be the points contained
in L:


 +-------------------+
 |XXXXXXXXXXXXXXXXXXX|
 |XXXXXXXXXXXXXXXXXXX|
 |XXXXXXXXXXXXXXXXXXX|
 |XXXXXXXXXXXXXXXXXXX|
 |XXXXXXXXXXXXXXXXXXX.------.
 |XXXXXXXXXXXXXXXXXXXXXXXXXXX`--.
 |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`.
 |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 +----------XXXXXXXXXXXXXXXXXXXXXXXX
           ;XXXXXXXXXXXXXXXXXXXXXXXXX:
           |XXXXXXXXXXXXXXXXXXXXXXXXX|
           :XXXXXXXXXXXXXXXXXXXXXXXXX;
            XXXXXXXXXXXXXXXXXXXXXXX/
             XXXXXXXXXXXXXXXXXXXXX/
              `.XXXXXXXXXXXXXXXXX,'
                '--.XXXXXXXXX_.-'
                    `------''


Simple algorithms exist in literature to calculate external
points for a set of points.

After having found external points, a constant intensity can
be assigned to them and such intensities can become entried
for a df3 file.

Example for exaternal points of level 1:


  1111111111111111111
  1                 1
  1                 1
  1                 1
  1                 1
  1                 111111111
  1                          1111
  1111111111                     11
            1                      1
            1                       1
            1                       1
            1                       1
             1                     1
              11                 11
                1111         1111
                    111111111


External points can be removed from L, obtaining a new container
L'. External points for L' constitutes the second level.

The process is reiterated for the next levels.


  1111111111111111111
  1222222222222222221
  1233333333333333321
  1234444444444444321
  1234444444555554321
  123333333345665432111111111
  1222222222345665432222222221111
  111111111123456654333333333222211
            123456654444444443333221
            1234566655555555544443321
            1234555566666666655554321
            1233444455555555544443321
             12233334444444443333221
              112222333333333222211
                11112222222221111
                    111111111



Then... Do you think is it possible to write a macro that
generate df3 entries according to the described rules?

If not yet implemented, do you think that a functionality that
generates df3 entries inline as described (intensity as function
of the distance) could be added to Povray, without including
df3 file every time?

Thanks.

Antonio


Post a reply to this message

From: Mike Williams
Subject: Re: <no subject>
Date: 3 Nov 2005 13:35:45
Message: <UyyGzBAdVlaDFwWh@econym.demon.co.uk>
Wasn't it Antonio Ferrari who wrote:

>Then... Do you think is it possible to write a macro that
>generate df3 entries according to the described rules?

It's possible to perform all the calculation within POV code, but I
believe that df3 files are binaries, and POV #write operations can only
write ASCII, so POV can't write df3 files directly.

I've done a quick proof-of-concept scene (see binaries.images) where I
split an object into a 40*40*40 array, use "inside()" to determine if a
point is inside the object, and determine the distance of each cell from
the edge in the way you describe.

It would be possible to then write the data from the array and have it
processed by a program that can write binary files, but I just plotted a
transparent cube in each cell with the pigment transparency of each cube
corresponding to the value in the array.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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