Iray environment properties

how we can do this using c++?
var viewport_manager = MainWindow.getViewportMgr(); var draw_style = viewport_manager.findUserDrawStyle("NVIDIA Iray"); var viewport = viewport_manager.getActiveViewport(); var viewport_3d = viewport.get3DViewport(); viewport_3d.setDrawStyle(draw_style); var render_manager = App.getRenderMgr(); Scene.addNode(new DzEnvironmentNode()); Scene.addNode(new DzTonemapperNode()); render_manager.getRenderElementObjects().forEach(function (element) { if (element.className() === "DzEnvironmentNode") { element.findPropertyByLabel("Draw Dome").setDoubleValue(1); } });
Post edited by MehdiZangenehBar on
Comments
A problem is that the SDK 4.5+ does not know about zEnvironmentNode and DzTonemapperNode. They were created after this version of the SDK was released.
One option to work around that problem is to create those nodes using a script called by your plugin. If you are so inclined, you could just get your plugin to call your whole script.
However, since this is an SDK forum let’s do what we can using the SDK.
Sorry I do not have a great deal of free time so not the best code it is verbose and has redundant checking. Use at your own risk, hopefully it will be of use to you and others.
CREDIT: apart from any spelling mistakes this code is simply an adaption from DAZ's examples(included with the SDK) and in the SDk documentation and from many previous forum contributors.
ok, thanks, code you please wrap your code using <pre> code </pre> tag? it is very hard to read in single line (that is forum problem)
OK, I just saw your code, so there no way to instansiate a class by name or any other trick?
for the first part, checking classname is not better way?
I don't undrstand why DzEnvironmentNode is not exposed in SDK!, but don't undrstand more why a scene node used to store environment data!
I also don't undrstand why auto creation of the environment and tonemap nodes will be executed synchronously?! the code should not be executed line by line?!
You can instance a DzNode by
However, because the SDK was created before DzEnvironmentNode there is no "dzenvironmentnode.h" file in the SDK. So you can not instance a DzEnvironmentNode with "new DzEnvironmentNode();"
When the SDK is next updated, I would expect it to be included then.
You asked why don't they include it!
When you maintain an SDK you have to be very careful of how, what and when you update, or you end up making a lot of extra work for yourself. It is easiest to hold off on minor changes and just issue big changes. It has been said that an update to the SDK is overdue!
The above is not the only way to instance a class. I provided just one alternate way in the example I gave you. I will leave it to you as homework to read the Qt documentation to find the other ways.
Yes there are other ways to check an objects class too, I provided just one of them.
A scene node can be used for many purposes. They provide an uncomplicated way to include something in the scene file when the user hits save. You can of course include information in the scene file using other methods however why create complexity when you already have a readymade option.
You could have environment and tonemap nodes stored in an asset file and use code to merge that into the scene. You would need to think of how you are going to manage the situation where one or both environment and tonemap already exists in the scene. There are lots of ways, it’s all in the SDK documentation
Have fun.
Some things it is suggested you might want to look at:
DzScene::findNode()
DzApp::findClassFactory()
DzClassFactory::createInstance()
qobject_cast<DzNode*>()
DzScene::addNode()
Brilliant!
That was what I was looking for!
Now we can instanciate a class which is not exist in SDK!
dzScene->addNode(qobject_cast<DzNode*>(dzApp->findClassFactory("DzEnvironmentNode")->createInstance()));
Don't forget to add error checking