コード例 #1
0
 def ProcessCameraUpdate(self, camera, now, frameTime):
     if camera._transformDistance:
         startTime, startValue, toValue, duration = camera._transformDistance
         ndt = min(
             1.0,
             blue.os.TimeDiffInMs(startTime, blue.os.GetWallclockTime()) /
             duration)
         camera.distance = mathUtil.Lerp(startValue, toValue, ndt)
         if ndt >= 1.0:
             camera._transformDistance = None
     if camera._transformPOI:
         startTime, startValue, toValue, duration = camera._transformPOI
         ndt = min(
             1.0,
             blue.os.TimeDiffInMs(startTime, blue.os.GetWallclockTime()) /
             duration)
         camera.yFactor = mathUtil.Lerp(-startValue[1], -toValue[1], ndt)
         if ndt >= 1.0:
             camera._transformPOI = None
     if camera.controlStyle != CONTROL_NONE:
         camera.minPitch, camera.maxPitch = camera.GetMinMaxPitchBasedOnDistance(
         )
         camera.pitch = min(camera.maxPitch,
                            max(camera.minPitch, camera.pitch))
         camera.LimitPanning()
     camera.UpdateProjectionMatrix()
コード例 #2
0
ファイル: effect.py プロジェクト: R4M80MrX/eve-1
 def FadeRGB(self, fr, to, sprite, time = 500.0, timeFunc = blue.os.GetWallclockTime):
     ndt = 0.0
     start = timeFunc()
     while ndt != 1.0:
         ndt = min(float(blue.os.TimeDiffInMs(start, timeFunc())) / float(time), 1.0)
         sprite.SetRGB(mathUtil.Lerp(fr[0], to[0], ndt), mathUtil.Lerp(fr[1], to[1], ndt), mathUtil.Lerp(fr[2], to[2], ndt))
         blue.pyos.synchro.Yield()
         if not object or getattr(object, 'destroyed', False):
             return
コード例 #3
0
 def UpdateSmoothMove(self, sPos, sRot, sTilt, sDist, ePos, eRot, eTilt, eDist, startTime, durationMS, callbackOnEnd):
     ndt = blue.os.TimeDiffInMs(startTime, blue.os.GetWallclockTime()) / durationMS
     ndt = max(0.0, min(1.0, ndt))
     self.AssembleViewMatrix((mathUtil.Lerp(sPos[0], ePos[0], ndt), mathUtil.Lerp(sPos[1], ePos[1], ndt), mathUtil.Lerp(sPos[2], ePos[2], ndt)), mathUtil.Lerp(sRot, eRot, ndt), mathUtil.Lerp(sTilt, eTilt, ndt), mathUtil.Lerp(sDist, eDist, ndt), True)
     if ndt >= 1.0:
         self._smoothMoveTimer = None
         self.zoom = eDist
         if callbackOnEnd:
             callbackOnEnd()
コード例 #4
0
ファイル: effect.py プロジェクト: R4M80MrX/eve-1
 def Fade(self, fr, to, object, time = 500.0, timeFunc = blue.os.GetWallclockTime):
     affectOpacity = hasattr(object, 'opacity')
     ndt = 0.0
     start = timeFunc()
     while ndt != 1.0:
         ndt = min(blue.os.TimeDiffInMs(start, timeFunc()) / time, 1.0)
         if affectOpacity:
             object.opacity = mathUtil.Lerp(fr, to, ndt)
         else:
             object.SetAlpha(mathUtil.Lerp(fr, to, ndt))
         blue.pyos.synchro.Yield()
         if not object or getattr(object, 'destroyed', False):
             return
コード例 #5
0
 def UpdateProgress_(self, ndt):
     l, t, w, h = self.GetAbsolute()
     if self._countDown:
         self.sr.progressBar.width = w - int(mathUtil.Lerp(0, w, ndt))
     else:
         self.sr.progressBar.width = int(mathUtil.Lerp(0, w, ndt))
     minWidth = self.PBGRAPHICMARGIN * 2 + self.sr.progressBarGraphic.rectWidth
     if self.sr.progressBar.width <= minWidth:
         self.sr.progressBarGraphic.width = self.PBGRAPHICMARGIN + (
             self.sr.progressBar.width - minWidth)
     else:
         self.sr.progressBarGraphic.width = self.PBGRAPHICMARGIN
     self._lastPortion = ndt
