コード例 #1
0
 def AlignToDirection(self, direction):
     zaxis = Vector3(direction)
     if zaxis.Length2() > 0.0:
         Up = Vector3([0.0, 1.0, 0.0])
         zaxis.Normalize()
         xaxis = zaxis ^ Up
         if xaxis.Length2() == 0.0:
             zaxis += Vector3().Randomize(0.0001)
             zaxis.Normalize()
             xaxis = zaxis ^ Up
         xaxis.Normalize()
         yaxis = xaxis ^ zaxis
     else:
         self.LogError('Space object', self.id,
                       'has zero dunDirection. I cannot rotate it.')
         return
     mat = ((xaxis[0], xaxis[1], xaxis[2], 0.0), (yaxis[0], yaxis[1],
                                                  yaxis[2], 0.0),
            (-zaxis[0], -zaxis[1], -zaxis[2], 0.0), (0.0, 0.0, 0.0, 1.0))
     quat = geo2.QuaternionRotationMatrix(mat)
     if self.model and self.HasBlueInterface(
             self.model, 'IEveSpaceObject2') and hasattr(
                 self.model, 'modelRotationCurve'):
         if not self.model.modelRotationCurve:
             self.model.modelRotationCurve = trinity.TriRotationCurve(
                 0.0, 0.0, 0.0, 1.0)
         self.model.modelRotationCurve.value = quat
     else:
         self.model.rotationCurve = None
コード例 #2
0
 def AlignToDirection(self):
     destination = sm.StartService('space').warpDestinationCache[3]
     ballPark = sm.StartService('michelle').GetBallpark()
     egoball = ballPark.GetBall(ballPark.ego)
     direction = [
         egoball.x - destination[0], egoball.y - destination[1],
         egoball.z - destination[2]
     ]
     zaxis = direction
     if geo2.Vec3LengthSqD(zaxis) > 0.0:
         zaxis = geo2.Vec3NormalizeD(zaxis)
         xaxis = geo2.Vec3CrossD((0, 1, 0), zaxis)
         if geo2.Vec3LengthSqD(xaxis) == 0.0:
             zaxis = geo2.Vec3AddD(zaxis, mathCommon.RandomVector(0.0001))
             zaxis = geo2.Vec3NormalizeD(zaxis)
             xaxis = geo2.Vec3CrossD((0, 1, 0), zaxis)
         xaxis = geo2.Vec3NormalizeD(xaxis)
         yaxis = geo2.Vec3CrossD(zaxis, xaxis)
     else:
         self.transformFlags = effectconsts.FX_TF_POSITION_BALL | effectconsts.FX_TF_ROTATION_BALL
         self.Prepare()
         return
     mat = ((xaxis[0], xaxis[1], xaxis[2], 0.0), (yaxis[0], yaxis[1],
                                                  yaxis[2], 0.0),
            (zaxis[0], zaxis[1], zaxis[2], 0.0), (0.0, 0.0, 0.0, 1.0))
     quat = geo2.QuaternionRotationMatrix(mat)
     self.gfxModel.rotationCurve = None
     if self.gfxModel and hasattr(self.gfxModel, 'modelRotationCurve'):
         self.gfxModel.modelRotationCurve = trinity.TriRotationCurve(
             0.0, 0.0, 0.0, 1.0)
         self.gfxModel.modelRotationCurve.value = quat
     self.debugAligned = True
コード例 #3
0
    def Assemble(self):
        if self.model is None:
            self.LogError('Cannot Assemble Asteroid, model failed to load')
            return
        self.model.modelScale = self.radius
        pi = math.pi
        identity = trinity.TriQuaternion()
        cleanRotation = trinity.TriQuaternion()
        preRotation = trinity.TriQuaternion()
        postRotation = trinity.TriQuaternion()
        rotKey = trinity.TriQuaternion()
        r = random.Random()
        r.seed(self.id)
        preRotation.SetYawPitchRoll(r.random() * pi,
                                    r.random() * pi,
                                    r.random() * pi)
        postRotation.SetYawPitchRoll(r.random() * pi,
                                     r.random() * pi,
                                     r.random() * pi)
        curve = trinity.TriRotationCurve()
        curve.extrapolation = trinity.TRIEXT_CYCLE
        duration = 50.0 * math.log(self.radius)
        rdur = r.random() * 50.0 * math.log(self.radius)
        duration += rdur
        for i in [0.0, 0.5, 1.0, 1.5, 2.0]:
            cleanRotation.SetYawPitchRoll(0.0, pi * i, 0.0)
            rotKey.SetIdentity()
            rotKey.MultiplyQuaternion(preRotation)
            rotKey.MultiplyQuaternion(cleanRotation)
            rotKey.MultiplyQuaternion(postRotation)
            curve.AddKey(duration * i, rotKey, identity, identity,
                         trinity.TRIINT_SLERP)

        curve.Sort()
        self.model.modelRotationCurve = curve
