0
$\begingroup$

My understanding is that objects can be added programmatically in Python fairly simply, such as:

import bpy
bpy.ops.mesh.primitive_cube_add(location=(1,0.0,2.0), radius=0.5)

However, in a generative art project, is it possible to test whether an added object overlaps (collides?) with a previously defined object and to modify its parameters if necessary and then retest? If this is indeed possible, can I also receive detailed information about the overlap/collision such as which object are involved, the amount of overlap, location of overlap, etc?

-d. vyd

$\endgroup$
  • $\begingroup$ see if this helps. blender.stackexchange.com/questions/95616/… $\endgroup$ – Ratt Dec 22 '17 at 7:48
  • $\begingroup$ @Ratt, I appreciate the link. It looks like this approach will only work with cubes and spheres and other very simply shapes. It would either fail with slightly more complicated objects or would need to be overly cautious (intentionally large radius in collision test). Is there any way to use Blender's collision detection for arbitrarily shaped objects? I'm aware that this might be slow. Ideally, I would like objects to touch--but not overlap. $\endgroup$ – D. Vyd Dec 22 '17 at 8:43
  • $\begingroup$ The script could be altered for a bounding box relatively easily, but if you are referring to a complete mesh collision test you would likely be better off adding the objects adding a rigid body physics type to it and running a physics simulation. The issue with that is the simulation would force objects to move out of each other as opposed to create them outside of each other. Perhaps updating your question with a bit more detail and examples of what type of objects (add some pictures) would help. $\endgroup$ – Ratt Dec 22 '17 at 9:08
  • $\begingroup$ I consider this answered for now. @Ratt, I appreciate your link and suggestions. $\endgroup$ – D. Vyd Dec 23 '17 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.