59 lines
2.4 KiB
Python
59 lines
2.4 KiB
Python
import socket
|
|
import sys
|
|
import os
|
|
|
|
# Available commands:
|
|
#
|
|
# Command 'IP'
|
|
# ============
|
|
# Notify the clients (inside of TARGET_IP) what server they are supposed to
|
|
# connect to for sending and retreiving the state of the player, i.e. the
|
|
# position of the bones and the face blend shapes.
|
|
#
|
|
# Example usage:
|
|
# TARGET_IP=<list of client ips> python3 control.py 'IP:10.42.0.1'
|
|
#
|
|
#
|
|
# Command 'MODE'
|
|
# ==============
|
|
# Set the mode of the clients.
|
|
# The mode controls which body parts (head and face) are shown as well as
|
|
# the interaction method (static or dynamic).
|
|
# The mode itself is split into four boolean attributes, which we set
|
|
# explicitly to change the mode.
|
|
# The boolean values are converted to integer and concatinated using
|
|
# semicolon (;).
|
|
# The boolean attributes are as follows:
|
|
# <show head?>;<show facial exrepssion?>;<show eye rotation?>;<show hands?>
|
|
#
|
|
# The different conditions are encoded as follows:
|
|
#
|
|
# | Condition | Mode Command | Additional Notes |
|
|
# |--------------------|----------------|--------------------------------------------------------------|
|
|
# | Dynamic Face | 'MODE:1;1;1;0' | |
|
|
# | Dynamic Hands | 'MODE:0;0;0;1' | |
|
|
# | Dynamic Hands+Face | 'MODE:1;1;1;1' | |
|
|
# | Static Face | 'MODE:1;0;0;0' | |
|
|
# | Static Hands | 'MODE:0;0;0;1' | Same as Dynamic Hands, but the users have to use controllers |
|
|
# | Static Hands+Face | 'MODE:1;0;0;1' | For achieving Static Hands the users have to use controllers |
|
|
#
|
|
# Example usage (set the mode to *Dynamic Hands+Face*):
|
|
# TARGET_IP=<list of client ips> python3 control.py 'MODE:1;1;1;1'
|
|
|
|
val = sys.argv[1]
|
|
TARGET_IP=os.getenv('TARGET_IP')
|
|
if TARGET_IP is None:
|
|
exit(f"You have to set the TARGET_IP environment variable for this to work. Example: TARGET_IP=10.42.0.38,10.42.0.101 python3 {sys.argv[0]} <command>")
|
|
|
|
|
|
for ip in TARGET_IP.split(','):
|
|
TARGET_ADDR = (ip, 5000)
|
|
if val.startswith("IP:") or val.startswith('MODE:'):
|
|
msg = val.encode('utf-8')
|
|
print(msg)
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
sock.sendto(msg, TARGET_ADDR)
|
|
sock.close()
|
|
else:
|
|
exit("Invalid command")
|