Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save howiemnet/ccc0a8ab07eaadfb854147ce038c2e96 to your computer and use it in GitHub Desktop.
Save howiemnet/ccc0a8ab07eaadfb854147ce038c2e96 to your computer and use it in GitHub Desktop.
import sys
import bpy
from math import pi, sin, cos, sqrt, atan2, fabs
import socket
rad2deg = 180/3.14159265
UDP_IP = "127.0.0.1"
UDP_PORT = 4950
xPan = bpy.data.scenes[0].objects["PTR_PAN"].matrix_world.to_euler("XYZ")[1]
xSlider = bpy.data.scenes[0].objects["SliderDummy"].location[0]
xTilt = - bpy.data.scenes[0].objects["PTR_TILT"].matrix_world.to_euler("XYZ")[1] * rad2deg
mTurn = bpy.data.scenes[0].objects["MTURN"].matrix_world.to_euler("XYZ")[2] * rad2deg
mFocus = -(bpy.data.scenes[0].objects["FocusDistanceDummy.001"].location[2])
if xPan < -1.5:
xPan = xPan + 3.1415926 + 3.1415926
xPan = xPan * rad2deg
#myString = "BIGSLIDER,PAN,TILT,MTURN,FOCUS\n" + str(xSlider) + "," + str(xPan)+ "," + str(xTilt)+ "," + str(mTurn) + "," + str(mFocus)
myString = "1,2,3,7,12\n" + str(xSlider) + "," + str(xPan)+ "," + str(xTilt)+ "," + str(mTurn) + "," + str(mFocus)
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.sendto(myString.encode('utf-8'),(UDP_IP, UDP_PORT))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment