Custom solvers

Gustavo BoehsGustavo Boehs Posts: 63 ✭✭
edited October 2016 in Kraken Rigging Framework

Hello guys. I'm trying to work a custom solver, based on what I can infer from the existing solvers. So from what I gather I have to create an object based on KrakenSolver and expose arguments to the DCCs using KrakenSolverArg[], correct?
If that is correct I have two further questions:
What are the must have methods (init, solve, setDebug, etc...)?
Why do all solvers use a canvas variable (constructor>variable>solve, see pic), even if they are not simulated and, in theory, don't need to cumulate values? Plus, are this connections built automatically by kl2dfg?

Best,
Gustavo

Comments

  • EricTEricT Administrator, Moderator, Fabric Employee Posts: 305 admin

    Hi Gustavo,

    The KrakenSolver.kl file implements a IKrakenSolver interface. This interface is what specifies what methods that any other solver that inherits from the KrakenSolver object needs to implement. This is just the getArguments() method. This method allows Kraken know what arguments are expected from each solver so it can ensure connections are made properly. However the other method that MUST exist is the solve() method. Since the arguments for this method may vary for each solver, we can't require it via the interface.

    We have 2 default args at all times which is drawDebug & rigScale. Each inherited solver object must have these.

    The solvers that are generated by Kraken or that have been generated automatically as Canvas presets have the solver created in one function node that is then plugged into a variable node. This ensures that the solver object isn't created each time the graph evaluates. We then plug it into the solve function node that calls the solver's solve() method to solve the pose and set the values from there.

    The canvas presets that are included with Kraken for the solvers were generated with kl2dfg plus a python helper script. I created the low level nodes via kl2dfg then created graphs that instanced those low level nodes and created the connections via the Fabric Python module in a batch process then saved those graphs out in batch. These can be regenerated as needed. It should be noted that I don't add GUIDs to the presets just yet. It's on the to-do list. :)

    See here:
    https://github.com/fabric-engine/Kraken/blob/develop/Utils/dfgPresetGen.py

    Eric Thivierge
    Kraken Developer
    Kraken Rigging Framework

  • Gustavo BoehsGustavo Boehs Posts: 63 ✭✭

    Thank you very much for the detailed explanation Eric. :)

Sign In or Register to comment.