Today I wrote the first version of a script that will drop any number of objects onto a “ground” object. Useful for: putting trees, rocks, etc, onto an irregular ground plane. Or sitting things on a table. Or whatever.
Usage: The object upon which all else will fall should be called “Ground”. Select the objects that you want to have sitting on that ground, and hit alt-p to run the script. Note that this isn’t phsyics - you’re objects will not tumble or stack up, etc. It’ll just drop them to the ground mesh.
Your still going for the bones not going through the floor? and would it be possible to move an object from left to right and it would follow the ground?
Very nice script indeed. Thankyou.
If you’re looking to extend this further how about…
1 - add the option to use the face normal of the face that the object ‘drops’ to to determine rotation of the falling object (handy for aligning objects to sloped sides of a mountain etc).
2 - instead of selecting all the objects that you wish to drop, chose one and the required number of duplicates and randomly scatter your object over the ground.
ps8: still working on the locking bones to the floor thing. Having trouble getting bone to follow my orders from Python.
Also, today I’m working on another version of this script that can be linked via frame-change or redraw links so that an object will follow the contours of a ground object as you move it around.
I probably won’t be adding randomized object creation to this script - that’s what Beast is for. This one is strictly for sticking already existing things to the ground. As for rotating of placed objects being influenced by the face normal - I’ve thought about it and I’m not sure I want to learn quite that much math. Calculating the z-value for x and y on an arbitrary triangle for this script was almost too much for me as it was!
Hi i tried your script, it register in the menu but when i click
on the menu it reply
“Version mismatch script was written for 232, it may fails with your 2.31”
and when i leave from the pop up message blender crash
===Drop to Ground - Start===
Traceback (most recent call last):
File “<string>”, line 61, in ?
AttributeError: Unknown object specified.
Segmentation fault
i compiled the last CVS on linux , python 2.2.2
i changed the line to match the version but when i
select the object to ground and start the script
i have this error
===Drop to Ground - Start===
===Drop to Ground - Done===
Memoryblock free: pointer not in memlist
Segmentation fault
Kino - I have not tested this with the current cvs script menus. I simply followed their instructions regarding headers. If it’s giving you a version incompatability, that’s because I put Blender: 232 in the header. Changing it to 231 would most likely fix that. If someone else has a problem with running through the menus, I’ll remove the link to the straight .py file until I can test it.
Also, another version of the script is now available. This one is for use with object script links, so you can animate or move an object around in real-time and have it stick to the contour of your terrain. It’s fun!
i tried the blend file you provided without using the menu and all go well
even if i change the version it dont work from the menu
Also, another version of the script is now available. This one is for use with object script links, so you can animate or move an object around in real-time and have it stick to the contour of your terrain. It’s fun!
Erm… probably because I don’t use a whole lot of tri-meshes and didn’t notice the discrepancy. Thanks for pointing that out. I’ll change them to both use world coords.
I am still working on my program that is modelled after yours.
It is a little difficult, as although I have programmed before I am completely new to Blender.
As it seemed I was having problems with tri faces. I rewrote the code to find if a point was inside or outside a face for both tri and quad faces. I got that to work. However now it seems that the code you have for determining the Z may be incorrect for tri faces (I am not sure).
I have spent a lot of time debugging and looking for an algorithm on math forums on how to calculate a point on a face. No luck, so I thought I should go to the source and see if you can help.
I’ll look at my code. It’s been a while since I’ve delved into it. One thing to think about, though, is that my code is optimized for the special case of moving in the Z direction given x and y coords. If you’re trying for full 3D motion, the math will be more complex.
Also, if you look at the code to check if a point is inside a quad, it is really just two calls to the tri-check function, once for each tri in the quad.
My house guests are leaving tonight, so I’ll look into the code tomorrow.