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 __updateCameraByMouseMove(self, dx, dy, dz):
     if self.__cam is not BigWorld.camera():
         return
     sourceMat = Math.Matrix(self.__cam.source)
     yaw = sourceMat.yaw
     pitch = sourceMat.pitch
     dist = self.__cam.pivotMaxDist
     currentMatrix = Math.Matrix(self.__cam.invViewMatrix)
     currentYaw = currentMatrix.yaw
     yaw = self.__yawCameraFilter.getNextYaw(currentYaw, yaw, dx)
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     pitch -= dy * cfg['cam_sens']
     dist -= dz * cfg['cam_dist_sens']
     camPitchConstr = self.__camConstraints[0]
     startPitch, endPitch = camPitchConstr
     pitch = mathUtils.clamp(math.radians(startPitch), math.radians(endPitch), pitch)
     distConstr = cfg['preview_cam_dist_constr'] if self.__selectedEmblemInfo else self.__camConstraints[2]
     minDist, maxDist = distConstr
     dist = mathUtils.clamp(minDist, maxDist, dist)
     self.__locatedOnEmbelem = False
     mat = Math.Matrix()
     mat.setRotateYPR((yaw, pitch, 0.0))
     self.__cam.source = mat
     self.__cam.pivotMaxDist = dist
     if self.settingsCore.getSetting('dynamicFov') and abs(distConstr[1] - distConstr[0]) > 0.001:
         relativeDist = (dist - distConstr[0]) / (distConstr[1] - distConstr[0])
         _, minFov, maxFov = self.settingsCore.getSetting('fov')
         fov = mathUtils.lerp(minFov, maxFov, relativeDist)
         BigWorld.callback(0, partial(FovExtended.instance().setFovByAbsoluteValue, math.radians(fov), 0.1))
 def locateCameraOnAnchor(self,
                          position,
                          normal,
                          up,
                          slotId,
                          forceRotate=False):
     if self.__hangarCameraManager is None or self.__hangarCameraManager.camera is None:
         return False
     else:
         self.__savePitch()
         self.__rotateTurretAndGun(slotId)
         if normal is not None:
             yaw, pitch = self.__getCameraYawPitch(
                 up, normal, clipCos=_PROJECTION_DECALS_DIR_CLIP_COS)
         else:
             yaw = None
             pitch = None
         distConstraints = self.__getDistConstraints(position)
         from gui.ClientHangarSpace import hangarCFG
         hangarCfg = hangarCFG()
         constraints = (hangarCfg['cam_pitch_constr'],
                        hangarCfg['cam_yaw_constr'], distConstraints)
         self._setCameraLocation(targetPos=position,
                                 pivotPos=Math.Vector3(0, 0, 0),
                                 yaw=yaw,
                                 pitch=pitch,
                                 camConstraints=constraints,
                                 forceRotate=forceRotate)
         self.__currentMode = C11nCameraModes.ANCHOR
         return True
Example #4
0
def setCameraLocation(settings):
    cfg = hangarCFG()
    dependency.instance(IHangarSpace).space.setCameraLocation(
        cfg[settings['target_pos'] + 'cam_start_target_pos'], Math.Vector3(*settings['pivot_pos']) if isinstance(
            settings['pivot_pos'], list) else cfg[settings['pivot_pos'] + 'cam_pivot_pos'],
        math.radians(settings['angles'][0]), math.radians(settings['angles'][1]), settings['dist'],
        None, True)
 def onEnterWorld(self, prereqs):
     super(ClientSelectableCameraVehicle, self).onEnterWorld(prereqs)
     cfg = hangarCFG()
     if 'shadow_model_name' in cfg:
         shadowName = cfg['shadow_model_name']
         if shadowName not in prereqs.failedIDs:
             self.__createFakeShadow(prereqs[shadowName])
