Ejemplo n.º 1
0
 def __init__(self, text, parent, size=72, shadow=0, hspace=8, font=None):
     self.transform = trinity.EveTransform()
     self.transform.mesh = trinity.Tr2Mesh()
     self.transform.mesh.geometryResPath = 'res:/Model/Global/zsprite.gr2'
     self.transform.modifier = 1
     self.measurer = trinity.Tr2FontMeasurer()
     self.measurer.limit = 0
     if font is None:
         font = _GetDefaultFont()
     self.measurer.font = font
     self.measurer.fontSize = size
     self.measurer.letterSpace = hspace
     area = trinity.Tr2MeshArea()
     self.transform.mesh.transparentAreas.append(area)
     area.effect = self.effect = trinity.Tr2Effect()
     sampler = list(self.effect.samplerOverrides.GetDefaultValue())
     sampler[0] = 'DiffuseMapSampler'
     sampler[1] = trinity.TRITADDRESS_CLAMP
     sampler[2] = trinity.TRITADDRESS_CLAMP
     self.effect.samplerOverrides.append(tuple(sampler))
     self.effect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/SpecialFX/TextureColor.fx'
     diffuseColor = trinity.Tr2Vector4Parameter()
     diffuseColor.name = 'DiffuseColor'
     self.effect.parameters.append(diffuseColor)
     self.diffuseColor = diffuseColor
     self.diffuseMap = trinity.TriTextureParameter()
     self.diffuseMap.name = 'DiffuseMap'
     self.effect.resources.append(self.diffuseMap)
     parent.children.append(self.transform)
     trinity.device.RegisterResource(self)
     self.SetText(text)
Ejemplo n.º 2
0
 def Create3DRender(self):
     self.renderTexture = trinity.TriTexture2DParameter()
     self.renderTexture.name = 'DiffuseMap'
     self.renderColor = trinity.TriVector4Parameter()
     self.renderColor.name = 'DiffuseColor'
     self.renderColor.value = (1, 1, 1, 1)
     self.renderEffect = trinity.Tr2Effect()
     self.renderEffect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/SpecialFX/TextureColor.fx'
     self.renderEffect.resources.append(self.renderTexture)
     self.renderEffect.parameters.append(self.renderColor)
     self.renderArea = trinity.Tr2MeshArea()
     self.renderArea.effect = self.renderEffect
     self.renderMesh = trinity.Tr2Mesh()
     self.renderMesh.name = 'orbitalBombardmentTarget'
     self.renderMesh.geometryResPath = 'res:/Graphics/Generic/UnitPlane/UnitPlane.gr2'
     self.renderMesh.transparentAreas.append(self.renderArea)
     self.transform = trinity.EveRootTransform()
     self.transform.mesh = self.renderMesh
     self.renderScene.objects.append(self.transform)
     self.renderJob = trinity.CreateRenderJob()
     self.renderJob.Update(self.renderScene)
     self.renderObject = self.GetRenderObject()
     self.renderObject.is2dPick = False
     self.renderTarget = trinity.Tr2RenderTarget(
         self.width, self.height, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM)
     self.renderJob.PushRenderTarget(self.renderTarget)
     self.renderJob.RenderScene(self.renderObject)
     self.renderJob.PopRenderTarget()
     self.renderJob.ScheduleRecurring(insertFront=True)
     self.renderTexture.SetResource(trinity.TriTextureRes(
         self.renderTarget))
     self.renderSteps[-1].enabled = False
     return self.transform
