[Closed] Lego-ise a terrain
I’m new to Maxscript, and I’m hoping to write a script that will “Lego-ise” a terrain (specifically a volcano). My plan is to sample the terrain geometry at regular points along the Y axis, and calculate how much area the geometry occupies inside a grid square, with a threshold to put a block in that square.
Since a picture is worth a thousand words here’s an example of what I’m talking about:
This shows a slice of the volcano near the top with a best-fit block layout. I would also need to sample the height map to decide how to texture each layer of blocks.
Now I have all the theory of what to do, but I’m really not sure how to do it. I can’t use the vertices since they’re all over the place, and I’m not sure how I can use Maxscript to ‘trace’ the contours of a face polygon.
Any ideas?
I animated laying flags in rooms with different shape. Therefore i choosed PFlow with BirthScript.
This way you can simply do your terrain.
Wouldn’t a birth script require me positioning each vertex exactly where I want a block to appear? This would require a lot more vertices than I would have thought necessary, plus take a lot of time. I’m hoping to use my existing terrain, and work out the best fit for layers of blocks inside it.
For placing my flags in rows and column i used nested for loops. The offset is given by your scattered object width and length.
I am a novice in maxscript, but i think i done alreaqdy something similiar…if i understood yout ideea correctly
With the birthscript you spawn a block of say 10x10x10 particels. (distance between them is givien by objectsize)
Then you detect whitch particle are in collision with your terrain. Delete the others and display the rest with your object geometrie.
All this can done with a simple PFlow.
There’s also a set of maxscript functions that allow you to calculate the shortest distance to a mesh from any point in space:
meshProjIntersect.closestFace()
meshProjIntersect.getHitDist()
Then you could sample say 101010 points in space and all those that are closer than a certain threshold will get a lego brick placed at them.