コード例 #4
0
ファイル: scenarioMgr.py プロジェクト: connoryang/1v1dec
    def AddBoundingCube(self,
                        ball,
                        model,
                        scale=1.0,
                        rotation=geo2.Vector(0, 0, 0, 1)):
        scene = sm.GetService('sceneManager').GetRegisteredScene('default')
        transform = trinity.EveRootTransform()
        transform.name = '_dungeon_editor_'
        transform.children.append(model)
        if hasattr(ball, 'model') and ball.model is not None:
            transform.translationCurve = ball.model.translationCurve
        else:
            try:
                transform.translationCurve = self.fakeBallTransforms[
                    ball.id].translationCurve
            except KeyError:
                self.LogError('AddBoundingCube failed because ball', ball.id,
                              "didn't have a fake ball!")

        transform.rotationCurve = trinity.TriRotationCurve()
        transform.rotationCurve.value = (rotation.x, rotation.y, rotation.z,
                                         rotation.w)
        scaleFromBall = max(ball.radius, 150)
        scale = scale * scaleFromBall
        model.scaling = (scale, scale, scale)
        scene.objects.append(transform)
コード例 #5
0
 def AlignToDirection(self, direction):
     """Align the space object to a direction."""
     if not self.model:
         return
     zaxis = direction
     if geo2.Vec3LengthSqD(zaxis) > 0.0:
         zaxis = geo2.Vec3NormalizeD(zaxis)
         xaxis = geo2.Vec3CrossD(zaxis, (0, 1, 0))
         if geo2.Vec3LengthSqD(xaxis) == 0.0:
             zaxis = geo2.Vec3AddD(zaxis, mathCommon.RandomVector(0.0001))
             zaxis = geo2.Vec3NormalizeD(zaxis)
             xaxis = geo2.Vec3CrossD(zaxis, (0, 1, 0))
         xaxis = geo2.Vec3NormalizeD(xaxis)
         yaxis = geo2.Vec3CrossD(xaxis, zaxis)
     else:
         self.LogError('Space object', self.id, 'has invalid direction (',
                       direction, '). Unable to rotate it.')
         return
     mat = ((xaxis[0], xaxis[1], xaxis[2], 0.0), (yaxis[0], yaxis[1],
                                                  yaxis[2], 0.0),
            (-zaxis[0], -zaxis[1], -zaxis[2], 0.0), (0.0, 0.0, 0.0, 1.0))
     quat = geo2.QuaternionRotationMatrix(mat)
     if hasattr(self.model, 'modelRotationCurve'):
         if not self.model.modelRotationCurve:
             self.model.modelRotationCurve = trinity.TriRotationCurve(
                 0.0, 0.0, 0.0, 1.0)
         self.model.modelRotationCurve.value = quat
     else:
         self.model.rotationCurve = None
コード例 #6
0
    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)
コード例 #7
0
ファイル: wreck.py プロジェクト: R4M80MrX/eve-1
 def Prepare(self, spaceMgr):
     spaceObject.DeployableSpaceObject.Prepare(self, spaceMgr)
     slimItem = sm.StartService('michelle').GetBallpark().GetInvItem(
         self.id)
     shipBall = None
     if hasattr(slimItem, 'launcherID'):
         shipBall = sm.StartService('michelle').GetBall(slimItem.launcherID)
     if shipBall is None or not hasattr(shipBall, 'model'):
         if hasattr(self.model, 'modelRotationCurve'):
             self.model.modelRotationCurve = trinity.TriRotationCurve()
             quat = geo2.QuaternionRotationSetYawPitchRoll(
                 random.random() * 6.28,
                 random.random() * 6.28,
                 random.random() * 6.28)
             self.model.modelRotationCurve.value = quat
         else:
             self.model.rotationCurve = None
             self.model.rotation.SetYawPitchRoll(random.random() * 6.28,
                                                 random.random() * 6.28,
                                                 random.random() * 6.28)
         self.model.display = 1
         self.delayedDisplay = 0
     else:
         self.model.rotationCurve = None
         if hasattr(self.model, 'modelRotationCurve'):
             if shipBall.model is not None:
                 if hasattr(
                         shipBall.model, 'modelRotationCurve'
                 ) and shipBall.model.modelRotationCurve is not None:
                     self.model.modelRotationCurve = shipBall.model.modelRotationCurve
                 else:
                     self.model.modelRotationCurve = trinity.TriRotationCurve(
                     )
                     quat = geo2.QuaternionRotationSetYawPitchRoll(
                         shipBall.yaw, shipBall.pitch, shipBall.roll)
                     self.model.modelRotationCurve.value = quat
         elif shipBall.model is not None:
             if hasattr(shipBall.model, 'rotation'):
                 self.model.rotation = shipBall.model.rotation
             else:
                 quat = geo2.QuaternionRotationSetYawPitchRoll(
                     shipBall.yaw, shipBall.pitch, shipBall.roll)
                 self.model.modelRotationCurve.value = quat
         shipBall.wreckID = self.id
         self.model.display = 0
         self.delayedDisplay = 1
         uthread.pool('Wreck::DisplayWreck', self.DisplayWreck, 3000)
