Beispiel #1
0
def CreateSprite(scale, size):
    sprite = trinity.Tr2Sprite2d()
    sprite.texturePrimary = trinity.Tr2Sprite2dTexture()
    sprite.texturePrimary.resPath = 'res:/Texture/Global/blackAlpha.dds'
    sprite.displayHeight = scale
    sprite.displayWidth = scale
    sprite.displayX = 0.5 * (1.0 - 1.0 / size)
    sprite.displayY = 0.5 * (1.0 - 1.0 / size)
    return sprite
Beispiel #2
0
def CreateRandomIcon():
    sprite = trinity.Tr2Sprite2d()
    name = iconFiles[random.randint(0, len(iconFiles) - 1)]
    size = 64
    name = 'res:/UI/Texture/Icons/icons' + name + '.dds'
    tex = trinity.Tr2Sprite2dTexture()
    tex.resPath = name
    sprite.texturePrimary = tex
    sprite.displayWidth = size
    sprite.displayHeight = size
    sprite.color = (1, 1, 1, 1)
    return sprite
    def Show(self, width=800, height=600):
        displayMode = trinity.adapters.GetCurrentDisplayMode(0)
        trinity.app.width = width
        trinity.app.height = height
        trinity.app.left = (displayMode.width - trinity.app.width) / 2
        trinity.app.top = (displayMode.height - trinity.app.height) / 2
        trinity.app.windowed = True
        trinity.app.AdjustWindowForChange(True, True)
        trinity.app.Create()
        pp = {
            'BackBufferWidth': trinity.app.width,
            'BackBufferHeight': trinity.app.height,
            'Windowed': True,
            'EnableAutoDepthStencil': True,
            'AutoDepthStencilFormat': trinity.DEPTH_STENCIL_FORMAT.D24S8,
            'BackBufferFormat': trinity.PIXEL_FORMAT.B8G8R8A8_UNORM,
            'PresentationInterval': trinity.PRESENT_INTERVAL.IMMEDIATE
        }
        trinity.app.ChangeDevice(0, 0, 0, pp)
        self.renderjob = trinity.CreateRenderJob('LoadingScreen')
        scene = trinity.Tr2Sprite2dScene()
        scene.isFullscreen = True
        scene.clearBackground = True
        scene.backgroundColor = (0, 0, 0, 0)
        self.renderjob.Update(scene)
        self.renderjob.RenderScene(scene)
        self.renderjob.ScheduleRecurring()
        sprite = trinity.Tr2Sprite2d()
        sprite.displayWidth = 32
        sprite.displayHeight = 32
        sprite.spriteEffect = trinity.TR2_SFX_FILL
        sprite.color = (1, 1, 1, 1)
        scene.children.append(sprite)

        def loading_screen():
            x = 100
            dx = 4
            y = height * 2 / 3
            while self.active:
                sprite.displayX = x
                sprite.displayY = y
                x += dx
                if x > width - 100 - sprite.displayWidth:
                    dx = -dx
                if x < 100:
                    dx = -dx
                blue.synchro.Yield()

        self.active = True
        uthread2.StartTasklet(loading_screen)
        blue.os.Pump()
        blue.os.Pump()
        blue.os.Pump()
Beispiel #4
0
 def GetPortraitTexture(self, portraitID):
     size = 512
     sceneManager = sm.GetService('sceneManager')
     scene = sceneManager.GetActiveScene()
     backdropPath = self.backdropPath
     if backdropPath:
         backdropScene = trinity.Tr2Sprite2dScene()
         backdropScene.displayWidth = size
         backdropScene.displayHeight = size
         sprite = trinity.Tr2Sprite2d()
         sprite.texturePrimary = trinity.Tr2Sprite2dTexture()
         sprite.texturePrimary.resPath = backdropPath
         sprite.displayWidth = size
         sprite.displayHeight = size
         backdropScene.children.append(sprite)
     target = trinity.Tr2RenderTarget(size, size, 1,
                                      trinity.PIXEL_FORMAT.B8G8R8X8_UNORM)
     depth = trinity.Tr2DepthStencil(size, size,
                                     trinity.DEPTH_STENCIL_FORMAT.AUTO)
     renderJob = trinity.CreateRenderJob('TakeSnapShot')
     renderJob.PushRenderTarget(target)
     renderJob.PushDepthStencil(depth)
     projection = trinity.TriProjection()
     projection.PerspectiveFov(self.camera.fieldOfView, 1, 0.1, 5.0)
     view = self.camera.viewMatrix
     renderJob.Clear((0.0, 0.0, 0.0, 1.0), 1.0)
     renderJob.SetProjection(projection)
     renderJob.SetView(view)
     if backdropPath:
         renderJob.Update(backdropScene)
         renderJob.RenderScene(backdropScene)
     renderJob.RenderScene(scene)
     trinity.WaitForResourceLoads()
     renderJob.PopDepthStencil()
     renderJob.PopRenderTarget()
     renderJob.ScheduleOnce()
     renderJob.WaitForFinish()
     filename = self.GetPortraitSnapshotPath(portraitID)
     trinity.Tr2HostBitmap(target).Save(filename)
     path = 'cache:/Pictures/Portraits/PortraitSnapshot_%s_%s.jpg' % (
         portraitID, session.userid)
     blue.motherLode.Delete(path)
     tex = blue.resMan.GetResource(path, 'atlas')
     return tex
