Exemplo n.º 1
0
//-----------------------------------------------------------------------------
void CPUTAssetSet::RenderRecursive(CPUTRenderParameters &renderParams, int materialIndex)
{
	if (!IsEnabled)
		return;
    CPUTMaterial* pCurrentMaterial = NULL;
    CPUTRenderStateBlock* pCurrentRenderState = NULL;
    CPUTRenderNode* pCurrent = mpRootNode;
    CPUTInputLayoutCache* pInputLayoutCache = CPUTInputLayoutCache::GetInputLayoutCache();
    while (pCurrent)
    {
        if (pCurrent->GetNodeType() == CPUTRenderNode::CPUT_NODE_MODEL)
        {
            CPUTModel* pModel = (CPUTModel*)pCurrent;
            pModel->UpdateShaderConstants(renderParams);
            int meshCount = pModel->GetMeshCount();
            for (int mesh = 0; mesh < meshCount; mesh++)
            {
                CPUTMaterial* pMaterial = pModel->GetMaterial(mesh, materialIndex);
                if (pMaterial != NULL)
                {
                    CPUTRenderStateBlock* pRenderStateBlock = pMaterial->GetRenderStateBlock();
                    CPUTMesh* pMesh = pModel->GetMesh(mesh);
                    SetMaterialStates(pMaterial, pCurrentMaterial);
                    SetRenderStateBlock(pRenderStateBlock, pCurrentRenderState);
                    pInputLayoutCache->Apply(pMesh, pMaterial);
                    pMesh->Draw();
                    SAFE_RELEASE(pCurrentMaterial);
                    pCurrentMaterial = pMaterial;
                    SAFE_RELEASE(pCurrentRenderState)
                    pCurrentRenderState = pRenderStateBlock;
                }
            }
        }
        CPUTRenderNode* pNext = pCurrent->GetChild();
        if (pNext == NULL)
        {
            pNext = pCurrent->GetSibling();

            if (pNext == NULL)
            {
                pNext = pCurrent->GetParent();
                if (pNext != NULL)
                {
                    pNext = pNext->GetSibling();
                }
            }
        }
        pCurrent = pNext;
    }
    SAFE_RELEASE(pCurrentMaterial);
    SAFE_RELEASE(pCurrentRenderState);
}
void CPUTGUIElement::Resize(int x, int y, int width, int height, int windowWidth, int windowHeight)
{
    if(mParentRelative)
    {
        mPosX = mRelX + x;
        mPosY = mRelY + y;
        if(mRelX < 0)
            mPosX += width;
        if(mRelY < 0)
            mPosY += height;
    }
    else
    {
        mPosX = mRelX;
        mPosY = mRelY;
        if(mRelX < 0)
            mPosX += windowWidth;
        if(mRelY < 0)
            mPosY += windowHeight;
    }

    float4x4 m = float4x4Translation((float)mPosX, (float)mPosY, 0);
    SetParentMatrix(m);
    CPUTRenderNode* pNode = mpChild;
    if(pNode)
    {
        ((CPUTGUIElement*)pNode)->Resize(mPosX, mPosY, mWidth, mHeight, windowWidth, windowHeight);
    }
    pNode = mpSibling;
    while(pNode)
    {
        ((CPUTGUIElement*)pNode)->Resize(x, y, width, height, windowWidth, windowHeight);
        pNode = pNode->GetSibling();
    }
}
Exemplo n.º 3
0
// RenderRecursive - recursively visit all sub-nodes in breadth-first mode
//-----------------------------------------------------------------------------
void CPUTRenderNode::RenderRecursive(CPUTRenderParameters &renderParams, int materialIndex)
{
    Render(renderParams, materialIndex);

    if(mpChild)
    {
        mpChild->RenderRecursive(renderParams, materialIndex);
        CPUTRenderNode *pNode = mpChild->GetSibling();
        while(pNode)
        {
            pNode->RenderRecursive(renderParams, materialIndex);
            pNode = pNode->GetSibling();
        }
    }
}
// RenderRecursive - recursively visit all sub-nodes in breadth-first mode
//-----------------------------------------------------------------------------
void CPUTRenderNode::RenderShadowRecursive(CPUTRenderParameters &renderParams)
{
    RenderShadow(renderParams);

    if(mpChild)
    {
        mpChild->RenderShadowRecursive(renderParams);
        CPUTRenderNode *pNode = mpChild->GetSibling();
        while(pNode)
        {
            pNode->RenderShadowRecursive(renderParams);
            pNode = pNode->GetSibling();
        }
    }
}