Setting third-party tag parameters
-
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.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
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:)
-kvb
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/07/2010 at 11:11, xxxxxxxx wrote:
Hi,
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.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
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.