Miarmy Crowd Simulation Documentation (English)

Directly Get Simulation Data Using MEL_Python

Before Miarmy 1.5, you need read agent joint data through "agent match" and read data from original agent. It's really slow for production, now we provide a new approach which can read the data directly from agent:
Please select the agent you want to read, then:
Run a Maya command "McdAgentMatchCmd -mm 3;" And this MEL will return an array,
For the returned array, the first and second element are <Agent ID> and <Agent TypeID>, with the agent type id you can use it to find which agent group
Then the following data for each joint:
<tx> <ty><tz><rx><ry><rz><sx><st><sz><Custom Data Number><1st Custom Data>…<Nth Custom Data>
<tx> <ty><tz><rx><ry><rz><sx><st><sz><Custom Data Number><1st Custom Data>…<Nth Custom Data>
……
<tx> <ty><tz><rx><ry><rz><sx><st><sz><Custom Data Number><1st Custom Data>…<Nth Custom Data>
The "red" element is dynamically, means its number is based on "Custom Data Number"
The joint order is based on maya order:



The order of data in returned array is the same as Maya hierarchy


Know the limitation:
Please notice, all the fetched data are represented in rotation order "XYZ" because our original agent is built in all XYZ order, if you want to change, please refer the following c++ code, it can help get the rotation value of others orders.
void McdSimpleCommand::rotOrderTest(){
    // execute: 22
    // for example:
    // we set 60, 60, 60 in XYZ order
    // we want to get rotate of XZY order:
    MTransformationMatrix::RotationOrder rotOrder = MTransformationMatrix::kXZY;
    double rotBuild[3] = { 60.0 * TO_RAD,
                60.0 * TO_RAD,
                60.0 * TO_RAD};
    MTransformationMatrix testTMat;
    // we set 60 60 60 in XYZ order
    testTMat.setRotation(rotBuild, MTransformationMatrix::kXYZ);
    testTMat.reorderRotation(rotOrder); // reorder it to XZY
    double rotFetch[3];
    testTMat.getRotation(rotFetch, rotOrder); // fetch out result in XZY
    // the result should be:
    // 3.694
    // 73.886
    // 25.665
}




Basefount Technology