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:
Cinema 4D Version: 11.5
Platform: Windows ;
Language(s) : C++ ;
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)
BaseTag *ltag = NULL;
sunLight = BaseObject::Alloc(Olight);
doc->InsertObject(sunLight, parent, prev, FALSE);
// add a Vray light tag
ltag = BaseTag::Alloc(Vlighttag);
param.SetLong(VRAYLIGHTTAG_COMMON_LIGHTTYPE_2); // Vray infinite light
ltag->SetParameter(DescID(VRAYLIGHTTAG_COMMON_LIGHTTYPE), param, 0L);
ltag->SetParameter(DescID(VRAYLIGHTTAG_COMMON_INTENSITY), param, 0L);
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.
On 09/07/2010 at 10:20, xxxxxxxx wrote:
hmmm, that does seem odd. Maybe try setting the tag parameters after you insert it?
shot in the dark, but might work:)
On 09/07/2010 at 11:11, xxxxxxxx wrote:
Many thanks for that. I have in fact already tried that, unfortunately it doesn't make any difference. But it was certainly worth a try.
On 10/07/2010 at 01:20, xxxxxxxx wrote:
Well... for anyone who needs to do this in the future, I think I've solved what was happening. There was nothing wrong with my code. What appears to happen is that the Vray light tag, when applied to a light, simply takes its values (or those which it can, such as brightness, color, shadows, etc.) from the existing light values, and does this after it has been inserted into the scene - overriding any value already there.
So the solution was to set the values in the light itself, then add the light tag and it works fine.