Exemple #1
0
def SetupAnimation(scene):
    layer1 = trinity.Tr2Sprite2dLayer()
    layer1.name = u'Layer 1'
    layer1.displayX = 80
    layer1.displayY = 80
    layer1.displayWidth = 400
    layer1.displayHeight = 200
    layer1.color = (1.0, 1.0, 1.0, 1.0)
    layer1.backgroundColor = (1.0, 0.2, 0.2, 0.5)
    layer1.clearBackground = True
    layer1.blendMode = trinity.TR2_SBM_BLEND
    for i in xrange(10):
        sprite = CreateRandomIcon()
        sprite.displayX = random.randint(0, 100)
        sprite.displayY = random.randint(0, 100)
        layer1.children.append(sprite)

    cs = trinity.TriCurveSet()
    SetupLotsOfIcons(layer1, cs, 20)
    scene.children.append(layer1)
    scene.curveSets.append(cs)
    cs.Play()
    layer2 = trinity.Tr2Sprite2dLayer()
    layer2.name = 'Layer 2'
    layer2.displayX = 40
    layer2.displayY = 40
    layer2.displayWidth = 400
    layer2.displayHeight = 200
    layer2.color = (1.0, 1.0, 1.0, 1.0)
    layer2.backgroundColor = (0.2, 1.0, 0.2, 1.0)
    layer2.clearBackground = True
    layer2.blendMode = trinity.TR2_SBM_BLEND
    for i in xrange(10):
        sprite = CreateRandomIcon()
        sprite.displayX = random.randint(0, 100)
        sprite.displayY = random.randint(0, 100)
        layer2.children.append(sprite)

    scene.children.append(layer2)
    ec1 = trinity.TriEventCurve()
    ec1.eventListener = blue.BlueEventToPython()
    ec1.eventListener.handler = EventHandler(scene, layer1)
    ec1.AddKey(1.0, u'FadeIn')
    ec1.AddKey(5.0, u'FadeOut')
    ec1.AddKey(6.0, u'DisplayOff')
    ec1.AddKey(6.1, u'End')
    ec2 = trinity.TriEventCurve()
    ec2.eventListener = blue.BlueEventToPython()
    ec2.eventListener.handler = EventHandler(scene, layer2)
    ec2.AddKey(1.0, u'BlurIn')
    ec2.AddKey(5.0, u'BlurOut')
    ec2.AddKey(6.0, u'DisplayOff')
    ec2.AddKey(6.1, u'End')
    cs = trinity.TriCurveSet()
    cs.name = 'Events'
    cs.curves.append(ec1)
    cs.curves.append(ec2)
Exemple #2
0
    def _SpawnExplosion(self, warheadIdx):
        if not self.model:
            self.LogWarn('Missile::_SpawnExplosion no model')
            return
        explosionPosition = self._GetExplosionPosition(warheadIdx)
        self.warheadsReleased += 1
        if self.exploded:
            return
        if self.warheadsReleased == self.totalWarheadCount:
            if self.model:
                self.model.target = None
                self.model.explosionCallback = None
                self.RemoveAndClearModel(self.model,
                                         self.globalsGlob.GetScene())
                self.model = None
            if self.delayedBall:
                self.globalsGlob.DestroyClientBall(self.delayedBall)
                self.delayedBall = None
            self.exploded = True
        actualModel = self.explosionManager.GetExplosion(
            self.explosionPath, preloaded=True, callback=self.CleanupExplosion)
        if actualModel is None:
            self.LogError('missile::LoadModel failed to get explosion ' +
                          str(self.explosionPath))
            self.explosionManager.Cancel(self.explosionPath, 1)
            return
        explosionBall = None
        if self.enabled:
            explosionBall = self.globalsGlob.SpawnClientBall(explosionPosition)
            actualModel.translationCurve = explosionBall
            rndRotation = geo2.QuaternionRotationSetYawPitchRoll(
                random.random() * 2.0 * math.pi,
                random.random() * 2.0 * math.pi,
                random.random() * 2.0 * math.pi)
            actualModel.rotation = rndRotation
            scene = self.globalsGlob.GetScene()
            if scene is not None:
                scene.objects.append(actualModel)
                audio = audio2.AudEmitter('effect_source_%s' % str(id(self)))
                obs = trinity.TriObserverLocal()
                obs.front = (0.0, -1.0, 0.0)
                obs.observer = audio
                del actualModel.observers[:]
                actualModel.observers.append(obs)

                def AudioSetup(*args):
                    for eachSet in actualModel.active.curveSets:
                        for eachCurve in eachSet.curves:
                            if eachCurve.__typename__ == 'TriEventCurve':
                                audio.SendEvent(eachCurve.GetKeyValue(0))
                                break

                loadedEventHandler = blue.BlueEventToPython()
                loadedEventHandler.handler = AudioSetup
                actualModel.loadedCallback = loadedEventHandler
            shakeMagnitude = min(actualModel.boundingSphereRadius, 250)
            shakeMagnitude = max(shakeMagnitude, 50)
            self.globalsGlob.ShakeCamera(shakeMagnitude, explosionPosition)
