Exemple #1
0
 def Prepare(self):
     shipBall = self.GetEffectShipBall()
     positionCurve = self.GetBallPositionCurve(shipBall)
     targetBall = self.GetEffectTargetBall()
     if shipBall is None:
         raise RuntimeError('StretchEffect: no ball found')
     if not getattr(shipBall, 'model', None):
         raise RuntimeError('StretchEffect: no model found')
     if targetBall is None:
         raise RuntimeError('StretchEffect: no target ball found')
     self.gfx = self.RecycleOrLoad(self.graphicFile)
     if self.gfx is None:
         raise RuntimeError('StretchEffect: no effect found: ' + str(getattr(self, 'graphicFile', 'None')))
     self.ScaleEffectAudioEmitters()
     self.gfxModel = self.gfx
     sourceBehavior = trinity.EveLocalPositionBehavior.nearestBounds
     self.gfx.source = trinity.EveLocalPositionCurve(sourceBehavior)
     self.gfx.source.offset = self.sourceOffset
     destBehavior = trinity.EveLocalPositionBehavior.nearestBounds
     self.gfx.dest = trinity.EveLocalPositionCurve(destBehavior)
     self.gfx.dest.offset = self.destinationOffset
     self.gfx.source.parentPositionCurve = positionCurve
     self.gfx.source.parentRotationCurve = shipBall
     self.gfx.source.alignPositionCurve = targetBall
     self.gfx.dest.parentPositionCurve = targetBall
     self.gfx.dest.parentRotationCurve = targetBall
     self.gfx.dest.alignPositionCurve = positionCurve
     sourceScale = GetBoundingBox(shipBall, scale=1.2)
     self.gfx.source.boundingSize = sourceScale
     targetScale = GetBoundingBox(targetBall, scale=1.2)
     self.gfx.dest.boundingSize = targetScale
     self.AddToScene(self.gfxModel)
Exemple #2
0
 def GetPositionCurve(self):
     if self.model is None:
         return self
     curve = trinity.EveLocalPositionCurve()
     curve.parent = self.model
     curve.behavior = trinity.EveLocalPositionBehavior.centerBounds
     return curve
Exemple #3
0
def GetBallPosition(ball):
    if getattr(ball, 'model',
               None) and not isinstance(ball.model, trinity.EvePlanet):
        elpc = trinity.EveLocalPositionCurve()
        elpc.parent = ball.model
        elpc.behavior = trinity.EveLocalPositionBehavior.centerBounds
        vec = elpc.GetVectorAt(blue.os.GetSimTime())
    else:
        vec = ball.GetVectorAt(blue.os.GetSimTime())
    return (vec.x, vec.y, vec.z)
Exemple #4
0
 def _GetTrackableCurve(self, itemID):
     item = sm.StartService('michelle').GetBall(itemID)
     if item is None or getattr(item, 'model', None) is None:
         return
     if item.model.__bluetype__ in evespacescene.EVESPACE_TRINITY_CLASSES:
         behavior = trinity.EveLocalPositionBehavior.centerBounds
         tracker = trinity.EveLocalPositionCurve(behavior)
         tracker.parent = item.model
         return tracker
     return item
Exemple #5
0
 def __init__(self,
              parentFunction,
              offset=(0, 0, 0),
              rotationFunction=None):
     curve = trinity.EveLocalPositionCurve()
     curve.behavior = trinity.EveLocalPositionBehavior.offsetPosition
     curve.parentPositionCurve = parentFunction
     curve.parentRotationCurve = rotationFunction
     curve.positionOffset = offset
     VectorFunction.__init__(self, curve)
