Esempio n. 1
0
    def PrepareAnimationSetupFor(self, fileName):
        if fileName in BUILD_MODEL:
            self.model.highDetailMesh.Freeze()
            self.model.mediumDetailMesh.Freeze()
            self.model.lowDetailMesh.Freeze()
            alphas = nodemanager.FindNodes(self.model, 'AlphaThreshold', 'trinity.TriVector4Parameter')
            curves = nodemanager.FindNodes(self.model, 'STATE_BUILD', 'trinity.TriCurveSet')
            curve = curves[0]
            src = curve.curves[0]
            while len(curve.bindings) > 0:
                curve.bindings.fremove(curve.bindings[0])

            for eachAlpha in alphas:
                binding = trinity.TriValueBinding()
                binding.sourceAttribute = 'value'
                binding.destinationAttribute = 'v1'
                binding.scale = 1.0
                binding.sourceObject = src
                binding.destinationObject = eachAlpha
                curve.bindings.append(binding)
                binding = None

            curve.scale = 0.0
            curve.Play()
        if fileName == ONLINE_MODEL:
            holograms = nodemanager.FindNodes(self.model.children, 'Holograms', 'trinity.EveTransform')
            projectors = nodemanager.FindNodes(self.model.children, 'Projectors', 'trinity.EveTransform')
            for each in holograms + projectors:
                each.display = False

            curves = nodemanager.FindNodes(self.model, 'STATE_ONLINE', 'trinity.TriCurveSet')
            for curve in curves:
                curve.scale = 0.0
                curve.Play()
Esempio n. 2
0
    def CheckHeightMaps(self):
        if 'LO' in trinity.GetShaderModel():
            heightMapParams = nodemanager.FindNodes(self.scene, 'HeightMap', 'trinity.TriTexture2DParameter')
            for param in heightMapParams:
                param.resourcePath = param.resourcePath.replace('_hi.dds', '_lo.dds')

        else:
            heightMapParams = nodemanager.FindNodes(self.scene, 'HeightMap', 'trinity.TriTexture2DParameter')
            for param in heightMapParams:
                param.resourcePath = param.resourcePath.replace('_lo.dds', '_hi.dds')
Esempio n. 3
0
    def GetMaterial(self):
        if self.model is None:
            self.LogWarn('GetMaterial - No model')
            return []
        res = []
        effects = nodemanager.FindNodes(self.model, 'Armor',
                                        'trinity.Tr2Effect')
        for each in effects:
            for glow in nodemanager.FindNodes(each, 'GlowColor',
                                              'trinity.TriVector4Parameter'):
                res.append(glow)

        return res
Esempio n. 4
0
    def SteadyStateAnimations(self, posState):
        if posState in (pos.STRUCTURE_ONLINE, pos.STRUCTURE_VULNERABLE):
            self.model.ChainAnimationEx('LOOP_Open', 0, 0, 1.0)
            curves = nodemanager.FindNodes(self.model, 'STATE_ONLINE', 'trinity.TriCurveSet')
            for each in curves:
                each.scale = 0.0
                each.PlayFrom(0)

            holograms = nodemanager.FindNodes(self.model.children, 'Holograms', 'trinity.EveTransform')
            projectors = nodemanager.FindNodes(self.model.children, 'Projectors', 'trinity.EveTransform')
            for each in holograms + projectors:
                each.display = True

        elif posState == pos.STRUCTURE_ANCHORED:
            curves = nodemanager.FindNodes(self.model, 'STATE_BUILD', 'trinity.TriCurveSet')
            for each in curves:
                each.scale = 0.0
                each.PlayFrom(each.GetMaxCurveDuration())
Esempio n. 5
0
 def Assemble(self):
     godmaStateManager = sm.StartService('godma').GetStateManager()
     slimItem = sm.StartService('michelle').GetBallpark().GetInvItem(
         self.id)
     godmaType = godmaStateManager.GetType(slimItem.typeID)
     self.effectRadius = godmaType.warpScrambleRange
     damages = nodemanager.FindNodes(self.model, 'locator_damage',
                                     'trinity.TriTransform')
     self.damages = damages
     spaceObject.DeployableSpaceObject.SetColorBasedOnStatus(self)
