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)
def _SetupRenderJob(self): self.renderJob = trinity.CreateRenderJob() self.renderJob.name = 'UI' self.PrepareBlurredBackBuffer() self.sceneViewStep = self.renderJob.SetView() self.scaledViewportStep = self.renderJob.SetViewport() self.sceneProjectionStep = self.renderJob.SetProjection() videoJobStep = self.renderJob.RunJob() videoJobStep.name = 'Videos' self.videoJob = trinity.CreateRenderJob() self.videoJob.name = 'Update videos job' videoJobStep.job = self.videoJob self.bracketCurveSet = trinity.TriCurveSet() self.bracketCurveSet.Play() self.renderJob.Update(self.bracketCurveSet).name = 'Update brackets' self.renderJob.SetViewport() self.renderJob.PythonCB(self.Update).name = 'Update uilib' self.desktopRenderJob = trinity.CreateRenderJob() self.desktopRenderJob.name = 'Desktop' self.renderJob.steps.append( trinity.TriStepRunJob(self.desktopRenderJob)) isFpsEnabled = trinity.IsFpsEnabled() if isFpsEnabled: trinity.SetFpsEnabled(False) self.renderJob.ScheduleRecurring() if isFpsEnabled: trinity.SetFpsEnabled(True)
def CreateBracketCurveSet(self): self.bracketCurveSet = trinity.TriCurveSet() self.bracketCurveSet.Play() step = trinity.TriStepUpdate() step.object = self.bracketCurveSet step.name = 'Update brackets' self.renderJob.AddStep('UPDATE_BRACKETS', step)
def SetupCurve(effect): doll = scene.dynamics[0] if doll is None: return setName = 'Dropshadow foot tracker' set = None for s in doll.curveSets: if s.name == setName: set = s set.curves.removeAt(-1) set.bindings.removeAt(-1) break else: set = trinity.TriCurveSet() set.name = setName doll.curveSets.append(set) bones = ['LeftFoot', 'RightFoot'] for bone in bones: curve = trinity.Tr2BoneMatrixCurve() curve.skinnedObject = doll curve.bone = bone curve.name = bone param = PD.FindOrAddVec4(effect, bone) bind = trinity.TriValueBinding() bind.destinationObject = param bind.destinationAttribute = 'value' bind.sourceObject = curve bind.sourceAttribute = 'currentValue' bind.name = bone set.curves.append(curve) set.bindings.append(bind) set.Play()
def SetupMyPositionTracker(self, transform): solarSystemSunID = self.sunID bp = sm.GetService('michelle').GetBallpark() if bp is not None: ball = bp.GetBall(solarSystemSunID) if ball is not None: vectorCurve = trinity.TriVectorCurve() vectorCurve.value = (-1.0, -1.0, -1.0) vectorSequencer = trinity.TriVectorSequencer() vectorSequencer.operator = trinity.TRIOP_MULTIPLY vectorSequencer.functions.append(ball) vectorSequencer.functions.append(vectorCurve) binding = trinity.TriValueBinding() binding.sourceAttribute = 'value' binding.destinationAttribute = 'translation' binding.scale = 1.0 binding.sourceObject = vectorSequencer binding.destinationObject = transform curveSet = trinity.TriCurveSet() curveSet.name = 'translationCurveSet' curveSet.playOnLoad = True curveSet.curves.append(vectorSequencer) curveSet.bindings.append(binding) transform.curveSets.append(curveSet) curveSet.Play()
def HighlightEntity(self, entity, highlight): highlightComponent = entity.GetComponent('highlight') if highlightComponent is None: return if highlightComponent.highlighted == highlight: return if highlightComponent.curve is None: return placeableComponent = entity.GetComponent('interiorPlaceable') if placeableComponent is None: return if placeableComponent.renderObject is None: return highlightParameters = [] curveSets = None object = placeableComponent.renderObject if hasattr(object, 'detailMeshes'): rebind = False for mesh in object.detailMeshes: rebind |= self._FindMeshHighlightParameters( mesh, highlightComponent.highlightAreas, highlightParameters, highlight) if rebind: object.BindLowLevelShaders() curveSets = object.curveSets elif hasattr( object, 'placeableRes' ) and object.placeableRes is not None and object.placeableRes.visualModel is not None: rebind = False for mesh in object.placeableRes.visualModel.meshes: rebind |= self._FindMeshHighlightParameters( mesh, highlightComponent.highlightAreas, highlightParameters, highlight) if rebind: object.BindLowLevelShaders() curveSets = object.placeableRes.curveSets if curveSets is not None and len(highlightParameters) > 0: if highlight: highlightComponent.curveSet = trinity.TriCurveSet() highlightComponent.curveSet.curves.append( highlightComponent.curve) for parameter in highlightParameters: binding = trinity.TriValueBinding() binding.sourceObject = highlightComponent.curve binding.sourceAttribute = 'value' binding.destinationObject = parameter binding.destinationAttribute = 'value' highlightComponent.curveSet.bindings.append(binding) curveSets.append(highlightComponent.curveSet) highlightComponent.curveSet.Play() elif highlightComponent.curveSet is not None and not highlight: curveSets.remove(highlightComponent.curveSet) highlightComponent.curveSet = None for parameter in highlightParameters: parameter.value = (0.0, 0.0, 0.0, 0.0) highlightComponent.highlighted = highlight
def PlayHighlightAnimation(self): cs = trinity.TriCurveSet() expandCurve = trinity.Tr2ScalarCurve() expandCurve.interpolation = trinity.TR2CURVE_HERMITE expandCurve.length = 0.3 expandCurve.startValue = 0.0 expandCurve.endValue = 100.0 cs.curves.append(expandCurve) trinity.CreateBinding(cs, expandCurve, 'currentValue', self.sr.label.GetRenderObject(), 'glowExpand') alphaCurve = trinity.Tr2ScalarCurve() alphaCurve.interpolation = trinity.TR2CURVE_HERMITE alphaCurve.length = 0.3 alphaCurve.startValue = 1.0 alphaCurve.endValue = 0.0 cs.curves.append(alphaCurve) trinity.CreateBinding(cs, alphaCurve, 'currentValue', self.sr.label.GetRenderObject(), 'glowColor.a') depthCurve = trinity.Tr2ScalarCurve() depthCurve.interpolation = trinity.TR2CURVE_HERMITE depthCurve.length = 0.3 depthCurve.startValue = 0 depthCurve.endValue = -0.25 cs.curves.append(depthCurve) trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMin') trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMax') cs.Play() cs.StopAfter(cs.GetMaxCurveDuration()) trinity.device.curveSets.append(cs) self.animation = cs
def CreateBracketCurveSet(self): self.bracketCurveSet = trinity.TriCurveSet() self.bracketCurveSet.Play() step = trinity.TriStepUpdate() step.object = self.bracketCurveSet step.name = 'Update brackets' self.renderJob.steps.append(step)
def DoCurveBindings(self): self.effect.PopulateParameters() self.curveSet = trinity.TriCurveSet() self.effectAvatar.curveSets.append(self.curveSet) bm = None for param in self.effect.parameters: if param.name == 'BlurMaskUV': bm = param break tx = None for param in self.effect.parameters: if param.name == 'AuraTextureUV': tx = param break def BindValueToExpression(destObj, valueName, expression): curve = trinity.Tr2ScalarExprCurve() curve.expr = expression curve.length = 86400 bind = trinity.TriValueBinding() bind.destinationObject = destObj bind.destinationAttribute = valueName bind.sourceObject = curve bind.sourceAttribute = 'currentValue' self.curveSet.curves.append(curve) self.curveSet.bindings.append(bind) seed = random.random() * 3 BindValueToExpression(bm, 'v1', 'sin(2*time+%f)/3.0 + perlin(value, %f-1, 2.5, 3.3)' % (seed, seed)) BindValueToExpression(bm, 'v2', 'time/5.0') BindValueToExpression(tx, 'v1', 'sin(1.2*time+%f)/3.3 + perlin(value, %f-1, 5.5, 3.3)' % (seed, seed)) BindValueToExpression(tx, 'v2', '-1.0*time/3.0')
def HandleBlur(self, name): cs = trinity.TriCurveSet() cs.name = str(name) curve = self.CreateCurveFromName(name) binding = self.CreateBinding(curve, 'blurFactor') cs.curves.append(curve) cs.bindings.append(binding) uthread.new(self.AddCurveSet_t, cs)
def CreateBracketCurveSet(self): """ Create a curveset to update any uiprimitives.Bracket present """ self.bracketCurveSet = trinity.TriCurveSet() self.bracketCurveSet.Play() step = trinity.TriStepUpdate() step.object = self.bracketCurveSet step.name = 'Update brackets' self.renderJob.AddStep('UPDATE_BRACKETS', step)
def CreateBracketCurveSet(self): """ Create a curveset to update any Bracket present """ self.bracketCurveSet = trinity.TriCurveSet() self.bracketCurveSet.Play() step = trinity.TriStepUpdate() step.object = self.bracketCurveSet step.name = 'Update brackets' self.renderJob.steps.append(step)
def CreateCurveSets(self): if getattr(uicore, 'stretchLinesCS', None): return desktopRO = uicore.desktop.GetRenderObject() stretchLinesCS = trinity.TriCurveSet() stretchLinesCS.name = 'StretchLines CurveSet' stretchLinesCS.Play() desktopRO.curveSets.append(stretchLinesCS) uicore.stretchLinesCS = stretchLinesCS
def ApplyParticleEffect(self, *args): if not sm.GetService('device').GetAppFeatureState('Interior.ParticlesEnabled', True): return True entityID, effectFilePath, boneName, duration, xOffset, yOffset, zOffset = args[:7] yawOffset, pitchOffset, rollOffset, ignoreTransform, effectStringID = args[7:] effectID = self._GetNextEffectID() zaction.AddPropertyForCurrentPythonProc({effectStringID: effectID}) translation = geo2.MatrixTranslation(xOffset, yOffset, zOffset) rotation = geo2.MatrixRotationYawPitchRoll(math.radians(yawOffset), math.radians(pitchOffset), math.radians(rollOffset)) offset = geo2.MatrixMultiply(rotation, translation) with self.activeParticlesSemaphore: trinityObject = trinity.Load(effectFilePath) entity = self.entityClient.FindEntityByID(entityID) scene = self.graphicClient.GetScene(entity.scene.sceneID) scene.AddDynamic(trinityObject) curveSet = None positionComponent = entity.GetComponent('position') if boneName or positionComponent: curveSet = trinity.TriCurveSet() scene.AddCurveSetToScene(curveSet) if boneName: paperDollComponent = entity.GetComponent('paperdoll') model = paperDollComponent.doll.avatar curve = trinity.Tr2BoneMatrixCurve() curve.skinnedObject = model curve.bone = boneName if not ignoreTransform: offset = geo2.MatrixMultiply(offset, trinityObject.transform) curve.transform = offset else: curve = GameWorld.PositionComponentCurve() curve.positionComponent = positionComponent curve.positionOffset = geo2.Vector(xOffset, yOffset, zOffset) curve.rotationOffset = geo2.QuaternionRotationSetYawPitchRoll(yawOffset, pitchOffset, rollOffset) bind = trinity.TriValueBinding() bind.destinationObject = trinityObject bind.destinationAttribute = 'transform' bind.sourceObject = curve bind.sourceAttribute = 'currentValue' curveSet.curves.append(curve) curveSet.bindings.append(bind) curveSet.Play() expireTime = blue.os.GetWallclockTime() + duration * const.MSEC effectData = util.KeyVal(effectID=effectID, entityID=entityID, effectFilePath=effectFilePath, expireTime=expireTime, offset=offset, trinityObject=trinityObject, sceneID=entity.scene.sceneID, curveSet=curveSet) self.activeParticleEffects[effectID] = effectData if duration > 0: self.timedParticleEffects.append(effectData) self.timedParticleEffects.sort(key=lambda entry: entry.expireTime) self.updateTaskletLock.set() self._ConnectEffectCurveSets(effectData, effectStringID) return True
def PlayUnhighlightAnimation(self): cs = trinity.TriCurveSet() depthCurve = trinity.Tr2ScalarCurve() depthCurve.interpolation = trinity.TR2CURVE_HERMITE depthCurve.length = 0.3 depthCurve.startValue = -0.25 depthCurve.endValue = 0 cs.curves.append(depthCurve) trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMin') trinity.CreateBinding(cs, depthCurve, 'currentValue', self.GetRenderObject(), 'depthMax') cs.Play() cs.StopAfter(cs.GetMaxCurveDuration()) trinity.device.curveSets.append(cs) self.animation = cs
def _SetupLightingCurves(self, scene): """ Creates curves and bindings to dim secondary lighting when warp tunnel gets opaque """ self.lightingCurveSet = trinity.TriCurveSet() self.lights = [] curve = trinity.Tr2ScalarExprCurve() curve.expr = 'input3 - input3 * min(max(input1 - input2, 0), 1)' curve.input1 = 1 curve.input2 = 0 curve.input3 = gfxsettings.SECONDARY_LIGHTING_INTENSITY curve.length = 1 curve.cycle = True self.lightingCurveSet.curves.append(curve) def FindBinding(curveSet, binding): cs = [ x for x in self.gfx.curveSets if x.name == curveSet ][0] return [ x for x in cs.bindings if x.name == binding ][0] trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeInCurveSet', 'FadeInBinding').sourceObject, 'value', curve, 'input1') trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeOutCurveSet', 'FadeOutBindin').sourceObject, 'value', curve, 'input2') trinity.CreateBinding(self.lightingCurveSet, curve, 'currentValue', scene.shLightingManager, 'secondaryIntensity') if scene.shLightingManager: light = self._SetupStaticLight(-1, self.lightingCurveSet) self.lights.append((light, None, None)) scene.shLightingManager.lights.append(light) light = self._SetupStaticLight(1, self.lightingCurveSet) self.lights.append((light, None, None)) scene.shLightingManager.lights.append(light) curve = trinity.Tr2ScalarExprCurve() curve.expr = 'input1 * min(max(input2 + 2 * min(max(min(max(input3, 0), 1) - min(max(input4, 0), 1), 0), 1), 0), 1)' curve.input1 = 1 curve.input2 = 0 curve.input3 = 0 curve.input4 = 0 curve.length = 1 curve.cycle = True self.lightingCurveSet.curves.append(curve) trinity.CreateBinding(self.lightingCurveSet, FindBinding('_Setup_', 'brightness_tunnel').sourceObject, 'currentValue', curve, 'input1').scale = gfxsettings.SECONDARY_LIGHTING_INTENSITY trinity.CreateBinding(self.lightingCurveSet, FindBinding('SpeedModifier', 'additiveBinding').sourceObject, 'value', curve, 'input2') trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeInCurveSet', 'FadeInBindingAdditive').sourceObject, 'value', curve, 'input3') trinity.CreateBinding(self.lightingCurveSet, FindBinding('FadeOutCurveSet', 'FadeOutBindingAdditive').sourceObject, 'value', curve, 'input4') trinity.CreateBinding(self.lightingCurveSet, curve, 'currentValue', scene.shLightingManager, 'primaryIntensity').scale = 2 self.shLightingManager = scene.shLightingManager scene.curveSets.append(self.lightingCurveSet) self.lightingCurveSet.Play() uthread.new(self._AnimateLights, scene)
def SetupScene(self): curveSet = trinity.TriCurveSet() curveSet.name = 'HighlighCurveSet' curveSet.playOnLoad = False curveSet.Stop() curveSet.scaledTime = 0.0 self.rootTransform.curveSets.append(curveSet) curve = trinity.TriScalarCurve() curve.value = 0.0 curve.extrapolation = trinity.TRIEXT_CYCLE curveSet.curves.append(curve) curve.AddKey(0.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE) curve.AddKey(1.0, 1.0, 0.0, 0.0, trinity.TRIINT_HERMITE) curve.AddKey(2.0, 0.0, 0.0, 0.0, trinity.TRIINT_HERMITE) curve.Sort() self.highlightCurveSet = curveSet self.highlightCurve = curve curveSet.Play()
def SetupSharedBlinkingCurve(self, cuverSetName, fromCurveValue, toCurveValue, duration, *args): curveSet = getattr(uicore, cuverSetName, None) if curveSet: curve = curveSet.curves[0] else: curveSet = trinity.TriCurveSet() setattr(uicore, cuverSetName, curveSet) setattr(curveSet, 'name', cuverSetName) trinity.device.curveSets.append(curveSet) curveSet.Play() curve = trinity.Tr2ScalarCurve() curve.name = 'blinking_curve' curve.length = duration curve.startValue = fromCurveValue curve.endValue = fromCurveValue curve.AddKey(duration / 2.0, toCurveValue) curve.cycle = True curve.interpolation = trinity.TR2CURVE_LINEAR curveSet.curves.append(curve) if getattr(self, 'blinkBinding', None) is not None: curveSet.bindings.remove(self.blinkBinding) self.blinkBinding = trinity.CreatePythonBinding(curveSet, curve, 'currentValue', self, 'opacity')
def __init__(self): sm.RegisterNotify(self) self.planetUISvc = None self.linkParentID = None self.routeParentID = None self.currentExpandedPin = None self.currentRoute = [] self.routeHoverPath = [] self.oneoffRoute = False self.isEdit = False self.currRouteVolume = None self.newPinType = None self.canMoveHeads = None self.depletionPoints = [] self.pinsByID = {} self.linksByPinIDs = {} self.linksByGraphicID = {} self.links = [] self.buildIndicatorPin = None self.currentEcuPinID = None self.bracketCurveSet = trinity.TriCurveSet() self.bracketCurveSet.name = 'PlanetBrackets' uicore.desktop.GetRenderObject().curveSets.append(self.bracketCurveSet)
def _CreateCurveSet(self): curveSet = trinity.TriCurveSet() trinity.device.curveSets.append(curveSet) return curveSet
def LoadOrbitalObjects(self, scene): orbitalObjects = sm.GetService('planetInfo').GetOrbitalsForPlanet( self.planetID, const.groupPlanetaryCustomsOffices) park = sm.GetService('michelle').GetBallpark() addedObjects = [] for orbitalObjectID in orbitalObjects: invItem = park.GetInvItem(orbitalObjectID) fileName = None if evetypes.GetGraphicID(invItem.typeID) is not None: if type(evetypes.GetGraphicID(invItem.typeID)) != type(0): raise RuntimeError('NeedGraphicIDNotMoniker', invItem.itemID) if inventorycommon.typeHelpers.GetGraphic(invItem.typeID): fileName = inventorycommon.typeHelpers.GetGraphicFile( invItem.typeID) if not (fileName.lower().endswith('.red') or fileName.lower().endswith('.blue')): filenameAndTurretType = fileName.split(' ') fileName = filenameAndTurretType[0] if fileName is None: self.LogError( 'Error: Object type %s has invalid graphicFile, using graphicID: %s' % (invItem.typeID, evetypes.GetGraphicID(invItem.typeID))) continue tryFileName = fileName.replace(':/Model', ':/dx9/Model').replace( '.blue', '.red') tryFileName = tryFileName.replace('.red', '_UI.red') model = None if tryFileName is not None: try: model = blue.resMan.LoadObject(tryFileName) except: model = None if model is None: self.LogError('Was looking for:', tryFileName, 'but it does not exist!') if model is None: try: model = blue.resMan.LoadObject(fileName) except: model = None if not model: log.LogError( 'Could not load model for orbital object. FileName:', fileName, ' id:', invItem.itemID, ' typeID:', getattr(invItem, 'typeID', '?unknown?')) if invItem is not None and hasattr(invItem, 'typeID'): log.LogError('Type is:', evetypes.GetName(invItem.typeID)) continue model.name = '%s' % invItem.itemID model.display = 0 model.scaling = (0.002, 0.002, 0.002) addedObjects.append(model) orbitRoot = trinity.EveTransform() orbitRoot.children.append(model) inclinationRoot = trinity.EveTransform() inclinationRoot.children.append(orbitRoot) orbitalInclination = orbitalObjectID / math.pi % ( math.pi / 4.0) - math.pi / 8.0 if orbitalInclination <= 0.0: orbitalInclination -= math.pi / 8.0 else: orbitalInclination += math.pi / 8.0 inclinationRoot.rotation = geo2.QuaternionRotationSetYawPitchRoll( 0.0, orbitalInclination, 0.0) rotationCurveSet = trinity.TriCurveSet() rotationCurveSet.playOnLoad = False rotationCurveSet.Stop() rotationCurveSet.scaledTime = 0.0 rotationCurveSet.scale = 0.25 orbitRoot.curveSets.append(rotationCurveSet) ypr = trinity.TriYPRSequencer() ypr.YawCurve = trinity.TriScalarCurve() ypr.YawCurve.extrapolation = trinity.TRIEXT_CYCLE ypr.YawCurve.AddKey(0.0, 0.0, 0.0, 0.0, trinity.TRIINT_LINEAR) ypr.YawCurve.AddKey(200.0, 360.0, 0.0, 0.0, trinity.TRIINT_LINEAR) ypr.YawCurve.Sort() rotationCurveSet.curves.append(ypr) binding = trinity.TriValueBinding() binding.sourceObject = ypr binding.sourceAttribute = 'value' binding.destinationObject = orbitRoot binding.destinationAttribute = 'rotation' rotationCurveSet.bindings.append(binding) rotationCurveSet.Play() model.translation = (0.0, 0.0, 1500.0) model.rotation = geo2.QuaternionRotationSetYawPitchRoll( math.pi, 0.0, 0.0) scene.objects.append(inclinationRoot) ls = trinity.EveCurveLineSet() ls.scaling = (1.0, 1.0, 1.0) tex2D1 = trinity.TriTextureParameter() tex2D1.name = 'TexMap' tex2D1.resourcePath = 'res:/UI/Texture/Planet/link.dds' ls.lineEffect.resources.append(tex2D1) tex2D2 = trinity.TriTextureParameter() tex2D2.name = 'OverlayTexMap' tex2D2.resourcePath = 'res:/UI/Texture/Planet/link.dds' ls.lineEffect.resources.append(tex2D2) lineColor = (1.0, 1.0, 1.0, 0.05) p1 = SurfacePoint(0.0, 0.0, -1500.0, 1000.0) p2 = SurfacePoint(5.0, 0.0, 1498.0, 1000.0) l1 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0) p1 = SurfacePoint(0.0, 0.0, -1500.0, 1000.0) p2 = SurfacePoint(-5.0, 0.0, 1498.0, 1000.0) l2 = ls.AddSpheredLineCrt(p1.GetAsXYZTuple(), lineColor, p2.GetAsXYZTuple(), lineColor, (0.0, 0.0, 0.0), 3.0) animationColor = (0.3, 0.3, 0.3, 0.5) ls.ChangeLineAnimation(l1, animationColor, 0.25, 1.0) ls.ChangeLineAnimation(l2, animationColor, -0.25, 1.0) ls.ChangeLineSegmentation(l1, 100) ls.ChangeLineSegmentation(l2, 100) ls.SubmitChanges() orbitRoot.children.append(ls) trinity.WaitForResourceLoads() for model in addedObjects: model.display = 1
def _PlayCameraAnimation(self, resPath, alignToParent=False, alignTargets=None, loop=False, parent=None, reload=False): if self.playingClip: self.interrupt = True blue.synchro.Yield() self.playingClip = True def RemoveCurveSetByName(scene, curveSetName): removeList = [] for cset in scene.curveSets: if cset.name == curveSetName: removeList.append(cset) for cset in removeList: scene.curveSets.remove(cset) curveSetName = 'AnimatedCamera' cset = trinity.TriCurveSet() cset.name = curveSetName cameraTransformTrack = trinity.Tr2GrannyTransformTrack() cameraTransformTrack.grannyResPath = str(resPath) cameraTransformTrack.name = 'camera1' cameraTransformTrack.group = 'camera1' cameraTransformTrack.cycle = True cset.curves.append(cameraTransformTrack) if alignTargets: t1 = alignTargets[0].model.worldPosition t2 = alignTargets[1].model.worldPosition distVector = geo2.Vec3Subtract(t1, t2) dist = geo2.Vec3Length(distVector) shakeSeq = trinity.TriXYZScalarSequencer() shakeSeq.XCurve = trinity.TriPerlinCurve() shakeSeq.YCurve = trinity.TriPerlinCurve() shakeSeq.ZCurve = trinity.TriPerlinCurve() for pCurve in [shakeSeq.XCurve, shakeSeq.YCurve, shakeSeq.ZCurve]: shake = dist / 50.0 pCurve.scale = shake pCurve.offset = -shake / 2.0 pCurve.speed = 0.8 pCurve.alpha = 1.3 cset.curves.append(shakeSeq) if reload: cameraTransformTrack.grannyRes.Reload() while cameraTransformTrack.grannyRes.isLoading: blue.synchro.Yield() numVecTracks = cameraTransformTrack.grannyRes.GetVectorTrackCount(0) if numVecTracks: self.vectorTracks = {} for trackNr in range(numVecTracks): vecTrack = trinity.Tr2GrannyVectorTrack() vecTrack.grannyResPath = str(resPath) vecTrack.group = 'camera1' vecTrack.name = cameraTransformTrack.grannyRes.GetVectorTrackName( 0, trackNr) vecTrack.cycle = True cset.curves.append(vecTrack) self.vectorTracks[vecTrack.name] = vecTrack scene = sm.GetService('sceneManager').GetRegisteredScene('default') RemoveCurveSetByName(scene, curveSetName) scene.curveSets.append(cset) cset.Play() uthread.new(self._UpdateCameraAnimation, alignToParent, alignTargets, loop, clipName=resPath, parent=parent)
def SetupWrinkleMapControls(self, avatar, effects, pdDoll): if avatar is None: return set = trinity.TriCurveSet() set.name = 'Wrinkles' for s in avatar.curveSets: if s.name == 'Wrinkles': for bind in s.bindings: if hasattr(bind, 'copyValueCallable'): bind.copyValueCallable = None avatar.curveSets.remove(s) break avatar.curveSets.append(set) weakAvatar = blue.BluePythonWeakRef(avatar) pdDoll.LoadBindPose() def CreateBoneDriver(set, bone1, bone2, zone, min, max, oldMin, oldMax, curveDictionary, name, tweakData): if bone1 in pdDoll.bindPose and bone1 in pdDoll.boneOffsets and bone2 in pdDoll.bindPose and bone2 in pdDoll.boneOffsets: bindPosePos1 = pdDoll.bindPose[bone1]['translation'] offset1 = pdDoll.boneOffsets[bone1]['translation'] bindPosePos2 = pdDoll.bindPose[bone2]['translation'] offset2 = pdDoll.boneOffsets[bone2]['translation'] realPos1 = (bindPosePos1[0] / 100.0 + offset1[0], bindPosePos1[1] / 100.0 + offset1[1], bindPosePos1[2] / 100.0 + offset1[2]) realPos2 = (bindPosePos2[0] / 100.0 + offset2[0], bindPosePos2[1] / 100.0 + offset2[1], bindPosePos2[2] / 100.0 + offset2[2]) bindPoseDist = geo2.Vec3Distance(bindPosePos1, bindPosePos2) / 100.0 dist = geo2.Vec3Distance(realPos1, realPos2) multiplier = dist / bindPoseDist oldMin = oldMin * multiplier oldMax = oldMax * multiplier def GetOrMakeCurve(bone, set, curveDictionary, name): curve = curveDictionary.get((weakAvatar, bone), None) if curve is not None: return curve curve = trinity.Tr2BoneMatrixCurve() curve.bone = bone curve.name = name curveDictionary[weakAvatar, bone] = curve set.curves.append(curve) return curve curve1 = GetOrMakeCurve(bone1, set, curveDictionary, 'bone1') curve2 = GetOrMakeCurve(bone2, set, curveDictionary, 'bone2') bind = trinity.TriValueBinding() set.bindings.append(bind) def distanceBinding(curve1, curve2, min, max, parameters, index, gamma): avatar = weakAvatar.object if avatar is None: return curve1.skinnedObject = avatar curve2.skinnedObject = avatar if curve1.startValue == curve1.currentValue or curve2.startValue == curve2.currentValue: curve1.skinnedObject = None curve2.skinnedObject = None return p1 = curve1.currentValue[3] p2 = curve2.currentValue[3] dist = geo2.Vec3Distance(p1, p2) d = 1.0 - (dist - min) * 1 / (max - min) if d < 0: d = 0 elif d > 1: d = 1 if gamma != 1.0: d = math.pow(d, gamma) if False: trinity.GetDebugRenderer().DrawLine((p1[0], p1[1], p1[2]), 4294967295L, (p2[0], p2[1], p2[2]), 4294967295L) trinity.GetDebugRenderer().Print3D((p1[0], p1[1], p1[2]), 4294967295L, str(dist)) trinity.GetDebugRenderer().Print3D((p2[0], p2[1], p2[2]), 4294967295L, str(d)) for p_ in parameters: p = p_.object if p is None: continue if index == 1: p.v1 = d if index == 2: p.v2 = d if index == 3: p.v3 = d if index == 4: p.v4 = d curve1.skinnedObject = None curve2.skinnedObject = None zone = zone - 1 paramIndex = zone / 4 + 1 index = zone % 4 + 1 param = 'WrinkleNormalStrength' + str(paramIndex) parameters = [] for fx in effects: for p in fx.parameters: if p.name == param: parameters.append(blue.BluePythonWeakRef(p)) gammaCurves = tweakData.get('gammaCurves', {}) gamma = gammaCurves.get(name, gammaCurves.get('default', 1.0)) bind.copyValueCallable = lambda source, dest: distanceBinding(curve1, curve2, oldMin, oldMax, parameters, index, gamma) def CreateAxisDriver(set, jointName, zone, axis, maxValue, name, tweakData, pdDoll): avatar = weakAvatar.object if avatar is None or not hasattr(avatar, 'animationUpdater') or avatar.animationUpdater is None or not hasattr(avatar.animationUpdater, 'network') or avatar.animationUpdater.network is None: return bind = trinity.TriValueBinding() set.bindings.append(bind) if not hasattr(avatar.animationUpdater, 'network'): return jointIndex = avatar.animationUpdater.network.GetBoneIndex(jointName) if jointIndex == -1: print "Error: Can't find bone for axis control: " + jointName return if not type(jointIndex) == type(1): print 'Non-int returned for bone in axis: ' + str(jointIndex) + ', name:' + jointName return bindPosePos = pdDoll.bindPose[jointName] if jointName in pdDoll.boneOffsets: offset = pdDoll.boneOffsets[jointName] else: offset = {'translation': [0, 0, 0]} startPos = [0, 0, 0, 0, 0, 0, 0, 0, 0, (bindPosePos['translation'][0] + offset['translation'][0]) / 100.0, (bindPosePos['translation'][1] + offset['translation'][1]) / 100.0, (bindPosePos['translation'][2] + offset['translation'][2]) / 100.0] def AxisBinding(startPos, jointIndex, axis, maxValue, parameters, index, gamma): avatar = weakAvatar.object if avatar is None: return if not hasattr(avatar.animationUpdater, 'network') or avatar.animationUpdater.network is None: return newPos = avatar.animationUpdater.network.GetRawTrackData(jointIndex) diff = (newPos[9] - startPos[9], newPos[10] - startPos[10], newPos[11] - startPos[11]) value = 0 if axis == 'x': value = diff[0] elif axis == 'y': value = diff[1] elif axis == 'z': value = diff[2] finalValue = 0 max = maxValue if max < 0: max = -max value = -value if value > max: finalValue = 1.0 elif value < 0: finalValue = 0.0 else: finalValue = value / max if gamma != 1.0: finalValue = math.pow(finalValue, gamma) for p_ in parameters: p = p_.object if p is None: continue if index == 1: p.v1 = finalValue if index == 2: p.v2 = finalValue if index == 3: p.v3 = finalValue if index == 4: p.v4 = finalValue zone = zone - 1 paramIndex = zone / 4 + 1 index = zone % 4 + 1 param = 'WrinkleNormalStrength' + str(paramIndex) parameters = [] for fx in effects: for p in fx.parameters: if p.name == param: parameters.append(blue.BluePythonWeakRef(p)) gammaCurves = tweakData.get('gammaCurves', {}) gamma = gammaCurves.get(name, gammaCurves.get('default', 1.0)) bind.name = 'AxisBind' bind.copyValueCallable = lambda source, dest: AxisBinding(startPos, jointIndex, axis, maxValue, parameters, index, gamma) rootFolder = 'R:/' if not legacy_r_drive.loadFromContent: rootFolder = 'res:/' faceSetupPath = rootFolder + 'Graphics/Character/Global/FaceSetup/BasicFace.face' if pdDoll.gender != pdDef.GENDER.FEMALE: faceSetupPath = rootFolder + 'Graphics/Character/Global/FaceSetup/BasicFaceMale.face' if not blue.paths.exists(faceSetupPath): return data = pdDm.LoadYamlFileNicely(faceSetupPath) faceTweaksPath = rootFolder + 'Graphics/Character/Global/FaceSetup/FaceTweakSettings.yaml' tweakData = pdDm.LoadYamlFileNicely(faceTweaksPath) curveDictionary = {} if data: for d in data: entry = data[d] if len(entry) == 7: CreateBoneDriver(set, entry[0], entry[1], entry[2], entry[3] / 100.0, entry[4] / 100.0, entry[5] / 100.0, entry[6] / 100.0, curveDictionary, d, tweakData) elif len(entry) == 4: CreateAxisDriver(set, entry[0], entry[1], entry[2], entry[3] / 100.0, d, tweakData, pdDoll) wrinkleMultiplier = tweakData.get('wrinkleMultiplier', 1.0) correctionMultiplier = tweakData.get('correctionMultiplier', 1.0) for fx in effects: for p in fx.parameters: if p.name == 'WrinkleParams': p.value = (wrinkleMultiplier, correctionMultiplier, 0.0, 0.0) set.Play() return set
def __init__(self, paparazziMode=False): if len(trinity.textureAtlasMan.atlases) == 0: trinity.textureAtlasMan.AddAtlas( trinity.PIXEL_FORMAT.B8G8R8A8_UNORM, 2048, 2048) self.textureAtlas = trinity.textureAtlasMan.atlases[0] self.textureAtlas.optimizeOnRemoval = False self.renderObjectToPyObjectDict = weakref.WeakValueDictionary() self.x = -1 self.y = -1 self.z = 0 self.dx = 0 self.dy = 0 self.dz = 0 self._mouseOver = None self._auxMouseOverRO = None self._capturingMouseItem = None self._clickItem = None self.exclusiveMouseFocusActive = False self.appfocusitem = None self.selectedCursorType = uiconst.UICURSOR_DEFAULT self.centerMouse = False self.ignoreDeadChar = None self._lastEventTime = None self._globalClickCounter = 0 self._globalKeyDownCounter = 0 self._clickTime = None self._clickCount = 0 self._clickTimer = None self._clickPosition = None self.rootObjects = [] self.rootObjectsByName = {} self._triuiRegs = {} self._triuiRegsByMsgID = {} self._mouseButtonStates = {} self._mouseDownPosition = {} self._appfocusitem = None self._modkeysOff = tuple([0 for x in uiconst.MODKEYS]) self._expandMenu = None self._keyDownAcceleratorThread = None self._pickProjection = trinity.TriProjection() self._pickView = trinity.TriView() self._pickViewport = trinity.TriViewport() self.cursorCache = {} self.alignIslands = [] uicore.uilib = self trinity.fontMan.loadFlag = 32 if not paparazziMode: self.inSceneRenderJob = trinity.CreateRenderJob() self.inSceneRenderJob.name = 'In-scene UI' self.inSceneRenderJob.ScheduleRecurring(insertFront=True) self.renderJob = trinity.CreateRenderJob() self.renderJob.name = 'UI' self.sceneViewStep = self.renderJob.SetView() self.scaledViewportStep = self.renderJob.SetViewport() self.sceneProjectionStep = self.renderJob.SetProjection() videoJobStep = self.renderJob.RunJob() videoJobStep.name = 'Videos' self.videoJob = trinity.CreateRenderJob() self.videoJob.name = 'Update videos job' videoJobStep.job = self.videoJob self.bracketCurveSet = trinity.TriCurveSet() self.bracketCurveSet.Play() self.renderJob.Update( self.bracketCurveSet).name = 'Update brackets' self.renderJob.SetViewport() self.renderJob.PythonCB(self.Update).name = 'Update uilib' isFpsEnabled = trinity.IsFpsEnabled() if isFpsEnabled: trinity.SetFpsEnabled(False) self.renderJob.ScheduleRecurring() if isFpsEnabled: trinity.SetFpsEnabled(True) self.desktop = self.CreateRootObject('Desktop', isFullscreen=True) uthread.new(self.EnableEventHandling) trinity.device.RegisterResource(self) self._hoverThread = None
def _AddTarget(self, dock=False, flush=False): import random dockCounter = 0 if flush: for each in self.children[:]: if isinstance(each, uicls.StretchLine) or each.name == 'targetTest': each.Close() else: for child in each.children[:]: if child.name == 'targetTest': child.Close() for each in self.children[:]: if each.name == 'targetTest': each.Close() else: for each in self.parent.children: if each.name == 'targetTest': dockCounter += 1 inTime = 0.5 curveSet = trinity.TriCurveSet() curveSet.scale = 1.0 par = uicls.Container(parent=self, name='targetTest', left=100, top=0, align=uiconst.TOPLEFT, width=300, height=128, idx=0) 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:/ui/sprite/carbontest/text.dds', left=96.0, width=200, height=64, effect=trinity.S2D_RFX_BLUR) caption = uicls.Sprite( parent=mainParent, texturePath='res:/ui/sprite/carbontest/caption.dds', left=50, top=56, width=160, height=32, effect=trinity.S2D_RFX_BLUR) bracket = uicls.Sprite( parent=mainParent, texturePath='res:/ui/sprite/carbontest/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 = self.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)) self.AddBinding(curve, 'currentValue', caption, 'color', curveSet) curve, binding = self.CreateScalarCurve(mainParent, 'currentValue', 'displayX', curveSet, length=inTime, startValue=-500.0, endValue=0.0, endTangent=-1000.0, cycle=False) correction = 0.0 innerTransform = uicls.Transform(parent=par, idx=0, left=8, top=8) innerTransform.rotationCenter = (64, 64) inner = uicls.Sprite( parent=innerTransform, pos=(0, 0, 128, 128), texturePath='res:/ui/sprite/carbontest/innercircles.dds', blurFactor=0.1, filter=True) curve, binding = self.CreatePerlinCurve(innerTransform, 'value', 'rotation', curveSet, scale=10.025) outerTransform = uicls.Transform(parent=par, idx=0, left=8, top=8) outerTransform.rotationCenter = (64, 64) outer = uicls.Sprite( parent=outerTransform, pos=(0, 0, 128, 128), texturePath='res:/ui/sprite/carbontest/outercircles.dds', blurFactor=0.1, filter=True) curve, binding = self.CreatePerlinCurve(outerTransform, 'value', 'rotation', curveSet, scale=10.00125) uicore.desktop.GetRenderObject().curveSets.append(curveSet) curveSet.Play()
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)
def AddPrepassAreasToStandardMesh(mesh, processDepthAreas, processDepthNormalAreas, avatar=None, doll=None, useLightControlMap=False): opaqueAreas = mesh.opaqueAreas processDepthAreas = len(mesh.depthAreas) <= 0 if processDepthNormalAreas: mesh.depthNormalAreas.removeAt(-1) mesh.decalPrepassAreas.removeAt(-1) mesh.opaquePrepassAreas.removeAt(-1) for area in mesh.transparentAreas: if area.name[0:8] == 'Prepass_': mesh.transparentAreas.remove(area) newAreas = [] for area in opaqueAreas: if IsGlassRelated(area): newArea = CopyAreaOnly(area) if newArea is not None: newArea.name = 'Prepass_' + newArea.name newArea.effect = ConvertEffectToTr2ShaderMaterial( area.effect, 'SHLighting', mesh.name) newArea.useSHLighting = True newAreas.append(newArea) area.debugIsHidden = True if processDepthAreas: newArea = CopyAreaForPrePassShadows(area, SOURCE_AREA_TYPE_OPAQUE) if newArea is not None: mesh.depthAreas.append(newArea) continue if area.effect is not None and hasattr( area.effect, 'effectFilePath' ) and 'hair' in area.effect.effectFilePath.lower(): continue if processDepthNormalAreas: newArea = CopyAreaForPrePassDepthNormal(area, SOURCE_AREA_TYPE_OPAQUE) if newArea is not None: mesh.depthNormalAreas.append(newArea) if processDepthAreas: newArea = CopyAreaForPrePassShadows(area, SOURCE_AREA_TYPE_OPAQUE) if newArea is not None: mesh.depthAreas.append(newArea) newArea = CopyAreaOnly(area) if newArea is not None: if mesh.name.startswith('head') and useLightControlMap: newArea.effect = ConvertEffectToTr2ShaderMaterial( area.effect, 'Prepass SHLighting', mesh.name) useLightControl = trinity.Tr2FloatParameter() useLightControl.name = 'UseLightControl' useLightControl.value = 0.5 newArea.effect.parameters[ useLightControl.name] = useLightControl lightControlMap = trinity.TriTexture2DParameter() lightControlMap.name = 'LightControlMap' lcmPath = LIGHT_CONTROL_MAP_FEMALE_PATH if doll and doll.gender == pdDef.GENDER.MALE: lcmPath = LIGHT_CONTROL_MAP_MALE_PATH lightControlMap.resourcePath = lcmPath newArea.effect.parameters[ lightControlMap.name] = lightControlMap lightControlMatrix = trinity.Tr2Matrix4Parameter() lightControlMatrix.name = 'LightControlMatrix' newArea.effect.parameters[ lightControlMatrix.name] = lightControlMatrix newArea.useSHLighting = True if avatar: headMatrixCurves = None boneMatrixCurve = None for cs in avatar.curveSets: if cs.name == 'HeadMatrixCurves': headMatrixCurves = cs for curve in headMatrixCurves.curves: if curve.bone == 'Head': boneMatrixCurve = curve break if not headMatrixCurves: headMatrixCurves = trinity.TriCurveSet() headMatrixCurves.name = 'HeadMatrixCurves' avatar.curveSets.append(headMatrixCurves) if not boneMatrixCurve: boneMatrixCurve = trinity.Tr2BoneMatrixCurve() boneMatrixCurve.bone = 'Head' boneMatrixCurve.name = 'HeadMatrixCurve' boneMatrixCurve.skinnedObject = avatar headMatrixCurves.curves.append(boneMatrixCurve) if len(headMatrixCurves.bindings): bind = headMatrixCurves.bindings[0] else: bind = trinity.TriValueBinding() headMatrixCurves.bindings.append(bind) bind.sourceObject = boneMatrixCurve bind.destinationObject = lightControlMatrix bind.sourceAttribute = 'currentValue' bind.destinationAttribute = 'value' headMatrixCurves.Play() else: newArea.effect = ConvertEffectToTr2ShaderMaterial( area.effect, 'Prepass', mesh.name) mesh.opaquePrepassAreas.append(newArea) def FixCutMask(area): if area.effect and 'CutMaskInfluence' in area.effect.parameters: area.effect.parameters['CutMaskInfluence'].value = 1.0 def AddAreasForRegularPLP(area, materialLookupTable=None, isTransparent=False): if area.effect is not None and hasattr( area.effect, 'effectFilePath' ) and 'hair' in area.effect.effectFilePath.lower(): return if processDepthNormalAreas: newArea = CopyAreaForPrePassDepthNormal( area, SOURCE_AREA_TYPE_DECAL, materialLookupTable=materialLookupTable) if newArea is not None: if isTransparent: FixCutMask(newArea) mesh.depthNormalAreas.append(newArea) if processDepthAreas: newArea = CopyAreaForPrePassShadows(area, SOURCE_AREA_TYPE_DECAL) if newArea is not None: if isTransparent: FixCutMask(newArea) mesh.depthAreas.append(newArea) newArea = CopyAreaOnly(area) if newArea is not None: newArea.effect = ConvertEffectToTr2ShaderMaterial( area.effect, 'Prepass Decal', mesh.name) if isTransparent: FixCutMask(newArea) mesh.decalPrepassAreas.append(newArea) area.debugIsHidden = True for area in mesh.decalAreas: if IsGlassRelated(area): newArea = CopyAreaOnly(area) if newArea is not None: newArea.name = 'Prepass_' + newArea.name newArea.effect = ConvertEffectToTr2ShaderMaterial( area.effect, 'SHLighting', mesh.name) newArea.useSHLighting = True newAreas.append(newArea) area.debugIsHidden = True if processDepthAreas: newArea = CopyAreaForPrePassShadows(area, SOURCE_AREA_TYPE_DECAL) if newArea is not None: mesh.depthAreas.append(newArea) else: AddAreasForRegularPLP(area) for area in mesh.transparentAreas: if area.effect is None: continue if hasattr(area.effect, 'effectFilePath' ) and 'hair' in area.effect.effectFilePath.lower(): continue if USE_DECAL_PLP_FOR_TRANSPARENT_AREAS and not IsEyeRelated( area) and not IsGlassRelated(area): AddAreasForRegularPLP( area, materialLookupTable=MATERIAL_ID_TRANSPARENT_HACK_EXACT, isTransparent=True) area.effect = None else: newArea = CopyAreaOnly(area) if newArea is not None: if 'C_SkinShiny' in area.effect.name: newArea.effect = ConvertEffectToTr2ShaderMaterial( area.effect, 'Prepass Decal', mesh.name) mesh.decalPrepassAreas.append(newArea) else: newArea.effect = ConvertEffectToTr2ShaderMaterial( area.effect, 'SHLighting', mesh.name) newArea.useSHLighting = True newAreas.append(newArea) area.debugIsHidden = True mesh.transparentAreas.extend(newAreas)
def CreateCurveSet(self, useRealTime=True): curveSet = trinity.TriCurveSet() curveSet.useRealTime = useRealTime trinity.device.curveSets.append(curveSet) return curveSet