I am having a hard time figuring out how to find spotlight lookAt/Target point. I need it to export some light information in a file so that I will able to use them with OpenGL and render a scene.
So far have this code
with open(bpy.path.abspath("//Taest.txt"), "w", encoding="utf8", newline="\n") as f:
fw = f.write
#fw("testing file write")
#for ob in bpy.context.scene.objects:
for ob in bpy.data.objects:
if ob.type == "LAMP" :
la = ob.data
fw(la.type + " " + la.name + "\n")
fw(vec3ToStr(ob.location) + "\n")
fw(colorToStr(la.color) + "\n")
fw(str(la.energy) + "\n")
#if la.type == "AREA" :
# print("\tAREA " + la.name)
if la.type == "POINT" :
fw(str(la.distance) + "\n")
fw(str(la.quadratic_attenuation) + "\n")
fw(str(la.linear_attenuation) + "\n")
if la.type == "SPOT" :
fw(str(la.distance) + "\n")
fw(str(la.quadratic_attenuation) + "\n")
fw(str(la.linear_attenuation) + "\n")
fw(str(la.spot_size) + "\n")
#empty = bpy.data.meshes.ne(type='PLAIN_AXES')
me = bpy.data.meshes.new("test Mesh")
obn = bpy.data.objects.new("test Obj" , me)
scn = bpy.context.scene
scn.objects.link(obn)
obn.location = ob.location #ob.shadow_buffer_clip_end <<< this is where i have trouble figuring out what to do ??
fw(vec3ToStr(me .location) + "\n")
obn.delete()
Solved
mat = ob.matrix_world
end = mat * Vector((0, 0, -la.shadow_buffer_clip_end))
fw(vec3ToStr(end) + "\n")
Solved
Its the same also for camera lookAt if case you need