Changes for KeyWord.* texture name recalls for custom matarl

alex_dergian

14-02-2007 20:28:19

Well i found it and changed it if you want plsm2 to laod a custom matiral goto line 569 OgrePagingLandScapeTexture.cpp

it looks like this for the section we are changing

while (tuIt.hasMoreElements ())
{
TextureUnitState * const tu = tuIt.getNext ();
const String texType (tu->getTextureName());
if (std::string::npos == texType.find("."))
{
// This Texture Name is A keyword,
// meaning we have to dynamically replace it
deformable = false;
// check by what texture to replace keyword
if (StringUtil::startsWith (texType, "image", true))
{
texName = opt->image_filename + endName;
deformable = true;
}
else if (StringUtil::startsWith (texType, "splatting", true))
{
texName = opt->SplatDetailMapNames[splat % opt->NumMatHeightSplat];
splat++;
}
else if (StringUtil::startsWith (texType, "base", true))
{
texName = beginName + texType + endName;
channel++;
deformable = true;
}
else if (StringUtil::startsWith (texType, "alpha", true))
{
texName = beginName + texType + nameSep +
StringConverter::toString(alphachannel) + endName;
deformable = true;
alphachannel++;
channel++;
}
else if (StringUtil::startsWith (texType, "coverage", true))
{
texName = beginName + texType + nameSep +
StringConverter::toString((coveragechannel * 4) % opt->NumMatHeightSplat) + endName;
deformable = true;
channel++;
coveragechannel++;
}
else if (StringUtil::startsWith (texType, "light", true))
{
texName = beginName + texType + endName + extName;
}
else if (StringUtil::startsWith (texType, "horizon", true))
{
texName = beginName + "HSP" + endName + extName;
mPositiveShadow = true;
}
if (deformable)
{
if(opt->Deformable &&
ResourceGroupManager::getSingleton().resourceExists(
opt->groupName,
texName + "modif." + extName))
{
finalTexName = texName + "modif." + extName;
}
else
{
finalTexName = texName + extName;
}
}
else
{
finalTexName = texName;
}
tu->setTextureName (finalTexName);
}
}


Now i only applided these changes to the Coverage, base and Alpha keywords but applying it for image should be too hard but here is the new code you need to replace that section of code with then from there you will use the keywords Alpha.* which is to say Alpha.MyAlphaRoadMap or Alpha.1 if you want to keep it simple you will need to have the name of your alpha corisponding with the .* i did by naming my files test.Alpha.SplatMajor#.X.Y.png
test.Alpha.SplatDetail#.X.Y.png

please note doing this will make the demos act strage so make sure you only apply this if you need the functionalliy to use zorder textures or recall a texture more then once also don't use textures with the keyword names like Alpha_png.jpb it will trigger the key word system and finaly here is the patch code

while (tuIt.hasMoreElements ())
{
TextureUnitState * const tu = tuIt.getNext ();
const String texType (tu->getTextureName());
// This Texture Name is A keyword,
// meaning we have to dynamically replace it
deformable = false;
bool renamed = false;
// check by what texture to replace keyword
if (StringUtil::startsWith (texType, "image", true))
{
texName = opt->image_filename + endName;
deformable = true;
}
else if (StringUtil::startsWith (texType, "splatting", true))
{
texName = opt->SplatDetailMapNames[splat % opt->NumMatHeightSplat];
splat++;
}
else if (StringUtil::startsWith (texType, "base", true))
{
texName = beginName + texType + endName;
channel++;
renamed = true;
deformable = true;
}
else if (StringUtil::startsWith (texType, "alpha", true))
{
texName = beginName + texType + endName;
deformable = true;
renamed = true;
alphachannel++;
channel++;
}
else if (StringUtil::startsWith (texType, "coverage", true))
{
texName = beginName + texType + endName;
deformable = true;
renamed = true;
channel++;
coveragechannel++;
}
else if (StringUtil::startsWith (texType, "light", true))
{
texName = beginName + texType + endName + extName;
}
else if (StringUtil::startsWith (texType, "horizon", true))
{
texName = beginName + "HSP" + endName + extName;
mPositiveShadow = true;
}
if (deformable)
{
if(opt->Deformable &&
ResourceGroupManager::getSingleton().resourceExists(
opt->groupName,
texName + "modif." + extName))
{
finalTexName = texName + "modif." + extName;
}
else
{
finalTexName = texName + extName;
}
}
else if( renamed )
{
finalTexName = texName;
}
else
{
finalTexName = texType;
}
tu->setTextureName (finalTexName);
}

alex_dergian

14-02-2007 20:34:22

to make this function line work with the demos just do a check for a "." and if it is found then do rename my way otherwize do it the old way

tuan kuranes

24-02-2007 11:48:07

CAn you elaborate a bit more on that ? What is the goal of that ?