Blender 2.7如何使用scrip查找聚光灯注视/目标

2024-06-26 14:15:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我很难弄清楚如何找到聚光灯注视点/目标点。我需要它在一个文件中导出一些光的信息,这样我就可以在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.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()

已解决

^{pr2}$

Tags: fordataifobjectstypelocationlawrite