Material* Sprite3DMaterial::clone() const
{
    auto material = new (std::nothrow) Sprite3DMaterial();
    if (material)
    {
        RenderState::cloneInto(material);
        
        for (const auto& technique: _techniques)
        {
            auto t = technique->clone();
            t->setParent(material);
            for (ssize_t i = 0; i < t->getPassCount(); i++) {
                t->getPassByIndex(i)->setParent(t);
            }
            material->_techniques.pushBack(t);
        }
        
        // current technique
        auto name = _currentTechnique->getName();
        material->_currentTechnique = material->getTechniqueByName(name);
        material->_type = _type;
        material->autorelease();
    }
    return material;
}
Esempio n. 2
0
Material* Material::clone() const
{
    auto material = new (std::nothrow) Material();
    if (material)
    {
        RenderState::cloneInto(material);

        for (const auto& technique: _techniques)
        {
            auto t = technique->clone();
            material->_techniques.pushBack(t);
        }

        // current technique
        auto name = _currentTechnique->getName();
        material->_currentTechnique = material->getTechniqueByName(name);

        material->autorelease();
    }
    return material;
}
Esempio n. 3
0
void Material::setTechnique(const std::string& techniqueName)
{
    auto technique = getTechniqueByName(techniqueName);
    if (technique)
        _currentTechnique = technique;
}