コード例 #6
0
def LerpHelper(lerpVals, value, errorValue):
    for i in xrange(len(lerpVals)):
        if value == lerpVals[i][0]:
            return lerpVals[i][1]
        if value > lerpVals[i][0] and value < lerpVals[i + 1][0]:
            lerpPct = (lerpVals[i][0] - value) / float(lerpVals[i][0] - lerpVals[i + 1][0])
            if isinstance(lerpVals[i][1], Iterable):
                return map(lambda x: mathUtil.Lerp(x[0], x[1], lerpPct), zip(lerpVals[i][1], lerpVals[i + 1][1]))
            else:
                return mathUtil.Lerp(lerpVals[i][1], lerpVals[i + 1][1], lerpPct)

    log.LogTraceback('TiDi LerpHelper ran off the edge')
    return errorValue
コード例 #7
0
 def FadeRGB(self,
             fr,
             to,
             sprite,
             time=500.0,
             timeFunc=blue.os.GetWallclockTime):
     ndt = 0.0
     start = timeFunc()
     while ndt != 1.0:
         ndt = min(
             float(blue.os.TimeDiffInMs(start, timeFunc())) / float(time),
             1.0)
         sprite.color.r = mathUtil.Lerp(fr[0], to[0], ndt)
         sprite.color.g = mathUtil.Lerp(fr[1], to[1], ndt)
         sprite.color.b = mathUtil.Lerp(fr[2], to[2], ndt)
         blue.pyos.synchro.Yield()
コード例 #8
0
ファイル: effect.py プロジェクト: R4M80MrX/eve-1
 def _Rotate(self, uitransform, time, fromRot, toRot, timeFunc):
     time *= 1000
     i = 0
     start, ndt = timeFunc(), 0.0
     while ndt != 1.0 and not uitransform.destroyed:
         ndt = max(ndt, min(blue.os.TimeDiffInMs(start, timeFunc()) / time, 1.0))
         deg = mathUtil.Lerp(fromRot, toRot, ndt)
         rad = mathUtil.DegToRad(deg)
         uitransform.SetRotation(rad)
         blue.pyos.synchro.Yield()
コード例 #9
0
 def Dolly(self, delta):
     if self.controlStyle == CONTROL_NONE:
         return
     if self.controlStyle == CONTROL_BOTH:
         self.xFactor = self.xTarget
         self.yFactor = self.yTarget
     newDistance = min(self.farDistance, max(self.nearDistance, self.distance - self.distance * (delta * 0.0025)))
     self.distance = newDistance
     if self._onFocusValue:
         portion = self.GetPortionFromDistance()
         self.yFactor = mathUtil.Lerp(self.nearFocusY, self.farFocusY, portion)
コード例 #10
0
 def Fade(self,
          fr,
          to,
          sprite,
          time=500.0,
          timeFunc=blue.os.GetWallclockTime):
     ndt = 0.0
     start = timeFunc()
     while ndt != 1.0:
         ndt = min(blue.os.TimeDiffInMs(start, timeFunc()) / time, 1.0)
         sprite.color.a = mathUtil.Lerp(fr, to, ndt)
         blue.pyos.synchro.Yield()
コード例 #11
0
 def HandlePointOfInterest(self):
     """
     Handles poi calculations. If there is a desired poi, then we lerp to that, making sure to update it if
     the camera or avatar moves around. Otherwise, if there is no desired poi, we calculate the correct one
     based on the camera position and avatar position
     """
     if self.desiredPoi is not None:
         camMoved = geo2.Vec3Distance(
             self.lerpPoiCamStats,
             (self.camera.yaw, self.camera.pitch, 0.0))
         avatarMoved = geo2.Vec3Distance(
             self.lerpPoiAvatarStats,
             self.entity.GetComponent('position').position)
         if camMoved > const.FLOAT_TOLERANCE or avatarMoved > const.FLOAT_TOLERANCE:
             self.desiredPoi = self.CalcCorrectCameraPoi(
                 self.camera.yaw, self.camera.pitch)
             if avatarMoved > const.FLOAT_TOLERANCE:
                 vect = geo2.Vec3Normalize(
                     geo2.Vec3Subtract(self.centerPoint,
                                       self.lastCenterPoint))
                 dist = geo2.Vec3Distance(self.lastCenterPoint,
                                          self.centerPoint)
                 self.camera.poi = geo2.Vec3Add(self.camera.poi,
                                                (val * dist
                                                 for val in vect))
             self.lerpPoiCamStats = (self.camera.yaw, self.camera.pitch,
                                     0.0)
             self.lerpPoiAvatarStats = self.entity.GetComponent(
                 'position').position
             self.useLerp = True
         if self.useLerp:
             newPoi = geo2.Vec3Lerp(self.camera.poi, self.desiredPoi,
                                    self.frameTime * LERP_SPEED)
             zoom = mathUtil.Lerp(self.camera.zoom, self.desiredZoom,
                                  self.frameTime * LERP_SPEED)
         else:
             newPoi = self.PlerpVec3(self.originalPoi, self.desiredPoi,
                                     self.lerpTimeLeft)
             zoom = self.Plerp(self.startZoom, self.desiredZoom,
                               self.lerpTimeLeft)
         self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = zoom
         self.lerpTimeLeft -= self.frameTime * const.SEC
         if geo2.Vec3Distance(
                 newPoi, self.desiredPoi) < const.FLOAT_TOLERANCE and abs(
                     self.camera.zoom -
                     self.desiredZoom) < const.FLOAT_TOLERANCE:
             self.desiredPoi = None
             self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = self.desiredZoom
     else:
         newPoi = self.CalcCorrectCameraPoi(self.camera.yaw,
                                            self.camera.pitch)
     self.camera.SetPointOfInterest(newPoi)
