搅拌机2.7如何找到聚光灯看/使用脚本目标
问题描述:
我很难搞清楚如何找到聚光灯看/目标点。我需要它将一些光信息导出到一个文件中,以便我可以将它们用于OpenGL并渲染场景。搅拌机2.7如何找到聚光灯看/使用脚本目标
到目前为止,有这样的代码
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")
它也同样为相机的lookAt如果万一你需要
mat = ob.matrix_world
end = mat * Vector((0, 0, -la.shadow_buffer_clip_end))
fw(vec3ToStr(end) + "\n")
将您的答案发布为问题的答案并接受它。 – AMACB