Trying to use the Geometry Stack

I'm trying to start using the Rigging Toolbox extension within Canvas, and my first attempt has been to replicate the sphereBlendShapes example.
Using Splice nodes, it works fine for me, in Maya 2015.

But when I begun to port the code into Canvas nodes I got stucked on the first step.

The first splice node was set up with this code:

## Set up the BlendShapesParams node.

initnode = cmds.createNode("spliceMayaNode", name = "BlendShapesSphereCharacter_Init")

cmds.fabricSplice('addInputPort', initnode, json.dumps({'portName':'filePath', 'dataType':'String', 'addMayaAttr': True}))
cmds.fabricSplice('addOutputPort', initnode, json.dumps({'portName':'stack', 'dataType':'GeometryStack', 'extension':'RiggingToolbox', 'addSpliceMayaAttr':True, 'autoInitObjects': True}))

cmds.setAttr(initnode + '.filePath', toolboxPath+"/Tests/GeometryStack/Resources/blendShapesSphereCharacter.json", type="string");

cmds.fabricSplice('addKLOperator', initnode, '{"opName":"blendShapesSphereCharacter"}', """

require RiggingToolbox;

operator blendShapesSphereCharacter(
  String filePath,
  io GeometryStack stack
) {
  report("Loading Character Definition:" + filePath);

So I created a canvas node with the same ports, and this code:

dfgEntry {
  report("Loading Character Definition! : " + filePath);

but on execution I got this error:

// [KL]: [FABRIC:MT] --------------------------------- // 
// [KL]: [FABRIC:MT] Loading Character Definition! : C:/apps/FABRIC/EXTS/RiggingToolbox/Tests/GeometryStack/Resources/blendShapesSphereCharacter.json // 
// [KL]: [FABRIC:MT] Error: GeometryStack/GeometryStack.kl:303:3: dereferenced null object // 
// [KL]: [FABRIC:MT] KL stack trace: // 
// [KL]: [FABRIC:MT] [ST] 1 method.loadJSONFile.L.UO_GeometryStack.R.OO_PersistenceContext.R.ST() GeometryStack.kl:298 // 
// [KL]: [FABRIC:MT] [ST] 2 method.loadJSONFile.L.UO_GeometryStack.R.ST() GeometryStack.kl:316 // 
// [KL]: [FABRIC:MT] [ST] 3 stub() DFGBinding.kl:17 // 

I attach a very simple Maya scene with this.

Any ideas?
Is my approach totally wrong?

Thanks in advance!


  • Roy NieterauRoy Nieterau Posts: 257 ✭✭✭
    edited December 2015

    Ah, you were so close! :)

    The GeometryStack that you have in the function is not initialized yet to an object and as such is null.
    All you'd have to do is stack = GeometryStack(); to create an instance of it.

    So this fixes it:

      stack = GeometryStack();

    I'd recommend setting up a separate GeometryStack node that initializes it and stores it into a Variable so it "stays around". The GeometryStack is supposed to contain data that persists so it can optimize its evaluation. That would be purely an optimization because I think you should be able to get this example running without keeping it around as a persisted variable.

    With that initialized you should be able to get through with the rest of the example? ;)

    Good luck!

  • GabrielRoyGabrielRoy Posts: 39

    Hey! Thanks Roy!
    Thought that declaring the io port stack would already create the stack object...

    Great, with this I hope I can advance a bit more before getting stucked again. I will bother you again otherwise ... :)

  • GabrielRoyGabrielRoy Posts: 39

    Finally got some time to go on with this and finished the blendShapes sample, and you can find it attached here.

    But along the way I found two problems:

    By default, the '''displayGeometries''' attribute of the stack is True and they get displayed, but even if this setup works fine in Splice, in Canvas it is very buggy. Not only the base deformed object gets displayed, but the targets as well, one on top of the other.

    To overcome this I extract the mesh from the stack and render it with another handle and a DrawPolygonMesh.
    In my screen capture you can see the automatically displayed geometry in blue, and the mesh in green. The blue one seems correct but when you begin to modify the values of the target weights it doesn't update correctly.

    The second problem is that when you start to play with the weights it crashes very, very often, both in canvas and in Maya.

  • Roy NieterauRoy Nieterau Posts: 257 ✭✭✭

    Good to see you got it working. Thanks for sharing the sample graph.

    The drawing is definitely a tricky one. :D It seems that there's nothing that is clearing up the previous "drawing" and I assume that's also where the crashes might be originating from. It could be some kind of stack overflow in the render queue. The crash only seems to happen "over time" when playing around with it a bit.

    Would love to see RiggingToolbox evolve a bit more so it's solid within Canvas and easy to use. :smile:

Sign In or Register to comment.