Exemple #1
0
    def GetPlanetPhoto(self, itemID, typeID, size=512):
        graphicID = evetypes.GetGraphicID(typeID)
        outPath = GetCachePath(typeID, graphicID, size, itemID)
        planet = Planet()
        planet.GetPlanetByID(itemID, typeID)
        if planet.model is None or planet.model.highDetail is None:
            return NOT_AVAILABLE_PATH
        planetTransform = trinity.EveTransform()
        planetTransform.scaling = (100.0, 100.0, 100.0)
        planetTransform.children.append(planet.model.highDetail)
        scene = self.GetPlanetScene()
        try:
            planet.DoPreProcessEffectForPhotoSvc(size)
        except:
            del planetTransform.children[:]
            return NOT_AVAILABLE_PATH

        trinity.WaitForResourceLoads()
        scene.sunDirection = (-1.0, 0.0, 0.0)
        scene.sunDiffuseColor = (1.0, 1.0, 1.0, 1.0)
        scene.objects.append(planetTransform)
        view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere(
            boundingSphereRadius=130)
        bitmap = photo.RenderToSurface(view,
                                       projection,
                                       size,
                                       scene,
                                       transparent=False)
        bitmap.Save(outPath)
        del planetTransform.children[:]
        self._RemovePathFromNotAvailList(outPath)
        return outPath
Exemple #2
0
def RenderSun(outPath,
              objectPath,
              scenePath,
              size=512,
              cameraAngle=(0, 0, 0),
              postProcessingQuality=2,
              antiAliasingQuality=3,
              modifyScene=None):
    scene = trinity.Load(scenePath)
    blue.resMan.Wait()
    lensflare = blue.resMan.LoadObject(objectPath)
    blue.resMan.Wait()
    blue.os.Pump()
    scene.lensflares.append(lensflare)
    SetupLensflare(lensflare)
    fov = 1.0
    boundingSphereRadius = 100.0
    boundingSphereCenter = (0.0, 0.0, 0.0)
    view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere(
        boundingSphereRadius,
        boundingSphereCenter,
        cameraAngle=cameraAngle,
        fov=fov)
    if modifyScene:
        view, projection = modifyScene(scene, view, projection)
    hostBitmap = RenderToSurface(scene=scene,
                                 view=view,
                                 projection=projection,
                                 size=size,
                                 postProcessingQuality=postProcessingQuality,
                                 antiAliasingQuality=antiAliasingQuality)
    hostBitmap.Save(outPath)
Exemple #3
0
def RenderTurret(outPath,
                 turretPath,
                 turretFaction,
                 size=128,
                 bgColor=None,
                 transparent=False,
                 postProcessingQuality=2,
                 supersampleQuality=2):
    scene = blue.resMan.LoadObject('res:/dx9/scene/fitting/previewTurrets.red')
    model = blue.resMan.LoadObject(
        'res:/dx9/model/ship/IconPreview/PreviewTurretShip.red')
    turretSet = FitTurret(model, 1, turretPath, turretFaction)
    blue.resMan.Wait()
    scene.objects.append(model)
    if transparent:
        scene.backgroundRenderingEnabled = False
    boundingSphereRadius = turretSet.boundingSphere[3] * 0.9
    boundingSphereCenter = turretSet.boundingSphere[:3]
    view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere(
        boundingSphereRadius,
        boundingSphereCenter,
        cameraAngle=(0.7, -0.6, 0.0),
        fov=0.5)
    hostBitmap = RenderToSurface(scene=scene,
                                 view=view,
                                 projection=projection,
                                 size=size,
                                 bgColor=bgColor,
                                 transparent=transparent,
                                 postProcessingQuality=postProcessingQuality,
                                 supersampleQuality=supersampleQuality)
    hostBitmap.Save(outPath)
Exemple #4
0
def GetViewProjectionForModel(model, scene, cameraAngle):
    if model is None:
        return (None, None)
    boundingSphereRadius = model.GetBoundingSphereRadius()
    if getattr(model, 'isAnimated', False):
        boundingSphere = model.CalculateSkinnedBoundingSphere()
        boundingSphereRadius = boundingSphere[3]
        boundingSphereCenter = boundingSphere[:3]
        bbMin, bbMax = model.GetLocalBoundingBox()
        view, projection = camera_util.GetViewAndProjectionForSkinnedModel(
            model,
            scene=scene,
            boundingSphereRadius=boundingSphereRadius,
            boundingSphereCenter=boundingSphereCenter,
            boundingBoxMin=bbMin,
            boundingBoxMax=bbMax,
            cameraAngle=cameraAngle)
    elif model.mesh is not None:
        geometry = model.mesh.geometry
        boundingSphereCenter = model.GetBoundingSphereCenter()
        view, projection = camera_util.GetViewAndProjectionUsingMeshGeometry(
            geometry,
            scene=scene,
            boundingSphereRadius=boundingSphereRadius,
            boundingSphereCenter=boundingSphereCenter,
            cameraAngle=cameraAngle)
    else:
        view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere(
            boundingSphereRadius)
    return (view, projection)
