im making prerendered graphics like doom, that has character sprites from 8 directions. to offload the work of manualy placing the pivot center for each frame i want to automate it. i had an idea of rendering another frame for each frame of just a brightly pink small ball where the pivot would be, then coding outside of blender a program that would place the pivot at the ball. but im trying first to just code it inside blender. is there a way to get a object’s position inside the rendered camera view, im just gona place the information as a string in a text file.
i found another topic on this but that used the deprecated blender game engine code, from what i tried that doesnt work
here is what ive managed to do
import bpy obj_camera = bpy.context.scene.camera obj_pivot = bpy.data.objects["__PIVOT_OBJ__"] def get_pivot(scene): cam_rotation = str(obj_camera.rotation_euler.x) +","+ str(obj_camera.rotation_euler.z) +"," + str(obj_camera.rotation_euler.y) cam_position = str(obj_camera.location.x) +","+ str(obj_camera.location.z) +"," + str(obj_camera.location.y) pivot_position = str(obj_pivot.location.x) +","+ str(obj_pivot.location.z) +"," + str(obj_pivot.location.y) print(":frame:" + str(bpy.context.scene.frame_current) + "\n:postion:" + cam_position + "\n:rotation:" + cam_rotation + "\n:pivot:" + pivot_position + "\n:_END_\n") return None bpy.app.handlers.frame_change_pre.append(get_pivot)
PIVOT_OBJ is the object that will be used as the pivot in the 2D image.
im also recording the pivot object position, camera position and rotation in 3D space since it could be usefull to have