Ejemplo n.º 3
0
    def CreateSun(self, sunGraphic):

        def GetEffectParameter(effect, parameterName):
            for each in effect.parameters:
                if each.name == parameterName:
                    return each

        scaling = 1.0 / mapViewConst.SOLARSYSTEM_SCALE * 16
        sunTransform = trinity.EveTransform()
        sunTransform.name = 'Sun'
        sunTransform.scaling = (scaling, scaling, scaling)
        sunTransform.useDistanceBasedScale = True
        sunTransform.distanceBasedScaleArg1 = 0.02
        sunTransform.distanceBasedScaleArg2 = 0.1
        self.systemMapTransform.children.append(sunTransform)
        for each in sunGraphic.mesh.additiveAreas:
            if 'flare' not in each.name.lower() and 'rainbow' not in each.name.lower():
                transform = trinity.EveTransform()
                try:
                    size = GetEffectParameter(each.effect, 'Size')
                    transform.scaling = (size.x, size.y, size.z)
                except:
                    continue

                transform.mesh = trinity.Tr2Mesh()
                transform.mesh.geometryResPath = 'res:/Model/Global/zsprite.gr2'
                transform.modifier = 1
                transform.name = each.name
                area = trinity.Tr2MeshArea()
                transform.mesh.additiveAreas.append(area)
                effect = trinity.Tr2Effect()
                effect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/SpecialFX/TextureColor.fx'
                area.effect = effect
                diffuseColor = trinity.Tr2Vector4Parameter()
                diffuseColor.name = 'DiffuseColor'
                effect.parameters.append(diffuseColor)
                diffuseColor = diffuseColor
                diffuseMap = trinity.TriTextureParameter()
                diffuseMap.name = 'DiffuseMap'
                diffuseMap.resourcePath = each.effect.resources[0].resourcePath
                effect.resources.append(diffuseMap)
                try:
                    color = GetEffectParameter(each.effect, 'Color')
                    diffuseColor.value = color.value
                except:
                    continue

                sunTransform.children.append(transform)
Ejemplo n.º 4
0
def AddPrepassAreasToStatic(static):
    if static.displayTargetMesh:
        mesh = trinity.Tr2Mesh()
        mesh.name = 'EnlightenAreas'
        mesh.geometryResPath = static.geometryResPath
        static.detailMeshes.append(mesh)
        for area in static.enlightenAreas:
            newArea = trinity.Tr2MeshArea()
            newArea.name = area.name
            newArea.index = area.index
            newArea.count = area.count
            newArea.effect = area.effect
            mesh.opaqueAreas.append(newArea)
            area.effect = None

        static.detailMeshes.append(mesh)
    for mesh in static.detailMeshes:
        AddPrepassAreasToStandardMesh(mesh)

    if ENABLE_MATERIAL_RES_SUPPORT:
        materialRes = Materials.LoadMaterialResFromObject(static)
        Materials.ApplyMaterialRes(static, materialRes)
