Example #1
0
 def hideMarker(self):
     if self.__modelSmall in BigWorld.models():
         self.__modelSmall.delMotor(self.__motor)
         BigWorld.delModel(self.__modelSmall)
     if self.__modelMedium in BigWorld.models():
         self.__modelMedium.delMotor(self.__motor)
         BigWorld.delModel(self.__modelMedium)
     if self.__modelBig in BigWorld.models():
         self.__modelBig.delMotor(self.__motor)
         BigWorld.delModel(self.__modelBig)
Example #2
0
 def stop(self):
     if self.__vehicleEffectsPlayer is not None:
         self.__vehicleEffectsPlayer.stop()
         self.__vehicleEffectsPlayer = None
     if self.__vehicleFakeModel in BigWorld.models():
         BigWorld.delModel(self.__vehicleFakeModel)
     if self.__cameraEffectsPlayer is not None:
         self.__cameraEffectsPlayer.stop()
         self.__cameraEffectsPlayer = None
     if self.__cameraFakeModel in BigWorld.models():
         BigWorld.delModel(self.__cameraFakeModel)
     return
 def destroy(self):
     if self.__model and self.__motor:
         self.__model.delMotor(self.__motor)
     self.__motor = None
     if self.__model and self.__model in BigWorld.models():
         BigWorld.delModel(self.__model)
     self.__model = None
Example #4
0
def onHealthChanged(self, newHealth, oldHealth, attackerID, attackReasonID):
    global isAlive
    if self.isPlayerVehicle and config.get(
            'sight/enabled', True) and battle.isBattleTypeSupported:
        isAlive = self.isAlive()
        if (not isAlive) and (sphere in BigWorld.models()):
            BigWorld.delModel(sphere)
Example #5
0
def update_sphere(position):
    global sphere
    if sphere is None:
        sphere = BigWorld.Model('objects/misc/bbox/sphere1.model')
    elif sphere in BigWorld.models():
        BigWorld.delModel(sphere)
    if (_explosionRadius is not None) and isAlive and isDownHotkey:
        sphere.position = position
        sphere.scale = Vector3(_explosionRadius, _explosionRadius,
                               _explosionRadius)
        BigWorld.addModel(sphere)
Example #6
0
 def destroy(self):
     self.__destroyed = True
     if self.__model:
         if self.__motor and self.__motor in self.__model.motors:
             self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
     self.__model = None
     self.__motor = None
     if self.__sound:
         self.__sound.stop()
     self.__sound = None
Example #7
0
 def destroy(self):
     self.__destroyed = True
     if self.__model:
         if self.__motor and self.__motor in self.__model.motors:
             self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
     self.__model = None
     self.__motor = None
     if self.__sound:
         self.__sound.stop()
     self.__sound = None
 def onLeaveWorld(self):
     if self.__vAppearance:
         self.__vAppearance.destroy()
         self.__vAppearance = None
     self.typeDescriptor = None
     self.__shadowModelFashion = None
     if self.__fakeShadowModel is not None and self.__fakeShadowModel in BigWorld.models(
     ):
         BigWorld.delModel(self.__fakeShadowModel)
         self.__fakeShadowModel = None
     super(ClientSelectableCameraVehicle, self).onLeaveWorld()
     return
Example #9
0
 def stop(self):
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
     if self.__sound is not None:
         self.__sound.stop()
         self.__sound = None
     self.__firstLaunch = True
     return
Example #10
0
 def destroy(self):
     self.__destroyed = True
     if self.__model:
         if self.__motor and self.__motor in self.__model.motors:
             self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
     self.__model = None
     self.__motor = None
     if self.__sound is not None:
         self.__sound.stop()
         self.__sound.releaseMatrix()
         self.__sound = None
     return
Example #11
0
 def destroy(self):
     self.__destroyed = True
     if self.__model:
         if self.__motor and self.__motor in self.__model.motors:
             self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
     self.__model = None
     self.__motor = None
     if self.__sound is not None:
         self.__sound.stop()
         self.__sound.releaseMatrix()
         self.__sound = None
     return
Example #12
0
 def stop(self):
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
     if self.__sound is not None:
         self.__sound.stop()
         self.__sound.releaseMatrix()
         self.__sound = None
     self.__firstLaunch = True
     return
Example #13
0
 def stop(self):
     self.__isStopped = True
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
     if self.__sound is not None:
         self.__sound.stop()
         self.__sound.releaseMatrix()
         self.__sound = None
     self.__firstLaunch = True
     if self.__waveImpulse is not None:
         self.__waveImpulse.destroy()
         self.__waveImpulse = None
     return