コード例 #12
0
 def _PanCamera(self,
                posbeg=None,
                posend=None,
                cambeg=None,
                camend=None,
                fovEnd=None,
                time=500.0,
                source='default'):
     cameraParent = self.GetCameraParent(source)
     if cameraParent is None:
         return
     start = blue.os.GetWallclockTime()
     ndt = 0.0
     fovBeg = None
     camera = sm.GetService('sceneManager').GetRegisteredCamera(source)
     if camera is None:
         return
     if fovEnd is not None:
         fovBeg = camera.fieldOfView
     while ndt != 1.0:
         ndt = max(
             0.0,
             min(
                 blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) /
                 time, 1.0))
         if posbeg and posend:
             cameraParent.translation.x = mathUtil.Lerp(
                 posbeg.x, posend.x, ndt)
             cameraParent.translation.y = mathUtil.Lerp(
                 posbeg.y, posend.y, ndt)
             cameraParent.translation.z = mathUtil.Lerp(
                 posbeg.z, posend.z, ndt)
         if cambeg and camend:
             camera.translationFromParent = self.CheckTranslationFromParent(
                 mathUtil.Lerp(cambeg, camend, ndt), source=source)
         if fovBeg and fovEnd:
             camera.fieldOfView = mathUtil.Lerp(fovBeg, fovEnd, ndt)
         blue.pyos.synchro.Yield()
コード例 #13
0
ファイル: eveWindow.py プロジェクト: R4M80MrX/eve-1
    def ToggleWindowOverlay(self, show):
        if getattr(self, 'isToggling', 0):
            return
        prestate = self.state
        if not self or self.destroyed:
            return
        if prestate != uiconst.UI_HIDDEN:
            self.state = uiconst.UI_DISABLED
        setattr(self, 'isToggling', 1)
        try:
            mainpar = uiutil.FindChild(self, 'startpage_mainpar')
            if not mainpar or mainpar.destroyed:
                return
            mainpar.state = uiconst.UI_PICKCHILDREN
            l, t, w, h = mainpar.parent.GetAbsolute()
            start, ndt = blue.os.GetWallclockTime(), 0.0
            time = 750.0
            while ndt != 1.0:
                ndt = max(ndt, min(blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) / time, 1.0))
                if show:
                    mainpar.top = int(mathUtil.Lerp(-h, 0, ndt))
                    mainpar.opacity = ndt
                else:
                    mainpar.top = int(mathUtil.Lerp(0, -h, ndt))
                    mainpar.opacity = 1.0 - ndt
                mainpar.height = -mainpar.top
                blue.pyos.synchro.Yield()

        finally:
            if not self.destroyed:
                self.state = prestate

        mainpar = uiutil.FindChild(self, 'startpage_mainpar')
        if mainpar and not mainpar.destroyed:
            uicore.registry.SetFocus(self.sr.wpCloseBtn)
        if not self or self.destroyed:
            return
        setattr(self, 'isToggling', 0)
コード例 #14
0
ファイル: effect.py プロジェクト: R4M80MrX/eve-1
    def Morph(self, func, time = 500.0, newthread = 1, timeFunc = blue.os.GetWallclockTime):
        if newthread:
            uthread.new(self.Morph, func, time, newthread=0, timeFunc=timeFunc).context = 'UIObject::effect.Morph'
            return
        start, ndt = timeFunc(), 0.0
        while ndt != 1.0:
            try:
                ndt = max(ndt, min(blue.os.TimeDiffInMs(start, timeFunc()) / time, 1.0))
            except:
                ndt = 1.0

            if ndt < 0.0:
                break
            val = mathUtil.Lerp(0.0, 1.0, ndt)
            func(val)
            blue.pyos.synchro.Yield()
