THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/07/2010 at 08:20, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.5
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
Can anyone offer any hints as to why this isn't working? What I'm trying to do is add a Vray light to a scene. This is the relevant code:
Bool SIBLDialog::CreateVraySun(BaseDocument *doc, BaseObject *parent, BaseObject *prev)
{
BaseObject *sunLight;
GeData param;
BaseTag *ltag = NULL;
sunLight = BaseObject::Alloc(Olight);
if(sunLight)
{
sunLight->SetName("sIBL_Sun");
doc->InsertObject(sunLight, parent, prev, FALSE);
doc->AddUndo(UNDO_NEW, sunLight);
// add a Vray light tag
ltag = BaseTag::Alloc(Vlighttag);
if(ltag)
{
param.SetLong(VRAYLIGHTTAG_COMMON_LIGHTTYPE_2); // Vray infinite light
ltag->SetParameter(DescID(VRAYLIGHTTAG_COMMON_LIGHTTYPE), param, 0L);
param.SetReal(5.1);
ltag->SetParameter(DescID(VRAYLIGHTTAG_COMMON_INTENSITY), param, 0L);
doc->AddUndo(UNDO_CHANGE, sunLight);
sunLight->InsertTag(ltag);
sunLight->Message(MSG_UPDATE);
}
}
return TRUE;
}
What this tries to do is add a C4D light to the scene, attach a Vray light tag, and set the light type and intensity parameters in that tag. What actually happens is that the light and the tag are successfully added, but the tag parameters are not changed. The DescID() values come from the .h files which come with Vray, and I've checked the return values from SetParameter(), and this returns TRUE in both cases, so the call is not failing. What's also odd is that, if after setting the parameters I do a GetParameter() on the tag, the values are the ones I set - they just don't show up in the tag in the AM.
Finally, just to clarify, I am calling StartUndo(), EndUndo() and EventAdd(), in the function which calls this one.
I'm missing something obvious, I'm sure - I'd be very grateful for comments on how to get this to work.