Community
Arnold General Rendering Forum
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Control Maya modifying camera attributes on camera type selection

10 ANTWORTEN 10
GELÖST
Antworten
Nachricht 1 von 11
Anonymous
933 Aufrufe, 10 Antworten

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)
Beschriftungen (3)
10 ANTWORTEN 10
Nachricht 2 von 11
Anonymous
als Antwort auf: Anonymous

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)

Nachricht 3 von 11
Anonymous
als Antwort auf: Anonymous

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)

Nachricht 4 von 11
Stephen.Blair
als Antwort auf: Anonymous

Hi @Alan Jones

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



// Stephen Blair
// Arnold Renderer Support
Nachricht 5 von 11
Anonymous
als Antwort auf: Stephen.Blair

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

Nachricht 6 von 11
Anonymous
als Antwort auf: 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.

Nachricht 7 von 11
Stephen.Blair
als Antwort auf: Anonymous

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
Nachricht 8 von 11
Anonymous
als Antwort auf: 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.

Nachricht 9 von 11
Anonymous
als Antwort auf: 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.

Nachricht 10 von 11
sebastien.blaineau.ortegaHRM3U
als Antwort auf: Anonymous

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

Nachricht 11 von 11
Anonymous

Thanks very much, Sebastien. Most appreciated.

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report