コード例 #15
0
 def HandlePointOfInterest(self):
     if self.desiredPoi is not None:
         camMoved = geo2.Vec3Distance(
             self.lerpPoiCamStats,
             (self.camera.yaw, self.camera.pitch, 0.0))
         avatarMoved = geo2.Vec3Distance(
             self.lerpPoiAvatarStats,
             self.entity.GetComponent('position').position)
         if camMoved > const.FLOAT_TOLERANCE or avatarMoved > const.FLOAT_TOLERANCE:
             self.desiredPoi = self.CalcCorrectCameraPoi(
                 self.camera.yaw, self.camera.pitch)
             if avatarMoved > const.FLOAT_TOLERANCE:
                 vect = geo2.Vec3Normalize(
                     geo2.Vec3Subtract(self.centerPoint,
                                       self.lastCenterPoint))
                 dist = geo2.Vec3Distance(self.lastCenterPoint,
                                          self.centerPoint)
                 self.camera.poi = geo2.Vec3Add(self.camera.poi,
                                                (val * dist
                                                 for val in vect))
             self.lerpPoiCamStats = (self.camera.yaw, self.camera.pitch,
                                     0.0)
             self.lerpPoiAvatarStats = self.entity.GetComponent(
                 'position').position
             self.useLerp = True
         if self.useLerp:
             newPoi = geo2.Vec3Lerp(self.camera.poi, self.desiredPoi,
                                    self.frameTime * LERP_SPEED)
             zoom = mathUtil.Lerp(self.camera.zoom, self.desiredZoom,
                                  self.frameTime * LERP_SPEED)
         else:
             newPoi = self.PlerpVec3(self.originalPoi, self.desiredPoi,
                                     self.lerpTimeLeft)
             zoom = self.Plerp(self.startZoom, self.desiredZoom,
                               self.lerpTimeLeft)
         self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = zoom
         self.lerpTimeLeft -= self.frameTime * const.SEC
         if geo2.Vec3Distance(
                 newPoi, self.desiredPoi) < const.FLOAT_TOLERANCE and abs(
                     self.camera.zoom -
                     self.desiredZoom) < const.FLOAT_TOLERANCE:
             self.desiredPoi = None
             self.camera.zoom = self.camera.collisionZoom = self.camera.desiredZoom = self.desiredZoom
     else:
         newPoi = self.CalcCorrectCameraPoi(self.camera.yaw,
                                            self.camera.pitch)
     self.camera.SetPointOfInterest(newPoi)
コード例 #16
0
    def Animate(self):
        if not self or self.destroyed:
            return
        prevFactor = 1
        while self and not self.destroyed:
            curFactor = blue.os.desiredSimDilation
            if (not self.initialized
                    or curFactor != prevFactor) and (curFactor < 0.98
                                                     or prevFactor < 0.98):
                if not self.initialized:
                    prevFactor = curFactor
                self.state = uiconst.UI_NORMAL
                self.hint = localization.GetByLabel('UI/Neocom/TidiTooltip',
                                                    tidiAmount=int(curFactor *
                                                                   100))
                if self.opacity < 1:
                    self.StartupAnim()
                    continue

                def RotateAndColor(animFactor):
                    animFactor = min(max(animFactor, 0), 1)
                    leftRamp = min(1.0, max(0.0, animFactor * 2))
                    rightRamp = min(1.0, max(0.0, animFactor * 2 - 1.0))
                    self.leftRamp.SetRotation(math.pi + math.pi * leftRamp)
                    self.rightRamp.SetRotation(math.pi + math.pi * rightRamp)
                    color = LerpHelper(labLerpValues, animFactor, (0, 0, 0))
                    self.coloredPie.color.SetRGB(*(Lab2RGB(color) + [0.65]))

                startTime = blue.os.GetWallclockTime()
                elapsedTimeMS = 0
                animDurationMS = 500
                while self and not self.destroyed and elapsedTimeMS < animDurationMS:
                    portionDone = elapsedTimeMS / float(animDurationMS)
                    animFactor = mathUtil.Lerp(prevFactor, curFactor,
                                               portionDone)
                    RotateAndColor(animFactor)
                    blue.pyos.synchro.Yield()
                    elapsedTimeMS = blue.os.TimeDiffInMs(
                        startTime, blue.os.GetWallclockTime())

                RotateAndColor(curFactor)
                prevFactor = curFactor
                if curFactor >= 0.98 and self:
                    self.ShutdownAnim()
            self.initialized = True
            blue.pyos.synchro.Yield()