Exemple #3
0
    def CreateDevice(self):
        self.LogInfo('CreateDevice')
        if '/safemode' in blue.pyos.GetArg():
            self.SetToSafeMode()
        triapp = trinity.app
        triapp.title = uicore.triappargs['title']
        triapp.minimumWidth = self.minimumSize['width']
        triapp.minimumHeight = self.minimumSize['height']
        triapp.width = triapp.minimumWidth
        triapp.height = triapp.minimumHeight
        triapp.hideTitle = 1
        triapp.fullscreen = 0
        triapp.Create()
        dev = trinity.device
        while not dev.DoesD3DDeviceExist():
            try:
                self.Initialize()
                triapp = trinity.app
                trinity.device.disableAsyncLoad = not bool(
                    settings.public.generic.Get('asyncLoad', 1))
                self.SetResourceCacheSize()
                dev.mipLevelSkipCount = gfxsettings.Get(
                    gfxsettings.GFX_TEXTURE_QUALITY)
                trinity.SetShaderModel(self.GetAppShaderModel())
                if not self.PrepareMain(True):
                    blue.os.Pump()
                    time.sleep(0.5)
                    continue
                if trinity.adapters.SupportsDepthStencilFormat(
                        trinity.adapters.DEFAULT_ADAPTER,
                        trinity.adapters.GetCurrentDisplayMode(
                            trinity.adapters.DEFAULT_ADAPTER).format,
                        trinity.DEPTH_STENCIL_FORMAT.READABLE):
                    trinity.AddGlobalSituationFlags(['OPT_INTZ'])
                else:
                    trinity.RemoveGlobalSituationFlags(['OPT_INTZ'])
                try:
                    trinity.RebindAllShaderMaterials()
                except:
                    pass

            except trinity.D3DERR_NOTAVAILABLE as e:
                sys.exc_clear()
                trinity.adapters.Refresh()
            except trinity.ALDeviceNotAvailable as e:
                sys.exc_clear()
                trinity.adapters.Refresh()

        if not blue.sysinfo.isTransgaming:
            resizeEventHandler = blue.BlueEventToPython()
            resizeEventHandler.handler = self.HandleResizeEvent
            triapp.resizeEventListener = resizeEventHandler
        for k, v in self.GetAppSettings().iteritems():
            trinity.settings.SetValue(k, v)

        for dir in self.GetAppMipLevelSkipExclusionDirectories():
            trinity.AddMipLevelSkipExclusionDirectory(dir)
Exemple #4
0
    def CreateDevice(self):
        self.LogInfo('CreateDevice')
        if '/safemode' in blue.pyos.GetArg():
            self.SetToSafeMode()
        triapp = trinity.app
        triapp.title = uicore.triappargs['title']
        triapp.hideTitle = 1
        triapp.fullscreen = 0
        triapp.Create()
        triapp.minimumWidth = self.minimumSize['width']
        triapp.minimumHeight = self.minimumSize['height']
        dev = trinity.device
        while not dev.DoesD3DDeviceExist():
            try:
                self.Initialize()
                triapp = trinity.app
                trinity.device.disableAsyncLoad = not bool(
                    settings.public.generic.Get('asyncLoad', 1))
                if self.IsHDRSupported() and settings.public.device.Get(
                        'hdrEnabled', self.GetDefaultHDRState()):
                    dev.hdrEnable = True
                else:
                    dev.hdrEnable = False
                self.SetResourceCacheSize()
                blue.os.sleeptime = 0
                dev.mipLevelSkipCount = settings.public.device.Get(
                    'textureQuality', self.GetDefaultTextureQuality())
                trinity.SetShaderModel(self.GetAppShaderModel())
                self.PrepareMain(True)
                if trinity.adapters.SupportsDepthStencilFormat(
                        trinity.adapters.DEFAULT_ADAPTER,
                        trinity.adapters.GetCurrentDisplayMode(
                            trinity.adapters.DEFAULT_ADAPTER).format,
                        trinity.DEPTH_STENCIL_FORMAT.READABLE):
                    trinity.AddGlobalSituationFlags(['OPT_INTZ'])
                else:
                    trinity.RemoveGlobalSituationFlags(['OPT_INTZ'])
                try:
                    trinity.RebindAllShaderMaterials()
                except:
                    pass

            except trinity.D3DERR_NOTAVAILABLE as e:
                sys.exc_clear()
                trinity.adapters.Refresh()

        if not blue.win32.IsTransgaming():
            resizeEventHandler = blue.BlueEventToPython()
            resizeEventHandler.handler = self.HandleResizeEvent
            triapp.resizeEventListener = resizeEventHandler
        for k, v in self.GetAppSettings().iteritems():
            trinity.settings.SetValue(k, v)

        for dir in self.GetAppMipLevelSkipExclusionDirectories():
            trinity.AddMipLevelSkipExclusionDirectory(dir)
Exemple #5
0
 def _CreateErrorHandler(self):
     eventHandler = blue.BlueEventToPython()
     eventHandler.handler = self._ErrorListener
     self.errorHandler = eventHandler
Exemple #6
0
 def CreateDevice(self):
     DeviceMgr.CreateDevice(self)
     if blue.sysinfo.isTransgaming:
         tgToggleEventHandler = blue.BlueEventToPython()
         tgToggleEventHandler.handler = self.ToggleWindowedTransGaming
         trinity.app.tgToggleEventListener = tgToggleEventHandler
Exemple #7
0
 def CreateDevice(self):
     svc.device.CreateDevice(self)
     if blue.win32.IsTransgaming():
         tgToggleEventHandler = blue.BlueEventToPython()
         tgToggleEventHandler.handler = self.ToggleWindowedTransGaming
         trinity.app.tgToggleEventListener = tgToggleEventHandler