POV-Ray : Newsgroups : povray.advanced-users : output an octree file Server Time
29 Jun 2024 02:02:07 EDT (-0400)
  output an octree file (Message 9 to 18 of 18)  
<<< Previous 8 Messages Goto Initial 10 Messages
From: Thomas de Groot
Subject: Re: output an octree file
Date: 13 Aug 2010 10:34:36
Message: <4c6557fc@news.povray.org>
"Jim Holsenback" <jho### [at] povrayorg> schreef in bericht 
news:4c652fc3@news.povray.org...
> On 08/13/2010 08:03 AM, jazzman wrote:
>> I can't seem to find any documentation on the "inside()" function. Could 
>> you
>> please refer me to some?
>
> It's alphabetically listed in this section:
> http://wiki.povray.org/content/Documentation:Reference_Section_2#Functions
>

... or the "quick and dirty" search for "inside" in the Index of Help. ;-)

Thomas


Post a reply to this message

From: clipka
Subject: Re: output an octree file
Date: 13 Aug 2010 12:17:17
Message: <4c65700d$1@news.povray.org>
Am 13.08.2010 13:03, schrieb jazzman:

> Actually, I need to know for every cube in the scene if it contains an object
> (not for every square on the screen). So I need to perform N^3 tests anyways.

I'd suggest to...