Ejemplo n.º 5
0
 def __init__(self, text, parent, size=72, shadow=0, hspace=8):
     self.transform = trinity.EveTransform()
     self.transform.mesh = trinity.Tr2Mesh()
     self.transform.mesh.geometryResPath = 'res:/Model/Global/zsprite.gr2'
     self.transform.modifier = 1
     self.measurer = trinity.Tr2FontMeasurer()
     self.measurer.limit = 0
     fontFamily = uicore.font.GetFontFamilyBasedOnClientLanguageID()[
         fontConst.STYLE_DEFAULT]
     self.measurer.font = fontFamily[2]
     self.measurer.fontSize = size
     self.measurer.letterSpace = hspace
     self.measurer.AddText(text.upper())
     height = self.measurer.ascender - self.measurer.descender
     width = self.measurer.cursorX
     self.measurer.CommitText(0, self.measurer.ascender)
     self.transform.scaling = (width, height, 0)
     area = trinity.Tr2MeshArea()
     self.transform.mesh.transparentAreas.append(area)
     area.effect = self.effect = trinity.Tr2Effect()
     sampler = list(self.effect.samplerOverrides.GetDefaultValue())
     sampler[0] = 'DiffuseMapSampler'
     sampler[1] = trinity.TRITADDRESS_CLAMP
     sampler[2] = trinity.TRITADDRESS_CLAMP
     self.effect.samplerOverrides.append(tuple(sampler))
     self.effect.effectFilePath = 'res:/Graphics/Effect/Managed/Space/SpecialFX/TextureColor.fx'
     diffuseColor = trinity.Tr2Vector4Parameter()
     diffuseColor.name = 'DiffuseColor'
     self.effect.parameters.append(diffuseColor)
     self.diffuseColor = diffuseColor
     self.diffuseMap = trinity.TriTextureParameter()
     self.diffuseMap.name = 'DiffuseMap'
     self.effect.resources.append(self.diffuseMap)
     parent.children.append(self.transform)
     trinity.device.RegisterResource(self)
     self.OnCreate(trinity.device)
    def SetShipModel(self, entity):
        hologramComponent = entity.GetComponent('shipHologram')
        if hologramComponent is None or not hologramComponent.graphicLoaded:
            return
        interiorPlaceable = entity.GetComponent('interiorPlaceable')
        if interiorPlaceable is None:
            return
        effect = trinity.Load(
            'res:/graphics/interior/effect/hologram/shipHologramEffect.red')
        targetPlaceable = interiorPlaceable.renderObject
        targetPlaceable.isUnique = True
        targetPlaceable.BindLowLevelShaders()
        targetVisual = targetPlaceable.placeableRes.visualModel
        mesh = None
        for each in targetVisual.meshes:
            if each.name == 'shipHologramMesh':
                mesh = each
                break

        if mesh is not None:
            targetVisual.meshes.remove(mesh)
        targetPlaceable.BoundingBoxReset()
        if self.activeShipModel is None:
            return
        if self.activeShipID is None:
            return
        mesh = trinity.Tr2Mesh()
        mesh.name = 'shipHologramMesh'
        mesh.geometryResPath = self.activeShipModel.mesh.GetGeometryResPath()
        maxIndex = 0
        for area in self.activeShipModel.mesh.opaqueAreas:
            maxIndex = max(maxIndex, area.index)

        for area in self.activeShipModel.mesh.decalAreas:
            maxIndex = max(maxIndex, area.index)

        for area in self.activeShipModel.mesh.transparentAreas:
            maxIndex = max(maxIndex, area.index)

        meshArea = trinity.Tr2MeshArea()
        meshArea.effect = effect
        meshArea.count = maxIndex + 1
        mesh.transparentAreas.append(meshArea)
        effect.BindLowLevelShader([])
        bbMinOriginal, bbMaxOriginal = targetVisual.GetBoundingBoxInLocalSpace(
        )
        scale, extra = self.CalculateModelScale(
            hologramComponent, self.activeShipModel.boundingSphereRadius,
            self.activeShipID)
        param = effect.parameters['ScalingAndOffset']
        x = param.x = hologramComponent.positionOffset[0]
        y = param.y = hologramComponent.positionOffset[1]
        z = param.z = hologramComponent.positionOffset[2]
        param.w = scale * extra
        param = effect.parameters['Color']
        param.x = hologramComponent.color[0]
        param.y = hologramComponent.color[1]
        param.z = hologramComponent.color[2]
        param = effect.parameters['SpotlightOrigin']
        param.x = hologramComponent.spotlightOrigin[0]
        param.y = hologramComponent.spotlightOrigin[1]
        param.z = hologramComponent.spotlightOrigin[2]
        targetVisual.meshes.append(mesh)
        trinity.WaitForResourceLoads()
        bbMin, bbMax = self.activeShipModel.GetLocalBoundingBox()
        maxBounds = max(abs(bbMin[0]),
                        max(bbMax[0], max(abs(bbMin[2]), bbMax[2])))
        bbMin = (-maxBounds, bbMin[2], -maxBounds)
        bbMax = (maxBounds, bbMax[2], maxBounds)
        bbMin = geo2.Vec3Scale(bbMin, scale)
        bbMax = geo2.Vec3Scale(bbMax, scale)
        bbMin = geo2.Vec3Add(bbMin, (x, y, z))
        bbMax = geo2.Vec3Add(bbMax, (x, y, z))
        bbMin = geo2.Min(bbMin, bbMinOriginal)
        bbMax = geo2.Max(bbMax, bbMaxOriginal)
        targetPlaceable.BoundingBoxOverride(bbMin, bbMax)