Example #1
0
Action::ResultE ShadingCallbacks::matDrawableRenderEnter(CNodePtr &pNode, 
                                                         Action   *action)
{
    ShadingAction    *a   = dynamic_cast<ShadingAction    *>(action         );
    MaterialDrawable *pMD = dynamic_cast<MaterialDrawable *>(pNode.getCPtr());

    Material::DrawFunctor func;

    func = osgTypedMethodFunctor1ObjPtr(pMD, 
                                        &MaterialDrawable::drawPrimitives);

    Material *m = a->getMaterial();

    if(m == NULL)
    {
        if(pMD->getMaterial() != NullFC)
        {
            m = pMD->getMaterial().getCPtr();
        }
        else
        {
            fprintf(stderr, "MaterialDrawable::render: no Material!?!\n");
            return Action::Continue;
        }
    }

    a->dropFunctor(func, m);

    return Action::Continue;
}
void MaterialDrawableBase::onCreate(const MaterialDrawable *source)
{
    Inherited::onCreate(source);

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

        pThis->setMaterial(source->getMaterial());
    }
}
void MaterialDrawableBase::execSyncV(      FieldContainer    &oFrom,
                                        ConstFieldMaskArg  whichField,
                                        AspectOffsetStore &oOffsets,
                                        ConstFieldMaskArg  syncMode,
                                  const UInt32             uiSyncInfo)
{
    MaterialDrawable *pThis = static_cast<MaterialDrawable *>(this);

    pThis->execSync(static_cast<MaterialDrawable *>(&oFrom),
                    whichField,
                    oOffsets,
                    syncMode,
                    uiSyncInfo);
}
void MaterialGroupPushGraphOp::pushMaterialGroup(MaterialGroup *mg)
{
    PushTargetStore::iterator ptIt  = _pushTargets.begin();
    PushTargetStore::iterator ptEnd = _pushTargets.end  ();
    
    for(; ptIt != ptEnd; ++ptIt)
    {
        MaterialDrawable *dstMD =
            dynamic_cast<MaterialDrawable *>((*ptIt)->getCore());
        if(dstMD != NULL)
        {
            dstMD->setMaterial(mg->getMaterial());
        }
    }
}