POV-Ray : Newsgroups : povray.advanced-users : output an octree file : Re: output an octree file Server Time
1 Jul 2024 05:46:03 EDT (-0400)
  Re: output an octree file  
From: Christian Froeschlin
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

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