Beispiel #1
0
def RenderISISObject(outPath, model, isSkinned, size=128):
    """
    Generates a render for ISIS. This render fixes the camera to the side and
    applies a specialized shader to the model.
    Assumption: This is only used for V3/V5 Ships.
    """
    scene = trinity.EveSpaceScene()
    SetupModel(model)
    _ApplyIsisEffect(model, isSkinned)
    scene.objects.append(model)
    blue.resMan.Wait()
    blue.os.Pump()
    view = projection = None
    if model:
        boundingSphereRadius = model.GetBoundingSphereRadius()
        angle = (-1.5708, 0, 0)
        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=angle)
    hostBitmap = RenderToSurface(scene=scene,
                                 view=view,
                                 projection=projection,
                                 size=size,
                                 transparent=False)
    hostBitmap.Save(outPath)
    trinity.app.ProcessMessages()
Beispiel #2
0
def RenderISISObject(outPath, model, isSkinned, size=128):
    scene = trinity.EveSpaceScene()
    SetupModel(model)
    _ApplyIsisEffect(model, isSkinned)
    scene.objects.append(model)
    blue.resMan.Wait()
    blue.os.Pump()
    view = projection = None
    if model:
        boundingSphereRadius = model.GetBoundingSphereRadius()
        angle = (-1.5708, 0, 0)
        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=angle)
    hostBitmap = RenderToSurface(scene=scene,
                                 view=view,
                                 projection=projection,
                                 size=size,
                                 transparent=False)
    hostBitmap.Save(outPath)
    trinity.app.ProcessMessages()
Beispiel #3
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)
Beispiel #4
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)