コード例 #8
0
 def SetRotation(self, yaw, pitch, roll):
     if hasattr(self.model, 'modelRotationCurve'):
         self.model.modelRotationCurve = trinity.TriRotationCurve()
         quat = geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, roll)
         self.model.modelRotationCurve.value = quat
     else:
         self.model.rotationCurve = None
         self.model.rotation.SetYawPitchRoll(yaw, pitch, roll)
コード例 #9
0
 def SetBallRotation(self, ball):
     self.model.rotationCurve = None
     if getattr(ball.model, 'modelRotationCurve', None) is not None:
         self.model.modelRotationCurve = ball.model.modelRotationCurve
     else:
         self.model.modelRotationCurve = trinity.TriRotationCurve()
         quat = geo2.QuaternionRotationSetYawPitchRoll(
             ball.yaw, ball.pitch, ball.roll)
         self.model.modelRotationCurve.value = quat
     ball.wreckID = self.id
     self.model.display = 0
     uthread.pool('Wreck::DisplayWreck', self.DisplayWreck, 2000)
コード例 #10
0
 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
コード例 #11
0
 def SetRandomRotation(self):
     if hasattr(self.model, 'modelRotationCurve'):
         self.model.modelRotationCurve = trinity.TriRotationCurve()
         quat = geo2.QuaternionRotationSetYawPitchRoll(
             random.random() * 6.28,
             random.random() * 6.28,
             random.random() * 6.28)
         self.model.modelRotationCurve.value = quat
     else:
         self.model.rotationCurve = None
         self.model.rotation.SetYawPitchRoll(random.random() * 6.28,
                                             random.random() * 6.28,
                                             random.random() * 6.28)
     self.model.display = 1
コード例 #12
0
ファイル: scenarioMgr.py プロジェクト: R4M80MrX/eve-1
 def SetDungeonOrigin(self):
     bp = sm.StartService('michelle').GetBallpark()
     if not bp or not bp.ego:
         return
     ego = bp.balls[bp.ego]
     translationCurve = bp.AddBall(-bp.ego, 1.0, 0.0, 0, 0, 0, 0, 0, 0,
                                   ego.x, ego.y, ego.z, 0, 0, 0, 0, 1.0)
     rotationCurve = trinity.TriRotationCurve()
     rotationCurve.value.SetYawPitchRoll(ego.yaw, ego.pitch, ego.roll)
     self.dungeonOrigin = trinity.TriTransform()
     self.dungeonOrigin.translationCurve = translationCurve
     self.dungeonOrigin.rotationCurve = rotationCurve
     self.dungeonOrigin.useCurves = 1
     self.dungeonOrigin.Update(blue.os.GetSimTime())
コード例 #13
0
 def SetStaticRotation(self):
     if self.model is None:
         return
     self.model.rotationCurve = None
     rot = self.typeData.get('dunRotation', None)
     if rot:
         yaw, pitch, roll = map(math.radians, rot)
         quat = geo2.QuaternionRotationSetYawPitchRoll(yaw, pitch, roll)
         if hasattr(self.model, 'rotation'):
             if type(self.model.rotation) == types.TupleType:
                 self.model.rotation = quat
             else:
                 self.model.rotation.SetYawPitchRoll(yaw, pitch, roll)
         else:
             self.model.rotationCurve = trinity.TriRotationCurve()
             self.model.rotationCurve.value = quat