- Test the scene objects one by one, unless they're very close to each 
other.
- For each object, restrict your testing to the bounding box as given by 
min_extent() and max_extent().
- Use 2x N^2 calls to trace() from two opposite sides of the bounding 
box, to further narrow down the subset of the bounding box where you 
have to use a series of inside() tests. (Obviously, you don't need to 
test on a line that doesn't intersect with the object anywhere.)


Post a reply to this message

From: Christian Froeschlin
Subject: Re: output an octree file
Date: 14 Aug 2010 06:03:33
Message: <4c6669f5$1@news.povray.org>
jazzman wrote:

> Could you please specify how exactly I'm supposed to divide the scene up into
> cubes? I'm not an expert in the SDL, so pointers to specific functions would be
> helpful.

Basically you would decide upon a "world size" N which encompasses
your data (e.g. 100x100x100 blocks) and a grid size d (e.g. 1 unit).
Then you'd create a three-dimensional array with N elements for
each dimension initialized with 0. Then you can nest 3 #while
loops to test for each individual cell.

For testing the invididual cells, you will need to decide upon
the required accuracy. Probably one test per cell is enough as
otherwise you'd use more cells in the first place. My first
idea was to use trace in each cell but that doesn't work if
the cell is completely contained in one object, so the inside
test would be better.

As clipka suggested, the procedure can be optimized in various
ways. If a large portion of your scene volume is empty you can
use min_extent max_extent to find to mark all cell candidates
in the array (e.g. write a -1) which could contain an object.
Then only those cells will have to be tested later.

And you can use trace to test a complete line of cells at once.
If you do not hit anything in that line, you can mark all cells
with 0 again as they will all be "empty".


Post a reply to this message

From: jazzman
Subject: Re: output an octree file
Date: 17 Aug 2010 08:30:01
Message: <web.4c6a8013e632d53af7e4a8d00@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 13.08.2010 13:03, schrieb jazzman:
>
> > Actually, I need to know for every cube in the scene if it contains an object
> > (not for every square on the screen). So I need to perform N^3 tests anyways.
>
> I'd suggest to...
>
> - Test the scene objects one by one, unless they're very close to each
> other.
> - For each object, restrict your testing to the bounding box as given by
> min_extent() and max_extent().
> - Use 2x N^2 calls to trace() from two opposite sides of the bounding
> box, to further narrow down the subset of the bounding box where you
> have to use a series of inside() tests. (Obviously, you don't need to
> test on a line that doesn't intersect with the object anywhere.)

Is there some kind of function that can return a list of all the objects in the
scene? I would need this kind of function to find the bounding box of each
object because i want it to work on any scene.


Post a reply to this message

From: Alain
Subject: Re: output an octree file
Date: 17 Aug 2010 16:02:08
Message: <4c6aeac0$1@news.povray.org>


> Is there some kind of function that can return a list of all the objects in the
> scene? I would need this kind of function to find the bounding box of each
> object because i want it to work on any scene.
>
>

There is no such function, at least, to my knowlege. Anyway, it could'nt 
return any object that are not yet defined.

What you can do is to create an array and declare your objects as 
elements of said array. Just replace the normal declaration by:
#declare Array[Index] = <object's definition>
You then use a loop to work your way through that array and instanciate 
the various objects.

You can also declare your objects normaly, then use
#declare Array[index] = Declared_Object
But this will require double the memory.

Both of those won't be able to take count of an object like 
sphere{<1,2,3>,2}



Alain


Post a reply to this message

From: Sven Geier
Subject: Re: output an octree file
Date: 31 Aug 2010 17:25:01
Message: <web.4c7d7306e632d53a274f74a20@news.povray.org>
Jim Holsenback <jho### [at] povrayorg> wrote:
> On 08/13/2010 08:03 AM, jazzman wrote:
> > I can't seem to find any documentation on the "inside()" function. Could you
> > please refer me to some?
>
> It's alphabetically listed in this section:
> http://wiki.povray.org/content/Documentation:Reference_Section_2#Functions

That's not much of a documentation, I'd like to note. I had never heard of this
function, but from the documentation I concluded that it should be possible to
do something like this with it:

#declare letters = object { text { ttf "arialuni.ttf"  "OPQ", 1, 0} };
isosurface {
  function { 0.5-inside( letters ,<x,y,z> ) }
  contained_by {sphere {0 2}}
  max_gradient 5
  pigment {color rgb .5}
}

Instead, this gives me the laconic error message

"C:\Documents and Settings\Sven\test.pov" line 17: Parse Error: Expected
'operand', object identifier found instead

with the cursor sitting on the object identifier "letters" in the "inside()"
function. So apparently "inside()" doesn't actually accept an object reference
as an argument, but requires an "operand" (whatever that may mean in this
context).


Post a reply to this message

From: Christian Froeschlin
Subject: Re: output an octree file
Date: 31 Aug 2010 18:28:58
Message: <4c7d822a$1@news.povray.org>
Sven Geier wrote:

> with the cursor sitting on the object identifier "letters" in the "inside()"
> function. So apparently "inside()" doesn't actually accept an object reference
> as an argument

I think the problem is that parsing function { ... }
blocks is rather restricted, so it may not be possible
to use inside() there. If you try something like

#if (inside(O,P))
   ...
#else
   ...
#end

it should work.


Post a reply to this message

From: Jim Holsenback
Subject: Re: output an octree file
Date: 31 Aug 2010 18:41:51
Message: <4c7d852f$1@news.povray.org>
On 08/31/2010 06:24 PM, Sven Geier wrote:
> That's not much of a documentation, I'd like to note. I had never heard of this
> function, but from the documentation I concluded that it should be possible to
> do something like this with it:
> 
> #declare letters = object { text { ttf "arialuni.ttf"  "OPQ", 1, 0} };
> isosurface {
>   function { 0.5-inside( letters ,<x,y,z> ) }
>   contained_by {sphere {0 2}}
>   max_gradient 5
>   pigment {color rgb .5}
> }

so you want to subtract either 0 or 1 from 0.5 .... that's what inside
is going to give you.

> Instead, this gives me the laconic error message
> 
> "C:\Documents and Settings\Sven\test.pov" line 17: Parse Error: Expected
> 'operand', object identifier found instead

maybe this applies:
inside does not accept object-identifiers to non-solid objects.

> So apparently "inside()" doesn't actually accept an object reference
> as an argument, but requires an "operand" (whatever that may mean in this
> context).

This works OK fine for me:

#declare TestObject = box { 0, 1 pigment { rgb 1 } };

#if ( inside ( TestBox, <0.5,0.5,0.5> ) )
	#debug "Inside\n"
#else
	#debug "Outside\n"
#end

change the vector to something outside the test object and the "Outside"
message is issued.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: output an octree file
Date: 1 Sep 2010 03:35:00
Message: <web.4c7e01a7e632d53ae619b42c0@news.povray.org>
"Sven Geier" <.sven.at.sgeier.dot.net.nospamplease> wrote:
> #declare letters = object { text { ttf "arialuni.ttf"  "OPQ", 1, 0} };
> isosurface {
>   function { 0.5-inside( letters ,<x,y,z> ) }
>   contained_by {sphere {0 2}}
>   max_gradient 5
>   pigment {color rgb .5}
> }
>
> Instead, this gives me the laconic error message
>
> "C:\Documents and Settings\Sven\test.pov" line 17: Parse Error: Expected
> 'operand', object identifier found instead

What this means is that POV-Ray thinks "inside" is another function and hence
expects that function to have operands. The declared object "letters" is not
allowed in functions, hence you get the error message that an object identifier
(which is what "letters" is) is not allowed. It is not an operand either because
the declared value has been expanded in the function already. And objects are
not allowed in functions as operands.

You need to actually read about what is allowed in functions and what is not
allowed: <http://www.povray.org/documentation/view/3.6.1/231/>

As you can see, "inside" is not in the list of built-in functions for use in
"function" statements.

However, you can still access an object inside a function by using the object
pattern. This works because you can declare pattern functions, as described on
the manual page above (and the pages that follow/link).

Thorsten, POV-Team


Post a reply to this message

From: Chris Cason
Subject: Re: output an octree file
Date: 1 Sep 2010 04:29:38
Message: <4c7e0ef2@news.povray.org>
On 10/08/2010 09:31, jazzman wrote:
> I was wondering if someone knows if there's an option to output an octree of the
> rendered scene from POV-ray. All I need is to know for each cell in a 3d grid of
> the scene whether it's occupied or not.

There's a new feature in the upcoming beta 39 (due out next week) that
ought to make doing what you want a lot easier. You'll need to post-
process the data but getting the cell occupation information should be
straightforward.

-- Chris


Post a reply to this message

<<< Previous 8 Messages Goto Initial 10 Messages

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