コード例 #17
0
ファイル: loginII.py プロジェクト: R4M80MrX/eve-1
    def FadeBG(self, fr, to, fadein, pic, time = 500.0):
        if self is None:
            return
        ndt = 0.0
        start = blue.os.GetWallclockTimeNow()
        while ndt != 1.0:
            ndt = min(blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) / time, 1.0)
            if self is None or pic is None or pic.destroyed:
                break
            pic.SetAlpha(mathUtil.Lerp(fr, to, ndt))
            blue.pyos.synchro.Yield()

        if self is None:
            return
        if not fadein:
            self.fadeCont.Flush()
            self.bg = None
コード例 #18
0
    def ResetFov(self):
        if self.prefov is not None:
            camera = sm.GetService('sceneManager').GetRegisteredCamera(
                'default')
            if camera is None:
                return
            to = FOV_MAX
            fr = camera.fieldOfView
            start, ndt = blue.os.GetSimTime(), 0.0
            while ndt != 1.0:
                ndt = min(
                    blue.os.TimeDiffInMs(start, blue.os.GetSimTime()) / 1000.0,
                    1.0)
                camera.fieldOfView = mathUtil.Lerp(fr, to, ndt)
                blue.pyos.synchro.Yield()

            self.prefov = None
        self.resetfov = 0
コード例 #19
0
    def FadeOpacityThread(self, toOpacity):
        self._newOpacity = None
        ndt = 0.0
        start = blue.os.GetWallclockTime()
        startOpacity = self.opacity
        while ndt != 1.0:
            ndt = min(
                float(blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()))
                / float(250.0), 1.0)
            self.opacity = min(
                1.0, max(0.0, mathUtil.Lerp(startOpacity, toOpacity, ndt)))
            if toOpacity == 1.0:
                self.Show()
            blue.pyos.synchro.Yield()
            if self._newOpacity:
                return

        if toOpacity == 0.0:
            self.Hide()
コード例 #20
0
ファイル: loading.py プロジェクト: R4M80MrX/eve-1
    def FadeToBlack(self, time=1000):
        if self.disabled:
            return
        if self.fadingToBlack or not uicore.layer.loading:
            return
        self.fadingToBlack = 1
        self.fadingFromBlack = 0
        fill, current = self.GetFill()
        fill.state = uiconst.UI_NORMAL
        time = float(time)
        start, ndt = blue.os.GetWallclockTime(), 0.0
        while ndt != 1.0 and not fill.destroyed and self.fadingToBlack:
            ndt = min(
                blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) / time,
                1.0)
            fill.color.a = mathUtil.Lerp(current, 1.0, ndt)
            blue.pyos.synchro.Yield()

        self.fadingToBlack = 0
コード例 #21
0
ファイル: expandablemenu.py プロジェクト: R4M80MrX/eve-1
    def Collapse(self, startup=0):
        if self._changing:
            self._break = True
        self._changing = True
        sh = self.height
        endHeight = self.GetCollapsedHeight()
        pl, pt, pw, ph = self.parent.GetAbsolute()
        self.sr.expanderIcon.LoadIcon('ui_38_16_228')
        if not startup:
            if self.sr.headerContent:
                sho = self.sr.headerContent.opacity
            start, ndt = blue.os.GetWallclockTime(), 0.0
            time = 250.0
            while ndt != 1.0:
                ndt = max(
                    ndt,
                    min(
                        blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime())
                        / time, 1.0))
                self.height = sh - int((sh - endHeight) * ndt)
                self.sr.content.opacity = 1.0 - 1.0 * ndt
                if self.sr.headerContent and self._hideHeaderContentOnMaximize:
                    self.sr.headerContent.opacity = mathUtil.Lerp(
                        sho, 1.0, ndt)
                if self.parent.sizecallback:
                    self.parent.sizecallback(self)
                blue.pyos.synchro.Yield()
                if self.destroyed or self._break:
                    break

        if self.destroyed:
            return
        self._changing = False
        self._break = False
        self.height = endHeight
        self._expanded = False
        self.sr.content.state = uiconst.UI_HIDDEN
        self.sr.content.opacity = 0.0
        if self.sr.headerContent:
            self.sr.headerContent.opacity = 1.0
        if not startup:
            self.Register()
コード例 #22
0
ファイル: slider.py プロジェクト: R4M80MrX/eve-1
    def MorphTo(self, value, time = 150.0):
        if getattr(self, 'morphTo', None) is not None:
            self.pendingMorph = (value, time)
            return
        self.morphTo = value
        startPos = self.value / (self.maxValue - self.minValue)
        endPos = value / (self.maxValue - self.minValue)
        start, ndt = blue.os.GetWallclockTime(), 0.0
        while ndt != 1.0:
            ndt = min(blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) / time, 1.0)
            newVal = mathUtil.Lerp(startPos, endPos, ndt)
            self.SlideTo(newVal)
            self.SetValue(newVal)
            blue.pyos.synchro.Yield()

        self.morphTo = None
        if getattr(self, 'pendingMorph', None):
            value, time = self.pendingMorph
            self.MorphTo(value, time)
        self.pendingMorph = None
