def prerequisites(self): if not self.modelName: return [] collisionModels = self._getCollisionModelsPrereqs() collisionAssembler = BigWorld.CollisionAssembler( collisionModels, self.spaceID) return [self.modelName, collisionAssembler]
def prerequisites(self): if self.modelName != '': bspModels = ((0, self.modelName), ) collisionAssembler = BigWorld.CollisionAssembler( bspModels, self.spaceID) return [self.modelName, collisionAssembler] return []
def prerequisites(self, typeDescriptor, vID, health=1, isCrewActive=True, isTurretDetached=False, outfitCD=''): prereqs = self.__appearance.prerequisites(typeDescriptor, vID, health, isCrewActive, isTurretDetached, outfitCD) compoundAssembler = prepareCompoundAssembler( typeDescriptor, self.__appearance.modelsSetParams, BigWorld.player().spaceID, isTurretDetached) if not isTurretDetached: bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), typeDescriptor.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), typeDescriptor.hull.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.TURRET), typeDescriptor.turret.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN), typeDescriptor.gun.hitTester.bspModelName)) else: bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), typeDescriptor.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), typeDescriptor.hull.hitTester.bspModelName)) collisionAssembler = BigWorld.CollisionAssembler( bspModels, BigWorld.player().spaceID) prereqs += [compoundAssembler, collisionAssembler] return (compoundAssembler, prereqs)
def __prepareModelAssembler(self): LOG_DEBUG('__prepareModelAssembler', self.__vehDescr.name, self.spaceID) assembler = BigWorld.CompoundAssembler(self.__vehDescr.name, self.spaceID) turretModel, gunModel = self.__getModels() assembler.addRootPart(turretModel, TankPartNames.TURRET) assembler.emplacePart(gunModel, TankNodeNames.GUN_JOINT, TankPartNames.GUN) parts = { TankPartNames.TURRET: self.__vehDescr.turret, TankPartNames.GUN: self.__vehDescr.gun } bspModels = () for partName, part in parts.iteritems(): partID = TankPartNames.getIdx(partName) crashedHT = part.hitTesterManager.crashedModelHitTester modelHT = part.hitTesterManager.modelHitTester hitTester = crashedHT if crashedHT is not None else modelHT bspModel = (partID, hitTester.bspModelName) bspModels = bspModels + (bspModel, ) collisionAssembler = BigWorld.CollisionAssembler( bspModels, self.spaceID) return [assembler, collisionAssembler]
def prerequisites(self): prereqs = super(NewYearSelectableObject, self).prerequisites() if not self.outlineModelName: collisionModels = ((0, self.modelName),) collisionAssembler = BigWorld.CollisionAssembler(collisionModels, self.spaceID) prereqs.append(collisionAssembler) return prereqs
def onAdded(self, singleCollision, go): if not singleCollision.asset: _logger.warning( 'Single Collision component with empty asset in gameObject id=%d', go.id) return collisionAssembler = BigWorld.CollisionAssembler( ((0, singleCollision.asset), ), self.spaceID) collisionAssembler.name = 'collision' BigWorld.loadResourceListBG((collisionAssembler, ), functools.partial(self.__onLoaded, go))
def __startBuild(self, vDesc, vState): self.__curBuildInd += 1 self.__vState = vState self.__resources = {} self.__vehicleStickers = None cfg = hangarCFG() if vState == 'undamaged': self.__currentEmblemsAlpha = cfg['emblems_alpha_undamaged'] self.__isVehicleDestroyed = False else: self.__currentEmblemsAlpha = cfg['emblems_alpha_damaged'] self.__isVehicleDestroyed = True self.__vDesc = vDesc resources = camouflages.getCamoPrereqs(self.__outfit, vDesc) splineDesc = vDesc.chassis.splineDesc if splineDesc is not None: resources.append(splineDesc.segmentModelLeft) resources.append(splineDesc.segmentModelRight) if splineDesc.leftDesc is not None: resources.append(splineDesc.leftDesc) if splineDesc.rightDesc is not None: resources.append(splineDesc.rightDesc) if splineDesc.segment2ModelLeft is not None: resources.append(splineDesc.segment2ModelLeft) if splineDesc.segment2ModelRight is not None: resources.append(splineDesc.segment2ModelRight) from vehicle_systems import model_assembler resources.append(model_assembler.prepareCompoundAssembler(self.__vDesc, ModelsSetParams(self.__outfit.modelsSet, self.__vState), self.__spaceId)) g_eventBus.handleEvent(CameraRelatedEvents(CameraRelatedEvents.VEHICLE_LOADING, ctx={'started': True, 'vEntityId': self.__vEntity.id}), scope=EVENT_BUS_SCOPE.DEFAULT) cfg = hangarCFG() gunScale = Math.Vector3(1.0, 1.0, 1.1) capsuleScale = Math.Vector3(1.5, 1.5, 1.5) loadedGunScale = cfg.get('cam_capsule_gun_scale', gunScale) if loadedGunScale is not None: gunScale = loadedGunScale loadedCapsuleScale = cfg.get('cam_capsule_scale', capsuleScale) if loadedCapsuleScale is not None: capsuleScale = loadedCapsuleScale bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), vDesc.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), vDesc.hull.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.TURRET), vDesc.turret.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN), vDesc.gun.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN) + 1, vDesc.hull.hitTester.bspModelName, capsuleScale), (TankPartNames.getIdx(TankPartNames.GUN) + 2, vDesc.turret.hitTester.bspModelName, capsuleScale), (TankPartNames.getIdx(TankPartNames.GUN) + 3, vDesc.gun.hitTester.bspModelName, gunScale)) collisionAssembler = BigWorld.CollisionAssembler(bspModels, self.__spaceId) resources.append(collisionAssembler) physicalTracksBuilders = vDesc.chassis.physicalTracks for name, builder in physicalTracksBuilders.iteritems(): resources.append(builder.createLoader('{0}PhysicalTrack'.format(name))) BigWorld.loadResourceListBG(tuple(resources), makeCallbackWeak(self.__onResourcesLoaded, self.__curBuildInd)) return
def __prepareModelAssembler(self): assembler = BigWorld.CompoundAssembler(self.__vehDescr.name, self.spaceID) turretModel = self.__vehDescr.turret.models.exploded gunModel = self.__vehDescr.gun.models.exploded assembler.addRootPart(turretModel, TankPartNames.TURRET) assembler.emplacePart(gunModel, TankNodeNames.GUN_JOINT, TankPartNames.GUN) bspModels = ((TankPartNames.getIdx(TankPartNames.TURRET), self.__vehDescr.turret.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN), self.__vehDescr.gun.hitTester.bspModelName)) collisionAssembler = BigWorld.CollisionAssembler( bspModels, BigWorld.player().spaceID) return [assembler, collisionAssembler]
def getWholeVehModels(vDesc): nationID, vehicleTypeID = vehicles.g_list.getIDsByName(vDesc.name) vType = vehicles.g_cache.vehicle(nationID, vehicleTypeID) prereqs = set(vDesc.prerequisites()) models = set() bspModels = set() index = 0 for chassie in vType.chassis: models.add(chassie.models.undamaged) splinePairs = chassie.splineDesc.trackPairs if chassie.splineDesc else {} for splinePairDesc in splinePairs.itervalues(): if splinePairDesc is not None: models.add(splinePairDesc.segmentModelLeft()) models.add(splinePairDesc.segmentModelRight()) models.add(splinePairDesc.segment2ModelLeft()) models.add(splinePairDesc.segment2ModelRight()) bspModels.add((index, chassie.hitTester.bspModelName)) index += 1 for hull in vType.hulls: prereqs.add(hull.models.undamaged) bspModels.add((index, hull.hitTester.bspModelName)) index += 1 for turrets in vType.turrets: for turret in turrets: models.add(turret.models.undamaged) bspModels.add((index, turret.hitTester.bspModelName)) index += 1 for gun in turret.guns: models.add(gun.models.undamaged) bspModels.add((index, gun.hitTester.bspModelName)) index += 1 result = list(prereqs) for model in models: if not model: continue compoundAssembler = BigWorld.CompoundAssembler() compoundAssembler.addRootPart(model, 'root') compoundAssembler.name = model compoundAssembler.spaceID = BigWorld.player().spaceID result.append(compoundAssembler) result.append(BigWorld.CollisionAssembler(tuple(bspModels), BigWorld.player().spaceID)) return result
def prereqs(self, spaceId): visualModel = BigWorld.CompoundAssembler( self.__stateName + ASSEMBLER_NAME_SUFFIXES.VISUAL, spaceId) bspModels = [] for componentIdx, (componentId, component) in enumerate( self.__stateProperties.components.iteritems()): if componentIdx == 0: visualModel.addRootPart(component.visualModel, 'root') else: visualModel.emplacePart(component.visualModel, 'root', componentId) bspModels.append((componentIdx, component.physicsModel)) collisionAssembler = BigWorld.CollisionAssembler( tuple(bspModels), self.spaceID) collisionAssembler.name = self.__stateName + ASSEMBLER_NAME_SUFFIXES.PHYSICS return [visualModel, collisionAssembler]
def prerequisites(self, typeDescriptor, vID, health, isCrewActive, isTurretDetached, outfitCD, renderState=None): self.damageState.update(health, isCrewActive, False) self.__typeDesc = typeDescriptor self.__vID = vID self._isTurretDetached = isTurretDetached self.__outfit = self._prepareOutfit(outfitCD) if self.damageState.isCurrentModelUndamaged: self.__attachments = camouflages.getAttachments(self.outfit, self.typeDescriptor) self.__renderState = renderState prereqs = self.typeDescriptor.prerequisites(True) prereqs.extend(camouflages.getCamoPrereqs(self.outfit, self.typeDescriptor)) prereqs.extend(camouflages.getModelAnimatorsPrereqs(self.outfit, self.worldID)) prereqs.extend(camouflages.getAttachmentsAnimatorsPrereqs(self.__attachments, self.worldID)) splineDesc = self.typeDescriptor.chassis.splineDesc if splineDesc is not None: modelsSet = self.outfit.modelsSet prereqs.append(splineDesc.segmentModelLeft(modelsSet)) prereqs.append(splineDesc.segmentModelRight(modelsSet)) segment2ModelLeft = splineDesc.segment2ModelLeft(modelsSet) if segment2ModelLeft is not None: prereqs.append(segment2ModelLeft) segment2ModelRight = splineDesc.segment2ModelRight(modelsSet) if segment2ModelRight is not None: prereqs.append(segment2ModelRight) modelsSetParams = self.modelsSetParams compoundAssembler = model_assembler.prepareCompoundAssembler(self.typeDescriptor, modelsSetParams, self.worldID, self.isTurretDetached, renderState=self.renderState) prereqs.append(compoundAssembler) if renderState == RenderStates.OVERLAY_COLLISION: self.damageState.update(0, isCrewActive, False) if not isTurretDetached: bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), typeDescriptor.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), typeDescriptor.hull.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.TURRET), typeDescriptor.turret.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN), typeDescriptor.gun.hitTester.bspModelName)) else: bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), typeDescriptor.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), typeDescriptor.hull.hitTester.bspModelName)) collisionAssembler = BigWorld.CollisionAssembler(bspModels, self.worldID) prereqs.append(collisionAssembler) physicalTracksBuilders = self.typeDescriptor.chassis.physicalTracks for name, builders in physicalTracksBuilders.iteritems(): for index, builder in enumerate(builders): prereqs.append(builder.createLoader(self.worldID, '{0}{1}PhysicalTrack'.format(name, index), modelsSetParams.skin)) return prereqs
def prepareCollisionAssembler(vehicleDesc, isTurretDetached, worldID): hitTestersByPart = {TankPartNames.CHASSIS: vehicleDesc.chassis.hitTester, TankPartNames.HULL: vehicleDesc.hull.hitTester} if not isTurretDetached: hitTestersByPart[TankPartNames.TURRET] = vehicleDesc.turret.hitTester hitTestersByPart[TankPartNames.GUN] = vehicleDesc.gun.hitTester bspModels = [] for partName, hitTester in hitTestersByPart.iteritems(): partId = TankPartNames.getIdx(partName) bspModel = (partId, hitTester.bspModelName, (0.0, 0.0, 0.0)) bspModels.append(bspModel) trackPairs = vehicleDesc.chassis.trackPairs[1:] for idx, trackPair in enumerate(trackPairs): totalDefaultParts = len(TankPartNames.ALL) bspModels.append((totalDefaultParts + idx, trackPair.hitTester.bspModelName)) assembler = BigWorld.CollisionAssembler(tuple(bspModels), worldID) return assembler
def prerequisites(self, typeDescriptor, vID, health=1, isCrewActive=True, isTurretDetached=False, outfitCD=''): prereqs = self.__appearance.prerequisites(typeDescriptor, vID, health, isCrewActive, isTurretDetached, outfitCD) compoundAssembler = prepareCompoundAssembler( typeDescriptor, self.__appearance.modelsSetParams, BigWorld.player().spaceID, isTurretDetached) if not isTurretDetached: bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), typeDescriptor.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), typeDescriptor.hull.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.TURRET), typeDescriptor.turret.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.GUN), typeDescriptor.gun.hitTester.bspModelName)) else: bspModels = ((TankPartNames.getIdx(TankPartNames.CHASSIS), typeDescriptor.chassis.hitTester.bspModelName), (TankPartNames.getIdx(TankPartNames.HULL), typeDescriptor.hull.hitTester.bspModelName)) collisionAssembler = BigWorld.CollisionAssembler( bspModels, BigWorld.player().spaceID) prereqs += [compoundAssembler, collisionAssembler] physicalTracksBuilders = typeDescriptor.chassis.physicalTracks for name, builder in physicalTracksBuilders.iteritems(): prereqs.append( builder.createLoader('{0}PhysicalTrack'.format(name))) return (compoundAssembler, prereqs)
def __getWholeVehModels(self, vDesc): nationID, vehicleTypeID = vehicles.g_list.getIDsByName(vDesc.name) vType = vehicles.g_cache.vehicle(nationID, vehicleTypeID) brprereqs = set(vDesc.prerequisites(True)) bspModels = set() index = 0 for chassie in vType.chassis: brprereqs.add(chassie.models.undamaged) splineDesc = chassie.splineDesc if splineDesc is not None: brprereqs.add(splineDesc.segmentModelLeft()) brprereqs.add(splineDesc.segmentModelRight()) brprereqs.add(splineDesc.segment2ModelLeft()) brprereqs.add(splineDesc.segment2ModelRight()) bspModels.add((index, chassie.hitTester.bspModelName)) index = index + 1 for hull in vType.hulls: brprereqs.add(hull.models.undamaged) bspModels.add((index, hull.hitTester.bspModelName)) index = index + 1 for turrets in vType.turrets: for turret in turrets: brprereqs.add(turret.models.undamaged) bspModels.add((index, turret.hitTester.bspModelName)) index = index + 1 for gun in turret.guns: brprereqs.add(gun.models.undamaged) bspModels.add((index, gun.hitTester.bspModelName)) index = index + 1 brprereqs.add( BigWorld.CollisionAssembler(tuple(bspModels), BigWorld.player().spaceID)) return brprereqs
def __startBuild(self, vDesc, vState): self.__curBuildInd += 1 self.__vState = vState self.__resources = {} self.__vehicleStickers = None cfg = hangarCFG() if vState == 'undamaged': self.__currentEmblemsAlpha = cfg['emblems_alpha_undamaged'] self.__isVehicleDestroyed = False else: self.__currentEmblemsAlpha = cfg['emblems_alpha_damaged'] self.__isVehicleDestroyed = True self.__vDesc = vDesc resources = camouflages.getCamoPrereqs(self.__outfit, vDesc) if not self.__isVehicleDestroyed: self.__attachments = camouflages.getAttachments(self.__outfit, vDesc) modelsSet = self.__outfit.modelsSet splineDesc = vDesc.chassis.splineDesc if splineDesc is not None: for _, trackDesc in splineDesc.trackPairs.iteritems(): resources += trackDesc.prerequisites(modelsSet) from vehicle_systems import model_assembler resources.append(model_assembler.prepareCompoundAssembler(self.__vDesc, ModelsSetParams(modelsSet, self.__vState, self.__attachments), self.__spaceId)) g_eventBus.handleEvent(CameraRelatedEvents(CameraRelatedEvents.VEHICLE_LOADING, ctx={'started': True, 'vEntityId': self.__vEntity.id, 'intCD': self.__vDesc.type.compactDescr}), scope=EVENT_BUS_SCOPE.DEFAULT) cfg = hangarCFG() gunScale = Math.Vector3(1.0, 1.0, 1.1) capsuleScale = Math.Vector3(1.5, 1.5, 1.5) loadedGunScale = cfg.get('cam_capsule_gun_scale', gunScale) if loadedGunScale is not None: gunScale = loadedGunScale loadedCapsuleScale = cfg.get('cam_capsule_scale', capsuleScale) if loadedCapsuleScale is not None: capsuleScale = loadedCapsuleScale hitTesterManagers = {TankPartNames.CHASSIS: vDesc.chassis.hitTesterManager, TankPartNames.HULL: vDesc.hull.hitTesterManager, TankPartNames.TURRET: vDesc.turret.hitTesterManager, TankPartNames.GUN: vDesc.gun.hitTesterManager} bspModels = () crashedBspModels = () for partName, htManager in hitTesterManagers.iteritems(): partId = TankPartNames.getIdx(partName) bspModel = (partId, htManager.modelHitTester.bspModelName) bspModels = bspModels + (bspModel,) if htManager.crashedModelHitTester: crashedBspModel = (partId, htManager.crashedModelHitTester.bspModelName) crashedBspModels = crashedBspModels + (crashedBspModel,) bspModels = bspModels + ((TankPartNames.getIdx(TankPartNames.GUN) + 1, vDesc.hull.hitTesterManager.modelHitTester.bspModelName, capsuleScale), (TankPartNames.getIdx(TankPartNames.GUN) + 2, vDesc.turret.hitTesterManager.modelHitTester.bspModelName, capsuleScale), (TankPartNames.getIdx(TankPartNames.GUN) + 3, vDesc.gun.hitTesterManager.modelHitTester.bspModelName, gunScale)) if vDesc.hull.hitTesterManager.crashedModelHitTester: crashedBspModels = crashedBspModels + ((TankPartNames.getIdx(TankPartNames.GUN) + 1, vDesc.hull.hitTesterManager.crashedModelHitTester.bspModelName, capsuleScale),) if vDesc.turret.hitTesterManager.crashedModelHitTester: crashedBspModels = crashedBspModels + ((TankPartNames.getIdx(TankPartNames.GUN) + 2, vDesc.turret.hitTesterManager.crashedModelHitTester.bspModelName, capsuleScale),) if vDesc.gun.hitTesterManager.crashedModelHitTester: crashedBspModels = crashedBspModels + ((TankPartNames.getIdx(TankPartNames.GUN) + 3, vDesc.gun.hitTesterManager.crashedModelHitTester.bspModelName, gunScale),) modelCA = BigWorld.CollisionAssembler(bspModels, self.__spaceId) modelCA.name = 'ModelCollisions' resources.append(modelCA) if crashedBspModels: crashedModelCA = BigWorld.CollisionAssembler(crashedBspModels, self.__spaceId) crashedModelCA.name = 'CrashedModelCollisions' resources.append(crashedModelCA) physicalTracksBuilders = vDesc.chassis.physicalTracks for name, builders in physicalTracksBuilders.iteritems(): for index, builder in enumerate(builders): resources.append(builder.createLoader(self.__spaceId, '{0}{1}PhysicalTrack'.format(name, index), modelsSet)) BigWorld.loadResourceListBG(tuple(resources), makeCallbackWeak(self.__onResourcesLoaded, self.__curBuildInd)) return