Exemple #1
0
        private static void ProcessNodes(IntPtr scene, IntPtr node, ref List <AssimpJoint> listJoints)
        {
            var joint = new AssimpJoint();

            var name = Assimp.aiNode_GetName(node);

            if (name == "")
            {
                name = "REMOVE-ME";
            }
            joint._Name       = name;
            joint._ParentName = "";
            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
            var quad = Assimp.aiNode_GetRotation(node);

            joint._Orientation = quad;

            if (Assimp.aiNode_GetParent(node) != null)
            {
                var parentName = Assimp.aiNode_GetName(Assimp.aiNode_GetParent(node));
                joint._ParentName = parentName;
            }
            listJoints.Add(joint);

            for (var i = 0; i < listJoints.Count; i++)
            {
                var parent = listJoints[i];
                if (joint._ParentName == parent._Name)
                {
                    joint._Parent = parent;
                    joint._Path  += parent._Path + "/";
                    break;
                }
            }

            joint._Path += name;

            if (joint._Parent != null)
            {
                //  trace(string.Format(" Joint  name: {0}  ; parent:{1} ;  path:{2} ", joint.Name, joint.parent.Name, joint.Path));
            }
            else
            {
                //  trace(string.Format(" Joint  name: {0}  ;  path:{1} ", joint.Name, joint.Path));
            }

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