コード例 #14
0
ファイル: scenarioMgr.py プロジェクト: R4M80MrX/eve-1
    def ReplaceObjectBall(self, ballID, slimItem):
        if ballID in self.fakeTransforms:
            return
        targetBall = sm.GetService('michelle').GetBall(ballID)
        targetModel = getattr(targetBall, 'model', None)
        modelWaitEntryTime = blue.os.GetWallclockTime()
        if slimItem.groupID not in self.groupsWithNoModel:
            while not targetModel:
                blue.pyos.synchro.SleepWallclock(100)
                targetModel = getattr(targetBall, 'model', None)
                if blue.os.GetWallclockTime(
                ) > modelWaitEntryTime + const.SEC * 15.0:
                    self.LogError(
                        'ReplaceObjectBall gave up on waiting for the object model to load.'
                    )
                    return False

        bp = sm.GetService('michelle').GetBallpark()
        replacementBall = bp.AddBall(-ballID, 1.0, 0.0, 0, 0, 0, 0, 0, 0,
                                     targetBall.x, targetBall.y, targetBall.z,
                                     0, 0, 0, 0, 1.0)
        replacementBall = FakeBall(replacementBall)
        replacementBall.__dict__['id'] = ballID
        tf = trinity.TriTransform()
        tf.translationCurve = replacementBall
        tf.rotationCurve = trinity.TriRotationCurve()
        if targetModel and targetModel.rotationCurve and hasattr(
                targetModel.rotationCurve, 'value'):
            yaw, pitch, roll = targetModel.rotationCurve.value.GetYawPitchRoll(
            )
            tf.rotationCurve.value.SetYawPitchRoll(yaw, pitch, roll)
        elif hasattr(targetModel, 'rotation'):
            yaw, pitch, roll = targetModel.rotation.GetYawPitchRoll()
            tf.rotationCurve.value.SetYawPitchRoll(yaw, pitch, roll)
        tf.useCurves = 1
        tf.Update(blue.os.GetSimTime())
        self.fakeTransforms[ballID] = tf
        if targetModel:
            self.backupTranslations[ballID] = targetModel.translationCurve
            self.backupRotations[ballID] = targetModel.rotationCurve
            targetModel.translationCurve = tf.translationCurve
            targetModel.rotationCurve = tf.rotationCurve
コード例 #15
0
 def SetStaticRotation(self):
     if self.model is None:
         return
     self.model.rotationCurve = None
     slimItem = sm.StartService('michelle').GetItem(self.id)
     if slimItem:
         rot = getattr(slimItem, 'dunRotation', None)
         if rot is not None:
             yaw, pitch, roll = rot
             quat = geo2.QuaternionRotationSetYawPitchRoll(
                 yaw * DEG2RAD, pitch * DEG2RAD, roll * DEG2RAD)
             if hasattr(self.model, 'rotation'):
                 if type(self.model.rotation) == types.TupleType:
                     self.model.rotation = quat
                 else:
                     self.model.rotation.SetYawPitchRoll(
                         yaw * DEG2RAD, pitch * DEG2RAD, roll * DEG2RAD)
             else:
                 self.model.rotationCurve = trinity.TriRotationCurve()
                 self.model.rotationCurve.value = quat
コード例 #16
0
    def ReplaceObjectBall(self, ballID, slimItem):
        """
        Replaces the ball of an object with a very small, fake ball that is used to
        safely move the object during editing.
        """
        if ballID in self.fakeBallTransforms:
            return
        targetBall = sm.GetService('michelle').GetBall(ballID)
        targetModel = getattr(targetBall, 'model', None)
        modelWaitEntryTime = blue.os.GetWallclockTime()
        if slimItem.groupID not in self.groupsWithNoModel:
            while not targetModel:
                blue.pyos.synchro.SleepWallclock(100)
                targetModel = getattr(targetBall, 'model', None)
                if blue.os.GetWallclockTime(
                ) > modelWaitEntryTime + const.SEC * 15.0:
                    self.LogError(
                        'ReplaceObjectBall gave up on waiting for the object model to load.'
                    )
                    return False

        bp = sm.GetService('michelle').GetBallpark()
        replacementBall = bp.AddBall(-ballID, 1.0, 0.0, 0, 0, 0, 0, 0, 0,
                                     targetBall.x, targetBall.y, targetBall.z,
                                     0, 0, 0, 0, 1.0)
        replacementBall = FakeBall(replacementBall)
        replacementBall.__dict__['id'] = ballID
        tf = trinity.EveRootTransform()
        tf.translationCurve = replacementBall
        if targetModel and targetModel.rotationCurve and hasattr(
                targetModel.rotationCurve, 'value'):
            tf.rotationCurve = targetModel.rotationCurve
        elif hasattr(targetModel, 'rotation'):
            tf.rotationCurve = trinity.TriRotationCurve()
            tf.rotationCurve.value = targetModel.rotation
        self.fakeBallTransforms[ballID] = tf
        if targetModel:
            self.backupTranslations[ballID] = targetModel.translationCurve
            self.backupRotations[ballID] = targetModel.rotationCurve
            targetModel.translationCurve = tf.translationCurve
            targetModel.rotationCurve = tf.rotationCurve
