#scripting job
2 messages in this thread
— Moved from Section 12 to Section 18 (Scripts) —
>> I have a tree, I want the tree to sit flat on the terrain so the bottom
>> of the tree sits on the top of the terrain. I only want the tree to
>> move on the Z axis, no rotation, no scaling, no nothing.
Do you have control of the trees' design? For simplicity in scripting, it
would be best if the pivot point is at the base of the trunk -or- if the base
of the trunk sits at the bottom/center of the bounding box. (In the worst
case, ALL trees should have a uniform distance from the bottom/center to the
center of the trunk base.)
I might have a chance to tinker with your problem, but I can't commit
to getting you a solution. Let me offer an approach that someone
(with more time and a better understanding of the math) might be able
to use for an immediate solution.
You, – the user – will select objects that you need to relocate. (This gives
you the very convenient object selection tools in 3DS.) The script will cycle
through all items one-by-one. If the selected-flag is on, then relocate that
object (otherwise ignore) and move on to the next. To move an object,
calculate a vertical line from the pivot point or bottom/center of the bounding
box. Sort through the faces for the "ground" object and find the face that
this line passes through. Determine the coordinate of the line/face
intersection and translate the mesh to that location.
This shouldn't be very difficult. My problem is the calculation of the
line/mesh intersection. If I can solve that today, I will work out a deal on
writing a full script. Since X and Y positions are fixed, and we are only
moving along one axis, the math shouldn't be that bad.
– Dave Marks
I created the trees myself, so, yes, I do have control of their design. At
present the pivot point of the trees is at the default center, only because I
have no skill at scripting and can't write one to automatically alter it to the
bottom center.