Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Get renderers list(C++)

Get renderers list(C++)

chrisdawlud
Enthusiast Enthusiast
1,031 Views
5 Replies
Message 1 of 6

Get renderers list(C++)

chrisdawlud
Enthusiast
Enthusiast

What is c++ equivalent of maxscript's rendererClass.classes?

 

 

0 Likes
Accepted solutions (1)
1,032 Views
5 Replies
Replies (5)
Message 2 of 6

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

 

ClassDirectory& class_dir = MAXScript_interface->GetDllDir().ClassDir();
SubClassList* renderers = class_dir.GetClassList(RENDERER_CLASS_ID);

and so on...

 

 

edited: ... but.. let me think a little more...

0 Likes
Message 3 of 6

chrisdawlud
Enthusiast
Enthusiast

I wrote the code below to obtain the renderers list.

It kind of works, but the thing is that for some renderers like Arnold, SuperClassID() returns REF_TARGET_CLASS_ID rather than expected RENDERER_CLASS_ID.

 

QHash<QString, Class_ID> Plugin::getRenderers()
{	
	auto renderers = QHash<QString, Class_ID>{};

	auto count = GetCOREInterface()->GetDllDir().Count();
	for (auto i = 0; i != count; ++i)
	{
		const auto desc = GetCOREInterface()->GetDllDir().GetDllDescription(i).GetClassDesc(0);
		
		//if (std::strcmp((char*)desc->ClassName(), "Arnold"))
		//	qDebug() << desc->SuperClassID();

		if (desc && desc->SuperClassID() == RENDERER_CLASS_ID)
		{
			const auto name = QString::fromWCharArray(desc->ClassName());
			renderers.insert(name, desc->ClassID());
		}		
	}

	return renderers;
}

 

I want to get complete renderers list just like it appears in Render Setup dialog. Does anyone know how to solve this?

 

 

0 Likes
Message 4 of 6

denisT.MaxDoctor
Advisor
Advisor

That's true. You can write a Renderer by extending just the ReferenceTarget. But anyway as I can see you have to add IRENDERERREQUIREMENTS_INTERFACE. So you can find all renderer classes by this interface. 

0 Likes
Message 5 of 6

chrisdawlud
Enthusiast
Enthusiast

Thanks for responding. I took a look at the IRenderRequirements class but it's not clear to me how to proceed. Could you show an example?

0 Likes
Message 6 of 6

chrisdawlud
Enthusiast
Enthusiast

This works correctly:

QList<QPair<QString, Class_ID>> Plugin::getRenderers()
{
	auto renderers = QList<QPair<QString, Class_ID>>{};

	static auto sub = ClassDirectory::GetInstance().GetClassList(RENDERER_CLASS_ID);
	const auto& xd = sub[0];

	for (auto i = 0; i != xd.Count(ACC_ALL); ++i) {
		const auto name = QString::fromWCharArray(xd[i].ClassName());
		const auto cid = xd[i].ClassID();
		renderers.append(QPair{ name, cid });
	}

	return renderers;
}