View Full Version : Placing boxes on terrain
05 May 2007, 10:56 PM
Another PF terrain question, is there a way to position boxes across a terrain mesh (varying elevations of course) so that the top face of the boxes sit as low to the terrain as they can without going through it? Specifically I'm using the boxes to be flat blocks of land to place house instances on - the box needs to 'sink' into the terrain until one of its corners touches the terrain mesh then stop.
The assumption is that the box is placed over terrain surface that is not flat - this means if I just position it from the centre point of the top face, some corners will be above the terrain (ok) and some will be below (not ok).
05 May 2007, 11:06 PM
Make a box with it's pivot at the bottom and use a shape instance of the box with a position object operator. Pflow will birth a particle on the mesh of the surface and place the pivot of the box object on it - you also have offset controls to pad it out from the surface a tad.
05 May 2007, 11:30 PM
sorry, I don't think I explained my problem very well, I probably need a picture to explain properly what I meant:
05 May 2007, 03:03 AM
Yup the method above will work fine too - just place the pivot of the box at the top and the side instead. It's all to do with where you placed the pivot on the box object before you use it as a shape instance.
05 May 2007, 03:24 AM
Problem is if I put the pivot point on one side, all boxes where the slope slopes up on that side will be fine, but boxes where the slope slopes up on the side opposite the pivot point will be completely buried...
05 May 2007, 12:23 PM
If it's a valley then maybe do two different systems to get the orientation correct? It's the type of thing where you'd use speed by surface to emit from your terrain but then you'd need a rotation operator to set all of the particles to be level with the horizon - I reckon you'd need a script operator or box #3 to do it since I can't think of a way to affect a single rotation axis at the moment (that said I'm fairly brain dead right now)
05 May 2007, 01:33 PM
Hmmm... I'm thinking about it, and I'm thinking this might be more of a job for reactor than particle flow...
05 May 2007, 02:30 PM
Reactor will drop the boxes but it'll make them bounce off at weird angles - it doesn't have any kind of controls for stick stuff into the surface - the other option is to model the terrain with a plane so you have a nice even spacing of edges and then use hinge from edge in the epoly modifier to rotate out the flat surfaces for the roofs with make planar to get them bang on.
05 May 2007, 05:34 PM
It seems more like a job for a Script than anything. It would be quite simple. Use IntersectRay to find the distance from each of your 4 top verts on the box to the mesh below and drop the box by the smallest one.
05 May 2007, 08:07 PM
Indeed - just trying to think of the best way to do it using as many in built functions and avoiding scripting - the raytracing would be by far best but again that assumes scripting.
05 May 2007, 06:30 PM
i realeased a tutorial at CGArena.com about placing stuff with particles:
and hereīs a max8 file that might get you there...itīs about rotation along normals but i
hope that it might help any further...maybe just have a look...
the deal is the following. set the speed the lowest possible like 0,0001 so the shape instance will not move visible. OR second method leave the speed at 300 which is default and pipe the particles in an age test which is set to 0 with 0 tollerance. pipe the age test into a new speed event set to 0 speed > done.
for your positioning problem i would try Placement Paint from box#1! you probably canīt have more power over position then with Placement Paint:
05 May 2007, 07:40 PM
Actually, this is what he needs.
This really is meant to work with boxs (they get converted to EditableMesh in the process..if thats a problem, let me know). Select all the boxes, run the script, and then pick your ground object. I didn't dummyproof this, so it may throw errors if it is not extecuted correctly.
grnd = pickObject()
for i in selection do
rayLngths = #()
for i2 in 1 to i.numverts do
rayLngths += #(distance ((intersectRay grnd (ray (getVert i i2) [0,0,-1])).pos) (getVert i i2))
move i [0,0,(-(amin rayLngths) - (in coordsys local i.max.z))]
05 May 2007, 11:28 PM
there's a free little tool to do it, i think.
05 May 2007, 12:10 AM
That is a nice tool, but it doesn't do exactly what ultramedia needed. Create an uneven surface, place a series of boxes above it and run the script and you will see what it does. Basicaly it sinks a box as far into the ground as possible without letting the top plane sink in, or stand out.
05 May 2007, 12:33 AM
Thanks for the script, it works great :) Screenshots incoming...
05 May 2007, 12:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.