def beginPlasmaWarp(target): global warpEffects allFinished = 1 for finished, i, s, t in warpEffects: if not finished: allFinished = 0 if allFinished: warpEffects = [] ps = Pixie.create('particles/plasma_suck.xml') try: target.node('biped Head').attach(ps) except: target.root.attach(ps) m = target.root m2 = Matrix() m2.setScale((1, 1, 1)) m2.postMultiply(m) v1 = Vector4(3.0, -100000, 0, 0) v2 = Vector4(0.0, 0, 0, 0) v = Vector4Animation() v.keyframes = [(0, v2), (3, v1)] v.duration = 1000000 v.time = 0 warpEffects.append([0, v, ps, target]) try: BigWorld.addWarp(100000, m2, v) except: pass return len(warpEffects) - 1
def __init__(self, exhaustEffectsDescriptor, drawOrder, uniqueEffects = None): if uniqueEffects is None: self.__uniqueEffects = {} else: self.__uniqueEffects = {name:effect.clone() for name, effect in uniqueEffects.iteritems()} self.__tables = [] self.__maxDrawOrder = drawOrder - 1 for rangeTable in exhaustEffectsDescriptor.tables: effectsValues = [] for name in rangeTable.values: effect = self.__uniqueEffects.get(name) if effect is None: effect = Pixie.create(name) self.__maxDrawOrder += 1 effect.drawOrder = self.__maxDrawOrder self.__uniqueEffects[name] = effect effectsValues.append(effect) self.__tables.append(RangeTable(rangeTable.keys, effectsValues)) if self.__maxDrawOrder < drawOrder: self.__maxDrawOrder = drawOrder self.__activeEffect = None for effect in self.__uniqueEffects.itervalues(): enablePixie(effect, False)
def setupTank(chassisFashion, gunFashion, vehicleDesc, worldMatrix, resources): print resources tank = resources[vehicleDesc.name] tank.matrix = worldMatrix tanks.append(tank) effect = Pixie.create('particles/Tank/exhaust/large_gas_gear.xml') tank.node('HP_gunFire').attach(effect) tank.node('HP_gunFire').attach( BigWorld.Model('helpers/models/position_gizmo.model')) tank.node('HP_Track_Exhaus_1').attach( BigWorld.Model('helpers/models/unit_cube.model')) m = mathUtils.createTranslationMatrix(Vector3(0, 10, 5)) fakeMatrixes.append(m) tank.node('gun').attach(effect.clone(), m) BigWorld.addModel(tank) recoilDescr = vehicleDesc.gun['recoil'] recoil = BigWorld.RecoilAnimator(recoilDescr['backoffTime'], recoilDescr['returnTime'], recoilDescr['amplitude'], recoilDescr['lodDist']) recoil.basisMatrix = tank.node('G').localMatrix recoil = assemblerModule.createGunAnimator(vehicleDesc, tank.node('G').localMatrix) recoil.lodSetting = 10 tank.node('G', recoil) gunFashion.gunLocalMatrix = recoil recoil.lodLink = DataLinks.createFloatLink(chassisFashion, 'lastLod') swingingAnimator = assemblerModule.createSwingingAnimator( vehicleDesc, tank.node('hull').localMatrix, worldMatrix) chassisFashion.setupSwinging(swingingAnimator, 'hull') swingingAnimator.lodLink = DataLinks.createFloatLink( chassisFashion, 'lastLod') tank.setupFashions([chassisFashion, None, None, gunFashion]) fashions.append(swingingAnimator) tank.node('hull', swingingAnimator) animMatrix = Math.MatrixAnimation() keys = [] for x in xrange(100): angle = math.pi * 0.5 * (1 if x & 1 else -1) keys.append((x * 3, mathUtils.createRotationMatrix((angle, 0, 0)))) animMatrix.keyframes = tuple(keys) tank.node('turret', animMatrix) return
def __createTrailParticlesIfNeeded(self, node, iTrack, effectGroup, effectIndex, drawOrder, isActiveNode): if effectIndex is None: return else: effectDesc = self.__vehicle.typeDescriptor.chassis['effects'].get(effectGroup) if effectDesc is None: return effectName = effectDesc[0].get(effectIndex) if effectName is None or effectName == 'none' or effectName == 'None': return if isinstance(effectName, list): effectIdx = iTrack effectIdx += 0 if isActiveNode else 2 effectName = effectName[effectIdx] nodeEffects = self.__trailParticles.get(node) if nodeEffects is None: nodeEffects = [] self.__trailParticles[node] = nodeEffects else: for nodeEffect in nodeEffects: createdForActiveNode = nodeEffect[5] if nodeEffect[1] == effectIndex and createdForActiveNode == isActiveNode: return pixie = Pixie.create(effectName) pixie.drawOrder = drawOrder node.attach(pixie) basicRates = [] for i in xrange(pixie.nSystems()): try: source = pixie.system(i).action(1) basicRates.append(source.rate) source.rate = source.rate * 0.001 except: basicRates.append(-1.0) source = pixie.system(i).action(16) source.MultRate(0.01) nodeEffects.append([pixie, effectIndex, 0, 0, basicRates, isActiveNode]) return
def __init__(self, vehicleTypeDescriptor): self.__enabled = True self.__exhaust = [] exhaust = vehicleTypeDescriptor.hull['exhaust'] engineTags = vehicleTypeDescriptor.engine['tags'] pixieName = None for tag in engineTags: pixieName = exhaust.get('pixie/' + tag, pixieName) rates = exhaust['rates'] for i in xrange(len(exhaust['nodes'])): pixie = Pixie.create(pixieName) pixie.drawOrder = 50 + i self.__exhaust.append([None, pixie]) for i in xrange(pixie.nSystems()): source = pixie.system(i).action(1) source.rate = rates[0] return
def load(self, pSection, prereqs = None): """ This method loads the ParticleSystem Actor from a data section. The the particle system resource ID is read from the section name. It is recommended to call this method with prerequisites passed in, as even if the textures referred to by the particle system are already in memory, a PyMetaParticleSystem can still take a significant time to construct. """ try: actor = prereqs.pop(pSection.asString) except: try: actor = Pixie.create(pSection.asString) except: ERROR_MSG('Could not create particle system', pSection.asString) actor = None return actor
def plasmaExplode(owner, targetModel, delTargetModel): m = BigWorld.Model('objects/models/fx/03_pchangs/shockwave.model') targetModel.root.attach(m) m.Go() BigWorld.callback(1.0, partial(targetModel.root.detach, m)) m = targetModel.root m2 = Matrix() m2.setScale((5, 5, 5)) m2.postMultiply(m) v1 = Vector4(1.0, 100000, 0, 0) v2 = Vector4(0.0, 0, 0, 0) v = Vector4Animation() v.keyframes = [(0, v1), (0.5, v2)] v.duration = 1 v.time = 0 try: BigWorld.addWarp(0.5, m2, v) except: pass shake(targetModel) ps2 = Pixie.create('particles/plasma_blow.xml') targetModel.root.attach(ps2) ps2.system(0).actions[0].force(1) BigWorld.callback(5.0, partial(targetModel.root.detach, ps2)) if delTargetModel: BigWorld.callback(5.0, partial(owner.delModel, targetModel)) if BigWorld.player().flashBangCount == 0: fba = Vector4Animation() fba.keyframes = [(0, Vector4(0, 0, 0, 0)), (0.1, Vector4(0.1, 0.1, 0.2, 0.5)), (0.3, Vector4(0, 0, 0, 0))] fba.duration = 0.3 try: BigWorld.flashBangAnimation(fba) except: pass BigWorld.callback(fba.duration, partial(BigWorld.flashBangAnimation, None)) return
def setupTank(chassisFashion, gunFashion, vehicleDesc, worldMatrix, resources): print resources tank = resources[vehicleDesc.name] tank.matrix = worldMatrix tanks.append(tank) effect = Pixie.create('particles/Tank/exhaust/large_gas_gear.xml') tank.node('HP_gunFire').attach(effect) tank.node('HP_gunFire').attach(BigWorld.Model('helpers/models/position_gizmo.model')) tank.node('HP_Track_Exhaus_1').attach(BigWorld.Model('helpers/models/unit_cube.model')) m = mathUtils.createTranslationMatrix(Vector3(0, 10, 5)) fakeMatrixes.append(m) tank.node('gun').attach(effect.clone(), m) BigWorld.addModel(tank) recoilDescr = vehicleDesc.gun['recoil'] recoil = BigWorld.RecoilAnimator(recoilDescr['backoffTime'], recoilDescr['returnTime'], recoilDescr['amplitude'], recoilDescr['lodDist']) recoil.basisMatrix = tank.node('G').localMatrix recoil = assemblerModule.createGunAnimator(vehicleDesc, tank.node('G').localMatrix) recoil.lodSetting = 10 tank.node('G', recoil) gunFashion.gunLocalMatrix = recoil recoil.lodLink = DataLinks.createFloatLink(chassisFashion, 'lastLod') swingingAnimator = assemblerModule.createSwingingAnimator(vehicleDesc, tank.node('hull').localMatrix, worldMatrix) chassisFashion.setupSwinging(swingingAnimator, 'hull') swingingAnimator.lodLink = DataLinks.createFloatLink(chassisFashion, 'lastLod') tank.setupFashions([chassisFashion, None, None, gunFashion]) fashions.append(swingingAnimator) tank.node('hull', swingingAnimator) animMatrix = Math.MatrixAnimation() keys = [] for x in xrange(100): angle = math.pi * 0.5 * (1 if x & 1 else -1) keys.append((x * 3, mathUtils.createRotationMatrix((angle, 0, 0)))) animMatrix.keyframes = tuple(keys) tank.node('turret', animMatrix) return
def onEnterWorld( self, prereqs ): Avatar.onEnterWorld( self, prereqs ) # Set the position/movement filter to correspond to an player avatar self.filter = BigWorld.PlayerAvatarFilter() # Setup the physics for the Avatar self.physics = BigWorld.STANDARD_PHYSICS self.physics.velocityMouse = "Direction" self.physics.oldStyleCollision = True self.physics.collide = True self.physics.collideTerrain = True self.physics.collideObjects = True self.physics.fall = True # Spawn self.spawnAtRandomLocation() # Dust particles self.dustTrail = Pixie.create ("particles/dust_trail.xml") self.attachDustTrail()