Esempio n. 6
0
    def StartAnimationsFrom(self, oldState, posState, timeSinceStartMs, playForward):
        transState = (oldState, posState)
        timeSincesStartS = timeSinceStartMs / 1000.0
        if transState == (pos.STRUCTURE_UNANCHORED, pos.STRUCTURE_ANCHORED):
            curves = nodemanager.FindNodes(self.model, 'STATE_BUILD', 'trinity.TriCurveSet')
            self.StartCurvesIn(curves, playForward, startTime=timeSincesStartS)
        elif transState == (pos.STRUCTURE_ANCHORED, pos.STRUCTURE_UNANCHORED):
            curves = nodemanager.FindNodes(self.model, 'STATE_BUILD', 'trinity.TriCurveSet')
            maxTime = 0.0
            for each in curves:
                maxTime = max(maxTime, each.GetMaxCurveDuration())

            maxTime = int(maxTime) * 1000
            godma = sm.GetService('godma')
            slim = self.ballpark.slimItems[self.id]
            unanchorTime = godma.GetTypeAttribute(slim.typeID, const.attributeUnanchoringDelay)
            self.StartCurvesIn(curves, playForward, delay=unanchorTime - maxTime, startTime=timeSincesStartS)
        elif transState in [(pos.STRUCTURE_ANCHORED, pos.STRUCTURE_ONLINING),
         (pos.STRUCTURE_ONLINE, pos.STRUCTURE_ANCHORED),
         (pos.STRUCTURE_ONLINING, pos.STRUCTURE_ANCHORED),
         (pos.STRUCTURE_VULNERABLE, pos.STRUCTURE_ANCHORED)]:
            curves = nodemanager.FindNodes(self.model, 'STATE_ONLINING', 'trinity.TriCurveSet')
            if playForward:
                self.model.ChainAnimationEx('Opening', 1, 0, 1.0)
                self.model.ChainAnimationEx('LOOP_Open', 0, 0, 1.0)
                for each in curves:
                    each.scale = 1.0
                    each.PlayFrom(timeSincesStartS)

            else:
                holograms = nodemanager.FindNodes(self.model.children, 'Holograms', 'trinity.EveTransform')
                projectors = nodemanager.FindNodes(self.model.children, 'Projectors', 'trinity.EveTransform')
                for each in holograms + projectors:
                    each.display = False

                self.model.ChainAnimationEx('Closing', 1, 0, 1.0)
                for each in curves:
                    each.scale = -1.0
                    each.PlayFrom(each.GetMaxCurveDuration() - timeSincesStartS)

        elif transState == (pos.STRUCTURE_ONLINING, pos.STRUCTURE_ONLINE):
            self.SteadyStateAnimations(posState)
Esempio n. 7
0
 def ChangeVulnerableState(self, toVulnerable):
     difuseNodes = nodemanager.FindNodes(self.model, 'DiffuseColor', 'trinity.TriVector4Parameter')
     for each in difuseNodes:
         if toVulnerable:
             each.v1 = 6.0
             each.v2 = 1.9765
             each.v3 = 1.0353
         else:
             each.v1 = 2.4314
             each.v2 = 3.6863
             each.v3 = 4.0
Esempio n. 8
0
    def GetDelayFromModel(self, posState):
        if posState in [(pos.STRUCTURE_ONLINE, pos.STRUCTURE_ANCHORED), (pos.STRUCTURE_ONLINING, pos.STRUCTURE_ANCHORED), (pos.STRUCTURE_VULNERABLE, pos.STRUCTURE_ANCHORED)]:
            delayBonus = 0.0
            if posState in [(pos.STRUCTURE_ONLINE, pos.STRUCTURE_ANCHORED), (pos.STRUCTURE_VULNERABLE, pos.STRUCTURE_ANCHORED)]:
                delayBonus = LOOP_ROTATION_TIME
            curves = nodemanager.FindNodes(self.model, 'STATE_ONLINE', 'trinity.TriCurveSet')
            for each in curves:
                delay = (each.GetMaxCurveDuration() + delayBonus) * 1000
                return delay

        return 10000
Esempio n. 9
0
 def FindOrMakeAlphathreshold(self, effect, v1, v2, v3, v4):
     nodes = nodemanager.FindNodes(effect.parameters, 'AlphaThreshold', 'trinity.TriVector4Parameter')
     res = None
     if nodes:
         res = nodes[0]
     else:
         res = trinity.TriVector4Parameter()
         res.name = 'AlphaThreshold'
     if res:
         res.v1 = v1
         res.v2 = v2
         res.v3 = v3
         res.v4 = v4
     return res
Esempio n. 10
0
    def FindOrMakeAlphathreshold(self, effect, v1, v2, v3, v4):
        """ find a alpha threshold, or make one."""
        for i, each in enumerate(effect.constParameters):
            if each[0] == 'AlphaThreshold':
                del effect.constParameters[i]
                break

        nodes = nodemanager.FindNodes(effect.parameters, 'AlphaThreshold', 'trinity.Tr2Vector4Parameter')
        res = None
        if nodes:
            res = nodes[0]
        else:
            res = trinity.Tr2Vector4Parameter()
            res.name = 'AlphaThreshold'
        if res:
            res.v1 = v1
            res.v2 = v2
            res.v3 = v3
            res.v4 = v4
        return res
Esempio n. 11
0
 def RemoveFloatAlphathreshold(self, effect):
     """ Some alpha chanels need to be converted to Vector4 params, so remove the float ones."""
     removes = nodemanager.FindNodes(effect.parameters, 'AlphaThreshold', 'trinity.Tr2FloatParameter')
     for each in removes:
         effect.parameters.fremove(each)
