ReferenceTarget object?

ReferenceTarget object?

JokerMartini23
Enthusiast Enthusiast
697 Views
2 Replies
Message 1 of 3

ReferenceTarget object?

JokerMartini23
Enthusiast
Enthusiast

In my code snippet I've saved a copy of the render engine in a REF_TYPE of my param block. How can I then cast this REF_TYPE back to the actual class type of Renderer? I don't understand?? Hope you can help. Thanks.

 

Lastly I would ask how to check if the variable rend is of class type Renderer before proceeding in my code?

 

ReferenceTarget *ref;
ref = pblock->GetReferenceTarget(pb_re01 + i, 0);
Renderer *rend = //ref as renderer

 

0 Likes
698 Views
2 Replies
Replies (2)
Message 2 of 3

denis_grigor
Autodesk Support
Autodesk Support
Hi,

I never did this for a renderer before, but you can try using the Interface Querying.

For instance, with the Scanline renderer it should look like this:

ReferenceTarget* ref;
ref = pblock->GetReferenceTarget(pb_re01 + i, 0);
Renderer* rend = static_cast<Renderer*>(ref->GetInterface(SCANLINE_RENDERER_INTERFACE));

If you have your own renderer then of course you should have an Interface_ID for it.
Finally, to check if "the variable rend is of class type Renderer", you have to check if it not nullptr and if the SuperClassID is RENDERER_CLASS_ID.

I hope it helps.

Denis GRIGOR
Developer Technical Services
Autodesk Developer Network



0 Likes
Message 3 of 3

JokerMartini23
Enthusiast
Enthusiast

I got it working no problem. My main question now is how can i save a copy of it? This code below saves a direct reference/pointer to the render engine. I want to store a 'clone' of it in my param block.

 

 

rend = GetCOREInterface()->GetCurrentRenderer();
MSTR renderName;
rend->GetClassName(renderName);
mprintf(_T("Captured: %s\n"), renderName);

if (hPanel)
	InitDialog(hPanel);
	pblock->SetValue(pb_re01+i, 0, rend);
0 Likes