20.04.2023, 12:35 PM
Code:
import bpy
from bpy_extras.object_utils import world_to_camera_view
context = bpy.context
dg = context.evaluated_depsgraph_get()
ob = context.object.evaluated_get(dg)
ps = ob.particle_systems.active
scene = bpy.context.scene
cam = bpy.data.objects['Camera']
render = scene.render
res_x = render.resolution_x
res_y = render.resolution_y
print("res_x:{},res_y:{}".format(res_x, res_y))
for particle in ps.particles:
if particle.is_visible:
print(particle.location)
coords_2d = world_to_camera_view(scene, cam, particle.location)
x = coords_2d[0]
y = coords_2d[1]
dist_to_cam = coords_2d[2]
rnd = lambda i: round(i)
print("x:{},y:{}".format(rnd(res_x*x),res_y- rnd(res_y*y)))
Ich konnte nun auch die Position der einzelnen Objekte in der Kamera extrahieren.