def TransitTo(self, atPosition, eyePosition, duration = 1.0, smoothing = 1.0, numPoints = 100, timeOffset = 0.0): """ Transit smoothly to a new at and eye position """ newDir = geo2.Vec3Direction(eyePosition, atPosition) atPoints = self.GetTransitAtCurve(self.atPosition, atPosition, newDir, smoothing, numPoints=numPoints) uicore.animations.MorphVector3(self, 'atPosition', curveType=atPoints, duration=duration, timeOffset=timeOffset) eyePoints = self.GetTransitEyeCurve(eyePosition, atPosition, newDir, atPoints) uicore.animations.MorphVector3(self, 'eyePosition', curveType=eyePoints, duration=duration, timeOffset=timeOffset)
def Transit(self, atPos0, eyePos0, atPos1, eyePos1, duration=1.0, smoothing=0.1, numPoints=1000, timeOffset=0.0, callback=None): newDir = geo2.Vec3Direction(eyePos1, atPos1) self.StopEyeAndAtAnimation() if self._atTransitOffset: atPos0 = geo2.Vec3Add(atPos0, self._atTransitOffset) if self._eyeTransitOffset: eyePos0 = geo2.Vec3Add(eyePos0, self._eyeTransitOffset) self.SetAtPosition(atPos1) self.SetEyePosition(eyePos1) self._atTransitOffset = geo2.Vec3Subtract(atPos0, atPos1) self._eyeTransitOffset = geo2.Vec3Subtract(eyePos0, eyePos1) uicore.animations.MorphVector3(self, '_atTransitOffset', self._atTransitOffset, (0, 0, 0), duration=duration, timeOffset=timeOffset, callback=callback) uicore.animations.MorphVector3(self, '_eyeTransitOffset', self._eyeTransitOffset, (0, 0, 0), duration=duration, timeOffset=timeOffset, callback=self.OnTransitEnd) self._transitDoneTime = blue.os.GetWallclockTime() + SEC * duration
def GetLookAtDirectionWithOffset(self): eyePos = geo2.Vec3AddD( self._eyePosition, self._eyeOffset) if self._eyeOffset else self._eyePosition atPos = geo2.Vec3AddD( self._atPosition, self._atOffset) if self._atOffset else self._atPosition return geo2.Vec3Direction(eyePos, atPos)
def Prepare(self): StretchEffect.Prepare(self) self.gfxModel.source.behavior = trinity.EveLocalPositionBehavior.damageLocator self.gfxModel.source.parent = self.GetEffectShipBall().model self.gfxModel.dest.behavior = trinity.EveLocalPositionBehavior.damageLocator self.gfxModel.dest.parent = self.GetEffectTargetBall().model p = self.GetEffectShipBall().GetVectorAt(blue.os.GetSimTime()) sourcePos = geo2.Vector(p.x, p.y, p.z) p = self.GetEffectTargetBall().GetVectorAt(blue.os.GetSimTime()) targetPos = geo2.Vector(p.x, p.y, p.z) sourceToTargetDir = geo2.Vec3Direction(sourcePos, targetPos) uthread.new(self.CreateImpact, sourceToTargetDir)
def Start(self, duration): sourceBall = self.GetEffectShipBall() targetBall = self.GetEffectTargetBall() sourcePos = sourceBall.GetVectorAt(blue.os.GetSimTime()) sourcePos = (sourcePos.x, sourcePos.y, sourcePos.z) targetPos = targetBall.GetVectorAt(blue.os.GetSimTime()) targetPos = (targetPos.x, targetPos.y, targetPos.z) direction = geo2.Vec3Direction(sourcePos, targetPos) rotation = geo2.QuaternionRotationArc((0, 0, 1), direction) direction = geo2.Vec3Scale(direction, -1.0) for x in range(self.projectileCount): uthread.new(self.StartIndividual, duration, sourceBall, targetBall, rotation, direction)
def _ResetEyeAndAtPosition(self, eyePos0, atPos0, distance=LOOKAT_DIST, animate=True, duration=None): direction = self._GetNewDirection(geo2.Vec3Subtract(eyePos0, atPos0)) eyePos1 = geo2.Vec3Add(atPos0, geo2.Vec3Scale(direction, distance)) if animate: if duration is None: duration = GetDurationByDistance(eyePos0, eyePos1, 0.4, 0.6) atPos1 = atPos0 diff = geo2.Vec3Scale(geo2.Vec3Direction(atPos0, eyePos0), distance / 5) atPos0 = geo2.Vec3Add(atPos0, diff) self.Transit(atPos0, eyePos0, atPos1, eyePos1, duration=duration, callback=self.EnableManualControl) else: self.SetAtPosition(atPos0) self.SetEyePosition(eyePos1)
def GetLookAtDirection(self): return geo2.Vec3Direction(self._eyePosition, self.GetZoomToPoint())
def GetLookAtDirection(self): return geo2.Vec3Direction(self.eyePosition, self.atPosition)