Notifications
Clear all
[Closed] UVW Unwrap modification to handle DirectX Effects in Multi-Material
Apr 17, 2007 9:55 am
Hi,
Here is a portion of code I’ve added to the Unwrap source code (available in samples\modifiers\uvwunwrap).
In fact, the standard UVW Unwrap does not handle DirectX Shaders in Multi-Materials. So, the bitmaps used in the effects aren’t shown in the map list, useful hum hum… The modification I’ve done resolve the problem.
In unwrap.cpp in ParseMaterials(), change the else if in the main if like this:
else if (topMaterial->ClassID() == Class_ID(MULTI_CLASS_ID,0))
{
MultiMtl *mtl = (MultiMtl*) topMaterial;
IParamBlock2 *pb = mtl->GetParamBlock(0);
if (pb)
{
int numMaterials = pb->Count(multi_mtls);
for (i = 0; i < numMaterials; i++)
{
int id;
Mtl *mat;
pb->GetValue(multi_mtls,0,mat,FOREVER,i);
pb->GetValue(multi_ids,0,id,FOREVER,i);
//modified in order to handle DxMaterials in a Multi/Sub
IDxMaterial *subdxMaterial = (IDxMaterial *) mat->GetInterface(IDXMATERIAL_INTERFACE);
if (subdxMaterial != NULL)
{
int numberBitmaps = subdxMaterial->GetNumberOfEffectBitmaps();
for (int i = 0; i < numberBitmaps; i++)
{
PBBitmap *pmap= subdxMaterial->GetEffectBitmap(i);
if (pmap)
{
//create new bitmap texture
BitmapTex *bmtex = (BitmapTex *) CreateInstance(TEXMAP_CLASS_ID, Class_ID(BMTEX_CLASS_ID,0));
//add it to the list
TSTR mapName;
mapName.printf("%s",pmap->bi.Name());
bmtex->SetMapName(mapName);
Texmap *map = (Texmap *) bmtex;
tmaps.Append(1,&map,100);
int id = -1;
matIDs.Append(1,&id,100);
}
}
}
else
{
int tex_count = mat->NumSubTexmaps();
for (int j = 0; j < tex_count; j++)
{
Texmap *tmap;
tmap = mat->GetSubTexmap(j);
if (tmap != NULL)
{
tmaps.Append(1,&tmap,100);
matIDs.Append(1,&id,100);
}
}
}
}
}
}
Recompile and distribute the release build to your artists and they will be happy :).