Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Control Maya modifying camera attributes on camera type selection

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
alan-LFL
667 Views, 10 Replies

Control Maya modifying camera attributes on camera type selection

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.

Tags (3)
Labels (3)
10 REPLIES 10
Message 2 of 11
alan-LFL
in reply to: alan-LFL

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)

Message 3 of 11
alan-LFL
in reply to: alan-LFL

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)

Message 4 of 11
Stephen.Blair
in reply to: alan-LFL

Hi @Alan Jones

I'll ask the MtoA devs to take a look at these questions...



// Stephen Blair
// Arnold Renderer Support
Message 5 of 11
alan-LFL
in reply to: Stephen.Blair

Awesome, thanks @Stephen Blair. You're the best.

Message 6 of 11
alan-LFL
in reply to: Stephen.Blair

Hi @Stephen Blair,

Any news on this? I've not found any way to have orthographic camera behavior in viewport etc on a custom Arnold camera node yet.

Would it be easier to track if I raised a support case?

Cheers,

Alan.

Message 7 of 11
Stephen.Blair
in reply to: alan-LFL

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)




// Stephen Blair
// Arnold Renderer Support
Message 8 of 11
alan-LFL
in reply to: Stephen.Blair

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.

Message 9 of 11
alan-LFL
in reply to: Stephen.Blair

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.

Message 10 of 11

Hi Alan,

it might be too late for the feature you needed to implement, but we addressed this limitation in the latest MtoA 4.0.3 that was just released.

You need to set a metadata orthographic = true for this node, please let us know if you need any help to implement it.

Thanks

Message 11 of 11

Thanks very much, Sebastien. Most appreciated.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report