2
$\begingroup$

I am very new at blender and I want to make a simple simulation in blender.

I used boolean operation to model the bowl-like shape. And I dropped the cube into the bowl. When I play the simulation via "Alt-A", the cube is stucking on the invisible surface. But I want to see the cube drop into the bowl.

What is the thing that I should correct?

Here is my code:

import bpy

def make_cup():

    bpy.ops.mesh.primitive_cone_add(radius1=2, radius2=4, depth=2, location=(0, 0, 0))
    cone1 = bpy.context.object
    cone1.name = 'cone1'

    bpy.ops.mesh.primitive_cone_add(radius1=2, radius2=4, depth=2, location=(0, 0, 0.5))
    cone2 = bpy.context.object
    cone2.name = 'cone2'

    mod_diff = cone1.modifiers.new('mod_diff', 'BOOLEAN')
    mod_diff.operation = 'DIFFERENCE'
    mod_diff.object = cone2  
    bpy.context.scene.objects.active = cone1
    res1 = bpy.ops.object.modifier_apply(modifier = 'mod_diff')

    cone2.select = True
    bpy.ops.object.delete()    

    cone1.select = True
    bpy.ops.transform.translate(value=(0, 0, 2))
    bpy.ops.rigidbody.objects_add(type='ACTIVE')

if __name__ == "__main__":

    for o in bpy.data.objects:
        o.select = True if o.type == 'MESH' else False
    bpy.ops.object.delete()

    make_cup()

    # floor
    bpy.ops.mesh.primitive_plane_add(radius=8, location=(0, 0, 0))
    bpy.ops.rigidbody.objects_add(type='PASSIVE')

    # square
    bpy.ops.mesh.primitive_cylinder_add(vertices=4, radius=1, depth=1, location=(0,0,4))
    bpy.ops.rigidbody.objects_add(type='ACTIVE')

enter image description here enter image description here

$\endgroup$
1
$\begingroup$

Make the collision shape of your bowl mesh

The default collision shape for rigid bodies is convex hull. This is why there is an "invisible wall" at the concavity of the bowl

In your script you need to set it to mesh. Here is py console code that changes this property for the context object

 C.object.rigid_body.collision_shape = 'MESH'

do same for bowl in your script.

rigid bodies: sphere not falling into the "box"

Rigid body physics problem even a torus acts like it had no hole in it

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.