def prepareCompoundAssembler(vehicleDesc,
                             modelsSetParams,
                             spaceID,
                             isTurretDetached=False):
    if constants.IS_DEVELOPMENT and modelsSetParams.state not in VehicleDamageState.MODEL_STATE_NAMES:
        raise SoftException(
            'Invalid modelStateName %s, must be in %s' %
            (modelsSetParams.state, VehicleDamageState.MODEL_STATE_NAMES))
    if spaceID is None:
        spaceID = BigWorld.player().spaceID
    partModels = getPartModelsFromDesc(vehicleDesc, modelsSetParams)
    chassis, hull, turret, gun = partModels
    assembler = BigWorld.CompoundAssembler()
    assembler.addRootPart(chassis, TankPartNames.CHASSIS)
    assembler.emplacePart(hull, 'V', TankPartNames.HULL)
    turretJointName = vehicleDesc.hull.turretHardPoints[0]
    assembler.addNodeAlias(turretJointName, TankNodeNames.TURRET_JOINT)
    if not isTurretDetached:
        assembler.addPart(turret, turretJointName, TankPartNames.TURRET)
        assembler.addPart(gun, TankNodeNames.GUN_JOINT, TankPartNames.GUN)
    cornerPoint = vehicleDesc.chassis.topRightCarryingPoint
    assembler.addNode(
        TankNodeNames.TRACK_LEFT_MID, TankPartNames.CHASSIS,
        mathUtils.createTranslationMatrix((-cornerPoint[0], 0, 0)))
    assembler.addNode(
        TankNodeNames.TRACK_RIGHT_MID, TankPartNames.CHASSIS,
        mathUtils.createTranslationMatrix((cornerPoint[0], 0, 0)))
    assembler.addNode(TankNodeNames.CHASSIS_MID_TRAIL, TankPartNames.CHASSIS)
    assembler.name = vehicleDesc.name
    assembler.spaceID = spaceID
    return assembler
Example #2
0
 def __setupTrackAssembler(self):
     modelNames = getPartModelsFromDesc(self.__vehicleDesc, 'destroyed')
     compoundAssembler = BigWorld.CompoundAssembler()
     compoundAssembler.addRootPart(modelNames.chassis, TankPartNames.CHASSIS, [('Tank', ''), ('V', 'Tank')], self.__entity.matrix)
     compoundAssembler.assemblerName = TankPartNames.CHASSIS
     compoundAssembler.spaceID = self.__entity.spaceID
     return compoundAssembler
Example #3
0
 def __setupTrackAssembler(self, entity):
     modelNames = getPartModelsFromDesc(self.__vehicleDesc, 'destroyed')
     compoundAssembler = BigWorld.CompoundAssembler()
     compoundAssembler.addRootPart(modelNames.chassis, TankPartNames.CHASSIS, [('Tank', ''), ('V', 'Tank')], entity.matrix)
     compoundAssembler.assemblerName = TankPartNames.CHASSIS
     compoundAssembler.spaceID = entity.spaceID
     return compoundAssembler
Example #4
0
 def __setupTrackAssembler(self, entity):
     modelNames = getPartModelsFromDesc(self.__vehicleDesc,
                                        ModelsSetParams(None, 'destroyed'))
     compoundAssembler = BigWorld.CompoundAssembler()
     compoundAssembler.addRootPart(modelNames.chassis,
                                   TankPartNames.CHASSIS,
                                   entity.filter.groundPlacingMatrix)
     compoundAssembler.assemblerName = TankPartNames.CHASSIS
     compoundAssembler.spaceID = entity.spaceID
     return compoundAssembler
