Object Plugin doesn´t render with Physical Renderer
-
I found out that I set self.OptimizeCache() set in the init and forgot to ask in the GVO if dirty so I added:
dirty: bool = op.CheckCache(hh) or op.IsDirty(c4d.DIRTYFLAGS_DATA) if not dirty: return op.GetCache(hh)
Now it renders in the Editor View but not in the Picture Viewer. The base is rendered, so think I have to do the actions not in the Message, there I change just the Data-Sturcture but loading in the GVO yes.....I will try that out...
-
Yes that was the problem, I did the model structure after a message and returned the object in the GVO but I have to do this one function in the GVO now it works. Thanks
-
Hi,
sorry for the late reply but i am happy you solved the problem.
The GVO is supposed to return the cache of the generator. This cache will be used as the object to be rendered. GVO is called from a thread and not the main thread. So, you are not allowed to add any kind of object in the scene. That is why you should add your object in the scene in the message function. Then you GVO function will kick in and will find the materials.
Cheers,
Manuel -
@manuel
ok I understand, yes but there is no object added in the GVO, in the GVO I just trigger some function to exchange virtual objects which are not in any document, and there I also exchange the material links in the texture tags to the materials which are already part of the active document.
So the Message gets Postsetparameter for instance. Then in the active document some objects will be reordered and then the GVO will triggered is dirty and calls a function to exchange the virtual objects related to the reorderd structure. Then the texturtags material links will be read exchanged and then the virtual object will be returned.I just have one function called carefully in the GVO which just triggers one time.
It adds a layer puts the node into the layer and loads the materials from the virtual document into the active document. then it puts the layer into a hidden description Baselink of the node, so that it can keep track. then it switches the variable to True.if not self.start_refresh: self.load_modules_new(op) if op[c4d.PY_LAYER] == 0 and op[c4d.PY_LAYER_ID] is None: self.create_layer(op, doc) self.add_new_materials_layer(op) elif op[c4d.PY_LAYER] == 1 and op[c4d.PY_LAYER_ID] is None: self.create_layer(op, doc) self.add_new_materials_layer(op) c4d.CallCommand(12147) self.start_refresh = True
May i also do this things in the Init() method, because I don´t know where to call this.
Also will the virtual document be destroyed when I close the node in the Object Manager? -
hi,
creating, inside GVO, a virtual document, and do operation there, is a valid workflow and we do it sometimes internally.
Problems occurs when you have material, links etc.I was just trying to emit some hypothesis on why object can render in the viewport and not in the picture viewer.
If i understand correctly, your workflow looks safe.About the last question, when you create your virtual document, you do it like
doc = functionToCreateTheDoc()
. When you exit the scope where you are, the python garbage collector will destroy the variabledoc
. If no other variable is using the same memory address, the memory will be cleaned.Cheers,
Manuel -
@manuel
the virtual document I already create in my__init__
function.
yes but I am a little bit unsure in terms of the layer and the material which just insert only the first time in the active document in the GVO. I would do it in the__init__
but I have no access to op, and doc. I tested a lot of scenarios, deleting the layer etc, he instantly creates a knew and puts the mats back into it, if the user presses an "Actualize" Button.
The most save workflow would be to let the user press a start button to create the layer, load the models into the virtual doc and then let the plugin do it´s job, if the layer accidently was deleted, the GetDEnabling method will hide the elements and the grayed out start button will be highlited again.
Cheers
Tom -
Hi,
did you tried the message MSG_MENUPREPARE? I would use that to "setup" anything in the scene when your nodeData is created.
Cheers,
Manuel. -
@Manuel
The message system is a bit overwhelming for me I just get step by step forward.
Where and how do I call this?
node.Message(c4d.MSG_MENUPREPARE) ?
sorry for this newbie question -
hi,
That is a valid question. One step after another, we are here to help.
You can override the function NodeData::Message() to react to some message Cinema4D is sending to all NodeData. This is exactly what you are already doing to react to button pressed by the user. In the same function, you can react to the message
MSG_DESCRIPTION_COMMAND
for buttons, orMSG_MENUPREPARE
when the user click on the menu to add the Node in the document. This is for example where phong tags can be added and attached to your object. This could also be a good place to load materials and create a material tag for your object.We have two manuals explaining the message system:
- on in the python documentation
- one in the c++ documentation
they are no difference between python and c++ but those manuals have different type of information.
The c++ manual show how to add an annotation tag when your object is added to the scene.Cheers,
Manuel -
@manuel
Thank you very much!