I'm trying to simulate laserbeams going through movable mirrors to see where they end up on some screen depending on the orientation of the mirrors. So I figured that I could use raycast from the laser source to the mirrors and from the location and normal vector of the mirror cast a new ray in the reflected direction an so on.
But I can't get the raycast to work. I have previously used the raycast from 3Dview to objects from the template with success. But I can't find any good explanation or documentation on the basic object.ray_cast() function.
import bpy import mathutils source = bpy.data.objects.get('Source') location = source.location direction = mathutils.Vector([0 , -1 , 0]) ray_succes, ray_object, ray_normal = source.ray_cast(location, direction)
But I get this error:
So I lack the basic understanding of how the function works. Any explanation, good answered questions, tutorials, documentation would be really appreciated. I'm open to alternative ways to shine light beams through mirrors which I can then move and rotate with python code.