Example #5
0
def attachModels(assembler, vehicleDesc, modelsSetParams, isTurretDetached, renderMode=None, overlayCollision=False):
    collisionState = renderMode in (TankRenderMode.CLIENT_COLLISION,
     TankRenderMode.SERVER_COLLISION,
     TankRenderMode.CRASH_COLLISION,
     TankRenderMode.ARMOR_WIDTH_COLLISION)
    if collisionState:
        partModels = getCollisionModelsFromDesc(vehicleDesc, renderMode)
    else:
        partModels = getPartModelsFromDesc(vehicleDesc, modelsSetParams)
    chassis, hull, turret, gun = partModels
    partNames = TankPartNames
    if overlayCollision:
        partNames = TankCollisionPartNames
    if not overlayCollision:
        assembler.addRootPart(chassis, TankPartNames.CHASSIS)
    else:
        assembler.addPart(chassis, TankPartNames.CHASSIS, TankCollisionPartNames.CHASSIS)
    if collisionState:
        trackPairs = vehicleDesc.chassis.trackPairs[1:]
        for idx, trackPair in enumerate(trackPairs):
            assembler.addPart(trackPair.hitTester.bspModelName, partNames.CHASSIS, 'trackPair' + str(idx + 1))

    if collisionState and vehicleDesc.isWheeledVehicle:
        for i, wheel in enumerate(vehicleDesc.chassis.wheels.wheels):
            bspPath = ''
            if renderMode == TankRenderMode.CLIENT_COLLISION:
                bspPath = wheel.hitTesterManager.edClientBspModel
            elif renderMode in (TankRenderMode.SERVER_COLLISION, TankRenderMode.ARMOR_WIDTH_COLLISION):
                bspPath = wheel.hitTesterManager.edServerBspModel
            if bspPath:
                assembler.addNode(wheel.nodeName, partNames.CHASSIS, math_utils.createTranslationMatrix(wheel.position))
                assembler.emplacePart(bspPath, wheel.nodeName, TankCollisionPartNames.WHEEL + str(i))

    if collisionState and not overlayCollision:
        assembler.addNode('V', TankPartNames.CHASSIS, math_utils.createTranslationMatrix(vehicleDesc.chassis.hullPosition))
    if not overlayCollision:
        assembler.emplacePart(hull, 'V', partNames.HULL)
    else:
        assembler.addPart(hull, 'V', partNames.HULL)
    turretJointName = vehicleDesc.hull.turretHardPoints[0]
    assembler.addNodeAlias(turretJointName, TankNodeNames.TURRET_JOINT)
    if not isTurretDetached:
        if collisionState and not overlayCollision:
            assembler.addNode(turretJointName, 'V', math_utils.createRTMatrix(Math.Vector3(0, vehicleDesc.hull.turretPitches[0], 0), vehicleDesc.hull.turretPositions[0]))
        assembler.addPart(turret, turretJointName, partNames.TURRET)
        if collisionState and not overlayCollision:
            assembler.addNode(TankNodeNames.GUN_JOINT, TankPartNames.TURRET, math_utils.createRTMatrix(Math.Vector3(0, vehicleDesc.turret.gunJointPitch, 0), vehicleDesc.turret.gunPosition))
        assembler.addPart(gun, TankNodeNames.GUN_JOINT, partNames.GUN)
        if modelsSetParams.state == 'undamaged':
            for attachment in modelsSetParams.attachments:
                if attachment.attachmentLogic == 'prefab':
                    continue
                assembler.addPart(attachment.modelName, attachment.attachNode, attachment.partNodeAlias, attachment.transform)
Example #6
0
 def __getModels(self):
     outfit = prepareBattleOutfit(self.outfitCD, self.__vehDescr,
                                  self.vehicleID)
     style = outfit.style
     if style is None:
         return (self.__vehDescr.turret.models.exploded,
                 self.__vehDescr.gun.models.exploded)
     else:
         modelsSetParams = ModelsSetParams(style.modelsSet,
                                           ModelStates.EXPLODED, [])
         _, _, turretModel, gunModel = getPartModelsFromDesc(
             self.__vehDescr, modelsSetParams)
         return (turretModel, gunModel)
def attachModels(assembler, vehicleDesc, modelsSetParams, isTurretDetached, renderState=None, overlayCollision=False):
    collisionState = renderState == RenderStates.CLIENT_COLLISION or renderState == RenderStates.SERVER_COLLISION
    if collisionState:
        partModels = getCollisionModelsFromDesc(vehicleDesc, renderState)
    else:
        partModels = getPartModelsFromDesc(vehicleDesc, modelsSetParams)
    chassis, hull, turret, gun = partModels
    partNames = TankPartNames
    if overlayCollision:
        partNames = TankCollisionPartNames
    if not overlayCollision:
        assembler.addRootPart(chassis, TankPartNames.CHASSIS)
    else:
        assembler.addPart(chassis, TankPartNames.CHASSIS, TankCollisionPartNames.CHASSIS)
    if collisionState and vehicleDesc.isWheeledVehicle:
        for i, wheel in enumerate(vehicleDesc.chassis.wheels.wheels):
            bspPath = ''
            if renderState == RenderStates.CLIENT_COLLISION:
                bspPath = wheel.hitTester.edClientBspModel
            elif renderState == RenderStates.SERVER_COLLISION:
                bspPath = wheel.hitTester.edServerBspModel
            if bspPath:
                assembler.addNode(wheel.nodeName, partNames.CHASSIS, math_utils.createTranslationMatrix(wheel.position))
                assembler.emplacePart(bspPath, wheel.nodeName, TankCollisionPartNames.WHEEL + str(i))

    if collisionState and not overlayCollision:
        assembler.addNode('V', TankPartNames.CHASSIS, math_utils.createTranslationMatrix(vehicleDesc.chassis.hullPosition))
    assembler.emplacePart(hull, 'V', partNames.HULL)
    turretJointName = vehicleDesc.hull.turretHardPoints[0]
    assembler.addNodeAlias(turretJointName, TankNodeNames.TURRET_JOINT)
    if not isTurretDetached:
        if collisionState and not overlayCollision:
            assembler.addNode(turretJointName, 'V', math_utils.createTranslationMatrix(vehicleDesc.hull.turretPositions[0]))
        assembler.addPart(turret, turretJointName, partNames.TURRET)
        if collisionState and not overlayCollision:
            assembler.addNode(TankNodeNames.GUN_JOINT, TankPartNames.TURRET, math_utils.createTranslationMatrix(vehicleDesc.turret.gunPosition))
        assembler.addPart(gun, TankNodeNames.GUN_JOINT, partNames.GUN)
        if modelsSetParams.state == 'undamaged':
            for attachment in modelsSetParams.attachments:
                assembler.addPart(attachment.modelName, attachment.attachNode, attachment.partNodeAlias, attachment.transform)