コード例 #23
0
ファイル: effect.py プロジェクト: R4M80MrX/eve-1
    def MorphUI(self, item, attrname, tval, time = 500.0, newthread = 1, ifWidthConstrain = 1, maxSteps = 100, float = 0, endState = None, timeFunc = blue.os.GetWallclockTime):
        cval = getattr(item, attrname, None)
        if cval is None:
            log.LogError('Attribute not found %s' % attrname)
            return
        if cval == tval:
            return
        if newthread:
            return uthread.new(self.MorphUI, item, attrname, tval, time, 0, ifWidthConstrain, maxSteps, float, endState=None)
        start, ndt = timeFunc(), 0.0
        steps = 0
        while ndt != 1.0:
            if steps > maxSteps:
                log.LogWarn('MorphUI::Exceeded maxSteps')
                setattr(item, attrname, tval)
                if attrname == 'width' and ifWidthConstrain:
                    setattr(item, 'height', tval)
                break
            try:
                ndt = max(ndt, min(blue.os.TimeDiffInMs(start, timeFunc()) / time, 1.0))
            except:
                log.LogWarn('MorphUI::Failed getting time diff. Diff should not exceed %s but is %s' % (time, start - blue.os.GetWallclockTimeNow()))
                ndt = 1.0

            if ndt < 0.0:
                log.LogWarn('MorphUI::Got fubar TimeDiffInMs, propably because of the timesync... ignoring', start, time)
                setattr(item, attrname, tval)
                if attrname == 'width' and ifWidthConstrain:
                    setattr(item, 'height', tval)
                break
            val = mathUtil.Lerp(cval, tval, ndt)
            if not float:
                val = int(val)
            setattr(item, attrname, val)
            if attrname == 'width' and ifWidthConstrain:
                setattr(item, 'height', val)
            blue.pyos.synchro.Yield()
            steps += 1

        if endState is not None:
            item.state = endState
コード例 #24
0
    def _KnightRideMotion(self, rideRight):
        numBoxes = float(len(self.boxes))
        negVal = -1.0 + 1.0 / numBoxes
        if rideRight:
            current, end = 1.0, negVal
        else:
            current, end = negVal, 1.0
        start, ndt = blue.os.GetWallclockTime(), 0.0
        while ndt != 1.0:
            if not self or self.destroyed or not self.knightRiding:
                break
            ndt = min(
                blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) /
                self.fadeTime, 1.0)
            lerpVal = mathUtil.Lerp(current, end, ndt) * math.pi
            for index, box in enumerate(self.boxes):
                box.opacity = min(
                    1.0,
                    max(
                        0.0,
                        math.sin(lerpVal + math.pi * (index / numBoxes)) * 3 -
                        2))

            blue.pyos.synchro.Yield()
コード例 #25
0
 def HandleZooming(self):
     self.zoom = mathUtil.Lerp(self.zoom, self.desiredZoom,
                               self.frameTime * cameras.ZOOM_SPEED_MODIFIER)
     self.collisionZoom = self.zoom