Esempio n. 12
0
    def PrepareModelForConstruction(self, builtAlready, onlineAlready):
        self.LogInfo('  PrepareModelForConstruction - Built:', builtAlready, ' Online:', onlineAlready)
        if not self.model:
            return (None, None)
        if not hasattr(self.model, 'curveSets'):
            return (None, None)
        model = self.model
        alphaParams = []
        if model.meshLod:
            self.PrepareAreasForConstruction(model.meshLod.opaqueAreas, alphaParams, 'high_opaque')
            self.PrepareAreasForConstruction(model.meshLod.decalAreas, alphaParams, 'high_decal')
            self.PrepareAreasForConstruction(model.meshLod.transparentAreas, alphaParams, 'high_transparent')
        else:
            self.PrepareAreasForConstruction(model.mesh.opaqueAreas, alphaParams, 'high_opaque')
            self.PrepareAreasForConstruction(model.mesh.decalAreas, alphaParams, 'high_decal')
            self.PrepareAreasForConstruction(model.mesh.transparentAreas, alphaParams, 'high_transparent')
        buildCurve = trinity.TriCurveSet()
        buildCurve.name = 'Build'
        buildCurve.playOnLoad = False
        buildCurve.Stop()
        buildCurve.scaledTime = 0.0
        model.curveSets.append(buildCurve)
        curve = trinity.TriScalarCurve()
        curve.value = 1.0
        curve.extrapolation = trinity.TRIEXT_CONSTANT
        buildCurve.curves.append(curve)
        curve.AddKey(0.0, 1.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
        curve.AddKey(10.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE)
        curve.Sort()
        for alphaParam in alphaParams:
            binding = trinity.TriValueBinding()
            binding.sourceAttribute = 'value'
            binding.destinationAttribute = 'value.x'
            binding.scale = 1.0
            binding.sourceObject = curve
            binding.destinationObject = alphaParam
            buildCurve.bindings.append(binding)

        glows = nodemanager.FindNodes(model, 'GlowColor', 'trinity.Tr2Vector4Parameter')
        finalColor = (1.0, 1.0, 1.0)
        if glows:
            r, g, b, a = glows[0].value
            finalColor = (r, g, b)
        onlineCurve = trinity.TriCurveSet()
        onlineCurve.name = 'Online'
        onlineCurve.playOnLoad = False
        onlineCurve.Stop()
        onlineCurve.scaledTime = 0.0
        model.curveSets.append(onlineCurve)
        curve = trinity.TriVectorCurve()
        onlineCurve.curves.append(curve)
        curve.value = finalColor
        curve.extrapolation = trinity.TRIEXT_CONSTANT
        curve.AddKey(0.0, ONLINE_GLOW_OFF, (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), trinity.TRIINT_HERMITE)
        curve.AddKey(1.9, ONLINE_GLOW_MID, (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), trinity.TRIINT_LINEAR)
        curve.AddKey(2.0, finalColor, (0.0, 0.0, 0.0), (0.0, 0.0, 0.0), trinity.TRIINT_HERMITE)
        curve.Sort()
        for each in glows:
            binding = trinity.TriValueBinding()
            binding.sourceAttribute = 'value'
            binding.destinationAttribute = 'value'
            binding.scale = 1.0
            binding.sourceObject = curve
            binding.destinationObject = each
            onlineCurve.bindings.append(binding)

        if builtAlready:
            buildCurve.Stop()
            buildCurve.scale = 0.0
            buildCurve.scaledTime = buildCurve.GetMaxCurveDuration()
            buildCurve.PlayFrom(buildCurve.scaledTime)
            self.LogInfo('  PrepareModelForConstruction - Already Built, set curve to:', buildCurve.scaledTime)
        if onlineAlready:
            onlineCurve.Stop()
            onlineCurve.scale = 0.0
            onlineCurve.scaledTime = onlineCurve.GetMaxCurveDuration()
            onlineCurve.PlayFrom(onlineCurve.scaledTime)
            self.LogInfo('  PrepareModelForConstruction - Already Online, Set curve Time to:', onlineCurve.scaledTime)
        trinity.WaitForResourceLoads()
        if model.meshLod:
            for each in model.meshLod.opaqueAreas:
                each.effect.PopulateParameters()

        else:
            for each in model.mesh.opaqueAreas:
                each.effect.PopulateParameters()

        return (buildCurve, onlineCurve)
Esempio n. 13
0
 def __MapAllianceLogo(self, iconPath):
     screenNodes = nodemanager.FindNodes(self.model.children, 'Screen', 'trinity.Tr2MeshArea')
     for each in screenNodes:
         for res in each.effect.resources:
             if res.name in ('MaskMap', 'DiffuseMap1'):
                 res.resourcePath = iconPath
Esempio n. 14
0
 def RemoveFloatAlphathreshold(self, effect):
     removes = nodemanager.FindNodes(effect.parameters, 'AlphaThreshold', 'trinity.TriFloatParameter')
     for each in removes:
         effect.parameters.fremove(each)