(UPDATE, created planes need not be segmented)
over the years i think of things that would make handy scripts to help my work flow. and since i know nothing about maxscript and am too lazy to learn, i come here and ask some nice polycount scripters to help me out and make them. its suprising that usualy they jump at the chance and it works out great.. for me! so heres my challenge now for anyone who wants to try an help, it may be complex. at work i need to set out a lot of nodes for technical side of a project. in order to do this i need to place out a lot of rectangles
so i would like a script that lets me select a ground plane rough, this will always be perfectly flat and could be in any shape or size. here is a example.
![script_1.jpg](http://dl.dropbox.com/u/1789373/script_1.jpg)
and then have the script propagate that surface area with the fewest plans as it can make, to take up the most surface area of that volumes
![script_2.jpg](http://dl.dropbox.com/u/1789373/script_2.jpg)
i did this example by hand so its probably not as efficient as could be
things that need to happen. all grids need to have edges that are every .5 meters, and are snaped even to maxs grid. (not on the z axis, z should be level with the ground plane) there needs to be a one grid space gap inbetween every grid plane. and a way to set the min size gridplane that will be created, like nothing smaller than 2x2 or 3x3 depending on what you want.
so anyone up for this challenge?
if so i will love you eternaly
![script_3.jpg](http://dl.dropbox.com/u/1789373/script_3.jpg)
Replies
You didn't really clarify what those clusters are, like if they really were the maximum possible area within a rectangular collection then your example doesn't fit. So I assume it would be some kind of harmony distribution with a few big and a few small ones if possible.
There are some voxel scripts out there, i did one too some time ago. Something like that might be a good start rasterizing the topogly of the flat initial surface into grid clusters.
scruples, and Rhjs grid planes need to be lined up with the max grid, and need to be efficient to get thefewwest planes possible to fill up an area (yes my example up top is not perfectly efficient) the planes also need to have verts every .5 meters snapped to max grid.
the grid is the most important here, these grids are replaced withpoint helpers on export at every vert. that allow other objects to snap to this surface in game.
so in this example
the red circle represents the area i need to be noded. so first the script would look and figure out the largest area a grid plane can be placed while sticking to the .5 grid and places it with a segment every half meter (that is the pink gridplane)
then with say it limited to a 2 grid min (it will not make any grides smaller than 2x2)
it looks for the next largest area it can place a grid plane, in my example the 2 purple ones are the same size so it doesnt matter where it goes first. after those 2 the object is filled up, theres no more spaces that a 2x2 grid can be placed (must stay one grid from other planes, and not go out side of selected shape.
during export each vert on these gridplanes will be replaced with a point node that allows objects to be snapped to this surface. (thats why the planes must be spaced apart or there will be double points where 2 verts share a grid point.
sorry this is a bit of a confusing request. trying to make it as clear as i can.
This makes me think its used for something like an valid building placement grid for an RTS or something.
keen its used to generate nodes for placing housing items in a zone, like dressers, trees statues and whatever. we end up with about 50k nodes in a file an that really hurts max's preformance, so we have a script that takes planes like this in max, and upon export ads the helper points every .5 meters and deletes the planes. the planes are much more max friendly than 50thousand helper points.
currently we have to go in by hand and hand snap the planes all over all the flat surfaces of a zone, which can take a while.
again this may be a horibly complex script, and not worh the time. but just figured i'd ask.
From what I understand the desired result is a bunch of points that represent the internal area of a shape.
What your current work flow is doing:
Create 2d vector shape
Try to fill this shape with a bunch of axis aligned squares
Fill each of these squares with grid aligned points
A much easier way to generate the points:
Create 2d vector shape
For each possible grid point check if it is inside the shape
You could go even further and not have point data at all. Because the points are on the grid you dont actually have to store any points, you just have to store where points can and cant exist, in this case a vector shape as an exported mesh.
In the engine you have objects placed on the grid while checking that each grid point occupied by the object is within the shape. That can really easily be done by raycasting the mesh at each occupied grid point. Something like this would take like 10 minutes to setup if you have a good physics/raycast api.