Exemple #5
0
def RenderTurret(outPath,
                 turretPath,
                 turretFaction,
                 size=128,
                 bgColor=None,
                 transparent=False,
                 usePreviewScene=True,
                 postProcessingQuality=2,
                 antiAliasingQuality=3):
    """
    Renders a turret at a given resolution.
    """
    if usePreviewScene:
        scene = blue.resMan.LoadObject(
            'res:/dx9/scene/fitting/previewTurrets.red')
        model = blue.resMan.LoadObject(
            'res:/dx9/model/ship/IconPreview/PreviewTurretShip.red')
    else:
        scene = blue.resMan.LoadObject('res:/dx9/Scene/preview/ship_other.red')
        scene.sunDirection = (-0.5, -0.5, 0.6)
        scene.sunDiffuseColor = (2.0, 2.0, 2.0)
        scene.ambientColor = (0.0, 0.0, 0.0)
        model = blue.resMan.LoadObject(
            'res:/dx9/model/ship/IconPreview/PhotoServiceTurretShip.red')
    turretSet = FitTurret(model, 1, turretPath, turretFaction)
    blue.resMan.Wait()
    scene.objects.append(model)
    if transparent:
        scene.backgroundRenderingEnabled = False
    boundingSphereRadius = turretSet.boundingSphere[3] * 0.9
    boundingSphereCenter = turretSet.boundingSphere[:3]
    view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere(
        boundingSphereRadius,
        boundingSphereCenter,
        cameraAngle=(0.7, -0.6, 0.0),
        fov=0.5)
    hostBitmap = RenderToSurface(scene=scene,
                                 view=view,
                                 projection=projection,
                                 size=size,
                                 bgColor=bgColor,
                                 transparent=transparent,
                                 postProcessingQuality=postProcessingQuality,
                                 antiAliasingQuality=antiAliasingQuality)
    hostBitmap.Save(outPath)
Exemple #6
0
def RenderSpaceObject(outPath,
                      scenePath='',
                      objectPath='',
                      sofDNA=None,
                      size=128,
                      bgColor=None,
                      transparent=False,
                      backgroundPath=None,
                      overlayPath=None,
                      techPath=None,
                      cameraAngle=None,
                      freezeTime=True,
                      postProcessingQuality=2,
                      antiAliasingQuality=3,
                      modifyScene=None,
                      sunDirection=None,
                      animationStates=[]):
    """
    This method loads up a trinity.EveSpaceObject and a trinity.EveSpaceScene from res paths passed in.
    The model and scene are modified and the camera (transforms) are set up in the same way as the Eve Photo service.
    """
    if freezeTime:
        FreezeTime()
    trinity.GetVariableStore().RegisterVariable('DepthMap',
                                                trinity.TriTextureRes())
    trinity.GetVariableStore().RegisterVariable('DepthMapMsaa',
                                                trinity.TriTextureRes())
    if scenePath:
        scene = blue.resMan.LoadObject(scenePath)
        SetupScene(scene,
                   transparentBackground=transparent,
                   sunDirection=sunDirection)
    else:
        scene = trinity.EveSpaceScene()
    model = None
    if sofDNA:
        factory = GetSofFactory()
        model = factory.BuildFromDNA(sofDNA)
    elif objectPath:
        model = blue.resMan.LoadObject(objectPath)
    if model:
        SetupModel(model)
        scene.objects.append(model)
    if len(animationStates) > 0:
        soanimation.LoadAnimationStatesFromFiles(animationStates, model,
                                                 trinity)
        soanimation.TriggerDefaultStates(model)
    blue.resMan.Wait()
    blue.os.Pump()
    view = projection = None
    if model:
        boundingSphereRadius = model.GetBoundingSphereRadius()
        if model.mesh is not None:
            geometry = model.mesh.geometry
            boundingSphereCenter = model.GetBoundingSphereCenter()
            view, projection = camera_util.GetViewAndProjectionUsingMeshGeometry(
                geometry,
                scene=scene,
                boundingSphereRadius=boundingSphereRadius,
                boundingSphereCenter=boundingSphereCenter,
                cameraAngle=cameraAngle)
        else:
            view, projection = camera_util.GetViewAndProjectionUsingBoundingSphere(
                boundingSphereRadius)
    if modifyScene:
        view, projection = modifyScene(scene, view, projection)
    hostBitmap = RenderToSurface(scene=scene,
                                 view=view,
                                 projection=projection,
                                 size=size,
                                 bgColor=bgColor,
                                 transparent=transparent,
                                 backgroundPath=backgroundPath,
                                 overlayPath=overlayPath,
                                 techPath=techPath,
                                 postProcessingQuality=postProcessingQuality,
                                 antiAliasingQuality=antiAliasingQuality)
    hostBitmap.Save(outPath)