Python Blender 2.7如何使用脚本查找聚光灯注视/目标
我很难想出如何找到聚光灯注视点/目标点。我需要它在一个文件中导出一些灯光信息,这样我就可以将它们与OpenGL一起使用并渲染场景 到目前为止,我们有这个代码Python Blender 2.7如何使用脚本查找聚光灯注视/目标,python,python-3.x,blender,blender-2.61,blender-2.67,Python,Python 3.x,Blender,Blender 2.61,Blender 2.67,我很难想出如何找到聚光灯注视点/目标点。我需要它在一个文件中导出一些灯光信息,这样我就可以将它们与OpenGL一起使用并渲染场景 到目前为止,我们有这个代码 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.
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()
解决
mat = ob.matrix_world
end = mat * Vector((0, 0, -la.shadow_buffer_clip_end))
fw(vec3ToStr(end) + "\n")
如果你需要的话,它也同样适用于相机观察
mat = ob.matrix_world
end = mat * Vector((0, 0, -la.shadow_buffer_clip_end))
fw(vec3ToStr(end) + "\n")
把你的答案作为问题的答案贴出来并接受它。
mat = ob.matrix_world
end = mat * Vector((0, 0, -la.shadow_buffer_clip_end))
fw(vec3ToStr(end) + "\n")