State machine debugger data
Maya
from AtomsMaya.hostbridge.atomsgroup import MayaAtomsGroupHostBridge from AtomsMaya.hostbridge.commands import MayaCommandsHostBridge def get_state_machine_operator_from_agent(agent): network = agent.network() for no in network.manager().getAllNodes(): if isinstance(no, Atoms.StateMachineOperator): return no nh = MayaAtomsGroupHostBridge() nh.set_app_obj("tcAgentGroupNodeShape1") ag = nh.get_agent_group() ids = ag.agentLocalIds() for i in range(1001, 1010): MayaCommandsHostBridge.set_frame(i) for agent_id in ids: agent = ag.agent(agent_id) state_machine_op = get_state_machine_operator_from_agent(agent) values = [] all_nodes = state_machine_op.network().manager().getAllNodes() for n in all_nodes: if not isinstance(n, (Atoms.BlendSpaceOperator, Atoms.AnimationStateOperator)): continue ap = n.getInputPort("active") if not ap or not ap.get(): continue state_weight = 1.0 pp = n.getOutputPort("outPose") if pp: for conn in pp.getConnections(): if not conn: continue if not conn.node(): continue if not isinstance(conn.node(), Atoms.MergeOperator): continue pp_name = conn.name() wp = "inPoseWeight" + pp_name[6:] w_port = conn.node().getInputPort(wp) if not w_port: continue state_weight = w_port.get() break all_in_nodes = n.network().manager().getAllNodes() for cn in all_in_nodes: ap = cn.getInputPort("active") if not ap or not ap.get(): continue fp = cn.getOutputPort("outClipFrame") if not fp: continue v = ["", 0, 0, "", 0] v[0] = cn.name() v[1] = fp.get() cpp = cn.getOutputPort("outPose") if cpp: for conn in cpp.getConnections(): if not conn: continue if not conn.node(): continue if not isinstance(conn.node(), Atoms.MergeOperator): continue pp_name = conn.name() wp = "inPoseWeight" + pp_name[6:] w_port = conn.node().getInputPort(wp) if not w_port: continue v[2] = w_port.get() v[3] = n.name() v[4] = state_weight values.append(v) values.sort(key=lambda tup: (tup[4], tup[2]), reverse=True) print(i, values)
Houdini
from AtomsHoudini.hostbridge.atomsgroup import HoudiniAtomsGroupHostBridge from AtomsHoudini.hostbridge.commands import HoudiniCommandsHostBridge def get_state_machine_operator_from_agent(agent): network = agent.network() for no in network.manager().getAllNodes(): if isinstance(no, Atoms.StateMachineOperator): return no nh = HoudiniAtomsGroupHostBridge() nh.set_app_obj("/obj/AgentGroupName") ag = nh.get_agent_group() ids = ag.agentLocalIds() for i in range(1001, 1010): HoudiniCommandsHostBridge.set_frame(i) for agent_id in ids: agent = ag.agent(agent_id) state_machine_op = get_state_machine_operator_from_agent(agent) values = [] all_nodes = state_machine_op.network().manager().getAllNodes() for n in all_nodes: if not isinstance(n, (Atoms.BlendSpaceOperator, Atoms.AnimationStateOperator)): continue ap = n.getInputPort("active") if not ap or not ap.get(): continue state_weight = 1.0 pp = n.getOutputPort("outPose") if pp: for conn in pp.getConnections(): if not conn: continue if not conn.node(): continue if not isinstance(conn.node(), Atoms.MergeOperator): continue pp_name = conn.name() wp = "inPoseWeight" + pp_name[6:] w_port = conn.node().getInputPort(wp) if not w_port: continue state_weight = w_port.get() break all_in_nodes = n.network().manager().getAllNodes() for cn in all_in_nodes: ap = cn.getInputPort("active") if not ap or not ap.get(): continue fp = cn.getOutputPort("outClipFrame") if not fp: continue v = ["", 0, 0, "", 0] v[0] = cn.name() v[1] = fp.get() cpp = cn.getOutputPort("outPose") if cpp: for conn in cpp.getConnections(): if not conn: continue if not conn.node(): continue if not isinstance(conn.node(), Atoms.MergeOperator): continue pp_name = conn.name() wp = "inPoseWeight" + pp_name[6:] w_port = conn.node().getInputPort(wp) if not w_port: continue v[2] = w_port.get() v[3] = n.name() v[4] = state_weight values.append(v) values.sort(key=lambda tup: (tup[4], tup[2]), reverse=True) print(i, values)
Copyright © 2017, Toolchefs LTD.