コード例 #1
0
    private static void processNodes(IntPtr scene, IntPtr node, ref List <AssimpJoint> listJoints)
    {
        AssimpJoint joint = new AssimpJoint();

        string name = Assimp.aiNode_GetName(node);

        if (name == "")
        {
            name = "REMOVE-ME";
        }
        joint.Name       = name;
        joint.parentName = "NONE";
        joint.Position   = Assimp.aiNode_GetPosition(node);
        //assimp quaternion is w,x,y,z and unity x,y,z,w bu int this lib i fix this for unity
        Quaternion quad = Assimp.aiNode_GetRotation(node);

        joint.Orientation = quad;



        if (Assimp.aiNode_GetParent(node) != null)
        {
            string parentName = Assimp.aiNode_GetName(Assimp.aiNode_GetParent(node));
            joint.parentName = parentName;
        }


        listJoints.Add(joint);

        for (int i = 0; i < listJoints.Count; i++)
        {
            AssimpJoint parent = listJoints[i];
            if (joint.parentName == parent.Name)
            {
                joint.parent = parent;
                joint.Path  += parent.Path + "/";
                break;
            }
        }

        joint.Path += name;

        if (joint.parent != null)
        {
            //   Debug.Log(string.Format(" Joint  name: {0}  ; parent:{1} ;  animation path:{2} ", joint.Name, joint.parent.Name,"Skeleton/" +  joint.Path));
        }
        else
        {
            //   Debug.Log(string.Format(" Joint  name: {0}  ; animation path:{1} ", joint.Name,"Skeleton/" + joint.Path));
        }

        for (int n = 0; n < Assimp.aiNode_GetNumChildren(node); n++)
        {
            processNodes(scene, Assimp.aiNode_GetChild(node, n), ref listJoints);
        }
    }