Я пытаюсь написать собственный скрипт для экспорта объектов на моей сцене с их центром вращения. Вот как выглядит мой алгоритм для получения центра вращения: 1- Выберите объект, используя его имя, затем вызовите 2- Привязать курсор к объекту (центру) 3- Получить координаты мыши 4- Записать координаты мыши
import bpy
sce = bpy.context.scene
ob_list = sce.objects
path = 'C:\\Users\\bestc\\Dropbox\\NetBeansProjects\\MoonlightWanderer\\res\\Character\\player.dat'
# Now copy the coordinate of the mouse as center of rotation
try:
outfile = open(path, 'w')
for ob in ob_list:
if ob.name != "Camera" and ob.name != "Lamp":
ob.select = True
bpy.ops.view3d.snap_cursor_to_selected()
mouseX, mouseY, mouseZ = bpy.ops.view3d.cursor_location
# write object name, coords, center of rotation and rotation followed by a newline
outfile.write( "%s\n" % (ob.name))
x, y, z = ob.location # unpack the ob.loc tuple for printing
x2, y2, z2 = ob.rotation_euler # unpack the ob.rot tuple for printing
outfile.write( "%f %f %f %f %f\n" % (y, z, mouseY, mouseZ, y2) )
#outfile.close()
except Exception as e:
print ("Oh no! something went wrong:", e)
else:
if outfile: outfile.close()
print("done writing")`enter code here`
Очевидно, проблема в шагах 2 и 3, но я не могу понять, как привязать курсор к объекту и получить координату курсора.