QUOTE(nls2222 @ 06/18/07, 01:44 PM) [snapback]268229[/snapback]
hi gentlesea,
I hope I understand what you mean.......but I think it is not possible for my project. With cells you mean the zones, right? but the zones are not growing. Your code will define the case that one zone is growing towards the other. but in my case not the zones are growing, but other cells.
OK, we mix up our terminology a little bit. Yes, with cells i mean zones. Think of them as of a grid that is defined using 3 carthesian coordinate systems. In my code those zones are not growing. It should be an array with seperates the whole scene into zones. An example:
Let's say you subdivide your scene into 10 units (Abtastpunkte) in every direction. This would give you 10*10*10 = 10^3 = 1000 zones. My code is now telling you if there's an object in each of these zones.
Save these "Abtastpunkte" into an array
CODE
float $allZones[1000];
To fill the array we start counting from 1 when using this formula.
Say you want to check the zone, which is defined by 1 on the x-Axis, 1 on the y-Axis and 1 on the z-Axis. This would be
int $zoneEntered = 10 * 10 * 1 + 10 * 1 + 1 = 111
Wait, I'll hear you say. I want to start from 1. When using this formula you have to subtract the first value from all the equations if you want to fit that in the array. So keep in mind that in our case 111 is always subtracted.
CODE
$allZones[$zoneEntered-111] = $valueToFill;
So you would access $allZones[$zoneEntered] = $allZones[111-111] = $allZones[0] and save a value of your growing cell there that tells you the cell is there or not (to find that out use projection of the bounding boxes to the axis, later more).
Now you check the zone, which is defined by 2 on the x-Axis, 1 on the y-Axis and 1 on the z-Axis. This gives you
CODE
int $zoneEntered = 10 * 10 * 1 + 10 * 1 + 2 = 112
subtracted with 111 gives you $zoneEntered = 1 as one would expect.
Here's what I needed to get the idea:
$zoneEntered(1, 1, 1) = 10 * 10 * 1 + 10 * 1 + 1 = 111
$zoneEntered(2, 1, 1) = 10 * 10 * 1 + 10 * 1 + 2 = 112
$zoneEntered(3, 1, 1) = 10 * 10 * 1 + 10 * 1 + 3 = 113
...
$zoneEntered(10, 1, 1) = 10 * 10 * 1 + 10 * 1 + 10 = 120
...
$zoneEntered(1, 2, 1) = 10 * 10 * 1 + 10 * 2 + 1 = 121
$zoneEntered(2, 2, 1) = 10 * 10 * 1 + 10 * 2 + 2 = 122
$zoneEntered(3, 2, 1) = 10 * 10 * 1 + 10 * 2 + 3 = 123
...
$zoneEntered(1, 3, 1) = 10 * 10 * 1 + 10 * 3 + 1 = 131
$zoneEntered(2, 3, 1) = 10 * 10 * 1 + 10 * 3 + 2 = 132
$zoneEntered(3, 3, 1) = 10 * 10 * 1 + 10 * 3 + 3 = 133
...
$zoneEntered(1, 10, 1) = 10 * 10 * 1 + 10 * 10 + 1 = 201
$zoneEntered(2, 10, 1) = 10 * 10 * 1 + 10 * 10 + 2 = 202
$zoneEntered(3, 10, 1) = 10 * 10 * 1 + 10 * 10 + 3 = 203
...
$zoneEntered(8, 10, 10) = 10 * 10 * 10 + 10 * 10 + 8 = 1108
$zoneEntered(9, 10, 10) = 10 * 10 * 10 + 10 * 10 + 9 = 1109
$zoneEntered(10, 10, 10) = 10 * 10 * 10 + 10 * 10 + 10 = 1110
So from the last value you subtract again 111 which is 999, and the range goes from 0-999, our 1000 values -> voila.
That shall be enough for the formula. Now the bounding boxes. There is a nice script here which gives you a very visual good idea of bounding boxes.
http://www.highend3d.com/maya/downloads/me.../misc/4505.html
Alternatively you could create a cylinder and choose
CODE
Shading - Bounding Box
QUOTE
How to define them? And how do I know if a cell enters this zone.
You define them like the script does. For entering the zones you have to compare the lowest value of your growing cell with the lowest value of the axis in every 3 directions.
Already got the idea?
Cheers
gentlesea