예제 #1
0
void ViewportBase::onCreate(const Viewport *source)
{
    Inherited::onCreate(source);

    if(source != NULL)
    {
        Viewport *pThis = static_cast<Viewport *>(this);

        pThis->setCamera(source->getCamera());

        pThis->setRoot(source->getRoot());

        pThis->setBackground(source->getBackground());

        MFUnrecForegroundPtr::const_iterator ForegroundsIt  =
            source->_mfForegrounds.begin();
        MFUnrecForegroundPtr::const_iterator ForegroundsEnd =
            source->_mfForegrounds.end  ();

        while(ForegroundsIt != ForegroundsEnd)
        {
            pThis->addForeground(*ForegroundsIt);

            ++ForegroundsIt;
        }

        pThis->setRenderOptions(source->getRenderOptions());
    }
}
void SortLastWindow::serverRender(Window         *serverWindow,
                                  UInt32          id,
                                  DrawActionBase *action      )
{
    Viewport *serverPort  = NULL;
    Viewport *clientPort  = NULL;
    UInt32    sv          = 0;
    UInt32    cv          = 0;
    UInt32    regionStart = 0;

    // duplicate viewports
    for(cv = 0, sv = 0; cv < getPort().size(); ++cv)
    {
        clientPort = getPort()[cv];

        if(serverWindow->getPort().size() <= sv)
        {
            // create new port
            serverPort = Viewport::create();

            serverWindow->addPort(serverPort);
        }
        else
        {
            serverPort = serverWindow->getPort()[sv];
        }

        // duplicate values

        if(getWidth() && getHeight())
        {
           serverPort->setSize(clientPort->getPixelLeft  (),
                               clientPort->getPixelBottom(),
                               clientPort->getPixelRight (),
                               clientPort->getPixelTop   ());
        }
        else
        {
            serverPort->setSize(0,0,0,0); 
        }
  
        serverPort->setCamera    (clientPort->getCamera    ());
        serverPort->setRoot      (clientPort->getRoot      ());
        serverPort->setBackground(clientPort->getBackground());

        // ignore statistics foreground
        serverPort->clearForegrounds();

        for(UInt32 f = 0 ; f < serverPort->getForegrounds().size(); ++f)
        {
            Foreground *fg = clientPort->getForegrounds()[f];

            StatisticsForeground *sfg = 
                dynamic_cast<StatisticsForeground *>(fg);

            if(sfg == NULL)
            {
                serverPort->addForeground(fg);
            }
        }

        serverPort->setTravMask(clientPort->getTravMask());

        sv++;
    }

    // remove unused ports
    while(serverWindow->getPort().size() > sv)
    {
        serverWindow->subPort(sv);
    }

    // setup visible nodes
    setupNodes(id);

    // render the viewports
    serverWindow->activate();
    serverWindow->frameInit();

    action->setWindow(serverWindow);

    if(getComposer() != NULL)
        getComposer()->startFrame();

    for(sv = 0; sv < serverWindow->getPort().size(); ++sv)
    {
        Viewport *vp         = serverWindow->getPort()[sv];
        Node     *root       = vp->getRoot();

        if(getComposer() != NULL)
            getComposer()->startViewport(vp);

        // render
        vp->render(action);

        // compose single viewport
        if(getComposer() != NULL)
            getComposer()->composeViewport(vp);
    }

    // compose whole window
    if(getComposer() != NULL)
        getComposer()->composeWindow();
}