Example #6
0
 def __init__(self, spaceId, vEntity):
     ComponentSystem.__init__(self)
     self.__loadState = _LoadStateNotifier()
     self.__curBuildInd = 0
     self.__vDesc = None
     self.__vState = None
     self.__fashions = VehiclePartsTuple(None, None, None, None)
     self.__repaintHandlers = [None, None, None, None]
     self.__camoHandlers = [None, None, None, None]
     self.__spaceId = spaceId
     self.__vEntity = weakref.proxy(vEntity)
     self.__onLoadedCallback = None
     self.__onLoadedAfterRefreshCallback = None
     self.__vehicleStickers = None
     self.__isVehicleDestroyed = False
     self.__outfit = None
     self.shadowManager = None
     cfg = hangarCFG()
     self.__currentEmblemsAlpha = cfg['emblems_alpha_undamaged']
     self.__showMarksOnGun = self.settingsCore.getSetting('showMarksOnGun')
     self.settingsCore.onSettingsChanged += self.__onSettingsChanged
     self.itemsCache.onSyncCompleted += self.__onItemsCacheSyncCompleted
     g_eventBus.addListener(CameraRelatedEvents.CAMERA_ENTITY_UPDATED,
                            self.__handleEntityUpdated)
     return
 def locateCameraToCustomizationPreview(self, forceLocate=False, preserveAngles=False, updateTankCentralPoint=False):
     if self.__hangarCameraManager is None or self.__hangarCameraManager.camera is None:
         return
     else:
         from gui.ClientHangarSpace import customizationHangarCFG, hangarCFG
         cfg = customizationHangarCFG()
         hangarConfig = hangarCFG()
         self.__rotateTurretAndGun()
         if self.__tankCentralPoint is None or updateTankCentralPoint:
             self.__tankCentralPoint = self.__getTankCentralPoint()
         worldPos = self.__tankCentralPoint
         if worldPos:
             pivotPos = Math.Vector3(0, 0, 0)
         else:
             worldPos = cfg['cam_start_target_pos']
             pivotPos = cfg['cam_pivot_pos']
         if preserveAngles:
             matrix = Math.Matrix(self.__hangarCameraManager.camera.invViewMatrix)
             previewYaw = matrix.yaw
             previewPitch = self.__prevPitch or 0.0
         else:
             previewYaw = math.radians(cfg['cam_start_angles'][0])
             previewPitch = math.radians(cfg['cam_start_angles'][1])
         self._setCameraLocation(targetPos=worldPos, pivotPos=pivotPos, yaw=previewYaw, pitch=previewPitch, dist=cfg['cam_start_dist'], camConstraints=[hangarConfig['cam_pitch_constr'], hangarConfig['cam_yaw_constr'], cfg['cam_dist_constr']], forceLocate=forceLocate)
         self.__currentMode = C11nCameraModes.PREVIEW
         self.enableMovementByMouse()
         self.__prevPitch = None
         return
 def locateCameraOnEmblem(self,
                          onHull,
                          emblemType,
                          emblemIdx,
                          relativeSize=0.5):
     self.__selectedEmblemInfo = (onHull, emblemType, emblemIdx,
                                  relativeSize)
     vEntity = BigWorld.entity(self.__currentEntityId)
     from HangarVehicle import HangarVehicle
     if not isinstance(vEntity, HangarVehicle):
         return False
     else:
         emblemPositionParams = vEntity.appearance.getEmblemPos(
             onHull, emblemType, emblemIdx)
         if emblemPositionParams is None:
             return False
         position = emblemPositionParams.position
         direction = emblemPositionParams.direction
         emblemPositionParams = emblemPositionParams.emblemDescription
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         emblemSize = emblemPositionParams[3] * cfg['v_scale']
         halfF = emblemSize / (2 * relativeSize)
         dist = halfF / math.tan(BigWorld.projection().fov / 2)
         self.setCameraLocation(position, Math.Vector3(0, 0,
                                                       0), direction.yaw,
                                -direction.pitch, dist, None, False)
         self.__locatedOnEmbelem = True
         return True
 def __setupCamera(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     self.__cam = BigWorld.CursorCamera()
     self.__cam.isHangar = True
     self.__cam.spaceID = self.__spaceId
     self.__cam.pivotMaxDist = mathUtils.clamp(cfg['cam_dist_constr'][0],
                                               cfg['cam_dist_constr'][1],
                                               cfg['cam_start_dist'])
     self.__cam.pivotMinDist = 0.0
     self.__cam.maxDistHalfLife = cfg['cam_fluency']
     self.__cam.turningHalfLife = cfg['cam_fluency']
     self.__cam.movementHalfLife = cfg['cam_fluency']
     self.__cam.pivotPosition = cfg['cam_pivot_pos']
     self.__camConstraints[0] = cfg['cam_pitch_constr']
     self.__camConstraints[1] = cfg['cam_yaw_constr']
     self.__camConstraints[2] = (0.0, 0.0)
     self.__yawCameraFilter = HangarCameraYawFilter(
         math.radians(cfg['cam_yaw_constr'][0]),
         math.radians(cfg['cam_yaw_constr'][1]), cfg['cam_sens'])
     self.__yawCameraFilter.setYawLimits(self.__camConstraints[1])
     mat = Math.Matrix()
     yaw = self.__yawCameraFilter.toLimit(
         math.radians(cfg['cam_start_angles'][0]))
     mat.setRotateYPR((yaw, math.radians(cfg['cam_start_angles'][1]), 0.0))
     self.__cam.source = mat
     mat = Math.Matrix()
     mat.setTranslate(cfg['cam_start_target_pos'])
     self.__cam.target = mat
     self.__cam.wg_applyParams()
     BigWorld.camera(self.__cam)
     self.__cameraIdle = HangarCameraIdle(self.__cam)
     self.__cameraParallax = HangarCameraParallax(self.__cam)
     self.__cam.setDynamicCollisions(True)
Example #10
0
 def __updateCameraByMouseMove(self, dx, dy, dz):
     if self.__cam is None:
         return
     elif self.__cam != BigWorld.camera() and not self.__handleInactiveCamera:
         return
     else:
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         self.__cam.movementMode = FAST_CAMERA_MOVEMENT_MODE
         if self.__rotationEnabled:
             sourceMat = Math.Matrix(self.__cam.source)
             yaw = sourceMat.yaw
             pitch = sourceMat.pitch
             currentMatrix = Math.Matrix(self.__cam.invViewMatrix)
             currentYaw = currentMatrix.yaw
             yaw = self.__yawCameraFilter.getNextYaw(currentYaw, yaw, dx)
             pitch -= dy * cfg['cam_sens']
             camPitchConstr = self.__camConstraints[0]
             startPitch, endPitch = camPitchConstr
             pitch = math_utils.clamp(math.radians(startPitch), math.radians(endPitch), pitch)
             mat = Math.Matrix()
             mat.setRotateYPR((yaw, pitch, 0.0))
             self.__cam.source = mat
         if self.__zoomEnabled:
             if dz < 0.0:
                 dist = self.__cam.pivotMaxDist
             else:
                 dist = self.__cam.targetMaxDist
             dist -= dz * cfg['cam_dist_sens']
             minDist, maxDist = self.__camConstraints[2]
             dist = math_utils.clamp(minDist, maxDist, dist)
             self.__cam.pivotMaxDist = dist
             self.__updateDynamicFov(dist=dist, rampTime=0.1)
         return
 def locateCameraOnDecal(self,
                         location,
                         width,
                         slotId,
                         relativeSize=0.5,
                         forceRotate=False):
     if self.__hangarCameraManager is None or self.__hangarCameraManager.camera is None:
         return False
     else:
         self.__savePitch()
         self.__rotateTurretAndGun(slotId)
         from gui.ClientHangarSpace import hangarCFG
         hangarCfg = hangarCFG()
         halfF = width / (2 * relativeSize)
         dist = halfF / math.tan(BigWorld.projection().fov * 0.5)
         distConstraints = self.__getDistConstraints(location.position)
         constraints = [
             hangarCfg['cam_pitch_constr'], hangarCfg['cam_yaw_constr'],
             distConstraints
         ]
         yaw, pitch = self.__getCameraYawPitch(location.up, location.normal)
         self._setCameraLocation(targetPos=location.position,
                                 pivotPos=Math.Vector3(0, 0, 0),
                                 yaw=yaw,
                                 pitch=pitch,
                                 dist=dist,
                                 camConstraints=constraints,
                                 forceRotate=forceRotate)
         self.__currentMode = C11nCameraModes.EMBLEM
         return True
 def __init__(self, spaceId, vEntity):
     ScriptGameObject.__init__(self, vEntity.spaceID)
     self.__loadState = _LoadStateNotifier()
     self.__curBuildInd = 0
     self.__vDesc = None
     self.__vState = None
     size = len(TankPartNames.ALL)
     self.__fashions = VehiclePartsTuple(*([None] * size))
     self.__repaintHandlers = [None] * size
     self.__camoHandlers = [None] * size
     self.__projectionDecalsHandlers = [None] * size
     self.__projectionDecalsUpdater = None
     self.__spaceId = spaceId
     self.__vEntity = weakref.proxy(vEntity)
     self.__onLoadedCallback = None
     self.__onLoadedAfterRefreshCallback = None
     self.__vehicleStickers = None
     self.__isVehicleDestroyed = False
     self.__outfit = None
     self.__staticTurretYaw = 0.0
     self.__staticGunPitch = 0.0
     self.__anchorsHelpers = None
     self.__anchorsParams = None
     self.__attachments = []
     self.__modelAnimators = []
     self.shadowManager = None
     cfg = hangarCFG()
     self.__currentEmblemsAlpha = cfg['emblems_alpha_undamaged']
     self.__showMarksOnGun = self.settingsCore.getSetting('showMarksOnGun')
     self.settingsCore.onSettingsChanged += self.__onSettingsChanged
     self.itemsCache.onSyncCompleted += self.__onItemsCacheSyncCompleted
     g_eventBus.addListener(CameraRelatedEvents.CAMERA_ENTITY_UPDATED,
                            self.__handleEntityUpdated)
     g_currentVehicle.onChanged += self.__onVehicleChanged
     return
Example #13
0
 def _finishCameraMovement(self):
     self.__curTime = None
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     self.__hangarCameraManager.camera.maxDistHalfLife = cfg['cam_fluency']
     self.__hangarCameraManager.camera.turningHalfLife = cfg['cam_fluency']
     self.__hangarCameraManager.camera.movementHalfLife = cfg['cam_fluency']
     return
    def __assembleModel(self):
        from vehicle_systems import model_assembler
        resources = self.__resources
        self.__vEntity.model = resources[self.__vDesc.name]
        if not self.__isVehicleDestroyed:
            self.__fashions = VehiclePartsTuple(BigWorld.WGVehicleFashion(False), BigWorld.WGBaseFashion(), BigWorld.WGBaseFashion(), BigWorld.WGBaseFashion())
            model_assembler.setupTracksFashion(self.__vDesc, self.__fashions.chassis)
            self.__vEntity.model.setupFashions(self.__fashions)
            self.__initMaterialHandlers()
            model_assembler.assembleCollisionObstaclesCollector(self, None)
            model_assembler.assembleTessellationCollisionSensor(self, None)
            self.wheelsAnimator = model_assembler.createWheelsAnimator(self.__vEntity.model, self.__vDesc, None)
            self.trackNodesAnimator = model_assembler.createTrackNodesAnimator(self.__vEntity.model, self.__vDesc, self.wheelsAnimator)
            chassisFashion = self.__fashions.chassis
            splineTracksImpl = model_assembler.setupSplineTracks(chassisFashion, self.__vDesc, self.__vEntity.model, self.__resources)
            model_assembler.assembleTracks(self.__resources, self.__vDesc, self, splineTracksImpl, True)
            self.updateCustomization(self.__outfit)
            dirtEnabled = BigWorld.WG_dirtEnabled() and 'HD' in self.__vDesc.type.tags
            if dirtEnabled:
                dirtHandlers = [BigWorld.PyDirtHandler(True, self.__vEntity.model.node(TankPartNames.CHASSIS).position.y),
                 BigWorld.PyDirtHandler(False, self.__vEntity.model.node(TankPartNames.HULL).position.y),
                 BigWorld.PyDirtHandler(False, self.__vEntity.model.node(TankPartNames.TURRET).position.y),
                 BigWorld.PyDirtHandler(False, self.__vEntity.model.node(TankPartNames.GUN).position.y)]
                modelHeight, _ = self.computeVehicleHeight()
                self.dirtComponent = Vehicular.DirtComponent(dirtHandlers, modelHeight)
                for fashionIdx, _ in enumerate(TankPartNames.ALL):
                    self.__fashions[fashionIdx].addMaterialHandler(dirtHandlers[fashionIdx])

                self.dirtComponent.setBase()
        else:
            self.__fashions = VehiclePartsTuple(BigWorld.WGBaseFashion(), BigWorld.WGBaseFashion(), BigWorld.WGBaseFashion(), BigWorld.WGBaseFashion())
            self.__vEntity.model.setupFashions(self.__fashions)
            self.wheelsAnimator = None
            self.trackNodesAnimator = None
            self.dirtComponent = None
        cfg = hangarCFG()
        turretYaw = self.__vDesc.gun.staticTurretYaw
        gunPitch = self.__vDesc.gun.staticPitch
        if not ('AT-SPG' in self.__vDesc.type.tags or 'SPG' in self.__vDesc.type.tags):
            if turretYaw is None:
                turretYaw = cfg['vehicle_turret_yaw']
                turretYawLimits = self.__vDesc.gun.turretYawLimits
                if turretYawLimits is not None:
                    turretYaw = mathUtils.clamp(turretYawLimits[0], turretYawLimits[1], turretYaw)
            if gunPitch is None:
                gunPitch = cfg['vehicle_gun_pitch']
                gunPitchLimits = self.__vDesc.gun.pitchLimits['absolute']
                gunPitch = mathUtils.clamp(gunPitchLimits[0], gunPitchLimits[1], gunPitch)
        else:
            if turretYaw is None:
                turretYaw = 0.0
            if gunPitch is None:
                gunPitch = 0.0
        turretYawMatrix = mathUtils.createRotationMatrix((turretYaw, 0.0, 0.0))
        self.__vEntity.model.node(TankPartNames.TURRET, turretYawMatrix)
        gunPitchMatrix = mathUtils.createRotationMatrix((0.0, gunPitch, 0.0))
        self.__vEntity.model.node(TankPartNames.GUN, gunPitchMatrix)
        return
 def __getCameraPivotDistance(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     point1 = self.__cam.target.translation + cfg['cam_pivot_pos']
     point2 = self.__cam.position
     d2 = (point2 - point1).length
     d3 = max(self.__cam.targetMaxDist, d2)
     return mathUtils.clamp(self.__camConstraints[2][0],
                            self.__camConstraints[2][1], d3)
Example #16
0
 def __updateCameraPitchLimits(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     if self.__allowCustomCamDistance and self.__isInPlatoon and cfg.camPitchConstrPlatoon:
         minDist, maxDist = cfg.camPitchConstrPlatoon
         if maxDist < minDist:
             _logger.warning('incorrect values - camera MAX pitch < camera MIN pitch, use min distance as max')
             maxDist = minDist
         self.__camConstraints[0] = (minDist, maxDist)
 def locateCameraToPreview(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     self.setCameraLocation(
         targetPos=cfg['preview_cam_start_target_pos'],
         pivotPos=cfg['preview_cam_pivot_pos'],
         yaw=math.radians(cfg['preview_cam_start_angles'][0]),
         pitch=math.radians(cfg['preview_cam_start_angles'][1]),
         dist=cfg['preview_cam_start_dist'])
Example #18
0
 def onEnterWorld(self, prereqs):
     super(ClientSelectableCameraVehicle, self).onEnterWorld(prereqs)
     self.__defaultPos = self.position
     self.__defaultYPR = Math.Vector3(self.yaw, self.pitch, self.roll)
     cfg = hangarCFG()
     if 'shadow_model_name' in cfg:
         shadowName = cfg['shadow_model_name']
         if shadowName not in prereqs.failedIDs:
             self.__createFakeShadow(prereqs[shadowName])
Example #19
0
 def setCameraLocation(self, targetPos=None, pivotPos=None, yaw=None, pitch=None, dist=None, camConstraints=None, ignoreConstraints=False, movementMode=FAST_CAMERA_MOVEMENT_MODE):
     if self.__cam is None:
         _logger.error('Unable to set camera location, because camera reference is None.')
         return
     else:
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         sourceMat = Math.Matrix(self.__cam.source)
         yawS = sourceMat.yaw if yaw is None else yaw
         pitchS = sourceMat.pitch if pitch is None else pitch
         if dist is None:
             dist = self.__cam.pivotMaxDist
         if movementMode != IMMEDIATE_CAMERA_MOVEMENT_MODE:
             self.__cam.movementMode = movementMode
         if camConstraints is None or camConstraints[0] is None:
             self.__camConstraints[0] = cfg['cam_pitch_constr']
         else:
             self.__camConstraints[0] = camConstraints[0]
         if camConstraints is None or camConstraints[1] is None:
             self.__camConstraints[1] = cfg['cam_yaw_constr']
         else:
             self.__camConstraints[1] = camConstraints[1]
         if camConstraints is None or camConstraints[2] is None:
             self.__updateCameraLimits()
         else:
             self.__camConstraints[2] = camConstraints[2]
         if not ignoreConstraints:
             if yaw is not None:
                 camYawConstr = self.__camConstraints[1]
                 startYaw, endYaw = camYawConstr
                 self.__yawCameraFilter.setConstraints(math.radians(startYaw), math.radians(endYaw))
                 self.__yawCameraFilter.setYawLimits(camYawConstr)
                 yawS = self.__yawCameraFilter.toLimit(yawS)
             if pitch is not None:
                 camPitchConstr = self.__camConstraints[0]
                 startPitch, endPitch = (math.radians(pc) for pc in camPitchConstr)
                 pitchS = math_utils.clamp(startPitch, endPitch, pitchS)
             minDist, maxDist = self.__camConstraints[2]
             dist = math_utils.clamp(minDist, maxDist, dist)
         if yaw is not None or pitch is not None:
             mat = Math.Matrix()
             pitchS = math_utils.clamp(-math.pi / 2 * 0.99, math.pi / 2 * 0.99, pitchS)
             mat.setRotateYPR((yawS, pitchS, 0.0))
             self.__cam.source = mat
         if targetPos is not None:
             targetMat = self.__cam.target
             targetMat.setTranslate(targetPos)
             self.__cam.target = targetMat
             self.__cam.target.setTranslate(targetPos)
         if pivotPos is not None:
             self.__cam.pivotPosition = pivotPos
         self.__cam.pivotMaxDist = dist
         if movementMode == IMMEDIATE_CAMERA_MOVEMENT_MODE:
             self.__cam.pivotMinDist = 0.0
             self.__cam.forceUpdate()
         return
 def setCameraLocation(self,
                       targetPos=None,
                       pivotPos=None,
                       yaw=None,
                       pitch=None,
                       dist=None,
                       camConstraints=None,
                       ignoreConstraints=False,
                       smothiedTransition=True,
                       previewMode=False,
                       verticalOffset=0.0):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     sourceMat = Math.Matrix(self.__cam.source)
     if yaw is None:
         yaw = sourceMat.yaw
     if pitch is None:
         pitch = sourceMat.pitch
     if dist is None:
         dist = self.__cam.pivotMaxDist
     self.__cam.screenSpaceVerticalOffset = verticalOffset
     if camConstraints is not None:
         self.__camConstraints = camConstraints
     else:
         self.__camConstraints[0] = cfg['cam_pitch_constr']
         self.__camConstraints[1] = cfg['cam_yaw_constr']
     camYawConstr = self.__camConstraints[1]
     startYaw, endYaw = camYawConstr
     self.__yawCameraFilter.setConstraints(math.radians(startYaw),
                                           math.radians(endYaw))
     self.__yawCameraFilter.setYawLimits(camYawConstr)
     if not ignoreConstraints:
         yaw = self.__yawCameraFilter.toLimit(yaw)
         pitchOffset = self.__cam.pitchOffset
         camPitchConstr = self.__camConstraints[0]
         startPitch, endPitch = (math.radians(pc) - pitchOffset
                                 for pc in camPitchConstr)
         pitch = mathUtils.clamp(startPitch, endPitch, pitch)
         distConstr = cfg[
             'preview_cam_dist_constr'] if self.__isPreviewMode else self.__camConstraints[
                 2]
         minDist, maxDist = distConstr
         dist = mathUtils.clamp(minDist, maxDist, dist)
     mat = Math.Matrix()
     pitch = mathUtils.clamp(-math.pi / 2 * 0.99, math.pi / 2 * 0.99, pitch)
     mat.setRotateYPR((yaw, pitch, 0.0))
     self.__cam.source = mat
     self.__cam.pivotMaxDist = dist
     if targetPos is not None:
         self.__cam.target.setTranslate(targetPos)
     if pivotPos is not None:
         self.__cam.pivotPosition = pivotPos
     if not smothiedTransition:
         self.__cam.forceUpdate()
     self.setPreviewMode(previewMode)
     return
Example #21
0
 def __readHangarCameraCfg(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     self.__defaultParams = _CameraParams(
         name='Tank',
         sensitivity=cfg['cam_sens'],
         pitchConstraints=cfg['cam_pitch_constr'],
         distConstraints=cfg['cam_dist_constr'],
         fluency=cfg['cam_fluency'])
     self.__currentParams = deepcopy(self.__defaultParams)
 def __updateCameraDistanceLimits(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     entity = BigWorld.entities.get(self.__currentEntityId)
     modelLength = entity.getModelLength() if entity and hasattr(
         entity, 'getModelLength') else 0.0
     minDist = max(modelLength * cfg['cam_min_dist_vehicle_hull_length_k'],
                   cfg['cam_dist_constr'][0])
     maxDist = entity.cameraMaxDistance if entity and hasattr(
         entity, 'cameraMaxDistance') else cfg['cam_dist_constr'][1]
     self.__camConstraints[2] = (minDist, maxDist)
 def locateCameraToStartState(self, needToSetCameraLocation=True):
     if self.__hangarCameraManager is None or self.__hangarCameraManager.camera is None:
         return
     else:
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         if needToSetCameraLocation:
             self.__hangarCameraManager.setCameraLocation(targetPos=cfg['cam_start_target_pos'], pivotPos=cfg['cam_pivot_pos'], yaw=math.radians(cfg['cam_start_angles'][0]), pitch=math.radians(cfg['cam_start_angles'][1]), dist=cfg['cam_start_dist'], camConstraints=[cfg['cam_pitch_constr'], cfg['cam_yaw_constr'], cfg['cam_dist_constr']])
         self.__currentMode = C11nCameraModes.START_STATE
         self.enableMovementByMouse()
         return
Example #24
0
 def __getEmblemCorners(self, hitPos, dir, up, emblem):
     cfg = hangarCFG()
     size = emblem[3] * cfg['v_scale']
     m = Math.Matrix()
     m.lookAt(hitPos, dir, up)
     m.invert()
     result = (Math.Vector3(size * 0.5, size * 0.5, -0.25),
               Math.Vector3(size * 0.5, -size * 0.5, -0.25),
               Math.Vector3(-size * 0.5, -size * 0.5, -0.25),
               Math.Vector3(-size * 0.5, size * 0.5, -0.25))
     return [m.applyPoint(vec) for vec in result]
 def __updateCameraDistanceLimits(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     entity = BigWorld.entities.get(self.__currentEntityId)
     modelLength = entity.getModelLength() if entity is not None and hasattr(entity, 'getModelLength') else 0.0
     minDist = max(modelLength * cfg['cam_min_dist_vehicle_hull_length_k'], cfg['cam_dist_constr'][0])
     maxDist = entity.cameraMaxDistance if entity is not None and hasattr(entity, 'cameraMaxDistance') else cfg['cam_dist_constr'][1]
     if maxDist < minDist:
         _logger.warning('incorrect values - camera MAX distance < camera MIN distance, use min distance as max')
         maxDist = minDist
     self.__camConstraints[2] = (minDist, maxDist)
     return
Example #26
0
 def locateCameraToPreview(self):
     if self.__hangarCameraManager is None or self.__hangarCameraManager.camera is None:
         return
     else:
         from gui.ClientHangarSpace import hangarCFG
         cfg = hangarCFG()
         self._setCameraLocation(
             targetPos=cfg['preview_cam_start_target_pos'],
             pivotPos=cfg['preview_cam_pivot_pos'],
             yaw=math.radians(cfg['preview_cam_start_angles'][0]),
             pitch=math.radians(cfg['preview_cam_start_angles'][1]),
             dist=cfg['preview_cam_start_dist'])
         return
Example #27
0
 def setPlatoonStartingCameraPosition(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     startYaw, startPitch = cfg.camStartAnglesPlatoon
     mat = Math.Matrix()
     yaw = self.__yawCameraFilter.toLimit(math.radians(startYaw))
     mat.setRotateYPR((yaw, math.radians(startPitch), 0.0))
     self.__cam.source = mat
     cameraDist = cfg.camStartDistPlatoon
     minDist, maxDist = cfg.camDistConstrPlatoon
     self.setPlatoonCameraDistance(enable=True)
     self.__cam.pivotMaxDist = math_utils.clamp(minDist, maxDist, cameraDist)
     self.__cam.forceUpdate()
Example #28
0
 def locateCameraToStartState(self):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     self.setCameraLocation(targetPos=cfg['cam_start_target_pos'],
                            pivotPos=cfg['cam_pivot_pos'],
                            yaw=math.radians(cfg['cam_start_angles'][0]),
                            pitch=math.radians(cfg['cam_start_angles'][1]),
                            dist=cfg['cam_start_dist'],
                            camConstraints=[
                                cfg['cam_pitch_constr'],
                                cfg['cam_yaw_constr'],
                                cfg['cam_dist_constr']
                            ])
Example #29
0
 def locateCameraToCustomizationPreview(self):
     from gui.ClientHangarSpace import customizationHangarCFG, hangarCFG
     cfg = customizationHangarCFG()
     hangarConfig = hangarCFG()
     self.setCameraLocation(targetPos=cfg['cam_start_target_pos'],
                            pivotPos=cfg['cam_pivot_pos'],
                            yaw=math.radians(cfg['cam_start_angles'][0]),
                            pitch=math.radians(cfg['cam_start_angles'][1]),
                            dist=cfg['cam_start_dist'],
                            camConstraints=[
                                hangarConfig['cam_pitch_constr'],
                                hangarConfig['cam_yaw_constr'],
                                cfg['cam_dist_constr']
                            ])
 def setCameraLocation(self,
                       targetPos=None,
                       pivotPos=None,
                       yaw=None,
                       pitch=None,
                       dist=None,
                       camConstraints=None,
                       ignoreConstraints=False,
                       smothiedTransition=True):
     from gui.ClientHangarSpace import hangarCFG
     cfg = hangarCFG()
     sourceMat = Math.Matrix(self.__cam.source)
     if yaw is None:
         yaw = sourceMat.yaw
     if pitch is None:
         pitch = sourceMat.pitch
     if dist is None:
         dist = self.__cam.pivotMaxDist
     if camConstraints is not None:
         self.__camConstraints = camConstraints
     else:
         self.__camConstraints[0] = cfg['cam_pitch_constr']
         self.__camConstraints[1] = cfg['cam_yaw_constr']
     self.__yawCameraFilter.setConstraints(
         math.radians(self.__camConstraints[1][0]),
         math.radians(self.__camConstraints[1][1]))
     self.__yawCameraFilter.setYawLimits(self.__camConstraints[1])
     if not ignoreConstraints:
         yaw = self.__yawCameraFilter.toLimit(yaw)
         pitch = mathUtils.clamp(math.radians(self.__camConstraints[0][0]),
                                 math.radians(self.__camConstraints[0][1]),
                                 pitch)
         distConstr = cfg[
             'preview_cam_dist_constr'] if self.__selectedEmblemInfo else self.__camConstraints[
                 2]
         dist = mathUtils.clamp(distConstr[0], distConstr[1], dist)
     mat = Math.Matrix()
     pitch = mathUtils.clamp(-math.pi / 2 * 0.99, math.pi / 2 * 0.99, pitch)
     mat.setRotateYPR((yaw, pitch, 0.0))
     self.__cam.source = mat
     self.__cam.pivotMaxDist = dist
     if targetPos is not None:
         self.__cam.target.setTranslate(targetPos)
     if pivotPos is not None:
         self.__cam.pivotPosition = pivotPos
     if not smothiedTransition:
         self.__cam.forceUpdate()
     return