【发布时间】:2013-03-14 16:25:35
【问题描述】:
如何发送矢量对象。 我正在尝试通过 udp 套接字连接以矢量格式发送对象的位置。
socket.sendto(self.cube.worldPosition,server_addr)
但我收到以下错误: TypeError: 'Vector' 不支持缓冲区接口
我怎样才能做到这一点,或者有没有其他方法可以发送对象的位置?
【问题讨论】:
标签: python sockets networking blender
如何发送矢量对象。 我正在尝试通过 udp 套接字连接以矢量格式发送对象的位置。
socket.sendto(self.cube.worldPosition,server_addr)
但我收到以下错误: TypeError: 'Vector' 不支持缓冲区接口
我怎样才能做到这一点,或者有没有其他方法可以发送对象的位置?
【问题讨论】:
标签: python sockets networking blender
只需访问向量的值,形成一个列表并使用pickle模块发送
##player.worldPosition is the vector
x = player.worldPosition[0]
y = player.worldPosition[1]
z = player.worldPosition[2]
xyz = [x,y,z] #forming the list
ddd = pickle.dumps(xyz) #serialize the list
self.socket.sendto(ddd,self.server_address) #off it goes
这对我有用
【讨论】: