Zoning In Maya Using Mel

Hi everyone!

I am currently working on my graduation project and I am using maya with MEL to simulate a natural growth of a building.
In certain zones I want mutations to occur, but I don't really know how to define a 3D-zone with MEL.

The shape of the zones will be quite amorph, so the area is hard to define.
In short: I need to know how to define a 3d-area and query if an object is inside or entering this area.

If you could brainstorm a bit and tell me about all the ideas that came up...... that would be great!!!

Thanks a lot,

Nora

Hi Nora,

first of all you have to decide how to structure your scene in logical parts. A rectilinear setup will be suitable for you. That is you define how much distance you want to have between your imaginary cells and specify them by saving the points in each of the 3 directions. You can then save, if a zone has been entered by setting a bit in an array that is defined as follows:

CODE
zoneEntered = Nx * Ny * z + Nx * y + x

Nx, Ny are the dimensions, that is your distance between the imaginary cells. To get around the amorphic structure I would suggest you try to define bounding boxes of the objects.

Greetings

gentlesea

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.

I probably didn'T explain it right, so I try again:

I wrote a script (or better several ) that let little cells (not particles, but little objects) grow from a starting point to an aimpoint by using different ways of recombination, so a growthcode if you want to call it like that.

While growing these cells should cross different zones in that they are supposed to behave differently. These zones are what I don't know about.
How to define them? And how do I know if a cell enters this zone.

About the bouding boxes:

I have read about it already, but I couldn't really find how to use them. I know there is this xform command, but I also don'T know how that works.
In general it might be a good idea, if I could just create an object as a zone and define it by its bouding box.
But then still I would need to know how to define when a cell enters this bounding box.

hope I could make it a bit more clear,
greets,
Nora

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

......yes I think now I get the idea.

thanks a lot for your patience! will try it and make a post about the outcome......

(und durch den hint mit den Abtastpunkten kann ich auch auf deutsch nochmal DANKE!!! sagen )

greets,

Nora