THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/11/2006 at 13:28, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.2-10.0
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
What is wrong with this code? I've tried without COPY_NO_INTERNALS, but the links to the Texture tags are then broken. I've tried calling AliasTrans::Translate after each and at the end (as shown). Is the AliasTrans::Init() document correct (source)? This is getting frustrating as it works to an extent, but the materials don't update properly (show the texture image) and rendering fails.
// Paste Materials
//*---------------------------------------------------------------------------*
Bool GeIPPPaste_Materials(BaseDocument* sdoc, BaseObject* sobj, BaseDocument* ddoc, BaseObject* dobj)
//*---------------------------------------------------------------------------*
{
BaseTag* stag;
BaseTag* dtag;
TextureTag* sttag;
TextureTag* dttag;
Material* smat;
Material* dmat;
GeData data;
String sname;
BOOL doTranslate = FALSE;
AutoAlloc<AliasTrans> aliastrans;
if (!(aliastrans && aliastrans->Init(sdoc))) return FALSE;
// Materials
for (stag = sobj->GetFirstTag(); stag; stag = stag->GetNext())
{
if (!stag->IsInstanceOf(Ttexture)) continue;
sttag = (TextureTag* )stag;
sttag->GetParameter(DescID(TEXTURETAG_MATERIAL), data, NULL);
smat = static_cast<Material*>(data.GetLink(sdoc, Mbase));
if (!smat) continue;
sname = stag->GetName();
for (dtag = dobj->GetFirstTag(); dtag; dtag = dtag->GetNext())
{
if (!dtag->IsInstanceOf(Ttexture)) continue;
dttag = (TextureTag* )dtag;
dttag->GetParameter(DescID(TEXTURETAG_MATERIAL), data, NULL);
dmat = static_cast<Material*>(data.GetLink(ddoc, Mbase));
if (!dmat) continue;
if (dtag->GetName() != sname) continue;
// Found matching materials, copy
if (!smat->CopyTo(dmat, COPY_NO_INTERNALS, aliastrans)) continue; //aliastrans->Translate(TRUE);
dmat->Update(TRUE, TRUE);
dmat->Message(MSG_CHANGE);
doTranslate = TRUE;
break;
}
}
if (doTranslate) aliastrans->Translate(TRUE);
return TRUE;
}
Thanks,