Hi all,
So I've implemented a custom Arnold camera node, created a CExtension which registers an mtoa translator and it all successfully goes through.
However, this type of camera is more akin to an othographic camera than a perspective one, but every time the camera type is chosen in the Arnold section of the camera, it disables the orthographic setting.
Is there some one I can hook myself in to these callbacks so that I can control what is set and adjusted when my camera type is selected? (If so, how? :P)
Cheers,
Alan.
Solved! Go to Solution.
Solved by sebastien.blaineau.ortegaHRM3U. Go to Solution.
Uh oh - guessing the answer may be no? Either that or it's very ugly.
Seems there is a MNodeMessage which has a parameter changed callback, but that requires a specific node for it to be registered for.
There's a MDGMessage that I could use to detect when a node is added, check if it's a camera node, then register the aforementioned MNodeMessage for it's parameter changes.
However, that may or may not trigger when a scene is opened (unclear from docs whether an existing node in a scene being loaded would count as an add - to be continued)
Also unclear whether callbacks are persisted, not in docs either. If both of those are false, then there's an MSceneMessage which has an opened callback that I could use to go and run through the entire scene, find all cameras and register the MNodeMessage callback mentioned at the start.
However, if there are other callbacks coming into play then those could change the values before I get them if it executes first. Or they may also execute afterwards and overwrite my changes. Or infinite loop.
Anyone at Autodesk able to confirm/deny any of this? (or provide a solution that would work)
Hi @Alan Jones
I'll ask the MtoA devs to take a look at these questions...
Here's something that might help:
def cameraTranslatorChanged(transPlug, *args): "called to sync .orthographic when .aiTranslator changes" if not core.arnoldIsCurrentRenderer(): return fnCam = om.MFnCamera(transPlug.node()) currTrans = transPlug.asString() orthoPlug = fnCam.findPlug('orthographic') isOrtho = orthoPlug.asBool() #print "cameraTranslatorChanged", fnCam.name(), currTrans, isOrtho # when a file is opening, we need to choose one attribute to lead, because # the order that attributes are set is unpredictable. This fixes a case # where translators may have gotten out of sync if om.MFileIO.isOpeningFile(): if isOrtho and currTrans != 'orthographic': orthoPlug.setBool(True) else: if not isOrtho and currTrans == 'orthographic': orthoPlug.setBool(True) elif isOrtho and currTrans != 'orthographic': orthoPlug.setBool(False) # def getCameraDefault(obj): isOrtho = om.MFnDependencyNode(obj).findPlug("orthographic").asBool() default = 'orthographic' if isOrtho else 'perspective' return default # templates.registerDefaultTranslator('camera', getCameraDefault) templates.registerDefaultTranslator('stereoRigCamera', getCameraDefault) # callbacks.addAttributeChangedCallbacks('camera', [('aiTranslator', cameraTranslatorChanged), ('orthographic', cameraOrthographicChanged)]) # callbacks.addAttributeChangedCallbacks('stereoRigCamera', [('aiTranslator', cameraTranslatorChanged), ('orthographic', cameraOrthographicChanged)
Thanks, Stephen. Are callbacks the best way to do this? i.e. is there nothing I should be doing in either my Arnold cpp code, mtoa translator, or elsewhere that provides this information in a manner your APIs expect?
Just checking as while this will work if my plugin is the only one checking, there could potentially be conflicts if another was doing the same thing. So it feels like there should be APIs available for custom cameras to register some properties of themselves.
Cheers,
Alan.
Doing callbacks such as this, still get written over by the mtoa scripts, so there is no way to package a plugin for distribution which works around this.