Exemple #6
0
 def Prepare(self, addToScene=True):
     shipBall = self.GetEffectShipBall()
     if shipBall is None:
         raise RuntimeError('ShipEffect: no ball found:' + self.__guid__)
     self.gfx = self.RecycleOrLoad(self.graphicFile)
     if self.gfx is None:
         raise RuntimeError('ShipEffect: no effect found:' + self.__guid__)
     self.AddSoundToEffect(2)
     if type(self.gfx) == trinity.EveTransform:
         self.gfxModel = trinity.EveRootTransform()
         self.gfxModel.children.append(self.gfx)
     else:
         self.gfxModel = self.gfx
     self.gfxModel.modelRotationCurve = getattr(shipBall.model,
                                                'modelRotationCurve', None)
     self.gfxModel.modelTranslationCurve = getattr(shipBall.model,
                                                   'modelTranslationCurve',
                                                   None)
     effectBall = shipBall
     if FX_TF_POSITION_BALL in self.transformFlags:
         self.gfxModel.translationCurve = self.GetBallPositionCurve(
             shipBall)
     if FX_TF_POSITION_MODEL in self.transformFlags:
         behavior = trinity.EveLocalPositionBehavior.centerBounds
         self.gfxModel.translationCurve = trinity.EveLocalPositionCurve(
             behavior)
         self.gfxModel.translationCurve.parent = shipBall.model
     if FX_TF_POSITION_TARGET in self.transformFlags:
         effectBall = self.GetEffectTargetBall()
         self.gfxModel.translationCurve = self.GetBallPositionCurve(
             effectBall)
     if FX_TF_SCALE_BOUNDING in self.transformFlags:
         shipBBoxMin, shipBBoxMax = effectBall.model.GetLocalBoundingBox()
         bBox = (max(-shipBBoxMin[0], shipBBoxMax[0]) * 1.2,
                 max(-shipBBoxMin[1], shipBBoxMax[1]) * 1.2,
                 max(-shipBBoxMin[2], shipBBoxMax[2]) * 1.2)
         self.gfxModel.scaling = bBox
     elif FX_TF_SCALE_SYMMETRIC in self.transformFlags:
         radius = effectBall.model.GetBoundingSphereRadius()
         self.gfxModel.scaling = (radius, radius, radius)
         self.gfx.translation = (0, 0, 0)
     elif FX_TF_SCALE_RADIUS in self.transformFlags:
         radius = effectBall.model.GetBoundingSphereRadius()
         self.gfxModel.scaling = (radius, radius, radius)
     if FX_TF_ROTATION_BALL in self.transformFlags:
         self.gfxModel.rotationCurve = effectBall
     self.gfxModel.name = self.__guid__
     if addToScene:
         self.AddToScene(self.gfxModel)
Exemple #7
0
 def _DoAnimatedLookAt(self,
                       item,
                       setZ=None,
                       resetCamera=False,
                       trackableItem=None,
                       cache=False):
     if item.model.__bluetype__ not in evespacescene.EVESPACE_TRINITY_CLASSES:
         self.animationController.Schedule(
             camutils.SetTranslationCurve(trackableItem))
         return
     behavior = trinity.EveLocalPositionBehavior.centerBounds
     tracker = trinity.EveLocalPositionCurve(behavior)
     tracker.parent = item.model
     self.animationController.Schedule(camutils.LookAt_Translation(tracker))
     self.animationController.Schedule(camutils.LookAt_FOV(resetCamera))
     self.animationController.Schedule(
         camutils.LookAt_Pan(setZ, cache=cache))
Exemple #8
0
 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)
Exemple #9
0
 def Prepare(self):
     shipBall = self.GetEffectShipBall()
     self.gfx = self.RecycleOrLoad(self.graphicFile)
     if self.gfx is None:
         log.LogError('effect not found: ' + str(self.graphicFile))
         return
     self.gfx.dest = trinity.EveRemotePositionCurve()
     self.gfx.dest.startPositionCurve = shipBall
     self.gfx.dest.offsetDir1 = self.startTargetOffset
     self.gfx.dest.offsetDir2 = self.endTargetOffset
     self.gfx.dest.sweepTime = self.durationSeconds
     sourceBehavior = trinity.EveLocalPositionBehavior.nearestBounds
     self.gfx.source = trinity.EveLocalPositionCurve(sourceBehavior)
     self.gfx.source.offset = self.sourceOffset
     self.gfx.source.parentPositionCurve = shipBall
     self.gfx.source.parentRotationCurve = shipBall
     self.gfx.source.alignPositionCurve = self.gfx.dest
     self.gfx.source.boundingSize = GetBoundingBox(shipBall, scale=1.2)
     self.AddToScene(self.gfx)
Exemple #10
0
 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
Exemple #11
0
 def SetTranslation(self, value):
     if self._translationCurve is None:
         behavior = trinity.EveLocalPositionBehavior.centerBounds
         curve = trinity.EveLocalPositionCurve(behavior)
         self.SetTranslationCurve(curve)
     self._translationCurve.value = value
Exemple #12
0
 def __init__(self, originFunction, targetFunction):
     curve = trinity.EveLocalPositionCurve()
     curve.behavior = trinity.EveLocalPositionBehavior.offsetPlaneRotation
     curve.parentPositionCurve = originFunction
     curve.alignPositionCurve = targetFunction
     VectorFunction.__init__(self, curve)