def setupSplineTracks(fashion, vDesc, chassisModel, prereqs): splineDesc = vDesc.chassis.splineDesc resultTracks = None if splineDesc is not None: leftSpline = None rightSpline = None segmentModelLeft = segmentModelRight = segment2ModelLeft = segment2ModelRight = None modelName = splineDesc.segmentModelLeft try: segmentModelLeft = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment model <%s>" % modelName) modelName = splineDesc.segmentModelRight try: segmentModelRight = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment model <%s>" % modelName) modelName = splineDesc.segment2ModelLeft if modelName is not None: try: segment2ModelLeft = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment 2 model <%s>" % modelName) modelName = splineDesc.segment2ModelRight if modelName is not None: try: segment2ModelRight = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment 2 model <%s>" % modelName) if segmentModelLeft is not None and segmentModelRight is not None: identityMatrix = Math.Matrix() identityMatrix.setIdentity() if splineDesc.leftDesc is not None: leftSpline = BigWorld.wg_createSplineTrack( fashion, chassisModel, splineDesc.leftDesc, splineDesc.segmentLength, segmentModelLeft, splineDesc.segmentOffset, segment2ModelLeft, splineDesc.segment2Offset, _ROOT_NODE_NAME, splineDesc.atlasUTiles, splineDesc.atlasVTiles) if splineDesc.rightDesc is not None: rightSpline = BigWorld.wg_createSplineTrack( fashion, chassisModel, splineDesc.rightDesc, splineDesc.segmentLength, segmentModelRight, splineDesc.segmentOffset, segment2ModelRight, splineDesc.segment2Offset, _ROOT_NODE_NAME, splineDesc.atlasUTiles, splineDesc.atlasVTiles) fashion.setSplineTrack(leftSpline, rightSpline) resultTracks = SplineTracks(leftSpline, rightSpline) return resultTracks
def _onVisibleChange(self, visible): if visible: if self._context.curTimeAction: parentQueue = CompoundSystem.getModelAction(self._context.cidProxy.handle, self.id, self.animtionNames[0])() for animName in self.animtionNames[1:]: try: parentQueue = parentQueue.action(animName)() except ValueError: debug_utils.LOG_ERROR('Animation %s not found for model %s' % (animName, self.mainModel.modelName)) elif CompoundSystem.getModelAction(self._context.cidProxy.handle, self.id, self.animtionNames[-1])() is None: debug_utils.LOG_ERROR('Animation %s not found for model %s' % self.animtionNames[-1]) return
def setupSplineTracks(fashion, vDesc, chassisModel, prereqs, modelsSet): splineDesc = vDesc.chassis.splineDesc resultTracks = None if splineDesc is not None: leftSpline = [] rightSpline = [] segmentModelLeft = segmentModelRight = segment2ModelLeft = segment2ModelRight = None modelName = splineDesc.segmentModelLeft(modelsSet) try: segmentModelLeft = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment model '%s'" % modelName) modelName = splineDesc.segmentModelRight(modelsSet) try: segmentModelRight = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment model '%s'" % modelName) modelName = splineDesc.segment2ModelLeft(modelsSet) if modelName is not None: try: segment2ModelLeft = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment 2 model '%s'" % modelName) modelName = splineDesc.segment2ModelRight(modelsSet) if modelName is not None: try: segment2ModelRight = prereqs[modelName] except Exception: debug_utils.LOG_ERROR("can't load track segment 2 model '%s'" % modelName) if segmentModelLeft is not None and segmentModelRight is not None: identityMatrix = Math.Matrix() identityMatrix.setIdentity() for desc in splineDesc.leftDesc: track = BigWorld.wg_createSplineTrack(chassisModel, desc[0], desc[1], desc[2], segmentModelLeft, desc[3], segment2ModelLeft, desc[4], _ROOT_NODE_NAME, splineDesc.atlasUTiles, splineDesc.atlasVTiles) if track is not None: leftSpline.append(track) for desc in splineDesc.rightDesc: track = BigWorld.wg_createSplineTrack(chassisModel, desc[0], desc[1], desc[2], segmentModelRight, desc[3], segment2ModelRight, desc[4], _ROOT_NODE_NAME, splineDesc.atlasUTiles, splineDesc.atlasVTiles) if track is not None: rightSpline.append(track) if len(leftSpline) != len(rightSpline) or not leftSpline: return fashion.setSplineTracks(leftSpline + rightSpline) resultTracks = SplineTracks(leftSpline, rightSpline) return resultTracks
def addEffect(self, path, visibleCondition, name, timed, delayRange = None): variant = 'OWN' if self.__context.isPlayer else 'OTHER' effectDB = db.DBLogic.g_instance.getEffectDataVariant(Effects.getEffectId(name), variant) if effectDB: effectType = effectDB['type'] nodeId = self.__rootNode.resolvePath(convertPath(path)).id sound = None if 'SoundEffectID' in effectDB: sound = [nodeId, effectDB['SoundEffectID'], None] if effectType == 'Loft' or effectType == 'Jet': effectObject = LoftEffectObject(self.__context, len(self.__loftList), sound) self.__boolCombiner.addObject(visibleCondition, effectObject.onVisibleChange) self.addLoftToList(nodeId, effectObject.isVisible, effectDB, name) self.__registerDrawObj(effectObject) elif effectType == 'TimedParticle' or effectType == 'LoopParticle' or effectType == 'TrailParticle': resourceName = effectDB.get('particleFile', None) if resourceName: objId = len(self.__particleList) if timed or effectType == 'TimedParticle': effectObject = TimeEffectObject(self.__context, objId, sound) elif effectType == 'TrailParticle': effectObject = TrailEffectObject(self.__context, objId, sound) else: effectObject = EffectObject(self.__context, objId, sound) effectObject.instantHide = effectDB.get('instantHide', False) self.__boolCombiner.addObject(visibleCondition, effectObject.onVisibleChange) self.addParticleToList(nodeId, effectObject.isVisible, resourceName, name) self.__registerDrawObj(effectObject) else: debug_utils.LOG_ERROR("Can't create effect {0}. Unsupported type {1} for compound model".format(Effects.getEffectId(name), effectType)) else: debug_utils.LOG_WARNING_DEBUG("Can't create effect {0}".format(Effects.getEffectId(name))) return
def unloadActiveMovie(self): self.unloadSubMovie() if self.__activeMovie is not None: activeMovieClassName = self.__activeMovie.className self.__prevActiveMovieClassName = activeMovieClassName debug_utils.LOG_DEBUG( 'unloadActiveMovie={0}'.format(activeMovieClassName), self.__activeMovie, self._initializeCalled) test = weakref.ref(self.__activeMovie) if self._initializeCalled: self._initializeCalled = False self.__activeMovie.call_1('dispose') self.__activeMovie.dispossessUI() self.__activeMovie.close() self.__activeMovie = None if test() is not None: import gc debug_utils.LOG_DEBUG('Screen referrers: ', gc.get_referrers(test())) if IS_DEVELOPMENT: import pprint pprint.pprint(gc.garbage) debug_utils.CRITICAL_ERROR( 'unloadActiveMovie: Screen {0} has refs'.format( activeMovieClassName)) else: debug_utils.LOG_ERROR( 'unloadActiveMovie: Screen {0} has refs'.format( activeMovieClassName)) if IS_DEVELOPMENT: callbacks = BigWorld.getCallbacks() if callbacks: debug_utils.LOG_WARNING( "don't canceled callbacks: {0}".format(callbacks)) return
def getDefaultCallbacks(ifaceName, lobby, data): from exchangeapi.IfaceUtils import IfaceNotFound try: return filter(None, [getIface(ifaceName).defaultCallback]) except IfaceNotFound as msg: debug_utils.LOG_ERROR(msg) return []
def onVisibleChange(self, visible): self.__visible = visible if not CompoundSystem.isHandleValid(self._context.cidProxy.handle): if self._context.cidProxy.handle != INVALID_ID: debug_utils.LOG_ERROR('Handle is not valid for object') return if self._context.isLoaded: self._onVisibleChange(visible)
def addController(self, path, controllerName): node = self.__rootNode.resolvePath(convertPath(path)) controller = self.__animationController.getController(controllerName) if controller: matrixProvider = controller.matrixProvider self.__matrixProviderList.append((node.id, matrixProvider)) else: debug_utils.LOG_ERROR("Unregistered animation controller '%s' for %s" % (controllerName, self.__context.objDBData.name)) return controller
def loadSubMovie(self, className): Class = self.__idict.get(className, None) if Class is not None: if className == main_interfaces.GUI_SCREEN_OPTIONS: movie = Class() self.__activeMovie.proxifyMovie(movie) else: debug_utils.LOG_ERROR('Cannot attach to movie: ', className) return
def syncHpMap(modelName, allnodes = False): import ResMgr visualName = _getVisualName(modelName) xml = ResMgr.openSection(visualName, False) hpMap = dict() if xml is not None: _loadVisual(xml, hpMap, None, allnodes) else: debug_utils.LOG_ERROR("Can't load visual file{0}".format(visualName)) ResMgr.purge(visualName) return hpMap
def loadMovie(self, className): self.unloadActiveMovie() Class = self.__idict.get(className, None) if Class is not None and (self.__activeMovie is None or not isinstance(self.__activeMovie, Class)): self.__activeMovie = Class() self.__activeMovie.addExternalCallbacks( {'initialized': self.__initialized}) self.__activeMovie.className = className self.__activeMovie.active(True) debug_utils.LOG_DEBUG('loadMovie=%s, %s' % (className, self.__activeMovie)) else: debug_utils.LOG_ERROR('Cannot load movie: ', className) return
def setDecalsByIds(self, camouflageID, decalIDs): """init decals and camouflage""" surfaceSettings = self.__visualSettings.surfaceSettings if surfaceSettings: detail = surfaceSettings.detailTexture if detail != '': decalGroups = surfaceSettings.decalsSettings.decalGroups camouflageTexture = decalGroups['camouflage'].getDecalTexNameByID(camouflageID) selfShadow = '' glossinessOffset = 0.0 bottomColor = Math.Vector4(1, 1, 1, 1) reflectionColor = Math.Vector4(1, 1, 1, 1) camouflageMask = '' camouflageStub = Math.Vector4(0, 0, 0, 0) camouflageNeutral = Math.Vector4(0, 0, 0, 0) camouflageAllied = Math.Vector4(0, 0, 0, 0) camouflageHostile = Math.Vector4(0, 0, 0, 0) camuflageSettings = decalGroups['camouflage'].getDecal(camouflageID) if camuflageSettings is not None: if hasattr(camuflageSettings, 'glossinessOffset'): glossinessOffset = camuflageSettings.glossinessOffset if hasattr(camuflageSettings, 'bottomColor'): bottomColor = camuflageSettings.bottomColor if hasattr(camuflageSettings, 'camouflageMask'): camouflageMask = camuflageSettings.camouflageMask if hasattr(camuflageSettings, 'camouflageNeutral'): camouflageNeutral = camuflageSettings.camouflageNeutral if hasattr(camuflageSettings, 'camouflageAllied'): camouflageAllied = camuflageSettings.camouflageAllied if hasattr(camuflageSettings, 'camouflageHostile'): camouflageHostile = camuflageSettings.camouflageHostile if hasattr(camuflageSettings, 'reflectionColor'): reflectionColor = camuflageSettings.reflectionColor debug_utils.LOG_TRACE('ModelManipulator: setDecalsByIds', decalIDs) decals = [] if len(decalIDs) < clientConsts.DECAL_NUM_MIN: debug_utils.LOG_ERROR("Can't set decals: wrong decal list size!") else: if not consts.IS_EDITOR and clientConsts.ENABLE_PLANE_CLAN_EMBLEM: import BWPersonality env = GameEnvironment.getClientArena() allowBGLoading = False if env and env.isLoaded() else True if env: avatarInfo = env.getAvatarInfo(self.__context.entityId) clanDBID = avatarInfo.get('clanDBID') if clanDBID and int(clanDBID) > 0: ClanEmblemsCache.g_clanEmblemsCache.get(clanDBID, self.__updateClanEmblemClbk, not allowBGLoading) elif int(BWPersonality.g_initPlayerInfo.clanDBID) > 0: ClanEmblemsCache.g_clanEmblemsCache.get(BWPersonality.g_initPlayerInfo.clanDBID, self.__updateClanEmblemClbk, not allowBGLoading) specialNationalityDecalId = decalIDs[10] if len(decalIDs) > 10 else -1 clanBigId = 0 clanSmallId = 0 if specialNationalityDecalId == 0: clanBigId = clientConsts.DECAL_DEFAULT_VALUE[0] clanSmallId = clientConsts.DECAL_DEFAULT_VALUE[1] elif specialNationalityDecalId > 0: clanBigId = specialNationalityDecalId clanSmallId = specialNationalityDecalId decals.append(decalGroups['clan_big'].getDecalTexNameByID(clanBigId) if clanBigId > 0 else '') decals.append(decalGroups['clan_small'].getDecalTexNameByID(clanSmallId) if clanSmallId > 0 else '') if self.__clanEmblemFileNameCached: decals.append(self.__clanEmblemFileNameCached) else: decals.append('') decals.append(decalGroups['platoon_number'].getDecalTexNameByID(decalIDs[3]) if decalIDs[3] != clientConsts.DECAL_ISNT_EXIST_VALUE[3] else '') decals.append(decalGroups['member_number'].getDecalTexNameByID(decalIDs[4]) if decalIDs[4] != clientConsts.DECAL_ISNT_EXIST_VALUE[4] else '') decals.append(decalGroups['air_frags'].getDecalTexNameByID(decalIDs[5][0]) if decalIDs[5][0] != clientConsts.DECAL_ISNT_EXIST_VALUE[5] else '') decals.append(decalGroups['ground_frags'].getDecalTexNameByID(decalIDs[5][1]) if decalIDs[5][1] != clientConsts.DECAL_ISNT_EXIST_VALUE[5] else '') decals.append('') decals.append(decalGroups['nose'].getDecalTexNameByID(decalIDs[6]) if decalIDs[6] != clientConsts.DECAL_ISNT_EXIST_VALUE[6] else '') decals.append(decalGroups['decor'].getDecalTexNameByID(decalIDs[7]) if decalIDs[7] != clientConsts.DECAL_ISNT_EXIST_VALUE[7] else '') self.setSurfaceParameters(glossinessOffset, bottomColor, reflectionColor, camouflageStub, camouflageAllied, camouflageHostile, camouflageNeutral) self.setSurfaceTextures(detail, camouflageTexture, selfShadow, decals, camouflageMask) else: debug_utils.LOG_WARNING('Wrong detail texture in surfaceSettings.detailTexture') else: debug_utils.LOG_WARNING('Wrong surfaceSettings') return