I'm constantly sending a camera's position matrix via UDP from Houdini and setting it in Cinema4d. Both are 3-D software programs. The data sends fine but Cinema4d freezes and is slow when updating the matrix from houdini. Why is this happening?
here is the python code i'm sending from Houdini:
import socket
UDP_IP = '192.168.1.8'
UDP_PORT = 7864
cam = hou.selectedNodes()
camerac4d = hou.node('/obj/obj_andcamera/cam1')
xform = camerac4d.worldTransform() #get the camera matrix
data_string = str(xform)
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) # UDP
sock.sendto(data_string, (UDP_IP, UDP_PORT))
UDP receiver in Cinema 4d:
import socket
def main():
operateon = doc.SearchObject('Camera') #get cinema 4d camera
UDP_IP = '192.168.1.8'
UDP_PORT = 7864
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.bind((UDP_IP,UDP_PORT))
data_string,addr = sock.recvfrom(1024)
data_string = ast.literal_eval(data_string) #converts string list
#set houdini matrix to cinema 4d camera
off = v(newlist[3][0],newlist[3][1], -newlist[3][2])
v1 = v(-newlist[0][0],newlist[0][1], newlist[0][2])
v2 = v(-newlist[1][0], -newlist[1][1], -newlist[1][2])
v3 = v(-newlist[2][0], -newlist[2][1], newlist[2][2])
mat = c4d.Matrix(off,v1*-1,v2*-1,v3)
newpos = operateon.SetMg(mat)
so i figured it out i just had to stick the matrix setting in a while loop that died after 5 tries so that cinema4d wouldn't crash and then had to update the viewport in cinema with a line of code that refreshes the viewport everytime the matrix gets updated at the end
def main():