コード例 #26
0
ファイル: effect.py プロジェクト: R4M80MrX/eve-1
    def CombineEffects(self, item, opacity = None, alpha = None, left = None, top = None, width = None, height = None, rgb = None, _11 = None, _12 = None, time = 250.0, closeWhenDone = False, abortFunction = None, callback = None, doneCallback = None, timeFunc = blue.os.GetWallclockTime):
        sOpacity = None
        if opacity is not None and hasattr(item, 'opacity'):
            sOpacity = item.opacity
        sAlpha = None
        if alpha is not None and hasattr(item, 'GetAlpha'):
            sAlpha = item.GetAlpha()
        s_11 = None
        if _11 is not None and hasattr(item, 'transform'):
            s_11 = item.transform._11
        s_12 = None
        if _12 is not None and hasattr(item, 'transform'):
            s_12 = item.transform._12
        sLeft = None
        if left is not None:
            sLeft = item.left
        sTop = None
        if top is not None:
            sTop = item.top
        sWidth = None
        if width is not None:
            sWidth = item.width
        sHeight = None
        if height is not None:
            sHeight = item.height
        sR = sG = sB = None
        if rgb is not None and hasattr(item, 'GetRGB'):
            sR, sG, sB = item.GetRGB()
            r, g, b = rgb
        start, ndt = timeFunc(), 0.0
        while ndt != 1.0:
            if item.destroyed:
                return
            try:
                ndt = max(ndt, min(blue.os.TimeDiffInMs(start, timeFunc()) / time, 1.0))
            except:
                log.LogWarn('CombineEffects::Failed getting time diff. Diff should not exceed %s but is %s' % (time, start - blue.os.GetWallclockTimeNow()))
                ndt = 1.0

            if sOpacity is not None:
                item.opacity = mathUtil.Lerp(sOpacity, opacity, ndt)
            if sAlpha is not None:
                item.SetAlpha(mathUtil.Lerp(sAlpha, alpha, ndt))
            _r = None
            if sR is not None:
                _r = mathUtil.Lerp(sR, r, ndt)
            _g = None
            if sG is not None:
                _g = mathUtil.Lerp(sG, g, ndt)
            _b = None
            if sB is not None:
                _b = mathUtil.Lerp(sB, b, ndt)
            if _r is not None or _g is not None or _b is not None:
                item.SetRGB(_r, _g, _b)
            if sLeft is not None:
                item.left = int(mathUtil.Lerp(sLeft, left, ndt))
            if sTop is not None:
                item.top = int(mathUtil.Lerp(sTop, top, ndt))
            if sWidth is not None:
                item.width = int(mathUtil.Lerp(sWidth, width, ndt))
            if sHeight is not None:
                item.height = int(mathUtil.Lerp(sHeight, height, ndt))
            if s_11 is not None:
                item.transform._11 = mathUtil.Lerp(s_11, _11, ndt)
            if s_12 is not None:
                item.transform._12 = mathUtil.Lerp(s_12, _12, ndt)
            if callback:
                callback(item)
            blue.pyos.synchro.Yield()
            if abortFunction and abortFunction():
                if closeWhenDone and not item.destroyed:
                    item.Close()
                return

        if doneCallback and not item.destroyed:
            doneCallback(item)
        if closeWhenDone and not item.destroyed:
            item.Close()
コード例 #27
0
 def Fade(self, what, f, t):
     start, ndt = blue.os.GetWallclockTime(), 0.0
     while ndt != 1.0:
         ndt = min(blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) / 1000.0, 1.0)
         what.color.a = mathUtil.Lerp(f, t, ndt)
         blue.pyos.synchro.Yield()
コード例 #28
0
    def _LookAt(self, item, itemID, setZ, resetCamera, smooth):
        if not item:
            return
        if item.GetModel() is None:
            return
        camera = sm.GetService('sceneManager').GetRegisteredCamera('default')
        if camera is None:
            return
        camera.interest = None
        self.GetCameraInterest().translationCurve = None
        cameraParent = self.GetCameraParent()
        if cameraParent is None:
            return
        sm.StartService('state').SetState(itemID, state.lookingAt, 1)
        self.lookingAt = itemID
        item.LookAtMe()
        if cameraParent.translationCurve is not None:
            startPos = cameraParent.translationCurve.GetVectorAt(
                blue.os.GetSimTime())
            startPos = (startPos.x, startPos.y, startPos.z)
            cameraParent.translationCurve = None
        else:
            startPos = cameraParent.translation
        startFov = camera.fieldOfView
        if resetCamera:
            endFov = sm.GetService('sceneManager').maxFov
        else:
            endFov = camera.fieldOfView
        if setZ is None:
            startTrZ = camera.translationFromParent
            endTrZ = self.CheckTranslationFromParent(1.0)
        elif setZ < 0.0:
            camera.translationFromParent = 2.0 * self.CheckTranslationFromParent(
                setZ)
            startTrZ = None
            endTrZ = None
        else:
            camera.translationFromParent = self.CheckTranslationFromParent(
                setZ)
            startTrZ = None
            endTrZ = None
        start = blue.os.GetWallclockTime()
        ndt = 0.0
        time = 500.0
        tracker = None
        tempTF = None
        if item.model.__bluetype__ in ('trinity.EveShip2',
                                       'trinity.EveStation2',
                                       'trinity.EveRootTransform'):
            tracker = trinity.EveSO2ModelCenterPos()
            tracker.parent = item.model
        while ndt != 1.0 and smooth:
            ndt = max(
                0.0,
                min(
                    blue.os.TimeDiffInMs(start, blue.os.GetWallclockTime()) /
                    time, 1.0))
            if tracker is None:
                break
            if hasattr(tracker.parent, 'modelWorldPosition'):
                endPos = tracker.parent.modelWorldPosition
            elif getattr(item.model, 'translationCurve', None) is not None:
                endPos = item.model.translationCurve.GetVectorAt(
                    blue.os.GetSimTime())
                endPos = (endPos.x, endPos.y, endPos.z)
            else:
                endPos = item.model.translation
            if startPos and endPos:
                cameraParent.translation = geo2.Vec3Lerp(startPos, endPos, ndt)
            if startTrZ and endTrZ:
                if endTrZ > startTrZ or resetCamera:
                    camera.translationFromParent = mathUtil.Lerp(
                        startTrZ, endTrZ, ndt)
            if startFov != endFov:
                camera.fieldOfView = mathUtil.Lerp(startFov, endFov, ndt)
            blue.pyos.synchro.Yield()

        if tracker:
            cameraParent.translationCurve = tracker
        else:
            cameraParent.translationCurve = item
        if self.current == 'default':
            self.lastInflightLookat = [itemID, camera.translationFromParent]
