【问题标题】:sending vector objetcs in blender over network通过网络在搅拌机中发送矢量对象
【发布时间】:2013-03-14 16:25:35
【问题描述】:

如何发送矢量对象。 我正在尝试通过 udp 套接字连接以矢量格式发送对象的位置。

socket.sendto(self.cube.worldPosition,server_addr)

但我收到以下错误: TypeError: 'Vector' 不支持缓冲区接口

我怎样才能做到这一点,或者有没有其他方法可以发送对象的位置?

【问题讨论】:

    标签: python sockets networking blender


    【解决方案1】:

    只需访问向量的值,形成一个列表并使用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 
    

    这对我有用

    【讨论】:

    • 不要使用 pickle 模块。看到这个页面上的红框了吗? docs.python.org/2/library/pickle.html>。注意它。我建议使用 AMP:amp-protocol.net>
    猜你喜欢
    • 2016-04-22
    • 2020-08-10
    • 1970-01-01
    • 2015-10-30
    • 1970-01-01
    • 2019-05-08
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多