I am sending object loc rot and scale every keyframe to http address using urllib but the frame rate drops significantly.
Thats the code I am using:
import bpy
import urllib
import mathutils
from bpy import context
from urllib import request, parse
from math import sin, cos, radians
from mathutils import Matrix
def RunPerFrame(scene):
for obj in bpy.data.objects:
mat = bpy.context.object.matrix_world
loc = mat.to_translation()
rot = mat.to_3x3().to_quaternion()
scale = obj.dimensions
qtX = round(rot.x,3)
qtY = round(rot.y,3)
qtZ = round(rot.z,3)
qtW = round(rot.w,3)
loX = round(loc.x,3)
loY = round(loc.y,3)
loZ = round(loc.z,3)
scX = round(scale.x,3)
scY = round(scale.y,3)
scZ = round(scale.z,3)
url = ''
values = { 'msgInstruction=' : 'MOVE_OBJ',
'rotQuat=' : str(qtX) + ',' + str(qtY) + ',' + str(qtZ) + ',' + str(qtW),
'objLoc=' : str(loX) + ',' + str(loY) + ',' + str(loZ),
'objScale=' : str(scX) + ',' + str(scY) + ',' + str(scZ) }
data = urllib.parse.urlencode(values)
encoded_data = data.encode('ascii')
req = urllib.request.Request(url, encoded_data)
response = urllib.request.urlopen(req)
the_page = response.read()
bpy.app.handlers.frame_change_pre.append(RunPerFrame)
Currently testing with one object and the frame rate drops below 2 fps Is there a way to make this faster with this code?