On 04/07/2015 at 21:00, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 15+
Platform: Windows ;
Language(s) : C++ ;
---------
I got a MaterialData plugin, where shaders are created dynamically, here is some code:
BaseShader* shader = nullptr;
//shader = static_cast<BaseShader*> (kndData->nodes[n].getInternalData(input).GetLink(mat->GetDocument()));//fails
//fails!!
//BaseList2D* mlnk = data->GetLink(kndData->nodes[n].getInternalID(input), mat->GetDocument(), Xbase);
//if(mlnk)
// shader = static_cast<BaseShader*> (mlnk);
shader = mat->GetFirstShader();//works
if(shader)
GePrint("found a shader link");
else
GePrint("shader link not found");
not sure why the standard ways of getting a link using a description id fails.
here is how I create the description:
cid = DescLevel(kndData->nodes[kndData->selectedNode].getInternalID(i), DTYPE_BASELISTLINK, 0);
if (!singleid || cid.IsPartOf(*singleid, nullptr))// important to check for speedup c4d!
{
BaseContainer dt = GetCustomDataTypeDefault(DTYPE_BASELISTLINK);
std::string dName = kndData->nodes[kndData->selectedNode].getInternalDataName(i);
String dtName(dName.c_str());
dt.SetString(DESC_SHORT_NAME, dtName);
dt.SetString(DESC_NAME, dtName);
dt.SetBool(DESC_ANIMATE, DESC_ANIMATE_ON);
dt.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_TEXBOX);
dt.SetInt32(DESC_SHADERLINKFLAG, TRUE);
if (!description->SetParameter(cid, dt, DescLevel(Tbaselist2d)))
return true;
}