static int iCreated = 0;
static const char szTmp[] =
{
"\"%s\"\
\n{\
\n\t\"$basetexture\" \"VGUI/white_additive\"\
\n\t\"$model\" \"1\"\
\n\t\"$nocull\" \"1\"\
\n\t\"$nofog\" \"1\"\
\n\t\"$ignorez\" \"%i\"\
\n\t\"$znearer\" \"1\"\
\n\t\"halflambert\" \"1\"\
\n\t\"$wireframe\" \"%i\"\
\n}\n"
};
char szMaterial[512];
char szBaseType[64];
if (bFullBright)
{
static const char pszBaseType[] = "UnlitGeneric";
sprintf_s(szMaterial,
sizeof(szMaterial),
szTmp, pszBaseType,
(bShouldIgnoreZ) ? 1 : 0,
(bIsWireframe) ? 1 : 0);
strcpy_s(szBaseType, pszBaseType);
}
else
{
static const char pszBaseType[] = "VertexLitGeneric";
sprintf_s(szMaterial,
sizeof(szMaterial),
szTmp, pszBaseType,
(bShouldIgnoreZ) ? 1 : 0,
(bIsWireframe) ? 1 : 0);
strcpy_s(szBaseType, pszBaseType);
}
char szName[512];
sprintf_s(szName, sizeof(szName), "custom_material_%i.vmt", iCreated);
iCreated++;
std::string strMatPath = GetWorkingPath() + "\\materials\\" + szName;
if (IsFileExists(strMatPath))
remove(strMatPath.c_str());
std::ofstream sMat;
sMat.open(strMatPath);
sMat << szMaterial;
sMat.close();
IMaterial* iMat = I.pMaterialSystem->FindMaterial(szName, "Model textures");
iMat->IncrementReferenceCount();
return iMat;