本文整理汇总了Python中mathutils.Quaternion.invert方法的典型用法代码示例。如果您正苦于以下问题:Python Quaternion.invert方法的具体用法?Python Quaternion.invert怎么用?Python Quaternion.invert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Quaternion
的用法示例。
在下文中一共展示了Quaternion.invert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: User
# 需要导入模块: from mathutils import Quaternion [as 别名]
# 或者: from mathutils.Quaternion import invert [as 别名]
class User(device.Sender):
def __init__(self, parent, configuration):
_configuration = configuration.copy()
_configuration['users'] = _configuration['viewer']
self._websocket = None
self._matrix = None
super(User, self).__init__(parent, _configuration)
self._viewer = self.BlenderVR.getUserByName(configuration['viewer'])
self._host = configuration['host']
self._available = True
# TODO, check if host is a valid one
def run(self):
try:
self._updateMatrix()
info = {'matrix' : self._matrix}
self.process(info)
except Exception as err:
self.logger.log_traceback(err)
def getName(self):
return self._viewer.getName()
def getUser(self):
return self._viewer
def isAvailable(self):
return self._available
def start(self):
try:
from websocket import create_connection
from mathutils import Matrix
self._websocket = create_connection("ws://{0}:8888/".format(self._host))
self._matrix = Matrix.Identity(4)
except Exception as err:
self.logger.log_traceback(err)
def _updateMatrix(self):
from mathutils import Quaternion, Matrix
import json
try:
self._websocket.send('n')
result = json.loads(self._websocket.recv())
self._matrix = Quaternion((result[7],
result[4],
result[5],
result[6])).to_matrix().to_4x4()
position = Matrix.Translation((result[1], result[2], result[3]))
self._matrix = position * self._matrix
self._matrix.invert()
except Exception as err:
self.logger.log_traceback(err)