def CopyMyScene(self): """ copies the stuff I need from original scene to display when you have been podded """ sceneOrg = self._sceneManager.GetRegisteredScene('default') if sceneOrg is None: return scene = trinity.EveSpaceScene() self.podDeathScene = scene scene.sunDiffuseColor = sceneOrg.sunDiffuseColor scene.ambientColor = sceneOrg.ambientColor scene.fogColor = sceneOrg.fogColor scene.backgroundRenderingEnabled = True scene.backgroundEffect = blue.classes.Copy(sceneOrg.backgroundEffect) for pathName in [ 'envMapResPath', 'envMap1ResPath', 'envMap2ResPath', 'envMap3ResPath' ]: path = getattr(sceneOrg, pathName, '') setattr(scene, pathName, path) sunBall = trinity.TriVectorCurve() sunPos = sceneOrg.sunBall.GetVectorAt(blue.os.GetSimTime()) sunBall.value = (sunPos.x, sunPos.y, sunPos.z) scene.sunBall = sunBall time = blue.os.GetSimTime() objectLists = [(sceneOrg.lensflares, scene.lensflares, trinity.EveLensflare), (sceneOrg.planets, scene.planets, trinity.EvePlanet), (sceneOrg.objects, scene.objects, trinity.EveStation2)] for eachList, destination, allowedTypes in objectLists: for obj in eachList: if session.solarsystemid is None: return try: if not isinstance(obj, allowedTypes): continue if not obj.display: continue if getattr( obj, 'translationCurve', None ) is not None and obj.translationCurve.__bluetype__ == 'destiny.ClientBall': pos = obj.translationCurve.GetVectorAt(time) if getattr(obj.translationCurve, 'translationCurve', None): obj.translationCurve.resourceCallback = None obj.translationCurve.model = None translationCurve = trinity.TriVectorCurve() translationCurve.value = (pos.x, pos.y, pos.z) obj.translationCurve = translationCurve if getattr( obj, 'rotationCurve', None ) is not None and obj.rotationCurve.__bluetype__ == 'destiny.ClientBall': obj.rotationCurve = None destination.append(obj) except Exception: pass
def Start(self, anchorCurve = None, areaIndication = None): self.anchorFunction = VectorFunction(anchorCurve) self.offsetAnchorFunction = OffsetPositionFunction(anchorCurve) self.planarFunction = OffsetPositionFunction(anchorCurve) planarCurve = self.planarFunction.GetBlueFunction() self.destinationFunction = OffsetPositionFunction(anchorCurve) destCurve = self.destinationFunction.GetBlueFunction() xzDirectionCurve = XZPlaneRotationFunction(anchorCurve, destCurve).GetBlueFunction() if anchorCurve is not None: labelCurve = AverageVectorFunction([destCurve, anchorCurve]).GetBlueFunction() else: labelCurve = AverageVectorFunction([destCurve, trinity.TriVectorCurve()]).GetBlueFunction() self.labelFunction = OffsetPositionFunction(labelCurve, LABEL_OFFSET) labelCurve = self.labelFunction.GetBlueFunction() self.distanceCircle = navUI.CreateRangeCircleConnector(navUI.STYLE_STRONG, self.color, anchorCurve, destCurve) self.xzLine = navUI.CreateStraightConnector(navUI.STYLE_DOTTED, self.color, anchorCurve, xzDirectionCurve) self.yLine = navUI.CreateStraightAnchorConnector(navUI.STYLE_FAINT, self.color, planarCurve, destCurve) self.yArc = navUI.CreateCurvedAnchorConnector(navUI.STYLE_DOTTED, self.color, anchorCurve, destCurve) self.pathLine = navUI.CreateStraightConnector(navUI.STYLE_STRONG, self.color, anchorCurve, destCurve) self.areaIndication = areaIndication if areaIndication is not None: areaIndication.SetCurves(self.offsetAnchorFunction, self.destinationFunction) areaIndication.Start() if self.showRange: self.label = navUI.CreateHoverLabel('0', navUI.ColorCombination(self.color, navUI.ALPHA_SOLID), labelCurve) self.label.measurer.fontSize = 20 self.state = _PATH_STATE_PICK_XZ
def GetZoomValues(self, model, thread): rad = 300 camera = self.sceneManager.GetRegisteredCamera(self.name) trinity.WaitForResourceLoads() rad = model.GetBoundingSphereRadius() center = model.boundingSphereCenter localBB = model.GetLocalBoundingBox() if localBB[0] is None or localBB[1] is None: log.LogError( "Failed to get bounding info for ship. Odds are the ship wasn't loaded properly." ) localBB = (trinity.TriVector(0, 0, 0), trinity.TriVector(0, 0, 0)) model.translationCurve = trinity.TriVectorCurve() negativeCenter = (-center[0], -localBB[0].y + 180.0, -center[2]) model.translationCurve.value = negativeCenter cameraparent = self.GetCameraParent() if cameraparent.translationCurve is not None: keyValue = cameraparent.translationCurve.keys[1].value if self.staticEnv: keyValue = (keyValue[0], -localBB[0].y + 180.0, keyValue[2]) cameraparent.translationCurve.keys[0].value = keyValue key1Value = cameraparent.translationCurve.keys[1].value key1Value = (key1Value[0], -localBB[0].y + 180.0, key1Value[2]) cameraparent.translationCurve.keys[1].value = key1Value cameraparent.translationCurve.start = blue.os.GetSimTime() zoomMultiplier = 1.0 aspectRatio = trinity.GetAspectRatio() if aspectRatio > 1.6: zoomMultiplier = aspectRatio / 1.6 self.minZoom = (rad + camera.frontClip + 50) * zoomMultiplier self.maxZoom = 2050.0 self.layer.maxZoom = self.maxZoom self.layer.minZoom = self.minZoom return (rad + camera.frontClip) * 2
def SetupScene(self, hangarScene): for obj in hangarScene.objects: if hasattr(obj, 'PlayAnimationEx'): obj.PlayAnimationEx('NormalLoop', 0, 0.0, 1.0) for obj in hangarScene.objects: if '_Traffic_' in obj.name: obj.RebuildBoosterSet() trafficStartEndArea = {} for obj in hangarScene.objects: if obj.__bluetype__ == 'trinity.EveStation2': for loc in obj.locators: if 'Traffic_Start_' in loc.name or 'Traffic_End_' in loc.name: trafficStartEndArea[loc.name] = geo2.Vec3Transform( (0.0, 0.0, 0.0), loc.transform) if len(trafficStartEndArea) == 6: for obj in hangarScene.objects: if '_Traffic_' in obj.name: obj.display = False obj.translationCurve = trinity.TriVectorCurve() obj.translationCurve.keys.append(trinity.TriVectorKey()) obj.translationCurve.keys.append(trinity.TriVectorKey()) obj.rotationCurve = trinity.TriRotationCurve() if random.randint(0, 1) == 0: obj.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll( 0.5 * math.pi, 0.0, 0.0) else: obj.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll( -0.5 * math.pi, 0.0, 0.0) uthreadObj = uthread.new(self.AnimateTraffic, obj, trafficStartEndArea) uthreadObj.context = 'HangarTraffic::SetupScene' self.threadList.append(uthreadObj)
def GetTranslationValue(obj): """If object has a translation curve, use obj.translationCurve.value. Otherwise, return a zero TriVector.""" try: return obj.translationCurve.value except AttributeError: return trinity.TriVectorCurve().value
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 __init__(self, positionFunction, planeY=0): curve = trinity.TriVectorSequencer() curve.operator = trinity.TRIOP_MULTIPLY curve.functions.append(positionFunction) self.projectionCurve = trinity.TriVectorCurve() self.projectionCurve.value = (0, planeY, 0) VectorFunction.__init__(self, curve)
def PlayResultEffects(self, sitesOrdered): self.LogInfo('PlayResultEffects') scene = self.sceneManager.GetRegisteredScene('default') soundLocators = [] invAU = 1.0 / AU vectorCurve = trinity.TriVectorCurve() vectorCurve.value = (invAU, invAU, invAU) self.EnableMouseTracking() try: startTimeSec = float(self.systemReadyTime + SWEEP_START_GRACE_TIME) / SEC lastPlayTimeSec = startTimeSec for delaySec, siteData in sitesOrdered: locatorData = self.siteController.spaceLocations.GetBySiteID( siteData.siteID) if IsSiteInstantlyAccessible(siteData): locatorData.bracket.state = uiconst.UI_NORMAL locatorData.bracket.DoEntryAnimation(enable=True) continue playTimeSec = startTimeSec + delaySec sleepTimeSec = playTimeSec - lastPlayTimeSec lastPlayTimeSec = playTimeSec self.ShowSiteDuringSweep(locatorData, scene, siteData, sleepTimeSec, soundLocators, vectorCurve) currentTimeSec = gametime.GetSimTime() endTimeSec = startTimeSec + SWEEP_CYCLE_TIME_SEC timeLeftSec = endTimeSec - currentTimeSec if timeLeftSec > 0: uthread2.SleepSim(timeLeftSec) self.audio.SendUIEvent('ui_scanner_stop') self.sensorSweepActive = False if not self.IsOverlayActive(): self._Hide() else: for locatorData in self.siteController.spaceLocations.IterLocations( ): if not IsSiteInstantlyAccessible(locatorData.siteData): locatorData.bracket.DoEnableAnimation() locatorData.bracket.state = uiconst.UI_NORMAL uthread2.SleepSim(1.0) self.DoScanEnded(sitesOrdered) except (InvalidClientStateError, KeyError): pass finally: self.sensorSweepActive = False if scene is not None: for tr in soundLocators: if tr in scene.objects: scene.objects.remove(tr) self.audio.SendUIEvent('ui_scanner_stop') self.SendMessage( overlayConst.MESSAGE_ON_SENSOR_OVERLAY_SWEEP_ENDED) self.UpdateVisibleSites()
def SetupTracking(self): self.TearDownTracking() bp = sm.GetService('michelle').GetBallpark() if not bp: return sunBall = None if self.trackObjectID == session.shipid: for itemID, each in bp.slimItems.iteritems(): if each.groupID == const.groupSun: sunBall = bp.GetBall(itemID) break trackBallID = self.trackObjectID ball = bp.GetBall(trackBallID) if ball is None or sunBall is None: return vectorCurve = trinity.TriVectorCurve() vectorCurve.value = (-SOLARSYSTEM_SCALE, -SOLARSYSTEM_SCALE, -SOLARSYSTEM_SCALE) invSunPos = trinity.TriVectorSequencer() invSunPos.operator = trinity.TRIOP_MULTIPLY invSunPos.functions.append(sunBall) invSunPos.functions.append(vectorCurve) vectorCurve = trinity.TriVectorCurve() vectorCurve.value = (SOLARSYSTEM_SCALE, SOLARSYSTEM_SCALE, SOLARSYSTEM_SCALE) ballPos = trinity.TriVectorSequencer() ballPos.operator = trinity.TRIOP_MULTIPLY ballPos.functions.append(ball) ballPos.functions.append(vectorCurve) vectorSequencer = trinity.TriVectorSequencer() vectorSequencer.operator = trinity.TRIOP_ADD vectorSequencer.functions.append(invSunPos) vectorSequencer.functions.append(ballPos) bind = trinity.TriValueBinding() bind.copyValueCallable = self.OnBallPositionUpdate bind.sourceObject = vectorSequencer bind.sourceAttribute = 'value' self.binding = bind self.vectorSequencer = vectorSequencer if self.curveSet: curveSet = self.curveSet() if curveSet: curveSet.curves.append(vectorSequencer) curveSet.bindings.append(bind)
def PlaceShip(self, model, typeID): model.translationCurve = trinity.TriVectorCurve() trinity.WaitForResourceLoads() localBB = model.GetLocalBoundingBox() width = abs(localBB[0][0]) if evetypes.GetGroupID(typeID) == const.groupTitan: width += 2000 self.endPos = geo2.Vec3Add(self.shipAnchorPoint, (width, 0.0, 0.0)) model.translationCurve.value = self.endPos self.ApplyShipBobbing(model, (0.0, model.translationCurve.value[1], 0.0), (0.0, 250.0, 0.0), model.GetBoundingSphereRadius())
def SetupFakeAudioTransformLocation(self, shipPosition): self.fakeAudioTransform.translationCurve = trinity.TriVectorCurve() viewTransformOffset = geo2.MatrixTransformation( (0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0), (0.0, 0.0, 0.0), self.sceneRotation, self.sceneTranslation) viewTransformInverse = geo2.MatrixInverse(viewTransformOffset) newAudioEmitterPosition = geo2.Vec3TransformCoord( shipPosition, viewTransformInverse) self.fakeAudioTransform.translationCurve.value = newAudioEmitterPosition distance = geo2.Vec3Distance((0, 0, 0), newAudioEmitterPosition) gallenteHangarBaseline = 561.28692627 audioScaleFactor = distance / gallenteHangarBaseline self.generalAudioEntity.SetAttenuationScalingFactor(audioScaleFactor)
def _LoadModel(self, variant, display): scene = sm.GetService('sceneManager').GetRegisteredScene('default') if scene is None: return sof = sm.GetService('sofService').spaceObjectFactory model = sof.BuildFromDNA(BuildSOFDNAFromTypeID(self.typeID) + variant) model.modelRotationCurve = trinity.TriRotationCurve() model.translationCurve = trinity.TriVectorCurve() model.name = 'StructurePlacement' model.translationCurve.value = self.GetCurrShipPosition() model.display = display scene.objects.append(model) return model
def GetCameraParent(self): cp = sm.GetService('camera').GetCameraParent(self.name) if cp.translationCurve is not None: return cp c = trinity.TriVectorCurve() c.extrapolation = trinity.TRIEXT_CONSTANT for t in (0.0, 1.0): k = trinity.TriVectorKey() k.time = t k.interpolation = trinity.TRIINT_LINEAR c.keys.append(k) c.Sort() cp.translationCurve = c return cp
def ApplyShipBobbing(self, model, initialPosition, deltaPosition, cycleLengthInSec): curve = trinity.TriVectorCurve() topPosition = geo2.Vec3Add(initialPosition, deltaPosition) bottomPosition = geo2.Vec3Subtract(initialPosition, deltaPosition) z = (0.0, 0.0, 0.0) curve.AddKey(0.0, initialPosition, z, z, trinity.TRIINT_HERMITE) curve.AddKey(0.25 * cycleLengthInSec, bottomPosition, z, z, trinity.TRIINT_HERMITE) curve.AddKey(0.75 * cycleLengthInSec, topPosition, z, z, trinity.TRIINT_HERMITE) curve.AddKey(1.0 * cycleLengthInSec, initialPosition, z, z, trinity.TRIINT_HERMITE) curve.extrapolation = trinity.TRIEXT_CYCLE model.modelTranslationCurve = curve
def Prepare(self): StretchEffect.Prepare(self) shipBall = self.GetEffectShipBall() targetBall = self.GetEffectTargetBall() turret = shipBall.modules.get(self.moduleID, None) if turret is None: raise RuntimeError("StretchEffect: No module '%s' found" % self.moduleID) turretSet = turret.GetTurretSet() firingBoneWorldTransform = turretSet.GetFiringBoneWorldTransform(0) _, __, offsetPosition = geo2.MatrixDecompose(firingBoneWorldTransform) sourceOffsetCurve = trinity.TriVectorCurve() sourceOffsetCurve.value = offsetPosition self.gfx.source = sourceOffsetCurve destBehavior = trinity.EveLocalPositionBehavior.damageLocator self.gfx.dest = trinity.EveLocalPositionCurve(destBehavior) self.gfx.dest.parent = targetBall.model self.gfx.dest.alignPositionCurve = shipBall uthread.new(self.CreateImpact, targetBall, offsetPosition)
def FocusOnTrinityPoint(self, triVector, interpolate = True): if triVector and interpolate: now = blue.os.GetSimTime() cameraParent = sm.GetService('camera').GetCameraParent('systemmap') if cameraParent.translationCurve: startPos = cameraParent.translationCurve.GetVectorAt(now) startPos = (startPos.x, startPos.y, startPos.z) else: startPos = cameraParent.translation nullV = (0, 0, 0) vc = trinity.TriVectorCurve() vc.extrapolation = trinity.TRIEXT_CONSTANT vc.AddKey(0.0, startPos, nullV, nullV, trinity.TRIINT_HERMITE) vc.AddKey(0.5, triVector, nullV, nullV, trinity.TRIINT_HERMITE) vc.Sort() cameraParent.translationCurve = vc cameraParent.useCurves = 1 vc.start = now elif triVector: cameraParent = sm.GetService('camera').GetCameraParent('systemmap') cameraParent.translationCurve = None cameraParent.translation = triVector
def PositionShipModel(self, model): trinity.WaitForResourceLoads() localBB = model.GetLocalBoundingBox() boundingCenter = model.boundingSphereCenter[1] radius = model.boundingSphereRadius - self.shipPositionMinSize val = radius / (self.shipPositionMaxSize - self.shipPositionMinSize) if val > 1.0: val = 1.0 if val < 0: val = 0 val = pow(val, 1.0 / self.shipPositionCurveRoot) shipDirection = (self.sceneTranslation[0], 0, self.sceneTranslation[2]) shipDirection = geo2.Vec3Normalize(shipDirection) distancePosition = geo2.Lerp( (self.shipPositionMinDistance, self.shipPositionTargetHeightMin), (self.shipPositionMaxDistance, self.shipPositionTargetHeightMax), val) y = distancePosition[1] - boundingCenter y = y + self.sceneTranslation[1] if y < -localBB[0][1] + 180: y = -localBB[0][1] + 180 boundingBoxZCenter = localBB[0][2] + localBB[1][2] boundingBoxZCenter *= 0.5 shipPos = geo2.Vec3Scale(shipDirection, -distancePosition[0]) shipPos = geo2.Vec3Add(shipPos, self.sceneTranslation) shipPosition = (shipPos[0], y, shipPos[2]) model.translationCurve = trinity.TriVectorCurve() model.translationCurve.value = shipPosition model.rotationCurve = trinity.TriRotationCurve() model.rotationCurve.value = geo2.QuaternionRotationSetYawPitchRoll( self.shipPositionRotation * math.pi / 180, 0, 0) model.modelTranslationCurve = blue.resMan.LoadObject( 'res:/dx9/scene/hangar/ship_modelTranslationCurve.red') model.modelTranslationCurve.ZCurve.offset -= boundingBoxZCenter scaleMultiplier = 0.35 + 0.65 * (1 - val) capitalShips = [ const.groupDreadnought, const.groupSupercarrier, const.groupTitan, const.groupFreighter, const.groupJumpFreighter, const.groupCarrier, const.groupCapitalIndustrialShip, const.groupIndustrialCommandShip ] dogmaLocation = self.clientDogmaIM.GetDogmaLocation() if getattr(dogmaLocation.GetDogmaItem(util.GetActiveShip()), 'groupID', None) in capitalShips: scaleMultiplier = 0.35 + 0.25 * (1 - val) model.modelRotationCurve = blue.resMan.LoadObject( 'res:/dx9/scene/hangar/ship_modelRotationCurve.red') model.modelRotationCurve.PitchCurve.speed *= scaleMultiplier model.modelRotationCurve.RollCurve.speed *= scaleMultiplier model.modelRotationCurve.YawCurve.speed *= scaleMultiplier else: if val > 0.6: val = 0.6 scaleMultiplier = 0.35 + 0.65 * (1 - val / 0.6) model.modelRotationCurve = blue.resMan.LoadObject( 'res:/dx9/scene/hangar/ship_modelRotationCurveSpinning.red') model.modelRotationCurve.PitchCurve.speed *= scaleMultiplier model.modelRotationCurve.RollCurve.speed *= scaleMultiplier model.modelRotationCurve.YawCurve.start = blue.os.GetSimTime() model.modelRotationCurve.YawCurve.ScaleTime(6 * val + 1) yValues = [(0, model.translationCurve.value[1] - 20.0), (6.0, model.translationCurve.value[1] + 3.0), (9.0, model.translationCurve.value[1])] for time, yValue in yValues: k = trinity.TriVectorKey() k.value = (model.translationCurve.value[0], yValue, model.translationCurve.value[2]) k.interpolation = trinity.TRIINT_HERMITE k.time = time model.translationCurve.keys.append(k) model.translationCurve.Sort() model.translationCurve.extrapolation = trinity.TRIEXT_CONSTANT model.translationCurve.start = blue.os.GetWallclockTimeNow() self.SetupFakeAudioTransformLocation(shipPosition)
def GetTranslationValue(obj): try: return obj.translationCurve.value except AttributeError: return trinity.TriVectorCurve().value
def SetTranslationValue(obj, pos): if hasattr(obj, 'translationCurve') and obj.translationCurve is None: obj.translationCurve = trinity.TriVectorCurve() obj.translationCurve.value = pos
def StartIndividual(self, duration, sourceBall, targetBall, rotation, direction): effect = self.RecycleOrLoad(self.graphicFile) effect.source = trinity.TriVectorSequencer() effect.source.operator = 1 sourceLocation = trinity.EveLocalPositionCurve(self.startLocation) sourceLocation.parent = sourceBall.model sourceLocation.parentPositionCurve = sourceBall sourceLocation.parentRotationCurve = sourceBall sourceLocation.alignPositionCurve = targetBall sourceScale = GetBoundingBox(sourceBall, scale=1.2) sourceLocation.boundingSize = sourceScale effect.source.functions.append(sourceLocation) sourceOffsetCurve = trinity.TriVectorCurve() if self.projectileCount > 1: offset = (random.gauss(0.0, 1000.0), random.gauss(0.0, 1000.0), random.gauss(0.0, 700.0) - 2000.0) else: offset = (0, 0, -self.sourceOffset) offset = geo2.QuaternionTransformVector(rotation, offset) sourceOffsetCurve.value = offset effect.source.functions.append(sourceOffsetCurve) effect.dest = trinity.TriVectorSequencer() effect.dest.operator = 1 destLocation = trinity.EveLocalPositionCurve(self.destLocation) destLocation.parent = targetBall.model destLocation.alignPositionCurve = sourceBall destLocation.parentPositionCurve = targetBall destLocation.parentRotationCurve = targetBall targetScale = GetBoundingBox(targetBall, scale=1.2) destLocation.boundingSize = targetScale effect.dest.functions.append(destLocation) destOffsetCurve = trinity.TriVectorCurve() if self.projectileCount > 1: offset = (random.gauss(0.0, 1000.0), random.gauss(0.0, 1000.0), random.gauss(0.0, 700.0) + 500.0) else: offset = (0, 0, self.destinationOffset) offset = geo2.QuaternionTransformVector(rotation, offset) destOffsetCurve.value = offset effect.dest.functions.append(destOffsetCurve) blue.synchro.SleepSim(self.delayBeforeEffect) delay = random.random() * self.maxDelay blue.synchro.SleepSim(delay) self.AddToScene(effect) effect.Start() blue.synchro.SleepSim(self.delayUntilShipHit) if self.IsTargetStillValid() and self.delayUntilDamageApplied is not None: impactMass = targetBall.mass * targetBall.model.boundingSphereRadius * self.impactMassFraction / (250.0 * self.projectileCount) targetShip = self.GetEffectTargetBall() targetShip.ApplyTorqueAtPosition(effect.dest.value, direction, impactMass) impactDirection = geo2.Vec3Scale(direction, -1.0) if self.projectileCount == 1: impactScale = 16.0 * self.impactMassFraction else: impactScale = 8.0 * self.impactMassFraction damageDuration = self.delayUntilDamageApplied - self.delayUntilShipHit + 500 targetBall.model.CreateImpact(destLocation.damageLocatorIndex, impactDirection, damageDuration * 0.001, impactScale) blue.synchro.SleepSim(damageDuration) if self.projectileCount == 1 and self.IsTargetStillValid() and self.delayUntilDamageApplied is not None: targetBall.model.CreateImpact(destLocation.damageLocatorIndex, impactDirection, 3, impactScale) blue.synchro.SleepSim(duration * 3) self.RemoveFromScene(effect) sourceLocation.parent = None sourceLocation.alignPositionCurve = None destLocation.parent = None destLocation.alignPositionCurve = None
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 DrawRoute(self, destinations, usePoints=False, drawLines=False, blinking=True, flattened=False, rotationQuaternion=None): if not len(destinations): self.destinations = [] if self.model: self.model.diplay = False return if self.model: self.model.display = True else: self.model = trinity.Load(self.resPath) self.model.name = '__mapRoute' self.model.scaling = (self.ballScale, self.ballScale, self.ballScale) if not blinking: self.model.curveSets.removeAt(0) if drawLines: self.lineSet = trinity.EveLineSet() self.lineSet.effect = trinity.Tr2Effect() self.lineSet.effect.effectFilePath = LINESET_EFFECT transCurve = trinity.TriVectorCurve() transCurve.extrapolation = trinity.TRIEXT_CYCLE if type(rotationQuaternion ) != trinity.TriQuaternion and rotationQuaternion is not None: rotationQuaternion = trinity.TriQuaternion(*rotationQuaternion) if usePoints: for index, point in enumerate(destinations): pos = trinity.TriVector(*point) if flattened: pos.y = 0.0 if rotationQuaternion is not None: pos.TransformQuaternion(rotationQuaternion) pos.Scale(self.scale) transCurve.AddKey(index * self.timeBase, pos, trinity.TriVector(), trinity.TriVector(), trinity.TRIINT_LINEAR) if drawLines: numPoints = len(destinations) for index in xrange(numPoints): index2 = (index + 1) % numPoints p1 = geo2.Vector(*destinations[index]) * self.scale p2 = geo2.Vector(*destinations[index2]) * self.scale self.lineSet.AddLine(p1, self.lineColor, p2, self.lineColor) self.lineSet.SubmitChanges() else: map = sm.StartService('map') for index, destinationID in enumerate(destinations): destination = cfg.evelocations.Get(destinationID) pos = trinity.TriVector(destination.x, destination.y, destination.z) if flattened: pos.y = 0.0 if rotationQuaternion is not None: pos.TransformQuaternion(rotationQuaternion) pos.Scale(self.scale) transCurve.AddKey(index * 2 * self.timeBase, pos, trinity.TriVector(), trinity.TriVector(), trinity.TRIINT_LINEAR) transCurve.AddKey((index * 2 + 1) * self.timeBase, pos, trinity.TriVector(), trinity.TriVector(), trinity.TRIINT_LINEAR) now = blue.os.GetSimTime() self.model.translationCurve = transCurve self.model.translationCurve.start = now if blinking: self.model.curveSets[0].scale = 2.0 self.model.curveSets[0].PlayFrom(float(now / SEC)) self.destinations = destinations
def SetInterest(self, itemID, interpolate=True): solarsystem = sm.GetService('systemmap').GetCurrentSolarSystem() if solarsystem is None: log.LogTrace('No solar system (SystemmapNav::SetInterest)') return endPos = None for tf in solarsystem.children: tfName = getattr(tf, 'name', None) if tfName is None: continue if tfName.startswith('systemParent_'): for stf in tf.children: stfName = getattr(stf, 'name', None) if stfName is None: continue try: prefix, stfItemID = stfName.split('_') if prefix == 'scanResult': stfItemID = ('result', stfItemID) else: stfItemID = int(stfItemID) except: continue if stfItemID == itemID: endPos = trinity.TriVector(*stf.worldTransform[3][:3]) break if endPos: break elif tfName.startswith('bm_') and isinstance( itemID, tuple) and itemID[0] == 'bookmark': tfItemID = int(tfName.split('_')[1]) if tfItemID == itemID[1]: endPos = trinity.TriVector(*tf.worldTransform[3][:3]) break elif tfName.endswith(str(itemID)): endPos = trinity.TriVector(*tf.worldTransform[3][:3]) break if endPos is None and itemID == eve.session.shipid: endPos = maputils.GetMyPos() endPos.Scale(SYSTEMMAP_SCALE) if endPos and interpolate: now = blue.os.GetSimTime() cameraParent = sm.GetService('camera').GetCameraParent('systemmap') if cameraParent.translationCurve: startPos = cameraParent.translationCurve.GetVectorAt(now) else: startPos = cameraParent.translation nullV = trinity.TriVector() vc = trinity.TriVectorCurve() vc.extrapolation = trinity.TRIEXT_CONSTANT vc.AddKey(0.0, startPos, nullV, nullV, trinity.TRIINT_HERMITE) vc.AddKey(0.5, endPos, nullV, nullV, trinity.TRIINT_HERMITE) vc.Sort() cameraParent.translationCurve = vc cameraParent.useCurves = 1 vc.start = now elif endPos: cameraParent = sm.GetService('camera').GetCameraParent('systemmap') cameraParent.translationCurve = None cameraParent.translation = (endPos.x, endPos.y, endPos.z)
def InitModelPosition(self): self.model.rotationCurve = trinity.TriRotationCurve() self.model.rotationCurve.value = geo2.QuaternionRotationAxis((0, 1, 0), math.pi) self.model.translationCurve = trinity.TriVectorCurve()
def DrawRoute(self, destinations, usePoints = False, drawLines = False, blinking = True, flattened = False, rotationQuaternion = None): """ Create a blinking ball and attach a translation curve to animate it along autopilot path flattened: If set, eliminates the y-coordinate. Best used in conjunction with rotationQuaternion. rotationQuaternion: If set, transforms each destination point by the given quaternion. """ if not len(destinations): self.destinations = [] if self.model: self.model.diplay = False return if self.model: self.model.display = True else: self.model = trinity.Load(self.resPath) self.model.name = '__mapRoute' self.model.scaling = (self.ballScale, self.ballScale, self.ballScale) if not blinking: self.model.curveSets.removeAt(0) if drawLines: self.lineSet = trinity.EveLineSet() self.lineSet.effect = trinity.Tr2Effect() self.lineSet.effect.effectFilePath = LINESET_EFFECT transCurve = trinity.TriVectorCurve() transCurve.extrapolation = trinity.TRIEXT_CYCLE if type(rotationQuaternion) != trinity.TriQuaternion and rotationQuaternion is not None: rotationQuaternion = trinity.TriQuaternion(*rotationQuaternion) emptyVector = (0.0, 0.0, 0.0) if usePoints: for index, point in enumerate(destinations): pos = trinity.TriVector(*point) if flattened: pos.y = 0.0 if rotationQuaternion is not None: pos.TransformQuaternion(rotationQuaternion) pos.Scale(self.scale) pythonPos = (pos.x, pos.y, pos.z) transCurve.AddKey(index * self.timeBase, pythonPos, emptyVector, emptyVector, trinity.TRIINT_LINEAR) if drawLines: numPoints = len(destinations) for index in xrange(numPoints): index2 = (index + 1) % numPoints p1 = geo2.Vector(*destinations[index]) * self.scale p2 = geo2.Vector(*destinations[index2]) * self.scale self.lineSet.AddLine(p1, self.lineColor, p2, self.lineColor) self.lineSet.SubmitChanges() else: map = sm.StartService('map') for index, destinationID in enumerate(destinations): destination = cfg.evelocations.Get(destinationID) pos = trinity.TriVector(destination.x, destination.y, destination.z) if flattened: pos.y = 0.0 if rotationQuaternion is not None: pos.TransformQuaternion(rotationQuaternion) pos.Scale(self.scale) pythonPos = (pos.x, pos.y, pos.z) transCurve.AddKey(index * 2 * self.timeBase, pythonPos, emptyVector, emptyVector, trinity.TRIINT_LINEAR) transCurve.AddKey((index * 2 + 1.0) * self.timeBase, pythonPos, emptyVector, emptyVector, trinity.TRIINT_LINEAR) now = blue.os.GetSimTime() self.model.translationCurve = transCurve self.model.translationCurve.start = now if blinking: self.model.curveSets[0].scale = 2.0 self.model.curveSets[0].PlayFrom(float(now / const.SEC)) self.destinations = destinations
def SetTranslationValue(obj, pos): """Sets the translationCurve value for an object, creating a curve if one does not already exist.""" if hasattr(obj, 'translationCurve') and obj.translationCurve is None: obj.translationCurve = trinity.TriVectorCurve() obj.translationCurve.value = pos