422 Ogre::MaterialSerializer ogreMaterialSerializer;
423 std::vector<SPass*> generatedShaderPasses;
424 std::vector<STechnique*> generatedShadowTechs;
425 std::vector<STechnique*> generatedShaderGenTechs;
426 std::vector<STechnique*> generatedShaderLegacyTechs;
429 Ogre::String matPath = (path.empty()) ?
ogreMaterial->getOrigin() : path;
435 packdir mypack = (packdir)SCgetExtra(
"FirstPack");
436 boost::filesystem::path upartitionPath(mypack->path);
437 upartitionPath = upartitionPath.generic_string();
439 std::string ufilepath(matPath);
443 std::string curPart = boost::filesystem::path(mypack->path).generic_string();
444 if (matPath.find(curPart) != std::string::npos)
446 ufilepath = upartitionPath.append(ufilepath.substr(curPart.length())).generic_string();
448 if (!boost::filesystem::exists(ufilepath))
450 boost::system::error_code ec;
451 boost::filesystem::path subd(ufilepath);
452 subd.remove_filename();
453 boost::filesystem::create_directories(subd, ec);
459 mypack = mypack->next;
464 Ogre::ResourceManager::ResourceMapIterator it = Ogre::MaterialManager::getSingleton().getResourceIterator();
465 while (it.hasMoreElements())
467 Ogre::MaterialPtr mat = Ogre::static_pointer_cast<Ogre::Material>(it.getNext());
468 Ogre::RTShader::ShaderGenerator::getSingletonPtr()->removeAllShaderBasedTechniques(*mat.get());
470 if (mat->getGroup() ==
ogreMaterial->getGroup() && mat->getOrigin() == matPath)
475 Ogre::Material::Techniques techs = mat->getTechniques();
477 for (
unsigned int i = 0; i < techs.size(); i++,
id++)
479 Ogre::Technique* tech = techs[i];
482 if (tech->getSchemeName().find(std::string(SO3_INTERNAL_RESOURCE_GROUP)) != Ogre::String::npos)
484 mat->removeTechnique(
id);
490 Ogre::Any bindedSTechnique = tech->getUserObjectBindings().getUserAny(
"STechnique");
491 if (bindedSTechnique.has_value())
493 STechnique* stechnique = Ogre::any_cast<STechnique*> (bindedSTechnique);
495 if (tech->getSchemeName() == Ogre::MSN_SHADERGEN)
497 tech->setSchemeName(Ogre::MSN_DEFAULT);
498 generatedShaderGenTechs.push_back(stechnique);
501 if (tech->getSchemeName() ==
"SO3_LEGACY")
503 tech->setSchemeName(Ogre::MSN_DEFAULT);
504 generatedShaderLegacyTechs.push_back(stechnique);
510 generatedShadowTechs.push_back(stechnique);
514 Ogre::Technique::Passes passes = tech->getPasses();
515 for (
unsigned int j = 0; j < passes.size(); j++)
517 Ogre::Any bindedSPass = passes[j]->getUserObjectBindings().getUserAny(
"SPass");
518 if (bindedSPass.has_value())
520 SPass* pass = Ogre::any_cast<SPass*> (bindedSPass);
524 generatedShaderPasses.push_back(pass);
530 ogreMaterialSerializer.queueForExport(mat);
536 Ogre::RTShader::ShaderGenerator::getSingletonPtr()->removeAllShaderBasedTechniques(*
ogreMaterial.get());
537 Ogre::Material::Techniques techs =
ogreMaterial->getTechniques();
539 for (
unsigned int i = 0; i < techs.size(); i++,
id++)
541 Ogre::Technique* tech = techs[i];
544 if (tech->getSchemeName().find(std::string(SO3_INTERNAL_RESOURCE_GROUP)) != Ogre::String::npos)
552 Ogre::Any bindedSTechnique = tech->getUserObjectBindings().getUserAny(
"STechnique");
553 if (bindedSTechnique.has_value())
555 STechnique* stechnique = Ogre::any_cast<STechnique*> (bindedSTechnique);
557 if (tech->getSchemeName() == Ogre::MSN_SHADERGEN)
559 tech->setSchemeName(Ogre::MSN_DEFAULT);
560 generatedShaderGenTechs.push_back(stechnique);
563 if (tech->getSchemeName() ==
"SO3_LEGACY")
565 tech->setSchemeName(Ogre::MSN_DEFAULT);
566 generatedShaderLegacyTechs.push_back(stechnique);
572 generatedShadowTechs.push_back(stechnique);
576 Ogre::Technique::Passes passes = tech->getPasses();
577 for (
unsigned int j = 0; j < passes.size(); j++)
579 Ogre::Any bindedSPass = passes[j]->getUserObjectBindings().getUserAny(
"SPass");
580 if (bindedSPass.has_value())
582 SPass* pass = Ogre::any_cast<SPass*> (bindedSPass);
586 generatedShaderPasses.push_back(pass);
599 ogreMaterialSerializer.exportQueued(ufilepath);
602 for (
unsigned int i = 0; i < generatedShaderPasses.size(); i++)
604 generatedShaderPasses[i]->BuildShader(
true);
607 for (
unsigned int i = 0; i < generatedShaderGenTechs.size(); i++)
609 generatedShaderGenTechs[i]->SetSchemeName(Ogre::MSN_SHADERGEN);
612 for (
unsigned int i = 0; i < generatedShaderLegacyTechs.size(); i++)
614 generatedShaderLegacyTechs[i]->SetSchemeName(
"SO3_LEGACY");
618 for (
unsigned int i = 0; i < generatedShadowTechs.size(); i++)
627 Ogre::MaterialSerializer ogreMaterialSerializer;
628 std::vector<SPass*> generatedShaderPasses;
629 std::vector<STechnique*> generatedShadowTechs;
630 std::vector<STechnique*> generatedShaderGenTechs;
631 std::vector<STechnique*> generatedShaderLegacyTechs;
637 packdir mypack = (packdir)SCgetExtra(
"FirstPack");
638 boost::filesystem::path upartitionPath(mypack->path);
639 upartitionPath = upartitionPath.generic_string();
641 std::string ufilepath(path);
645 std::string curPart = boost::filesystem::path(mypack->path).generic_string();
646 if (path.find(curPart) != std::string::npos)
648 ufilepath = upartitionPath.append(ufilepath.substr(curPart.length())).generic_string();
651 if (!boost::filesystem::exists(ufilepath))
653 boost::system::error_code ec;
654 boost::filesystem::path subd(ufilepath);
655 subd.remove_filename();
656 boost::filesystem::create_directories(subd, ec);
661 mypack = mypack->next;
664 Ogre::ResourceManager::ResourceMapIterator it = Ogre::MaterialManager::getSingleton().getResourceIterator();
665 while (it.hasMoreElements())
667 Ogre::MaterialPtr mat = Ogre::static_pointer_cast<Ogre::Material>(it.getNext());
668 Ogre::RTShader::ShaderGenerator::getSingletonPtr()->removeAllShaderBasedTechniques(*mat.get());
670 if (mat->getOrigin() == path)
672 Ogre::Material::Techniques techs = mat->getTechniques();
674 for (
unsigned int i = 0; i < techs.size(); i++,
id++)
676 Ogre::Technique* tech = techs[i];
679 if (tech->getSchemeName().find(std::string(SO3_INTERNAL_RESOURCE_GROUP)) != Ogre::String::npos)
681 mat->removeTechnique(
id);
687 Ogre::Any bindedSTechnique = tech->getUserObjectBindings().getUserAny(
"STechnique");
688 if (bindedSTechnique.has_value())
690 STechnique* stechnique = Ogre::any_cast<STechnique*> (bindedSTechnique);
691 if (tech->getSchemeName() == Ogre::MSN_SHADERGEN)
693 tech->setSchemeName(Ogre::MSN_DEFAULT);
694 generatedShaderGenTechs.push_back(stechnique);
697 if (tech->getSchemeName() ==
"SO3_LEGACY")
699 tech->setSchemeName(Ogre::MSN_DEFAULT);
700 generatedShaderLegacyTechs.push_back(stechnique);
707 generatedShadowTechs.push_back(stechnique);
711 Ogre::Technique::Passes passes = tech->getPasses();
712 for (
unsigned int j = 0; j < passes.size(); j++)
714 Ogre::Any bindedSPass = passes[j]->getUserObjectBindings().getUserAny(
"SPass");
715 if (bindedSPass.has_value())
717 SPass* pass = Ogre::any_cast<SPass*> (bindedSPass);
721 generatedShaderPasses.push_back(pass);
727 ogreMaterialSerializer.queueForExport(mat);
732 ogreMaterialSerializer.exportQueued(ufilepath);
735 for (
unsigned int i = 0; i < generatedShaderPasses.size(); i++)
737 generatedShaderPasses[i]->BuildShader(
true);
740 for (
unsigned int i = 0; i < generatedShaderGenTechs.size(); i++)
742 generatedShaderGenTechs[i]->SetSchemeName(Ogre::MSN_SHADERGEN);
745 for (
unsigned int i = 0; i < generatedShaderLegacyTechs.size(); i++)
747 generatedShaderLegacyTechs[i]->SetSchemeName(
"SO3_LEGACY");
751 for (
unsigned int i = 0; i < generatedShadowTechs.size(); i++)