def setControlMtx(self, mtx): translation = Matrix() translation.translation = Vector3(0, 0, BigWorld.player().reductionPoint) self._controlMtx = MatrixProduct() self._controlMtx.b = mtx self._controlMtx.a = translation
def __pickVehicle(self): if self.__boundVehicleMProv is not None: return else: x, y = GUI.mcursor().position from AvatarInputHandler import cameras dir, start = cameras.getWorldRayAndPoint(x, y) end = start + dir.scale(100000.0) pos, colldata = collideDynamicAndStatic(start, end, (), 0) vehicle = None if colldata is not None: entity = colldata[0] from Vehicle import Vehicle if isinstance(entity, Vehicle): vehMatProv = entity.matrix vehMatInv = Matrix(vehMatProv) vehMatInv.invert() localPos = vehMatInv.applyPoint(pos) result = Math.MatrixProduct() localTransMat = Matrix() localTransMat.translation = localPos result.a = localTransMat result.b = vehMatProv return result 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
def __getMarkerMatrix(self, destructibleEntity): guiNode = destructibleEntity.getGuiNode() if guiNode is not None: return guiNode else: m = Matrix() m.translation = destructibleEntity.position + settings.MARKER_POSITION_ADJUSTMENT return m
def createSRTMatrix(scale, rotation, translation): scaleMatrix = Matrix() scaleMatrix.setScale(scale) result = Matrix() result.setRotateYPR(rotation) result.translation = translation result.preMultiply(scaleMatrix) return result
def prerequisites(self): stepRepairPointComponent = BigWorld.player().arena.componentSystem.stepRepairPointComponent if stepRepairPointComponent is not None: stepRepairPointComponent.addStepRepairPoint(self) rv = [_g_stepRepairPointSettings.flagModel, _g_stepRepairPointSettings.radiusModel] mProv = Matrix() mProv.translation = self.position self.__stepRepairPointSoundObject = SoundGroups.g_instance.WWgetSoundObject('stepRepairPoint_' + str(self), mProv) self.__stepRepairPointSoundObject.play(_g_stepRepairPointSettings.attachedSoundEventName) return rv
def _createMarkerWithPosition(self, symbol, position, active=True): """Creates 2D marker that has static position on world. :param symbol: string containing name of symbol to create desired UI component in the Flash. :param position: Math.Vector3 containing world position. :param active: True if marker is visible, otherwise - False. :return: integer containing unique ID of marker. """ matrixProvider = Matrix() matrixProvider.translation = position return self._parentObj.createMarker(symbol, matrixProvider, active)
def assembleCompoundModel(models, position, vehicleDesc): tank = BigWorld.createCompoundTank() chassis = BigWorld.ModelLite(models[0]) hull = BigWorld.ModelLite(models[1]) turret = BigWorld.ModelLite(models[2]) gun = BigWorld.ModelLite(models[3]) matrix = Matrix() matrix.translation = position tank.attachPart(0, chassis, '', matrix) tank.attachPart(1, hull, 'V') tank.attachPart(2, turret, 'HP_turretJoint') tank.attachPart(3, gun, 'HP_gunJoint') BigWorld.addModel(tank) return tank
def prerequisites(self): stepRepairPointComponent = BigWorld.player().arena.componentSystem.stepRepairPointComponent if stepRepairPointComponent is not None: stepRepairPointComponent.addStepRepairPoint(self) assembler = BigWorld.CompoundAssembler(_g_stepRepairPointSettings.flagModel, self.spaceID) assembler.addRootPart(_g_stepRepairPointSettings.flagModel, 'root') rv = [assembler, _g_stepRepairPointSettings.radiusModel] if _g_stepRepairPointSettings.flagAnim is not None: loader = AnimationSequence.Loader(_g_stepRepairPointSettings.flagAnim, self.spaceID) rv.append(loader) mProv = Matrix() mProv.translation = self.position self.__stepRepairPointSoundObject = SoundGroups.g_instance.WWgetSoundObject('stepRepairPoint_' + str(self), mProv) self.__stepRepairPointSoundObject.play(_g_stepRepairPointSettings.attachedSoundEventName) return rv
def __drawDebugOutput(self, matrixProvider): self.__resetDebugOutput() if matrixProvider is None: return else: matrixProvider = Matrix(matrixProvider) pos = matrixProvider.translation endPos = matrixProvider.translation endPos.y += 70.0 self.__debugLine = Flock.DebugLine(pos, endPos) self.__debugLine.thickness = 1.0 matrixProvider.translation = pos self.__debugGizmo.setMatrix(matrixProvider) self.__callbackDelayer.delayCallback(4.0, self.__resetDebugOutput) return
def prerequisites(self): self.capturePercentage = float(self.pointsPercentage) / 100 self.__isCapturedOnStart = self.isCaptured sectorBaseComponent = BigWorld.player( ).arena.componentSystem.sectorBaseComponent if sectorBaseComponent is not None: sectorBaseComponent.addSectorBase(self) rv = [ _g_sectorBaseSettings.flagModelName, _g_sectorBaseSettings.flagStaffModelName, _g_sectorBaseSettings.radiusModel ] mProv = Matrix() mProv.translation = self.position self.__baseCaptureSoundObject = SoundGroups.g_instance.WWgetSoundObject( 'base_' + str(self.baseID), mProv) self.__baseCaptureSoundObject.play( _g_sectorBaseSettings.baseAttachedSoundEventName) return rv
def prerequisites(self): self.capturePercentage = float(self.pointsPercentage) / 100 self.__isCapturedOnStart = self.isCaptured sectorBaseComponent = BigWorld.player().arena.componentSystem.sectorBaseComponent if sectorBaseComponent is not None: sectorBaseComponent.addSectorBase(self) assembler = BigWorld.CompoundAssembler(_g_sectorBaseSettings.flagStaffModelName, self.spaceID) assembler.addRootPart(_g_sectorBaseSettings.flagStaffModelName, 'root') scaleMatrix = Matrix() scaleMatrix.setScale(_g_sectorBaseSettings.flagScale) assembler.addPart(_g_sectorBaseSettings.flagModelName, _g_sectorBaseSettings.flagStaffFlagHP, _g_sectorBaseSettings.flagNodeAliasName, scaleMatrix) rv = [assembler, _g_sectorBaseSettings.radiusModel] if _g_sectorBaseSettings.flagAnim is not None: loader = AnimationSequence.Loader(_g_sectorBaseSettings.flagAnim, self.spaceID) rv.append(loader) mProv = Matrix() mProv.translation = self.position self.__baseCaptureSoundObject = SoundGroups.g_instance.WWgetSoundObject('base_' + str(self.baseID), mProv) self.__baseCaptureSoundObject.play(_g_sectorBaseSettings.baseAttachedSoundEventName) return rv
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)
def createStaticMarker(self, pos, symbol): mProv = Matrix() mProv.translation = pos handle = self.__ownUI.addMarker(mProv, symbol) return (mProv, handle)
def createRTMatrix(rotation, translation): result = Matrix() result.setRotateYPR(rotation) result.translation = translation return result
def createStaticMarker(self, pos, symbol): mProv = Matrix() mProv.translation = pos handle = self.__battleApp.markersManager.createMarker(mProv, symbol) return (mProv, handle)
def _createMarker(self, pos, symbol, active=True): mProv = Matrix() mProv.translation = pos return self._parentObj.createMarker(mProv, symbol, active)
def _createMarkerWithPosition(self, symbol, position, active=True): matrixProvider = Matrix() matrixProvider.translation = position return self._parentObj.createMarker(symbol, matrixProvider, active)
def __getMatrixProvider(self, position): matrixProvider = Matrix() matrixProvider.translation = position return matrixProvider
def _createMarker(self, pos, symbol, active = True): mProv = Matrix() mProv.translation = pos return self._parentObj.createMarker(mProv, symbol, active)
def __createMatrix(self, position): matrixProvider = Matrix() matrixProvider.translation = position return matrixProvider