Example #14
0
 def stop(self):
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
         self.__curve = None
     if self.__sound is not None:
         self.__sound.stop()
         self.__sound = None
     if self.__particles is not None:
         self.__particlesNode.detach(self.__particles)
         self.__particlesNode = None
         self.__particles = None
     return
Example #15
0
 def stop(self):
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
         self.__curve = None
     if self.__sound is not None:
         self.__sound.stop()
         self.__sound = None
     if self.__particles is not None:
         self.__particlesNode.detach(self.__particles)
         self.__particlesNode = None
         self.__particles = None
     return
Example #16
0
 def stop(self):
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         if self.__motor is not None and self.__motor in self.__model.motors:
             self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
         self.__curve = None
     if self.__sound is not None:
         self.__sound.stopAll()
         self.__sound = None
     if self.__particle[1] is not None and self.__particle[1].pixie is not None:
         self.__particle[0].detach(self.__particle[1].pixie)
     self.__particle = (None, None)
     self.__firstLaunch = True
     return
Example #17
0
 def stop(self):
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         if self.__motor is not None and self.__motor in self.__model.motors:
             self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
         self.__curve = None
     if self.__sound is not None:
         self.__sound.stopAll()
         self.__sound = None
     if self.__particle[1] is not None and self.__particle[1].pixie is not None:
         self.__particle[0].detach(self.__particle[1].pixie)
     self.__particle = (None, None)
     self.__firstLaunch = True
     return
Example #18
0
 def stop(self):
     self.__isStopped = True
     if self.__cbID is not None:
         BigWorld.cancelCallback(self.__cbID)
         self.__cbID = None
     if self.__model is not None:
         if self.__motor is not None and self.__motor in self.__model.motors:
             self.__model.delMotor(self.__motor)
         if self.__model in BigWorld.models():
             BigWorld.delModel(self.__model)
         self.__model = None
         self.__motor = None
         self.__curve = None
     if self.__sound is not None:
         self.__sound.stop(self.FADE_TIME)
         self.__sound.releaseMatrix()
     if self.__particle[1] is not None and self.__particle[1].pixie is not None:
         self.__particle[0].detach(self.__particle[1].pixie)
         self.__particle[1].destroy()
     self.__particle = (None, None)
     self.__firstLaunch = True
     return
Example #19
0
def attach(vehicleID, modID=None, visible=False):
    if vehicleID not in dynamic_db:
        return
    for mod, dyn in dynamic_db[vehicleID].iteritems():
        if modID is not None and modID != mod:
            continue
        dyn['entered'] = True
        if not dyn['loaded']:
            return
        vEntity = BigWorld.entity(vehicleID)
        if vEntity is None:
            return
        compoundModel = vEntity.model
        scaleMat = math_utils.createIdentityMatrix()
        attachMode = dyn['mode']
        if 'scale' in attachMode:
            scaleMat.setScale(Math.Vector3(1.025))
        for modelDict in dyn['models'].itervalues():
            model = modelDict['model']
            if model is not None:
                if 'attach' in attachMode:
                    try:
                        compoundModel.node(modelDict['nodeName']).attach(
                            model, scaleMat)
                    except StandardError:
                        if g_config.data['isDebug']:
                            traceback.print_exc()
                elif 'motor' in attachMode:
                    if model not in BigWorld.models():
                        modelDict['motor'] = motor = BigWorld.Servo(
                            math_utils.MatrixProviders.product(
                                compoundModel.node(modelDict['nodeName']),
                                scaleMat))
                        model.addMotor(motor)
                        BigWorld.addModel(model)
                model.visible = visible and dyn['visible']