def prepareCompoundAssembler(vehicleDesc, modelStateName, spaceID, isTurretDetached = False):
    if constants.IS_DEVELOPMENT and modelStateName not in VehicleDamageState.MODEL_STATE_NAMES:
        raise Exception('Invalid modelStateName %s, must be in %s' % (modelStateName, VehicleDamageState.MODEL_STATE_NAMES))
    if spaceID is None:
        spaceID = BigWorld.player().spaceID
    partModels = getPartModelsFromDesc(vehicleDesc, modelStateName)
    chassis, hull, turret, gun = partModels
    assembler = BigWorld.CompoundAssembler()
    skeleton = getSkeleton(vehicleDesc, modelStateName)
    assembler.addRootPart(chassis, TankPartNames.CHASSIS, skeleton.chassis, mathUtils.createIdentityMatrix())
    assembler.emplacePart(hull, 'V', TankPartNames.HULL, skeleton.hull)
    turretJointName = vehicleDesc.hull['turretHardPoints'][0]
    assembler.renameNode(turretJointName, TankNodeNames.TURRET_JOINT)
    if not isTurretDetached:
        assembler.addPart(turret, TankNodeNames.TURRET_JOINT, TankPartNames.TURRET, skeleton.turret, mathUtils.createIdentityMatrix())
        assembler.addPart(gun, TankNodeNames.GUN_JOINT, TankPartNames.GUN, skeleton.gun, mathUtils.createIdentityMatrix())
    cornerPoint = vehicleDesc.chassis['topRightCarryingPoint']
    assembler.addDummyNode(TankPartNames.CHASSIS, TankNodeNames.TRACK_LEFT_MID, mathUtils.createTranslationMatrix((-cornerPoint[0], 0, 0)))
    assembler.addDummyNode(TankPartNames.CHASSIS, TankNodeNames.TRACK_RIGHT_MID, mathUtils.createTranslationMatrix((cornerPoint[0], 0, 0)))
    assembler.addDummyNode(TankPartNames.CHASSIS, TankNodeNames.CHASSIS_MID_TRAIL)
    assembler.assemblerName = vehicleDesc.name
    assembler.spaceID = spaceID
    return assembler
Example #9
0
def prepareCompoundAssembler(vehicleDesc,
                             modelStateName,
                             spaceID,
                             isTurretDetached=False):
    if constants.IS_DEVELOPMENT and modelStateName not in VehicleDamageState.MODEL_STATE_NAMES:
        raise Exception('Invalid modelStateName %s, must be in %s' %
                        (modelStateName, VehicleDamageState.MODEL_STATE_NAMES))
    if spaceID is None:
        spaceID = BigWorld.player().spaceID
    partModels = getPartModelsFromDesc(vehicleDesc, modelStateName)
    chassis, hull, turret, gun = partModels
    assembler = BigWorld.CompoundAssembler()
    skeleton = getSkeleton(vehicleDesc, modelStateName)
    assembler.addRootPart(chassis, TankPartNames.CHASSIS, skeleton.chassis,
                          mathUtils.createIdentityMatrix())
    assembler.emplacePart(hull, 'V', TankPartNames.HULL, skeleton.hull)
    turretJointName = vehicleDesc.hull['turretHardPoints'][0]
    assembler.renameNode(turretJointName, TankNodeNames.TURRET_JOINT)
    if not isTurretDetached:
        assembler.addPart(turret, TankNodeNames.TURRET_JOINT,
                          TankPartNames.TURRET, skeleton.turret,
                          mathUtils.createIdentityMatrix())
        assembler.addPart(gun, TankNodeNames.GUN_JOINT, TankPartNames.GUN,
                          skeleton.gun, mathUtils.createIdentityMatrix())
    cornerPoint = vehicleDesc.chassis['topRightCarryingPoint']
    assembler.addDummyNode(
        TankPartNames.CHASSIS, TankNodeNames.TRACK_LEFT_MID,
        mathUtils.createTranslationMatrix((-cornerPoint[0], 0, 0)))
    assembler.addDummyNode(
        TankPartNames.CHASSIS, TankNodeNames.TRACK_RIGHT_MID,
        mathUtils.createTranslationMatrix((cornerPoint[0], 0, 0)))
    assembler.addDummyNode(TankPartNames.CHASSIS,
                           TankNodeNames.CHASSIS_MID_TRAIL)
    assembler.assemblerName = vehicleDesc.name
    assembler.spaceID = spaceID
    return assembler