本文整理汇总了Python中Math.Matrix.preMultiply方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.preMultiply方法的具体用法?Python Matrix.preMultiply怎么用?Python Matrix.preMultiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math.Matrix
的用法示例。
在下文中一共展示了Matrix.preMultiply方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createSRTMatrix
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import preMultiply [as 别名]
def createSRTMatrix(scale, rotation, translation):
scaleMatrix = Matrix()
scaleMatrix.setScale(scale)
result = Matrix()
result.setRotateYPR(rotation)
result.translation = translation
result.preMultiply(scaleMatrix)
return result
示例2: decodeHitPoints
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import preMultiply [as 别名]
def decodeHitPoints(encodedPoints, vehicleDescr):
resultPoints = []
maxHitEffectCode = None
for encodedPoint in encodedPoints:
compName, hitEffectCode, startPoint, endPoint = DamageFromShotDecoder.decodeSegment(
encodedPoint, vehicleDescr
)
if startPoint == endPoint:
continue
maxHitEffectCode = max(hitEffectCode, maxHitEffectCode)
hitTester = getattr(vehicleDescr, compName)["hitTester"]
hitTestRes = hitTester.localHitTest(startPoint, endPoint)
if not hitTestRes:
width, height, depth = (hitTester.bbox[1] - hitTester.bbox[0]) / 256.0
directions = [
Math.Vector3(0.0, -height, 0.0),
Math.Vector3(0.0, height, 0.0),
Math.Vector3(-width, 0.0, 0.0),
Math.Vector3(width, 0.0, 0.0),
Math.Vector3(0.0, 0.0, -depth),
Math.Vector3(0.0, 0.0, depth),
]
for direction in directions:
hitTestRes = hitTester.localHitTest(startPoint + direction, endPoint + direction)
if hitTestRes is not None:
break
if hitTestRes is None:
continue
minDist = hitTestRes[0][0]
for i in xrange(1, len(hitTestRes)):
dist = hitTestRes[i][0]
if dist < minDist:
minDist = dist
hitDir = endPoint - startPoint
hitDir.normalise()
rot = Matrix()
rot.setRotateYPR((hitDir.yaw, hitDir.pitch, 0.0))
matrix = Matrix()
matrix.setTranslate(startPoint + hitDir * minDist)
matrix.preMultiply(rot)
effectGroup = DamageFromShotDecoder.__hitEffectCodeToEffectGroup[hitEffectCode]
resultPoints.append(DamageFromShotDecoder.ShotPoint(compName, matrix, effectGroup))
return (maxHitEffectCode, resultPoints)
示例3: CircularFlyer
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import preMultiply [as 别名]
class CircularFlyer(BigWorld.UserDataObject):
def __init__(self):
BigWorld.UserDataObject.__init__(self)
self.__prevTime = BigWorld.time()
self.__angularVelocity = 2 * math.pi / self.rotationPeriod
if not self.rotateClockwise:
self.__angularVelocity *= -1
self.__currentAngle = 0.0
self.__updateCallbackId = None
self.__model = None
self.__modelMatrix = None
self.__sound = None
BigWorld.loadResourceListBG((self.modelName, self.pixieName), self.__onResourcesLoaded)
return
def __del__(self):
self.__clear()
def __clear(self):
if self.__updateCallbackId is not None:
BigWorld.cancelCallback(self.__updateCallbackId)
self.__updateCallbackId = None
if self.__sound is not None:
self.__sound.stop()
self.__sound = None
if self.__model is not None:
BigWorld.delModel(self.__model)
self.__model = None
return
def __onResourcesLoaded(self, resourceRefs):
if self.guid not in BigWorld.userDataObjects:
return
else:
self.__clear()
if self.modelName in resourceRefs.failedIDs:
return
try:
self.__model = resourceRefs[self.modelName]
self.__modelMatrix = Matrix()
self.__modelMatrix.setIdentity()
servo = BigWorld.Servo(self.__modelMatrix)
self.__model.addMotor(servo)
BigWorld.addModel(self.__model)
if self.actionName != '':
action = self.__model.action(self.actionName)
if action is not None:
action()
if self.pixieName != '' and self.pixieName not in resourceRefs.failedIDs:
pixieNode = self.__model.node(self.pixieHardPoint)
pixieNode.attach(resourceRefs[self.pixieName])
if self.soundName != '':
self.__sound = SoundGroups.g_instance.playSoundModel(self.__model, self.soundName)
except:
LOG_CURRENT_EXCEPTION()
self.__model = None
return
self.__prevTime = BigWorld.time()
self.__update()
return
def __update(self):
self.__updateCallbackId = None
self.__updateCallbackId = BigWorld.callback(0.0, self.__update)
curTime = BigWorld.time()
dt = curTime - self.__prevTime
self.__prevTime = curTime
self.__currentAngle += self.__angularVelocity * dt
if self.__currentAngle > 2 * math.pi:
self.__currentAngle -= 2 * math.pi
elif self.__currentAngle < -2 * math.pi:
self.__currentAngle += 2 * math.pi
radialPosition = Vector3(self.radius * math.sin(self.__currentAngle), 0, self.radius * math.cos(self.__currentAngle))
modelYaw = self.__currentAngle
if self.rotateClockwise:
modelYaw += math.pi / 2
else:
modelYaw -= math.pi / 2
localMatrix = Matrix()
localMatrix.setRotateY(modelYaw)
localMatrix.translation = radialPosition
self.__modelMatrix.setRotateYPR((self.yaw, self.pitch, self.roll))
self.__modelMatrix.translation = self.position
self.__modelMatrix.preMultiply(localMatrix)
return
示例4: __worldYawPitchToTurret
# 需要导入模块: from Math import Matrix [as 别名]
# 或者: from Math.Matrix import preMultiply [as 别名]
def __worldYawPitchToTurret(self, worldYaw, worldPitch):
worldToTurret = Matrix(self.__vehicleMProv)
worldToTurret.invert()
worldToTurret.preMultiply(mathUtils.createRotationMatrix((worldYaw, worldPitch, 0.0)))
return (worldToTurret.yaw, worldToTurret.pitch)