Beispiel #5
0
def _AddTarget():
    import trinity
    import uiconst
    import random
    import uicls
    par = uicls.Container(parent=uicore.desktop,
                          left=256,
                          top=random.randint(1, 500),
                          align=uiconst.RELATIVE,
                          width=300,
                          height=128)
    curveSet = par.CreateCurveSet()
    curveSet.scale = 1.0
    curve = trinity.TriPerlinCurve()
    curve.scale = 1000.0
    curve.offset = -0.0
    curve.N = 2
    curve.speed = 1.0
    curve.alpha = 1000.0
    curve.beta = 5000.0
    curveSet.curves.append(curve)
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = par
    binding.destinationAttribute = 'displayY'
    binding.scale = 1
    curveSet.bindings.append(binding)
    curve = trinity.TriPerlinCurve()
    curve.scale = 1200.0
    curve.offset = -300.0
    curve.N = 2
    curve.speed = 1.0
    curve.alpha = 1200.0
    curve.beta = 8000.0
    curveSet.curves.append(curve)
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = par
    binding.destinationAttribute = 'displayX'
    binding.scale = 1
    curveSet.bindings.append(binding)
    inTime = 0.5
    mainParent = uicls.Container(parent=par,
                                 name='mainParent',
                                 align=uiconst.RELATIVE,
                                 width=200,
                                 height=64,
                                 top=32,
                                 left=96)
    maintext = uicls.Sprite(parent=mainParent,
                            texturePath='res:/UICore/texture/text.dds',
                            left=96.0,
                            width=200,
                            height=64,
                            effect=trinity.S2D_RFX_BLUR)
    caption = uicls.Sprite(parent=mainParent,
                           texturePath='res:/UICore/texture/caption.dds',
                           left=50,
                           top=56,
                           width=160,
                           height=32,
                           effect=trinity.S2D_RFX_BLUR)
    bracket = uicls.Sprite(parent=mainParent,
                           texturePath='res:/UICore/texture/brackettext.dds',
                           left=200,
                           top=56,
                           width=100,
                           height=32,
                           effect=trinity.S2D_RFX_BLUR)
    scrolltext = uicls.Label(parent=mainParent,
                             text='0123456789',
                             align=uiconst.TOPLEFT,
                             left=237,
                             top=7,
                             fontsize=9,
                             color=(1.0, 1.0, 1.0, 0.5))
    curve, binding = CreateColorCurve(bracket,
                                      curveSet,
                                      length=0.5,
                                      startValue=(1, 1, 1, 1),
                                      endValue=(1, 1, 1, 0),
                                      cycle=True)
    curve.AddKey(0.0, (1, 1, 1, 0.0))
    curve.AddKey(0.1, (1, 1, 1, 1))
    curve.AddKey(0.5, (1, 1, 1, 0.0))
    AddBinding(curve, 'currentValue', caption, 'color', curveSet)
    curve, binding = CreateScalarCurve(mainParent,
                                       'currentValue',
                                       'displayX',
                                       curveSet,
                                       length=inTime,
                                       startValue=-500.0,
                                       endValue=0.0,
                                       endTangent=-1000.0,
                                       cycle=False)
    correction = -0.5
    curve = trinity.TriPerlinCurve()
    curve.scale = 400.0
    curve.offset = 200.0
    curveSet.curves.append(curve)
    innerTransform = trinity.Tr2Sprite2dTransform()
    innerTransform.translation = (0, 0)
    innerTransform.rotationCenter = (64, 64)
    par.children.insert(0, innerTransform)
    inner = trinity.Tr2Sprite2d()
    innerTransform.children.append(inner)
    inner.displayWidth = inner.displayHeight = 128
    inner.displayX = correction
    inner.displayY = correction
    inner.texturePrimary = trinity.Tr2Sprite2dTexture()
    inner.texturePrimary.resPath = 'res:/uicore/Texture/innercircles.dds'
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = innerTransform
    binding.destinationAttribute = 'rotation'
    binding.scale = 0.025
    curveSet.bindings.append(binding)
    curve = trinity.TriSineCurve()
    curve.scale = 500.0
    curve.offset = 300.0
    curve.speed = 0.3
    curveSet.curves.append(curve)
    outerTransform = trinity.Tr2Sprite2dTransform()
    outerTransform.translation = (0, 0)
    outerTransform.rotationCenter = (64, 64)
    par.children.insert(0, outerTransform)
    outer = trinity.Tr2Sprite2d()
    outerTransform.children.append(outer)
    outer.displayWidth = outer.displayHeight = 128
    outer.displayX = correction
    outer.displayY = correction
    outer.texturePrimary = trinity.Tr2Sprite2dTexture()
    outer.texturePrimary.resPath = 'res:/uicore/Texture/outercircles.dds'
    outer.effect = trinity.S2D_RFX_BLUR
    outer.blurFactor = 0.1
    binding = trinity.TriValueBinding()
    binding.sourceObject = curve
    binding.sourceAttribute = 'value'
    binding.destinationObject = outerTransform
    binding.destinationAttribute = 'rotation'
    binding.scale = 0.00125
    curveSet.bindings.append(binding)
    curveSet.Play()