コード例 #29
0
    def _BlinkThread(self):
        startTimes = {}
        countsA = {}
        countsRGB = {}
        if not hasattr(self, 'blinksA'):
            self.blinksA = {}
        if not hasattr(self, 'blinksRGB'):
            self.blinksRGB = {}
        try:
            while 1:
                if not self:
                    return
                diffTimes = {}
                rem = []
                for key, each in self.blinksA.iteritems():
                    sprite, a, minA, time, maxCount, passColor, timeFunc = each
                    if not sprite or sprite.destroyed:
                        rem.append(key)
                        continue
                    if passColor and getattr(sprite, 'tripass', None):
                        color = sprite.tripass.textureStage0.customColor
                    else:
                        color = sprite.color
                    if key in getattr(self, 'remPending', []):
                        rem.append(key)
                        color.a = minA or a
                        continue
                    now = timeFunc()
                    try:
                        diff = blue.os.TimeDiffInMs(now, startTimes[timeFunc])
                    except KeyError:
                        startTimes[timeFunc] = now
                        diff = 0

                    pos = diff % time
                    if pos < time / 2.0:
                        ndt = min(pos / (time / 2.0), 1.0)
                        color.a = mathUtil.Lerp(a, minA, ndt)
                    else:
                        ndt = min((pos - time / 2.0) / (time / 2.0), 1.0)
                        color.a = mathUtil.Lerp(minA, a, ndt)
                    if key not in countsA:
                        countsA[key] = timeFunc()
                    if maxCount and blue.os.TimeDiffInMs(
                            countsA[key], timeFunc()) / time > maxCount:
                        rem.append(key)
                        color.a = minA or a
                        if key in countsA:
                            del countsA[key]

                for each in rem:
                    if each in self.blinksA:
                        del self.blinksA[each]

                rem = []
                for key, each in self.blinksRGB.iteritems():
                    sprite, r, g, b, time, maxCount, passColor, timeFunc = each
                    if not sprite or sprite.destroyed:
                        rem.append(key)
                        continue
                    if passColor and getattr(sprite, 'tripass', None):
                        color = sprite.tripass.textureStage0.customColor
                    else:
                        color = sprite.color
                    if key in getattr(self, 'remPending', []):
                        rem.append(key)
                        color.r = r
                        color.g = g
                        color.b = b
                        continue
                    now = timeFunc()
                    try:
                        diff = blue.os.TimeDiffInMs(now, startTimes[timeFunc])
                    except KeyError:
                        startTimes[timeFunc] = now
                        diff = 0

                    pos = diff % time
                    if pos < time / 2.0:
                        ndt = min(pos / (time / 2.0), 1.0)
                        color.r = mathUtil.Lerp(r, 0.0, ndt)
                        color.g = mathUtil.Lerp(g, 0.0, ndt)
                        color.b = mathUtil.Lerp(b, 0.0, ndt)
                    else:
                        ndt = min((pos - time / 2.0) / (time / 2.0), 1.0)
                        color.r = mathUtil.Lerp(0.0, r, ndt)
                        color.g = mathUtil.Lerp(0.0, g, ndt)
                        color.b = mathUtil.Lerp(0.0, b, ndt)
                    if key not in countsRGB:
                        countsRGB[key] = timeFunc()
                    if maxCount and blue.os.TimeDiffInMs(
                            countsRGB[key], timeFunc()) / time > maxCount:
                        rem.append(key)
                        color.r = r
                        color.g = g
                        color.b = b
                        if key in countsRGB:
                            del countsRGB[key]

                for each in rem:
                    if each in self.blinksRGB:
                        del self.blinksRGB[each]

                self.remPending = []
                if not len(self.blinksA) and not len(
                        self.blinksRGB) or not self.blink_running:
                    self.blinksA = {}
                    self.blinksRGB = {}
                    self.blink_running = False
                    break
                blue.pyos.synchro.Yield()

        except Exception:
            self.blink_running = False
            log.LogException()
            sys.exc_clear()