コード例 #17
0
    def Assemble(self):
        if self.model is None:
            self.LogError('Cannot Assemble Asteroid, model failed to load')
            return
        if self.HasBlueInterface(self.model, 'IEveSpaceObject2'):
            self.model.modelScale = self.radius
            pi = math.pi
            id = trinity.TriQuaternion()
            cleanRotation = trinity.TriQuaternion()
            preRotation = trinity.TriQuaternion()
            postRotation = trinity.TriQuaternion()
            rotKey = trinity.TriQuaternion()
            preRotation.SetYawPitchRoll(random.random() * pi,
                                        random.random() * pi,
                                        random.random() * pi)
            postRotation.SetYawPitchRoll(random.random() * pi,
                                         random.random() * pi,
                                         random.random() * pi)
            curve = trinity.TriRotationCurve()
            curve.extrapolation = trinity.TRIEXT_CYCLE
            duration = 50.0 + random.random() * 50.0 * math.log(self.radius)
            for i in [0.0, 0.5, 1.0, 1.5, 2.0]:
                cleanRotation.SetYawPitchRoll(0.0, pi * i, 0.0)
                rotKey.SetIdentity()
                rotKey.MultiplyQuaternion(preRotation)
                rotKey.MultiplyQuaternion(cleanRotation)
                rotKey.MultiplyQuaternion(postRotation)
                curve.AddKey(duration * i, rotKey, id, id,
                             trinity.TRIINT_SLERP)

            curve.Sort()
            self.model.modelRotationCurve = curve
        else:
            self.model.rotation.SetYawPitchRoll(random.random() * 6.28,
                                                random.random() * 6.28,
                                                random.random() * 6.28)
            timecurves.ResetTimeCurves(self.model, self.id * 12345L)
            timecurves.ScaleTime(self.model, 5.0 + self.id % 20 / 20.0)
            self.model.scaling.SetXYZ(self.radius, self.radius, self.radius)
            self.model.boundingSphereRadius = 1.0
コード例 #18
0
ファイル: Warp.py プロジェクト: R4M80MrX/eve-1
 def AlignToDirection(self):
     destination = sm.StartService('space').warpDestinationCache[3]
     ballPark = sm.StartService('michelle').GetBallpark()
     egoball = ballPark.GetBall(ballPark.ego)
     direction = [egoball.x - destination[0], egoball.y - destination[1], egoball.z - destination[2]]
     zaxis = Vector3(direction)
     if zaxis.Length2() > 0.0:
         Up = Vector3([0.0, 1.0, 0.0])
         zaxis.Normalize()
         xaxis = Up ^ zaxis
         if xaxis.Length2() == 0.0:
             zaxis += Vector3().Randomize(0.0001)
             zaxis.Normalize()
             xaxis = Up ^ zaxis
         xaxis.Normalize()
         yaxis = zaxis ^ xaxis
     else:
         self.transformFlags = effects.FX_TF_POSITION_BALL | effects.FX_TF_ROTATION_BALL
         self.Prepare()
         return
     mat = ((xaxis[0],
       xaxis[1],
       xaxis[2],
       0.0),
      (yaxis[0],
       yaxis[1],
       yaxis[2],
       0.0),
      (zaxis[0],
       zaxis[1],
       zaxis[2],
       0.0),
      (0.0, 0.0, 0.0, 1.0))
     quat = geo2.QuaternionRotationMatrix(mat)
     self.gfxModel.rotationCurve = None
     if self.gfxModel and hasattr(self.gfxModel, 'modelRotationCurve'):
         self.gfxModel.modelRotationCurve = trinity.TriRotationCurve(0.0, 0.0, 0.0, 1.0)
         self.gfxModel.modelRotationCurve.value = quat
     self.debugAligned = True
コード例 #19
0
 def InitModelPosition(self):
     self.model.rotationCurve = trinity.TriRotationCurve()
     self.model.rotationCurve.value = geo2.QuaternionRotationAxis((0, 1, 0),
                                                                  math.pi)
     self.model.translationCurve = trinity.TriVectorCurve()
コード例 #20
0
    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)