Example #20
0
def lightsCreate(vehicleID, callPlace=''):
    try:
        vehicle = BigWorld.player().arena.vehicles[vehicleID]
        vEntity = BigWorld.entity(vehicleID)
        if vEntity is None:
            return
        vDesc = vEntity.typeDescriptor
        if vehicleID == BigWorld.player().playerVehicleID:
            print 'LampLights: Create at %s' % callPlace
        constNodesList = [
            TankNodeNames.TRACK_LEFT_UP_FRONT,
            TankNodeNames.TRACK_LEFT_UP_REAR,
            TankNodeNames.TRACK_RIGHT_UP_FRONT,
            TankNodeNames.TRACK_RIGHT_UP_REAR
        ]
        compoundModel = vEntity.appearance.compoundModel
        nodeListML, nodeListNL = findWheelNodes(vehicleID, 'L')
        nodeListMR, nodeListNR = findWheelNodes(vehicleID, 'R')
        fakesDict[vehicleID] = fakeDict = {}
        fakeMotorsDict[vehicleID] = fakeMotorDict = {}

        sourcesDict = {TankPartNames.CHASSIS: None, TankPartNames.HULL: None}
        for tankPartName in sourcesDict.keys():
            curSource = getattr(vDesc, tankPartName).models.undamaged
            modelSec = ResMgr.openSection(curSource)
            if modelSec is None:
                print 'LampLights: file not found:', curSource
            sourceSecStr = modelSec['nodefullVisual'].asString
            sourceSec = ResMgr.openSection(sourceSecStr + '.visual')
            if sourceSec is None:
                sourceSec = ResMgr.openSection(sourceSecStr +
                                               '.visual_processed')
            if sourceSec is None:
                print 'LampLights: visual not found for', curSource
                print callPlace
            else:
                sourcesDict[tankPartName] = sourceSec
        HullMat = math_utils.createIdentityMatrix()
        deHullMat = math_utils.createIdentityMatrix()
        if sourcesDict[TankPartNames.CHASSIS] is not None:
            deHullMat = nodeWatcher(sourcesDict[TankPartNames.CHASSIS], 'V')
            deHullMat.invert()
        for tankPartName in (TankPartNames.CHASSIS, TankPartNames.HULL):
            fakeDict[tankPartName] = BigWorld.Model('objects/fake_model.model')
            fakeDict[tankPartName +
                     'Root'] = BigWorld.Model('objects/fake_model.model')
            compoundModel.node(TankPartNames.HULL).attach(
                fakeDict[tankPartName + 'Root'],
                HullMat if 'hull' in tankPartName else deHullMat)
            if fakeMotorDict.get(tankPartName) not in tuple(
                    fakeDict[tankPartName].motors):
                fakeMotorDict[tankPartName] = BigWorld.Servo(
                    fakeDict[tankPartName + 'Root'].matrix)
                fakeDict[tankPartName].addMotor(fakeMotorDict[tankPartName])
            if fakeDict[tankPartName] not in tuple(BigWorld.models()):
                BigWorld.addModel(fakeDict[tankPartName])
        for idx, node in enumerate(nodeListNL):
            fakeDict[node] = BigWorld.Model('objects/fake_model.model')
            fakeDict[TankPartNames.CHASSIS].node('', nodeListML[idx]).attach(
                fakeDict[node])

        for idx, node in enumerate(nodeListNR):
            fakeDict[node] = BigWorld.Model('objects/fake_model.model')
            fakeDict[TankPartNames.CHASSIS].node('', nodeListMR[idx]).attach(
                fakeDict[node])

        for node in constNodesList:
            fakeDict[node] = BigWorld.Model('objects/fake_model.model')
            restoreMat = math_utils.createIdentityMatrix()
            transMat = None
            isChassis = False
            if sourcesDict[TankPartNames.HULL] is not None:
                transMat = nodeWatcher(sourcesDict[TankPartNames.HULL], node)
            if transMat is None and sourcesDict[
                    TankPartNames.CHASSIS] is not None:
                transMat = nodeWatcher(sourcesDict[TankPartNames.CHASSIS],
                                       node)
                if transMat is None:
                    transMat = nodeWatcher(sourcesDict[TankPartNames.CHASSIS],
                                           node.replace('Up', ''))
                isChassis = True
            if transMat is None:
                print _config.ID + ': restore Matrix not found for node', node, 'in', vDesc.hull.models.undamaged
                print callPlace
            else:
                restoreMat.setTranslate(transMat.translation)
            fakeDict[TankPartNames.HULL if not isChassis else TankPartNames.
                     CHASSIS].node('', restoreMat).attach(fakeDict[node])

        fakeDict[TankPartNames.GUN +
                 'Root'] = BigWorld.Model('objects/fake_model.model')
        compoundModel.node(TankPartNames.GUN).attach(
            fakeDict[TankPartNames.GUN + 'Root'])
        fakeDict[TankPartNames.GUN] = BigWorld.Model(
            'objects/fake_model.model')
        if fakeMotorDict.get(TankPartNames.GUN) not in tuple(
                fakeDict[TankPartNames.GUN].motors):
            fakeMotorDict[TankPartNames.GUN] = BigWorld.Servo(
                fakeDict[TankPartNames.GUN + 'Root'].matrix)
            fakeDict[TankPartNames.GUN].addMotor(
                fakeMotorDict[TankPartNames.GUN])
        if fakeDict[TankPartNames.GUN] not in tuple(BigWorld.models()):
            BigWorld.addModel(fakeDict[TankPartNames.GUN])
        fakeDict[TankPartNames.TURRET] = BigWorld.Model(
            'objects/fake_model.model')
        fakeDict[TankPartNames.TURRET +
                 'Root'] = BigWorld.Model('objects/fake_model.model')
        fakeDict[TankPartNames.TURRET +
                 'RootRoot'] = BigWorld.Model('objects/fake_model.model')
        hull_bbox_min, hull_bbox_max, _ = vDesc.hull.hitTester.bbox
        turret_pos_on_hull = vDesc.hull.turretPositions[0]
        turret_bbox_max = vDesc.turret.hitTester.bbox[1]
        gun_pos_on_turret = vDesc.turret.gunPosition
        gun_pos_on_hull = gun_pos_on_turret + turret_pos_on_hull
        gun_bbox_max = vDesc.gun.hitTester.bbox[1]
        if hull_bbox_max.y >= turret_pos_on_hull.y + turret_bbox_max.y:
            observer_pos = Math.Vector3(0, hull_bbox_max.y, 0)
            node = TankPartNames.HULL
        elif gun_pos_on_turret.y + gun_bbox_max.y >= turret_bbox_max.y:
            observer_pos = Math.Vector3(0, gun_bbox_max.y, 0)
            node = TankPartNames.GUN
        else:
            observer_pos = Math.Vector3(0, turret_bbox_max.y, 0)
            node = TankPartNames.TURRET
        mat = Math.Matrix()
        mat.setTranslate(observer_pos)
        compoundModel.node(node).attach(fakeDict[TankPartNames.TURRET +
                                                 'RootRoot'])
        if fakeMotorDict.get(TankPartNames.TURRET + 'Root') not in tuple(
                fakeDict[TankPartNames.TURRET + 'Root'].motors):
            fakeMotorDict[TankPartNames.TURRET + 'Root'] = BigWorld.Servo(
                fakeDict[TankPartNames.TURRET + 'RootRoot'].matrix)
            fakeDict[TankPartNames.TURRET + 'Root'].addMotor(
                fakeMotorDict[TankPartNames.TURRET + 'Root'])
        if fakeDict[TankPartNames.TURRET + 'Root'] not in tuple(
                BigWorld.models()):
            BigWorld.addModel(fakeDict[TankPartNames.TURRET + 'Root'])
        fakeDict[TankPartNames.TURRET + 'Root'].node('', mat).attach(
            fakeDict[TankPartNames.TURRET])

        hullLocalCenterY = (hull_bbox_min.y + hull_bbox_max.y) / 2.0
        hullLocalCenterZ = (hull_bbox_min.z + hull_bbox_max.z) / 2.0
        nodes = {
            'hullLocalPt1':
            Math.Vector3(0.0, hullLocalCenterY, hull_bbox_max.z),
            'hullLocalPt2':
            Math.Vector3(0.0, hullLocalCenterY, hull_bbox_min.z),
            'hullLocalPt3':
            Math.Vector3(hull_bbox_max.x, gun_pos_on_hull.y, hullLocalCenterZ),
            'hullLocalPt4':
            Math.Vector3(hull_bbox_min.x, gun_pos_on_hull.y, hullLocalCenterZ),
            'hullGunLocal':
            gun_pos_on_hull
        }
        for node in nodes:
            fakeDict[node] = BigWorld.Model('objects/fake_model.model')
            fakeDict[TankPartNames.HULL].node(
                '', math_utils.createTranslationMatrix(nodes[node])).attach(
                    fakeDict[node])

        lightDBDict.setdefault(vehicleID, {})
        for configDict in _config.configsDict.values():
            for name in sorted(configDict.keys()):
                try:
                    if name in ('enable', 'meta', 'attachToPlayer',
                                'attachToAlly', 'attachToEnemy'):
                        continue
                    confDict = configDict[name]
                    needToAttach = \
                        confDict['attachToPlayer'] and vehicleID == BigWorld.player().playerVehicleID or \
                        confDict['attachToEnemy'] and vehicle['team'] != BigWorld.player().team or \
                        confDict['attachToAlly'] and vehicleID != BigWorld.player().playerVehicleID and \
                        vehicle['team'] == BigWorld.player().team
                    if not needToAttach:
                        continue
                    nodeL = []
                    if '.' in name:
                        nodeL.append(confDict['place'])
                    elif confDict['place'] == 'leftFront':
                        nodeL.append(TankNodeNames.TRACK_LEFT_UP_FRONT)
                    elif confDict['place'] == 'rightFront':
                        nodeL.append(TankNodeNames.TRACK_RIGHT_UP_FRONT)
                    elif confDict['place'] == 'leftRear':
                        nodeL.append(TankNodeNames.TRACK_LEFT_UP_REAR)
                    elif confDict['place'] == 'rightRear':
                        nodeL.append(TankNodeNames.TRACK_RIGHT_UP_REAR)
                    elif confDict['place'] == 'hull':
                        nodeL.append(TankPartNames.HULL)
                    elif confDict['place'] == 'turret':
                        nodeL.append(TankPartNames.TURRET)
                    elif confDict['place'] == 'spot':
                        nodeL.extend([TankPartNames.TURRET, TankPartNames.GUN])
                        nodeL.extend(
                            ['hullLocalPt%s' % num for num in xrange(1, 5)])
                        nodeL.append('hullGunLocal')
                    elif 'wheels' in confDict['place']:
                        if 'left' in confDict['place']:
                            nodeL.extend(nodeListNL)
                        else:
                            nodeL.extend(nodeListNR)

                    nameTree = name.split('.')[:-1]
                    namesList = []
                    for curKey in lightDBDict[vehicleID].keys():
                        curTree = curKey.split('.')
                        if len(curTree) != len(nameTree) or any(
                                upperName not in curTree[depth]
                                for depth, upperName in enumerate(nameTree)):
                            continue
                        namesList.append(curKey + '.' + name.split('.')[-1])
                    if not namesList:
                        namesList = [name]
                    for fullName in namesList:
                        for node in nodeL:
                            curName = fullName + ':' + node
                            if 'model' not in confDict['type']:
                                if confDict['type'] == 'spotLight':
                                    LightSource = BigWorld.PySpotLight()
                                    LightSource.coneAngle = confDict['ca']
                                else:
                                    LightSource = BigWorld.PyOmniLight()
                                    if confDict['type'] != 'omniLight':
                                        LOG_ERROR(
                                            'Unknown type of %s: %s. Set to omniLight'
                                            % (name, confDict['type']))
                                LightSource.innerRadius = confDict[
                                    'innerRadius']
                                LightSource.outerRadius = confDict[
                                    'outerRadius']
                                LightSource.castShadows = confDict['cs']
                                LightSource.multiplier = confDict['bright']
                                if isinstance(confDict['colour'][0], tuple):
                                    if confDict['type'] != 'spotLight':
                                        FrontLightShader = Math.Vector4Animation(
                                        )
                                        FrontLightShader.duration = confDict[
                                            'dur']
                                        FrontLightShader.keyframes = confDict[
                                            'colour']
                                        LightSource.colorAnimator = FrontLightShader
                                    else:
                                        LightSource.colour = confDict[
                                            'colour'][0][1]
                                else:
                                    LightSource.colour = confDict['colour']
                            else:
                                LightSource = BigWorld.Model(confDict['path'])
                            if '.' not in name:
                                if node in fakeDict:
                                    fakeNode = fakeDict[node].node(
                                        '', computeTransform(confDict))
                            else:
                                if curName not in fakeDict:
                                    fakeDict[curName] = BigWorld.Model(
                                        'objects/fake_model.model')
                                    lightDBDict[vehicleID][curName.rsplit(
                                        '.', 1)[0]].node(node).attach(
                                            fakeDict[curName])
                                fakeNode = fakeDict[curName].node(
                                    '', computeTransform(confDict))
                            if 'model' not in confDict['type']:
                                # noinspection PyUnboundLocalVariable
                                LightSource.source = fakeNode
                            elif not LightSource.attached:
                                fakeNode.attach(LightSource)
                            lightVisible(
                                LightSource, _config.isLampsVisible
                                and name in _config.modes['constant'])
                            lightDBDict[vehicleID][curName] = LightSource

                except StandardError:
                    traceback.print_exc()
                    print name
                    print callPlace
                    print vDesc.name

    except StandardError:
        traceback.print_exc()
        print callPlace
Example #21
0
 def hideMarker(self):
     global marker
     if self.__model in BigWorld.models():
         self.__model.delMotor(self.__motor)
         BigWorld.delModel(self.__model)