本文整理匯總了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)