示例#1
0
 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
示例#2
0
 def GetTranslationFromParentForItem(self, itemID, fov=None):
     camera = sm.GetService('sceneManager').GetRegisteredCamera('default')
     if camera is None:
         return
     if fov is None:
         fov = camera.fieldOfView
     ballpark = sm.GetService('michelle').GetBallpark()
     if ballpark:
         ball = ballpark.GetBall(itemID)
         if ball and ball.model:
             rad = None
             if ball.model.__bluetype__ in ('eve.EveShip', 'eve.EveStation',
                                            'trinity.EveShip2',
                                            'trinity.EveStation2',
                                            'trinity.EveRootTransform'):
                 rad = ball.model.GetBoundingSphereRadius()
                 zoomMultiplier = 1.0
                 aspectRatio = trinity.GetAspectRatio()
                 if aspectRatio > 1.6:
                     zoomMultiplier = aspectRatio / 1.6
                 return (rad + camera.frontClip) * zoomMultiplier + 2
             if hasattr(ball.model, 'children'):
                 if ball.model.children:
                     rad = ball.model.children[0].GetBoundingSphereRadius()
             if not rad or rad <= 0.0:
                 rad = ball.radius
             camangle = camera.fieldOfView * 0.5
             return max(15.0, rad / sin(camangle) * cos(camangle))
示例#3
0
 def PickObject(self, x, y):
     if self.sceneManager.GetActiveScene() != self.renderScene:
         return
     rescale = 1.0 / 10000.0
     projection = trinity.TriProjection()
     projection.PerspectiveFov(trinity.GetFieldOfView(),
                               trinity.GetAspectRatio(),
                               trinity.GetFrontClip(),
                               trinity.GetBackClip())
     view = trinity.TriView()
     view.transform = trinity.GetViewTransform()
     scaling, rotation, translation = geo2.MatrixDecompose(
         self.transform.worldTransform)
     pZ = geo2.Vec3Transform((0, 0, 1), self.transform.worldTransform)
     surfaceNormal = geo2.Subtract(pZ, translation)
     cameraZ = geo2.Vector(view.transform[0][2], view.transform[1][2],
                           view.transform[2][2])
     if geo2.Vec3Dot(surfaceNormal, cameraZ) < 0:
         return
     self.renderObject.translation = geo2.Vec3Scale(translation, rescale)
     self.renderObject.rotation = rotation
     self.renderObject.scaling = geo2.Vec3Scale(scaling, rescale)
     scaling, rotation, translation = geo2.MatrixDecompose(view.transform)
     translation = geo2.Vec3Scale(translation, rescale)
     view.transform = geo2.MatrixTransformation(None, None, scaling, None,
                                                rotation, translation)
     return self.renderObject.PickObject(x, y, projection, view,
                                         trinity.device.viewport)
示例#4
0
 def _GetTranslationFromParentForItem(self, itemID):
     ballpark = sm.GetService('michelle').GetBallpark()
     if ballpark is None:
         return
     ball = ballpark.GetBall(itemID)
     ball, model, ballRadius = ball, getattr(ball, 'model', None), getattr(
         ball, 'radius', None)
     if model is None:
         return
     rad = None
     if model.__bluetype__ in evespacescene.EVESPACE_TRINITY_CLASSES:
         rad = model.GetBoundingSphereRadius()
         zoomMultiplier = 1.1 * camutils.GetARZoomMultiplier(
             trinity.GetAspectRatio())
         return (rad + self.frontClip) * zoomMultiplier + 2
     if len(getattr(model, 'children', [])) > 0:
         rad = ball.model.children[0].GetBoundingSphereRadius()
     if rad is None or rad <= 0.0:
         rad = ballRadius
     camangle = self.fieldOfView * 0.5
     return max(15.0, rad / sin(camangle) * cos(camangle))
示例#5
0
def GetBallMaxZoom(ball, nearClip):
    rad = GetBallRadius(ball)
    zoomMultiplier = 1.5 * GetARZoomMultiplier(trinity.GetAspectRatio())
    return (rad + nearClip) * zoomMultiplier + 2