Exemplo n.º 1
0
        void CheckConsistency()
        {
            PrepareBones();
            Hashtable map = new Hashtable();

            foreach (BoneInfo bone in bones)
            {
                if (bone.anchor)
                {
                    if (map[bone.anchor] != null)
                    {
                        BoneInfo oldBone = (BoneInfo)map[bone.anchor];
                        Debug.Log("{0} and {1} may not be assigned to the same bone." + bone.name + oldBone.name);
                    }
                    map[bone.anchor] = bone;
                }
            }

            foreach (BoneInfo bone in bones)
            {
                if (bone.anchor == null)
                {
                    Debug.Log("{0} has not been assigned yet.\n" + bone.name);
                }
            }
        }
Exemplo n.º 2
0
        private void Cleanup()
        {
            IEnumerator enumerator = this.bones.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    BoneInfo current = (BoneInfo)enumerator.Current;
                    if (current.anchor != null)
                    {
                        foreach (Joint joint in current.anchor.GetComponentsInChildren(typeof(Joint)))
                        {
                            Object.DestroyImmediate(joint);
                        }
                        foreach (Rigidbody rigidbody in current.anchor.GetComponentsInChildren(typeof(Rigidbody)))
                        {
                            Object.DestroyImmediate(rigidbody);
                        }
                        foreach (Collider collider in current.anchor.GetComponentsInChildren(typeof(Collider)))
                        {
                            Object.DestroyImmediate(collider);
                        }
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable == null)
                {
                }
                disposable.Dispose();
            }
        }
Exemplo n.º 3
0
        private BoneInfo FindBone(string name)
        {
            IEnumerator enumerator = this.bones.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    BoneInfo current = (BoneInfo)enumerator.Current;
                    if (current.name == name)
                    {
                        return(current);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        private void AddJoint(string name, Transform anchor, string parent, Vector3 worldTwistAxis, Vector3 worldSwingAxis, float minLimit, float maxLimit, float swingLimit, System.Type colliderType, float radiusScale, float density)
        {
            BoneInfo info = new BoneInfo {
                name         = name,
                anchor       = anchor,
                axis         = worldTwistAxis,
                normalAxis   = worldSwingAxis,
                minLimit     = minLimit,
                maxLimit     = maxLimit,
                swingLimit   = swingLimit,
                density      = density,
                colliderType = colliderType,
                radiusScale  = radiusScale
            };

            if (this.FindBone(parent) != null)
            {
                info.parent = this.FindBone(parent);
            }
            else if (name.StartsWith("Left"))
            {
                info.parent = this.FindBone("Left " + parent);
            }
            else if (name.StartsWith("Right"))
            {
                info.parent = this.FindBone("Right " + parent);
            }
            info.parent.children.Add(info);
            this.bones.Add(info);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor for the animation player. It makes the
        /// association between a clip and a model and sets up for playing
        /// </summary>
        public AnimationPlayer(AnimationClip clip, AnimatedModel model, bool looping, int keyframestart = 0, int keyframeend = 0, int fps = 24)
        {
            this.clip  = clip;
            this.model = model;
            Looping    = looping;

            // Create the bone information classes
            boneCnt   = clip.Bones.Count;
            boneInfos = new BoneInfo[boneCnt];

            if (keyframeend != 0)
            {
                StartDuration = (float)keyframestart / fps;
                EndDuration   = (float)keyframeend / fps;
            }

            for (int b = 0; b < boneInfos.Length; b++)
            {
                // Create it
                boneInfos[b] = new BoneInfo(clip.Bones[b]);

                // Assign it to a model bone
                boneInfos[b].SetModel(model);
            }

            Rewind();
        }
Exemplo n.º 6
0
 public AvatarSkeleton(AvatarLad lad, Dictionary <uint, double> visualParamInputs)
 {
     foreach (BoneInfo bone in DefaultSkeleton.Bones)
     {
         var newBone = new BoneInfo(bone);
         Bones.Add(newBone);
         BuildBonesRef(newBone);
     }
     foreach (KeyValuePair <uint, AvatarLad.VisualParam> kvp in lad.VisualParams)
     {
         double val;
         if (visualParamInputs.TryGetValue(kvp.Key, out val))
         {
             foreach (AvatarLad.BoneParam bp in kvp.Value.Bones)
             {
                 Vector3  scale  = bp.Scale * val;
                 Vector3  offset = bp.Offset * val;
                 BoneInfo bone;
                 if (BonesRef.TryGetValue(bp.Name, out bone))
                 {
                     bone.Scale     = bone.Scale.ElementMultiply(scale);
                     bone.Position += offset;
                 }
                 foreach (CollisionVolume colvol in bone.CollisionVolumes)
                 {
                     colvol.Scale = colvol.Scale.ElementMultiply(scale);
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
        public void Serialize(List <BoneInfo> result, float boneRange, MyCubeGrid grid)
        {
            var info = new BoneInfo();

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Serialize");

            float boneErrorSquared = GetMaxBoneError(grid.GridSize);

            boneErrorSquared *= boneErrorSquared;

            foreach (var bone in Bones)
            {
                Vector3I?cube = GetCubeFromBone(bone.Key, grid);
                if (cube != null)
                {
                    var   boneOffset = GetDefinitionOffsetWithNeighbours(cube.Value, bone.Key, grid);
                    float distance   = Math.Abs(boneOffset.LengthSquared() - bone.Value.LengthSquared());
                    if (distance > boneErrorSquared)
                    {
                        info.BonePosition = bone.Key;
                        info.BoneOffset   = Vector3UByte.Normalize(bone.Value, boneRange);
                        if (!Vector3UByte.IsMiddle(info.BoneOffset)) // Middle number means zero in floats
                        {
                            result.Add(info);
                        }
                    }
                }
            }
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Exemplo n.º 8
0
        private static void CreateAiNodesFromBoneInfos(List <BoneInfo> boneInfos, Ai.Scene aiScene,
                                                       Ai.Node aiParentBone, BoneInfo parentBoneInfo, Dictionary <string, Ai.Node> convertedBones)
        {
            foreach (var boneInfo in boneInfos)
            {
                if (boneInfo.Parent != parentBoneInfo)
                {
                    continue;
                }

                if (!convertedBones.TryGetValue(boneInfo.Name, out var aiBoneNode))
                {
                    aiBoneNode = CreateAiNodeFromBoneInfo(boneInfo, parentBoneInfo?.InverseBindPoseMatrix ?? Matrix4x4.Identity);

                    if (aiParentBone == null)
                    {
                        aiScene.RootNode.Children.Add(aiBoneNode);
                    }
                    else
                    {
                        aiParentBone.Children.Add(aiBoneNode);
                    }

                    convertedBones.Add(boneInfo.Name, aiBoneNode);
                }

                CreateAiNodesFromBoneInfos(boneInfos, aiScene, aiBoneNode, boneInfo, convertedBones);
            }
        }
Exemplo n.º 9
0
    private BoneInfo FindBone(string name)
    {
        IEnumerator enumerator = bones.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                BoneInfo boneInfo = (BoneInfo)enumerator.Current;
                if (boneInfo.name == name)
                {
                    return(boneInfo);
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
        return(null);
    }
Exemplo n.º 10
0
        private void CalculateMass()
        {
            this.CalculateMassRecurse(this.rootBone);
            float       num        = this.totalMass / this.rootBone.summedMass;
            IEnumerator enumerator = this.bones.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    BoneInfo  current   = (BoneInfo)enumerator.Current;
                    Rigidbody component = current.anchor.GetComponent <Rigidbody>();
                    component.mass *= num;
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            this.CalculateMassRecurse(this.rootBone);
        }
Exemplo n.º 11
0
        private BoneInfo[] GetBoneInfos()
        {
            BoneInfo[] ret = new BoneInfo[_allBoneDatas.Count];
            for (int i = 0; i < ret.Length; i++)
            {
                ret[i]             = new BoneInfo();
                ret[i].name        = _allBoneDatas[i].transform.name;
                ret[i].bindPose    = _allBoneDatas[i].bindPose;
                ret[i].parentIdx   = -1;
                ret[i].isJoint     = _allBoneDatas[i].isJoint;
                ret[i].isPureJoint = _allBoneDatas[i].isPureJoint;
                ret[i].exposed     = _allBoneDatas[i].exposed;

                Transform parent = _allBoneDatas[i].transform.parent;
                for (int j = 0; j < _allBoneDatas.Count; j++)
                {
                    if (_allBoneDatas[j].transform == parent)
                    {
                        ret[i].parentIdx = j;
                        break;
                    }
                }
            }

            return(ret);
        }
Exemplo n.º 12
0
        public void Initialize(AnimationClip clip, MyCharacter model, float weight, float timeScale, bool justFirstFrame, string[] explicitBones = null)
        {
            m_clip           = clip;
            m_model          = model;
            m_weight         = weight;
            m_timeScale      = timeScale;
            m_justFirstFrame = justFirstFrame;

            // Create the bone information classes
            m_boneCount = explicitBones == null ? clip.Bones.Count : explicitBones.Length;
            if (m_boneInfos == null || m_boneInfos.Length < m_boneCount)
            {
                m_boneInfos = new BoneInfo[m_boneCount];
            }

            for (int b = 0; b < m_boneCount; b++)
            {
                // Create it
                m_boneInfos[b] = new BoneInfo(explicitBones == null ? clip.Bones[b] : FindBone(clip.Bones, explicitBones[b]), this);

                // Assign it to a model bone
                m_boneInfos[b].SetModel(model);
            }

            Position = 0;

            m_initialized = true;
        }
        void PrepareBones()
        {
            if (root)
            {
                worldRight   = root.TransformDirection(right);
                worldUp      = root.TransformDirection(up);
                worldForward = root.TransformDirection(forward);
            }

            bones = new ArrayList();

            rootBone         = new BoneInfo();
            rootBone.name    = "Root";
            rootBone.anchor  = root;
            rootBone.parent  = null;
            rootBone.density = 2.5F;
            bones.Add(rootBone);

            AddMirroredJoint("Hips", leftHips, rightHips, "Root", worldRight, worldForward, -20, 70, 30, typeof(CapsuleCollider), 0.3F, 1.5F);
            AddMirroredJoint("Knee", leftKnee, rightKnee, "Hips", worldRight, worldForward, -80, 0, 0, typeof(CapsuleCollider), 0.25F, 1.5F);
            // AddMirroredJoint ("Hips", leftHips, rightHips, "Root", worldRight, worldForward, -0, -70, 30, typeof(CapsuleCollider), 0.3F, 1.5F);
            // AddMirroredJoint ("Knee", leftKnee, rightKnee, "Hips", worldRight, worldForward, -0, -50, 0, typeof(CapsuleCollider), .25F, 1.5F);

            AddJoint("Middle Spine", middleSpine, "Root", worldRight, worldForward, -20, 20, 10, null, 1, 2.5F);

            AddMirroredJoint("Arm", leftArm, rightArm, "Middle Spine", worldUp, worldForward, -70, 10, 50, typeof(CapsuleCollider), 0.25F, 1.0F);
            AddMirroredJoint("Elbow", leftElbow, rightElbow, "Arm", worldForward, worldUp, -90, 0, 0, typeof(CapsuleCollider), 0.20F, 1.0F);

            AddJoint("Head", head, "Middle Spine", worldRight, worldForward, -40, 25, 25, null, 1, 1.0F);
        }
        void Awake()
        {
            print("=================\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!cam postion = " + mainCamera.transform.position);
            if (m_SyncLevel == 0)
            {
                m_Bones = m_Target.GetComponentsInChildren <Transform>();
            }
            else
            {
                m_Bones = BuildBones(m_Target, 0).ToArray();
            }

            m_BoneInfos = new BoneInfo[m_Bones.Length];
            for (int i = 0; i < m_Bones.Length; i++)
            {
                m_BoneInfos[i]        = new BoneInfo();
                m_BoneInfos[i].m_bone = m_Bones[i];
            }

            // cache these to avoid per-frame allocations.
            if (localPlayerAuthority)
            {
                m_LocalTransformWriter = new NetworkWriter();
            }
            numBones = m_Bones.Length;

            NetworkServer.RegisterHandler(SkeletonMsg, HandleSkeleton);
        }
        string CheckConsistency()
        {
            PrepareBones();
            Hashtable map = new Hashtable();

            foreach (BoneInfo bone in bones)
            {
                if (bone.anchor)
                {
                    if (map[bone.anchor] != null)
                    {
                        BoneInfo oldBone = (BoneInfo)map[bone.anchor];
                        return(String.Format("{0} and {1} may not be assigned to the same bone.", bone.name, oldBone.name));
                    }
                    map[bone.anchor] = bone;
                }
            }

            foreach (BoneInfo bone in bones)
            {
                if (bone.anchor == null)
                {
                    return(String.Format("{0} has not been assigned yet.\n", bone.name));
                }
            }

            return("");
        }
        void AddJoint(string name, Transform anchor, string parent, Vector3 worldTwistAxis, Vector3 worldSwingAxis, float minLimit, float maxLimit, float swingLimit, Type colliderType, float radiusScale, float density)
        {
            BoneInfo bone = new BoneInfo();

            bone.name         = name;
            bone.anchor       = anchor;
            bone.axis         = worldTwistAxis;
            bone.normalAxis   = worldSwingAxis;
            bone.minLimit     = minLimit;
            bone.maxLimit     = maxLimit;
            bone.swingLimit   = swingLimit;
            bone.density      = density;
            bone.colliderType = colliderType;
            bone.radiusScale  = radiusScale;

            if (FindBone(parent) != null)
            {
                bone.parent = FindBone(parent);
            }
            else if (name.StartsWith("Left"))
            {
                bone.parent = FindBone("Left " + parent);
            }
            else if (name.StartsWith("Right"))
            {
                bone.parent = FindBone("Right " + parent);
            }


            bone.parent.children.Add(bone);
            bones.Add(bone);
        }
Exemplo n.º 17
0
 private void LoadBonesInfo(AnimatedNode node, BoneInfo parent = null)
 {
     if (bonesMapping.ContainsKey(node.Name))
     {
         var point     = Vector3.Zero;
         var boneIndex = bonesMapping[node.Name];
         var bone      = Bones[boneIndex];
         var transform = m_globalInverseTransform * bone.BoneOffset;
         transform.Transpose();
         bone.Point = -Vector3.Transform(point, transform);
         if (parent != null)
         {
             var line = new BoneLineInfo
             {
                 Point     = bone.Point,
                 Direction = bone.Point - parent.Point
             };
             line.Length     = line.Direction.Length;
             line.Direction /= line.Length;
             parent.Lines.Add(line);
         }
         foreach (var child in node.Childs)
         {
             LoadBonesInfo(child, bone);
         }
     }
     else
     {
         foreach (var child in node.Childs)
         {
             LoadBonesInfo(child, parent);
         }
     }
 }
Exemplo n.º 18
0
        private void BuildCapsules()
        {
            IEnumerator enumerator = this.bones.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    BoneInfo current = (BoneInfo)enumerator.Current;
                    if (current.colliderType == typeof(CapsuleCollider))
                    {
                        int   num;
                        float num2;
                        if (current.children.Count == 1)
                        {
                            BoneInfo info2    = (BoneInfo)current.children[0];
                            Vector3  position = info2.anchor.position;
                            CalculateDirection(current.anchor.InverseTransformPoint(position), out num, out num2);
                        }
                        else
                        {
                            Vector3 vector2 = (current.anchor.position - current.parent.anchor.position) + current.anchor.position;
                            CalculateDirection(current.anchor.InverseTransformPoint(vector2), out num, out num2);
                            if (current.anchor.GetComponentsInChildren(typeof(Transform)).Length > 1)
                            {
                                Bounds bounds = new Bounds();
                                foreach (Transform transform in current.anchor.GetComponentsInChildren(typeof(Transform)))
                                {
                                    bounds.Encapsulate(current.anchor.InverseTransformPoint(transform.position));
                                }
                                if (num2 > 0f)
                                {
                                    num2 = bounds.max[num];
                                }
                                else
                                {
                                    num2 = bounds.min[num];
                                }
                            }
                        }
                        CapsuleCollider collider = current.anchor.gameObject.AddComponent <CapsuleCollider>();
                        collider.direction = num;
                        Vector3 zero = Vector3.zero;
                        zero[num]       = num2 * 0.5f;
                        collider.center = zero;
                        collider.height = Mathf.Abs(num2);
                        collider.radius = Mathf.Abs((float)(num2 * current.radiusScale));
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
Exemplo n.º 19
0
 public void UpdateBones()
 {
     for (int i = 0; i < m_boneCount; i++)
     {
         BoneInfo bone = m_boneInfos[i];
         bone.SetPosition(m_position);
     }
 }
Exemplo n.º 20
0
        private static void SetPosition(BoneInfo boneInfo, Vector3 receivedPosition)
        {
            // if (boneInfo.Rigidbody != null)
            //     boneInfo.Rigidbody.MovePosition(boneInfo.Transform.TransformVector(receivedPosition));
            // else
            //     boneInfo.Transform.localPosition = receivedPosition;

            boneInfo.Transform.localPosition = receivedPosition;
        }
Exemplo n.º 21
0
        private void Load(Stream s)
        {
            var doc = new XmlDocument
            {
                XmlResolver = null
            };

            doc.Load(s);
            var rootelem = doc.GetElementsByTagName("linden_skeleton")[0] as XmlElement;

            if (rootelem == null)
            {
                throw new InvalidDataException();
            }
            var stack = new List <KeyValuePair <XmlElement, BoneInfo> >();

            foreach (XmlElement elem in rootelem.ChildNodes.OfType <XmlElement>())
            {
                if (elem.Name == "bone")
                {
                    var info = new BoneInfo(elem);
                    BonesRef.Add(info.Name, info);
                    foreach (string alias in info.Aliases)
                    {
                        BonesRef.Add(alias, info);
                    }
                    Bones.Add(info);
                    stack.Add(new KeyValuePair <XmlElement, BoneInfo>(elem, info));
                }
            }

            while (stack.Count != 0)
            {
                KeyValuePair <XmlElement, BoneInfo> kvp = stack[0];
                stack.RemoveAt(0);

                foreach (XmlElement elem in kvp.Key.ChildNodes.OfType <XmlElement>())
                {
                    if (elem.Name == "bone")
                    {
                        var info = new BoneInfo(elem);
                        kvp.Value.Children.Add(info);
                        BonesRef.Add(info.Name, info);
                        foreach (string alias in info.Aliases)
                        {
                            BonesRef.Add(alias, info);
                        }
                        stack.Add(new KeyValuePair <XmlElement, BoneInfo>(elem, info));
                    }
                    else if (elem.Name == "collision_volume")
                    {
                        var colvol = new CollisionVolume(elem);
                        kvp.Value.CollisionVolumes.Add(colvol);
                    }
                }
            }
        }
Exemplo n.º 22
0
        private BoneInfo[] GetAllBonesAndDataInList()
        {
            //Create list of bones
            List <BoneInfo> bonesList = new List <BoneInfo>();

            //Get the skinned mesh renderer
            SkinnedMeshRenderer meshRender = GetComponent <SkinnedMeshRenderer>();

            //Start the scan
            if (meshRender != null && meshRender.sharedMesh != null)
            {
                //Get all bones
                Transform[] allBonesTransform = meshRender.bones;

                //Create all boneinfo
                for (int i = 0; i < allBonesTransform.Length; i++)
                {
                    BoneInfo boneInfo = new BoneInfo();
                    boneInfo.transform      = allBonesTransform[i];
                    boneInfo.name           = allBonesTransform[i].name;
                    boneInfo.gameObject     = allBonesTransform[i].transform.gameObject;
                    boneInfo.transformPath  = GetGameObjectPath(allBonesTransform[i]);
                    boneInfo.hierarchyIndex = i;

                    bonesList.Add(boneInfo);
                }

                //Associate each vertice influenced by each bone to respective key
                for (int i = 0; i < meshRender.sharedMesh.vertexCount; i++)
                {
                    //Verify if exists a weight of a possible bone X influencing this vertice. Create a vertice data that stores and link this vertice inside your respective BoneInfo
                    if (meshRender.sharedMesh.boneWeights[i].weight0 > 0)
                    {
                        int boneIndexOfInfluencerBoneOfThisVertice = meshRender.sharedMesh.boneWeights[i].boneIndex0;
                        bonesList[boneIndexOfInfluencerBoneOfThisVertice].verticesOfThis.Add(new VerticeData(bonesList[boneIndexOfInfluencerBoneOfThisVertice], meshRender.sharedMesh.boneWeights[i].weight0, i));
                    }
                    if (meshRender.sharedMesh.boneWeights[i].weight1 > 0)
                    {
                        int boneIndexOfInfluencerBoneOfThisVertice = meshRender.sharedMesh.boneWeights[i].boneIndex1;
                        bonesList[boneIndexOfInfluencerBoneOfThisVertice].verticesOfThis.Add(new VerticeData(bonesList[boneIndexOfInfluencerBoneOfThisVertice], meshRender.sharedMesh.boneWeights[i].weight1, i));
                    }
                    if (meshRender.sharedMesh.boneWeights[i].weight2 > 0)
                    {
                        int boneIndexOfInfluencerBoneOfThisVertice = meshRender.sharedMesh.boneWeights[i].boneIndex2;
                        bonesList[boneIndexOfInfluencerBoneOfThisVertice].verticesOfThis.Add(new VerticeData(bonesList[boneIndexOfInfluencerBoneOfThisVertice], meshRender.sharedMesh.boneWeights[i].weight2, i));
                    }
                    if (meshRender.sharedMesh.boneWeights[i].weight3 > 0)
                    {
                        int boneIndexOfInfluencerBoneOfThisVertice = meshRender.sharedMesh.boneWeights[i].boneIndex3;
                        bonesList[boneIndexOfInfluencerBoneOfThisVertice].verticesOfThis.Add(new VerticeData(bonesList[boneIndexOfInfluencerBoneOfThisVertice], meshRender.sharedMesh.boneWeights[i].weight3, i));
                    }
                }
            }

            //Return the list
            return(bonesList.ToArray());
        }
        /// <summary>
        /// 指定された<see cref="VRMSpringBone"/>を基に<see cref="DynamicBone"/>を設定します。
        /// </summary>
        /// <param name="springBone"></param>
        /// <param name="dynamicBoneColliderGroups">キーに<see cref="VRMSpringBoneColliderGroup"/>、値に対応する<see cref="DynamicBoneCollider"/>のリストを持つジャグ配列。</param>
        /// <param name="swayingParametersConverter"></param>
        private static void ConvertVRMSpringBone(
            VRMSpringBone springBone,
            IDictionary <VRMSpringBoneColliderGroup, IEnumerable <MonoBehaviour> > dynamicBoneColliderGroups,
            Converter.SwayingParametersConverter swayingParametersConverter
            )
        {
            var springBoneParameters = new SpringBoneParameters(stiffnessForce: springBone.m_stiffnessForce, dragForce: springBone.m_dragForce);
            var boneInfo             = new BoneInfo(vrmMeta: springBone.gameObject.GetComponentsInParent <VRMMeta>()[0]);

            foreach (var transform in springBone.RootBones)
            {
                var dynamicBone = springBone.gameObject.AddComponent(DynamicBoneType);
                DynamicBoneType.GetField("m_Root").SetValue(dynamicBone, transform);
                DynamicBoneType.GetField("m_Exclusions").SetValue(dynamicBone, new List <Transform>());

                DynamicBoneParameters dynamicBoneParameters = null;
                if (swayingParametersConverter != null)
                {
                    dynamicBoneParameters = swayingParametersConverter(
                        springBoneParameters: springBoneParameters,
                        boneInfo: boneInfo
                        );
                }
                if (dynamicBoneParameters != null)
                {
                    DynamicBoneType.GetField("m_Damping").SetValue(dynamicBone, dynamicBoneParameters.Damping);
                    DynamicBoneType.GetField("m_DampingDistrib")
                    .SetValue(dynamicBone, dynamicBoneParameters.DampingDistrib);
                    DynamicBoneType.GetField("m_Elasticity").SetValue(dynamicBone, dynamicBoneParameters.Elasticity);
                    DynamicBoneType.GetField("m_ElasticityDistrib")
                    .SetValue(dynamicBone, dynamicBoneParameters.ElasticityDistrib);
                    DynamicBoneType.GetField("m_Stiffness").SetValue(dynamicBone, dynamicBoneParameters.Stiffness);
                    DynamicBoneType.GetField("m_StiffnessDistrib")
                    .SetValue(dynamicBone, dynamicBoneParameters.StiffnessDistrib);
                    DynamicBoneType.GetField("m_Inert").SetValue(dynamicBone, dynamicBoneParameters.Inert);
                    DynamicBoneType.GetField("m_InertDistrib")
                    .SetValue(dynamicBone, dynamicBoneParameters.InertDistrib);
                }

                DynamicBoneType.GetField("m_Gravity")
                .SetValue(dynamicBone, springBone.m_gravityDir * springBone.m_gravityPower);
                DynamicBoneType.GetField("m_Radius").SetValue(dynamicBone, springBone.m_hitRadius);
                if (dynamicBoneColliderGroups != null)
                {
                    var        colliders = Activator.CreateInstance(type: DynamicBoneColliderBaseListType);
                    MethodInfo addMethod = DynamicBoneColliderBaseListType.GetMethod("Add");
                    foreach (var collider in springBone.ColliderGroups.SelectMany(
                                 colliderGroup => dynamicBoneColliderGroups[colliderGroup]
                                 ))
                    {
                        addMethod.Invoke(colliders, new[] { collider });
                    }
                    DynamicBoneType.GetField("m_Colliders").SetValue(dynamicBone, colliders);
                }
            }
        }
	void CalculateMassRecurse (BoneInfo bone)
	{
		float mass = bone.anchor.GetComponent<Rigidbody>().mass;
		foreach (BoneInfo child in bone.children)
		{
			CalculateMassRecurse (child);
			mass += child.summedMass;
		}
		bone.summedMass = mass;
	}
Exemplo n.º 25
0
        private static void SetRotation(BoneInfo boneInfo, Vector3 receivedRotation)
        {
            // Quaternion localRotation = Quaternion.Euler(receivedRotation);
            // if (boneInfo.Rigidbody != null)
            //     boneInfo.Rigidbody.MoveRotation(boneInfo.Transform.TransformRotation(localRotation));
            // else
            //     boneInfo.Transform.localRotation = localRotation;

            boneInfo.Transform.localRotation = Quaternion.Euler(receivedRotation);
        }
Exemplo n.º 26
0
        private static Ai.Node CreateAiNodeFromBoneInfo(BoneInfo boneInfo, Matrix4x4 inverseParentTransformation)
        {
            var aiNode = new Ai.Node(boneInfo.Name);

            Matrix4x4.Invert(boneInfo.InverseBindPoseMatrix, out var transformation);

            aiNode.Transform = Matrix4x4.Multiply(transformation, inverseParentTransformation).ToAssimpTransposed();

            return(aiNode);
        }
Exemplo n.º 27
0
    private void BuildCapsules()
    {
        IEnumerator enumerator = bones.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                BoneInfo boneInfo = (BoneInfo)enumerator.Current;
                if (boneInfo.colliderType == typeof(CapsuleCollider))
                {
                    int   direction;
                    float distance;
                    if (boneInfo.children.Count == 1)
                    {
                        BoneInfo boneInfo2 = (BoneInfo)boneInfo.children[0];
                        Vector3  position  = boneInfo2.anchor.position;
                        CalculateDirection(boneInfo.anchor.InverseTransformPoint(position), out direction, out distance);
                    }
                    else
                    {
                        Vector3 position2 = boneInfo.anchor.position - boneInfo.parent.anchor.position + boneInfo.anchor.position;
                        CalculateDirection(boneInfo.anchor.InverseTransformPoint(position2), out direction, out distance);
                        if (boneInfo.anchor.GetComponentsInChildren(typeof(Transform)).Length > 1)
                        {
                            Bounds      bounds = default(Bounds);
                            Component[] componentsInChildren = boneInfo.anchor.GetComponentsInChildren(typeof(Transform));
                            for (int i = 0; i < componentsInChildren.Length; i++)
                            {
                                Transform transform = (Transform)componentsInChildren[i];
                                bounds.Encapsulate(boneInfo.anchor.InverseTransformPoint(transform.position));
                            }
                            distance = ((!(distance > 0f)) ? bounds.min[direction] : bounds.max[direction]);
                        }
                    }
                    CapsuleCollider capsuleCollider = boneInfo.anchor.gameObject.AddComponent <CapsuleCollider>();
                    capsuleCollider.direction = direction;
                    Vector3 zero = Vector3.zero;
                    zero[direction]        = distance * 0.5f;
                    capsuleCollider.center = zero;
                    capsuleCollider.height = Mathf.Abs(distance);
                    capsuleCollider.radius = Mathf.Abs(distance * boneInfo.radiusScale);
                    PlayerRef.Colliders.Add(capsuleCollider);
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
    }
Exemplo n.º 28
0
        private string CheckConsistency()
        {
            this.PrepareBones();
            Hashtable   hashtable  = new Hashtable();
            IEnumerator enumerator = this.bones.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    BoneInfo current = (BoneInfo)enumerator.Current;
                    if (current.anchor != null)
                    {
                        if (hashtable[current.anchor] != null)
                        {
                            BoneInfo info2 = (BoneInfo)hashtable[current.anchor];
                            return($"{current.name} and {info2.name} may not be assigned to the same bone.");
                        }
                        hashtable[current.anchor] = current;
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            IEnumerator enumerator2 = this.bones.GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    BoneInfo info3 = (BoneInfo)enumerator2.Current;
                    if (info3.anchor == null)
                    {
                        return($"{info3.name} has not been assigned yet.
");
                    }
                }
            }
            finally
            {
                IDisposable disposable2 = enumerator2 as IDisposable;
                if (disposable2 != null)
                {
                    disposable2.Dispose();
                }
            }
            return("");
        }
Exemplo n.º 29
0
    public void SetTarget(GameObject target)
    {
        this.target = target;
        selected    = -1;
        if (target == null)
        {
            return;
        }

        Animator animator = target.GetComponent(typeof(Animator)) as Animator;

        if (animator == null)
        {
            return;
        }

        avatar = animator.avatar;
        if (avatar == null || !avatar.isValid || !avatar.isHuman)
        {
            return;
        }

        muscleMinMaxValues = PSMuscleDefine.GetMuscleMinMaxValues();

        Array boneArray = Enum.GetValues(typeof(HumanBodyBones));

        Array.Sort(boneArray);

        boneInfos = new BoneInfo[HumanTrait.BoneCount];

        for (int i = 0; i < HumanTrait.BoneCount; i++)
        {
            BoneInfo info = new BoneInfo();
            info.bone          = animator.GetBoneTransform((HumanBodyBones)boneArray.GetValue(i));
            info.humanBoneName = HumanTrait.BoneName [i];
            info.boneId        = i;

            info.muscleXId = HumanTrait.MuscleFromBone(info.boneId, 0);
            info.muscleYId = HumanTrait.MuscleFromBone(info.boneId, 1);
            info.muscleZId = HumanTrait.MuscleFromBone(info.boneId, 2);
            if (info.muscleXId != -1 || info.muscleYId != -1 || info.muscleZId != -1)
            {
                boneInfos [i] = info;
            }
        }

        // get avatar methods
        getAxisLength   = avatar.GetType().GetMethod("GetAxisLength", flags);
        getPreRotation  = avatar.GetType().GetMethod("GetPreRotation", flags);
        getPostRotation = avatar.GetType().GetMethod("GetPostRotation", flags);
        getZYRoll       = avatar.GetType().GetMethod("GetZYRoll", flags);
        getLimitSign    = avatar.GetType().GetMethod("GetLimitSign", flags);
        getZYPostQ      = avatar.GetType().GetMethod("GetZYPostQ", flags);
    }
Exemplo n.º 30
0
    public void ShowHandles()
    {
        if (target == null || !tabOption.showWindowTool)
        {
            return;
        }

        Vector3 rootT = new Vector3(tabMuscle.rootValue [0], tabMuscle.rootValue [1], tabMuscle.rootValue [2]);

        DrawCap(1000, rootT, tabOption.rootSize, tabOption.rootColor, PSTabOption.caps [tabOption.rootShape]);
        if (selected > -1)
        {
            Handles.BeginGUI();
            if (selected == 1000)
            {
                GUILayout.Window(1, new Rect(Screen.width - 220, Screen.height - 180, 200, 100), RootGUI, "Root");
            }
            else
            {
                GUILayout.Window(2, new Rect(Screen.width - 220, Screen.height - 180, 200, 100), MuscleGUI, boneInfos [selected].humanBoneName);
            }
            Handles.EndGUI();
        }

        for (int i = 0; i < boneInfos.Length; i++)
        {
            BoneInfo rot = boneInfos [i];
            if (rot == null || rot.bone == null)
            {
                continue;
            }

            if (tabOption.showBoneNames && (!tabOption.showSelectedNameOnly || selected == i))
            {
                DrawLabel(rot.bone.position, rot.humanBoneName);
            }

            DrawCap(i, rot.bone.position, tabOption.boneSize, tabOption.boneColor, PSTabOption.caps [tabOption.boneShape]);
        }

        if (selected == 1000)
        {
            DrawRootHandles();
        }
        else if (selected > -1)
        {
            DrawMuscleHandle();
        }

        if (tabOption.showSkeleton)
        {
            DrawSkeleton(target.transform, true);
        }
    }
Exemplo n.º 31
0
 public bool IsSame()
 {
     bool r=true;
     if(_bones.Count<transformsToSend.Count){
         _bones.Clear();
         foreach(Transform boneTf in transformsToSend){
             BoneInfo bInfo=new BoneInfo();
             bInfo.localPos=boneTf.localPosition;
             bInfo.localRot=boneTf.localRotation;
             _bones.Add(boneTf,bInfo);
         }
         r=false;
     }else if(_bones.Count==transformsToSend.Count){
         foreach(Transform boneTf in transformsToSend){
             BoneInfo bInfo=_bones[boneTf];
             r=r&&bInfo.localPos==boneTf.localPosition&&bInfo.localRot==boneTf.localRotation;
         }
     }
     return r;
 }
Exemplo n.º 32
0
        /// <summary>
        /// Constructor for the animation player. It makes the 
        /// association between a clip and a model and sets up for playing
        /// </summary>
        /// <param name="clip"></param>
        public AnimationPlayer(AnimationClip clip, AnimatedModel model)
        {
            this.clip = clip;
            this.model = model;

            // Create the bone information classes
            boneCnt = clip.Bones.Count;
            boneInfos = new BoneInfo[boneCnt];

            for(int b=0;  b<boneInfos.Length;  b++)
            {
                // Create it
                boneInfos[b] = new BoneInfo(clip.Bones[b]);

                // Assign it to a model bone
                boneInfos[b].SetModel(model);
            }

            Rewind();
        }
Exemplo n.º 33
0
        public void Serialize(List<BoneInfo> result, float boneRange, MyCubeGrid grid)
        {
            var info = new BoneInfo();
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Serialize");
            
            float boneErrorSquared = GetMaxBoneError(grid.GridSize);
            boneErrorSquared *= boneErrorSquared;

            foreach (var bone in Bones)
            {
                Vector3I? cube = GetCubeFromBone(bone.Key, grid);
                if (cube != null)
                {
                    var boneOffset = GetDefinitionOffsetWithNeighbours(cube.Value, bone.Key, grid);
                    float distance = Math.Abs(boneOffset.LengthSquared() - bone.Value.LengthSquared());
                    if (distance > boneErrorSquared)
                    {
                        info.BonePosition = bone.Key;
                        info.BoneOffset = Vector3UByte.Normalize(bone.Value, boneRange);
                        if (!Vector3UByte.IsMiddle(info.BoneOffset)) // Middle number means zero in floats
                        {
                            result.Add(info);
                        }
                    }
                }
            }
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
Exemplo n.º 34
0
        public void Initialize(AnimationPlayer player)
        {
            if (m_hash != 0)
            {
                CachedAnimationPlayers.Remove(m_hash);
                m_hash = 0;
            }

            Name = player.Name;
            m_duration = player.m_duration;
            m_skinnedEntity = player.m_skinnedEntity;
            m_weight = player.Weight;
            m_timeScale = player.m_timeScale;
            m_frameOption = player.m_frameOption;

            foreach(var list in m_boneLODs.Values)
                list.Clear();
            //m_boneLODs.Clear();

            m_boneCount = player.m_boneCount;
            if (m_boneInfos == null || m_boneInfos.Length < m_boneCount)
                m_boneInfos = new BoneInfo[m_boneCount];


            Position = player.Position;


            for (int b = 0; b < m_boneCount; b++)
            {
                var boneInfo = m_boneInfos[b];
                if (boneInfo == null)
                {
                    boneInfo = new BoneInfo();
                    m_boneInfos[b] = boneInfo;
                }

                // Create it
                boneInfo.ClipBone = player.m_boneInfos[b].ClipBone;
                boneInfo.Player = this;
                    
                // Assign it to a model bone
                boneInfo.SetModel(m_skinnedEntity);
                boneInfo.CurrentKeyframe = player.m_boneInfos[b].CurrentKeyframe;
                boneInfo.SetPosition(Position);


                if (player.m_boneLODs != null && boneInfo.ModelBone != null && ENABLE_ANIMATION_LODS)
                {
                    foreach (var boneLOD in player.m_boneLODs)
                    {
                        List<BoneInfo> lodBones;
                        if (!m_boneLODs.TryGetValue(boneLOD.Key, out lodBones))
                        {
                            lodBones = new List<BoneInfo>();
                            m_boneLODs.Add(boneLOD.Key, lodBones);
                        }

                        foreach (var boneName in boneLOD.Value)
                        {
                            if (boneName.ModelBone == null)
                                continue;

                            if (boneInfo.ModelBone.Name == boneName.ModelBone.Name)
                            {
                                lodBones.Add(boneInfo);
                                break;
                            }
                        }
                    }
                }

                if (MyFakes.ENABLE_BONES_AND_ANIMATIONS_DEBUG)
                {
                    int index;
                    System.Diagnostics.Debug.Assert(m_skinnedEntity.AnimationController.FindBone(boneInfo.ClipBone.Name, out index) != null, "Can not find clip bone with name: " + boneInfo.ClipBone.Name + " in model: " + m_skinnedEntity.Name);
                }
            }


            m_initialized = true;
        }
Exemplo n.º 35
0
        public void Initialize(MyModel animationModel, string playerName, int clipIndex, MySkinnedEntity skinnedEntity, float weight, float timeScale, MyFrameOption frameOption, string[] explicitBones = null, Dictionary<float, string[]> boneLODs = null)
        {
            if (m_hash != 0)
            {
                CachedAnimationPlayers.Remove(m_hash);
                m_hash = 0;
            }

            var clip = animationModel.Animations.Clips[clipIndex];
            Name = MyStringId.GetOrCompute(animationModel.AssetName + " : " + playerName);
            m_duration = (float)clip.Duration;
            m_skinnedEntity = skinnedEntity;
            m_weight = weight;
            m_timeScale = timeScale;
            m_frameOption = frameOption;

            foreach (var list in m_boneLODs.Values)
                list.Clear();
            //m_boneLODs.Clear();

            List<BoneInfo> lod0;
            if (!m_boneLODs.TryGetValue(0, out lod0))
            {
                lod0 = new List<BoneInfo>();
                m_boneLODs.Add(0, lod0);
            }

            // Create the bone information classes
            var maxBoneCount = explicitBones == null ? clip.Bones.Count : explicitBones.Length;
            if (m_boneInfos == null || m_boneInfos.Length < maxBoneCount)
                m_boneInfos = new BoneInfo[maxBoneCount];

            int neededBonesCount = 0;

            for (int b = 0; b < maxBoneCount; b++)
            {
                var bone = explicitBones == null ? clip.Bones[b] : FindBone(clip.Bones, explicitBones[b]);
                if (bone == null)
                    continue;

                if (bone.Keyframes.Count == 0) 
                    continue;

                // Create it
                BoneInfo boneInfo = m_boneInfos[neededBonesCount];
                if(m_boneInfos[neededBonesCount] == null)
                    boneInfo = new BoneInfo(bone, this);
                else
                {
                    boneInfo.Clear();
                    boneInfo.Init(bone, this);
                }

                m_boneInfos[neededBonesCount] = boneInfo;

                // Assign it to a model bone
                m_boneInfos[neededBonesCount].SetModel(skinnedEntity);

                if (boneInfo.ModelBone != null)
                {
                    lod0.Add(boneInfo);

                    if (boneLODs != null)
                    {
                        foreach (var boneLOD in boneLODs)
                        {
                            List<BoneInfo> lodBones;
                            if (!m_boneLODs.TryGetValue(boneLOD.Key, out lodBones))
                            {
                                lodBones = new List<BoneInfo>();
                                m_boneLODs.Add(boneLOD.Key, lodBones);
                            }

                            foreach (var boneName in boneLOD.Value)
                            {
                                if (boneInfo.ModelBone.Name == boneName)
                                {
                                    lodBones.Add(boneInfo);
                                    break;
                                }
                            }
                        }
                    }
                }

                neededBonesCount++;
            }

            m_boneCount = neededBonesCount;

            Position = 0;

            m_initialized = true;
        }
Exemplo n.º 36
0
	void AddJoint (string name, Transform anchor, string parent, Vector3 worldTwistAxis, Vector3 worldSwingAxis, float minLimit, float maxLimit, float swingLimit, Type colliderType, float radiusScale, float density)
	{
		BoneInfo bone = new BoneInfo();
		bone.name = name;
		bone.anchor = anchor;
		bone.axis = worldTwistAxis;
		bone.normalAxis = worldSwingAxis;
		bone.minLimit = minLimit;
		bone.maxLimit = maxLimit;
		bone.swingLimit = swingLimit;
		bone.density = density;
		bone.colliderType = colliderType;
		bone.radiusScale = radiusScale;
		
		if (FindBone (parent) != null)
			bone.parent = FindBone (parent);
		else if (name.StartsWith ("Left"))
			bone.parent = FindBone ("Left " + parent);
		else if (name.StartsWith ("Right"))
			bone.parent = FindBone ("Right "+ parent);		
		
		bone.parent.children.Add(bone);
		bones.Add (bone);
	}
Exemplo n.º 37
0
	void CalculateMassRecurse (BoneInfo bone)
	{
		float mass = bone.anchor.GetComponent<Rigidbody>().mass;
		foreach (BoneInfo child in bone.children)
		{
			CalculateMassRecurse (child);
			mass += child.summedMass;
		}
		bone.summedMass = mass;
	}
        private void LoadBodyMeshes(string daePath, Scene scene, Node node, AnimatedNode animationNode)
        {
            if (node.HasMeshes)
            {
                var vertexPositions = new List<float>();
                var vertexNormals = new List<float>();
                var vertexTextureCoordinates = new List<float>();
                var vertexBoneIndices = new List<float>();
                var vertexBoneWeights = new List<float>();
                var indeces = new List<uint>();

                var fi = new FileInfo(daePath);
                foreach (var index in node.MeshIndices)
                {
                    var mesh = scene.Meshes[index];

                    var hasTexCoords = mesh.HasTextureCoords(0);

                    vertexPositions.Clear();
                    vertexNormals.Clear();
                    vertexTextureCoordinates.Clear();
                    vertexBoneIndices.Clear();
                    vertexBoneWeights.Clear();
                    indeces.Clear();

                    for (var i = 0; i < mesh.VertexCount; i++)
                    {
                        var vector = mesh.Vertices[i];
                        vertexPositions.Add(vector.X);
                        vertexPositions.Add(vector.Y);
                        vertexPositions.Add(vector.Z);

                        vector = mesh.HasNormals ? mesh.Normals[i] : ZERO_VECTRO3D;
                        vertexNormals.Add(vector.X);
                        vertexNormals.Add(vector.Y);
                        vertexNormals.Add(vector.Z);
                        vector = hasTexCoords ? mesh.GetTextureCoords(0)[i] : ZERO_VECTRO3D;
                        vertexTextureCoordinates.Add(vector.X);
                        vertexTextureCoordinates.Add(1.0f - vector.Y);
                        vertexBoneIndices.AddRange(new[] { 0.0f, 0.0f, 0.0f, 0.0f });
                        vertexBoneWeights.AddRange(new[] { 0.0f, 0.0f, 0.0f, 0.0f });
                    }

                    foreach (var face in mesh.Faces)
                    {
                        indeces.Add(face.Indices[0]);
                        indeces.Add(face.Indices[1]);
                        indeces.Add(face.Indices[2]);
                    }

                    if (mesh.HasBones)
                    {
                        foreach (var bone in mesh.Bones)
                        {
                            if (!bone.HasVertexWeights)
                                continue;
                            int boneIndex;
                            if (bonesMapping.ContainsKey(bone.Name))
                            {
                                boneIndex = bonesMapping[bone.Name];
                            }
                            else
                            {
                                boneIndex = Bones.Count;
                                var boneInfo = new BoneInfo
                                                   {
                                                       BoneOffset = FromMatrix(bone.OffsetMatrix),
                                                   };
                                Bones.Add(boneInfo);
                                bonesMapping.Add(bone.Name, boneIndex);
                            }
                            foreach (var weight in bone.VertexWeights)
                            {
                                var vi = (int)weight.VertexID * 4;
                                for (var i = 0; i < 4; i++)
                                {
                                    if (vertexBoneWeights[vi + i] == 0.0f)
                                    {
                                        vertexBoneIndices[vi + i] = boneIndex;
                                        vertexBoneWeights[vi + i] = weight.Weight;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    var mtr = scene.Materials[mesh.MaterialIndex];

                    var texturePath = string.Empty;
                    var transparentPath = string.Empty;
                    if (mtr.GetTextureCount(TextureType.Diffuse) > 0)
                    {
                        var tex = mtr.GetTexture(TextureType.Diffuse, 0);
                        texturePath = Path.Combine(fi.DirectoryName, tex.FilePath);

                        transparentPath = Path.Combine(Path.GetDirectoryName(tex.FilePath), Path.GetFileNameWithoutExtension(tex.FilePath) + "_alpha" + Path.GetExtension(tex.FilePath));
                        transparentPath = File.Exists(transparentPath) ? transparentPath : string.Empty;
                    }

                    var renderMesh = new DynamicRenderMesh(MeshType.Head);
                    if (renderMesh.Create(vertexPositions, vertexNormals, vertexTextureCoordinates, vertexBoneIndices, vertexBoneWeights, indeces, texturePath, transparentPath))
                    {
                        renderMesh.Transform = FromMatrix(node.Transform);
                        renderMesh.Material.DiffuseColor = new Vector4(mtr.ColorDiffuse.R, mtr.ColorDiffuse.G, mtr.ColorDiffuse.B, mtr.ColorDiffuse.A);
                        BodyMeshes.Add(renderMesh);
                    }
                }
            }

            var parentNode = animationNode;
            if (animationNode == null)
            {
                rootNode = new AnimatedNode();
                parentNode = rootNode;
            }

            parentNode.Name = node.Name;
            parentNode.Transform = FromMatrix(node.Transform);

            for (var i = 0; i < node.ChildCount; i++)
            {
                var childNode = new AnimatedNode
                {
                    Parent = parentNode
                };
                LoadBodyMeshes(daePath, scene, node.Children[i], childNode);
                parentNode.Childs.Add(childNode);
            }
        }
Exemplo n.º 39
0
	void PrepareBones ()
	{
		if(Selection.activeGameObject!=null && Selection.activeGameObject.transform.GetComponent<Animator>()!=null)
		{
			animator = Selection.activeGameObject.transform.GetComponent<Animator>();
		}
		if (animator != null) 
		{			
			try {
				root = animator.GetBoneTransform (HumanBodyBones.Hips);
				
				leftHips = animator.GetBoneTransform (HumanBodyBones.LeftUpperLeg);
				leftKnee = animator.GetBoneTransform (HumanBodyBones.LeftLowerLeg);
				leftFoot = animator.GetBoneTransform (HumanBodyBones.LeftFoot);
				
				rightHips = animator.GetBoneTransform (HumanBodyBones.RightUpperLeg);
				rightKnee = animator.GetBoneTransform (HumanBodyBones.RightLowerLeg);
				rightFoot = animator.GetBoneTransform (HumanBodyBones.RightFoot);
				
				leftArm = animator.GetBoneTransform (HumanBodyBones.LeftUpperArm);
				leftElbow = animator.GetBoneTransform (HumanBodyBones.LeftLowerArm);
				
				rightArm = animator.GetBoneTransform (HumanBodyBones.RightUpperArm);
				rightElbow = animator.GetBoneTransform (HumanBodyBones.RightLowerArm);
				
				middleSpine = animator.GetBoneTransform (HumanBodyBones.Chest);

				head = animator.GetBoneTransform (HumanBodyBones.Head);

				EditorUtility.SetDirty(this);
			} catch {
			}
		}
		if (root)
		{
			worldRight = root.TransformDirection(right);
			worldUp = root.TransformDirection(up);
			worldForward = root.TransformDirection(forward);
		}
		
		bones = new ArrayList();
		
		rootBone = new BoneInfo ();
		rootBone.name = "Root";
		rootBone.anchor = root;
		rootBone.parent = null;
		rootBone.density = 2.5F;
		bones.Add (rootBone);
		
		AddMirroredJoint ("Hips", leftHips, rightHips, "Root", worldRight, worldForward, -20, 70, 30, typeof(CapsuleCollider), 0.3F, 1.5F);
		AddMirroredJoint ("Knee", leftKnee, rightKnee, "Hips", worldRight, worldForward, -80, 0, 0, typeof(CapsuleCollider), 0.25F, 1.5F);
		//		AddMirroredJoint ("Hips", leftHips, rightHips, "Root", worldRight, worldForward, -0, -70, 30, typeof(CapsuleCollider), 0.3F, 1.5F);
		//		AddMirroredJoint ("Knee", leftKnee, rightKnee, "Hips", worldRight, worldForward, -0, -50, 0, typeof(CapsuleCollider), .25F, 1.5F);
		
		AddJoint ("Middle Spine", middleSpine, "Root", worldRight, worldForward, -20, 20, 10, null, 1, 2.5F);
		
		AddMirroredJoint ("Arm", leftArm, rightArm, "Middle Spine", worldUp, worldForward, -70, 10, 50, typeof(CapsuleCollider), 0.25F, 1.0F);
		AddMirroredJoint ("Elbow", leftElbow, rightElbow, "Arm", worldForward, worldUp, -90, 0, 0, typeof(CapsuleCollider), 0.20F, 1.0F);
		
		AddJoint ("Head", head, "Middle Spine", worldRight, worldForward, -40, 25, 25, null, 1, 1.0F);
	}
Exemplo n.º 40
0
 private void CalculateMassRecurse(BoneInfo bone)
 {
     float mass = bone.anchor.GetComponent<Rigidbody>().mass;
     IEnumerator enumerator = bone.children.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             BoneInfo current = (BoneInfo) enumerator.Current;
             this.CalculateMassRecurse(current);
             mass += current.summedMass;
         }
     }
     finally
     {
         IDisposable disposable = enumerator as IDisposable;
         if (disposable != null)
         {
             disposable.Dispose();
         }
     }
     bone.summedMass = mass;
 }
 private void LoadBonesInfo(AnimatedNode node, BoneInfo parent = null)
 {
     if (bonesMapping.ContainsKey(node.Name))
     {
         var point = Vector3.Zero;
         var boneIndex = bonesMapping[node.Name];
         var bone = Bones[boneIndex];
         var transform = m_globalInverseTransform * bone.BoneOffset;
         transform.Transpose();
         bone.Point = -Vector3.Transform(point, transform);
         if (parent != null)
         {
             var line = new BoneLineInfo
             {
                 Point = bone.Point,
                 Direction = bone.Point - parent.Point
             };
             line.Length = line.Direction.Length;
             line.Direction /= line.Length;
             parent.Lines.Add(line);
         }
         foreach (var child in node.Childs)
         {
             LoadBonesInfo(child, bone);
         }
     }
     else
     {
         foreach (var child in node.Childs)
         {
             LoadBonesInfo(child, parent);
         }
     }
 }
Exemplo n.º 42
0
 private void AddJoint(string name, Transform anchor, string parent, Vector3 worldTwistAxis, Vector3 worldSwingAxis, float minLimit, float maxLimit, float swingLimit, Type colliderType, float radiusScale, float density)
 {
     BoneInfo info = new BoneInfo {
         name = name,
         anchor = anchor,
         axis = worldTwistAxis,
         normalAxis = worldSwingAxis,
         minLimit = minLimit,
         maxLimit = maxLimit,
         swingLimit = swingLimit,
         density = density,
         colliderType = colliderType,
         radiusScale = radiusScale
     };
     if (this.FindBone(parent) != null)
     {
         info.parent = this.FindBone(parent);
     }
     else if (name.StartsWith("Left"))
     {
         info.parent = this.FindBone("Left " + parent);
     }
     else if (name.StartsWith("Right"))
     {
         info.parent = this.FindBone("Right " + parent);
     }
     info.parent.children.Add(info);
     this.bones.Add(info);
 }
Exemplo n.º 43
0
 private void PrepareBones()
 {
     if (this.pelvis != null)
     {
         this.worldRight = this.pelvis.TransformDirection(this.right);
         this.worldUp = this.pelvis.TransformDirection(this.up);
         this.worldForward = this.pelvis.TransformDirection(this.forward);
     }
     this.bones = new ArrayList();
     this.rootBone = new BoneInfo();
     this.rootBone.name = "Pelvis";
     this.rootBone.anchor = this.pelvis;
     this.rootBone.parent = null;
     this.rootBone.density = 2.5f;
     this.bones.Add(this.rootBone);
     this.AddMirroredJoint("Hips", this.leftHips, this.rightHips, "Pelvis", this.worldRight, this.worldForward, -20f, 70f, 30f, typeof(CapsuleCollider), 0.3f, 1.5f);
     this.AddMirroredJoint("Knee", this.leftKnee, this.rightKnee, "Hips", this.worldRight, this.worldForward, -80f, 0f, 0f, typeof(CapsuleCollider), 0.25f, 1.5f);
     this.AddJoint("Middle Spine", this.middleSpine, "Pelvis", this.worldRight, this.worldForward, -20f, 20f, 10f, null, 1f, 2.5f);
     this.AddMirroredJoint("Arm", this.leftArm, this.rightArm, "Middle Spine", this.worldUp, this.worldForward, -70f, 10f, 50f, typeof(CapsuleCollider), 0.25f, 1f);
     this.AddMirroredJoint("Elbow", this.leftElbow, this.rightElbow, "Arm", this.worldForward, this.worldUp, -90f, 0f, 0f, typeof(CapsuleCollider), 0.2f, 1f);
     this.AddJoint("Head", this.head, "Middle Spine", this.worldRight, this.worldForward, -40f, 25f, 25f, null, 1f, 1f);
 }
Exemplo n.º 44
0
    // When the user pressed the "Generate" button OnWizardOtherButton is called.
    void OnWizardOtherButton()
    {
        // Initialize list
        srcBoneInfoList = new List<BoneInfo>();
        dstBoneInfoList = new List<BoneInfo>();

        // ===== Set src bone info =====

        biSrcRoot = new BoneInfo();
        if (srcRoot != null)
        {
            biSrcRoot.transform = srcRoot;
            biSrcRoot.length    = -1.0f; // No parent
            biSrcRoot.path      = srcRoot.name;
        }
        srcBoneInfoList.Add(biSrcRoot);

        biSrcPelvis = new BoneInfo();
        if (srcPelvis != null)
        {
            biSrcPelvis.transform = srcPelvis;
            biSrcPelvis.length = (srcPelvis.position - srcRoot.position).magnitude;
            biSrcPelvis.path = srcRoot.name + "/" + srcPelvis.name;
        }
        srcBoneInfoList.Add(biSrcPelvis);

        biSrcSpine = new BoneInfo();
        if (srcSpine != null)
        {
            biSrcSpine.transform = srcSpine;
            biSrcSpine.length = (srcSpine.position - srcPelvis.position).magnitude;
            biSrcSpine.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name;
        }
        srcBoneInfoList.Add(biSrcSpine);

        // Src LThigh

        biSrcLThigh = new BoneInfo();
        if (srcLThigh != null)
        {
            biSrcLThigh.transform = srcLThigh;
            biSrcLThigh.length = (srcLThigh.position - srcSpine.position).magnitude;
            biSrcLThigh.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcLThigh.name;
        }
        srcBoneInfoList.Add(biSrcLThigh);

        biSrcLCalf = new BoneInfo();
        if (srcLCalf != null)
        {
            biSrcLCalf.transform = srcLCalf;
            biSrcLCalf.length = (srcLCalf.position - srcLThigh.position).magnitude;
            biSrcLCalf.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcLThigh.name + "/"
                            + srcLCalf.name;
        }
        srcBoneInfoList.Add(biSrcLCalf);

        biSrcLFoot = new BoneInfo();
        if (srcLFoot != null)
        {
            biSrcLFoot.transform = srcLFoot;
            biSrcLFoot.length = (srcLFoot.position - srcLCalf.position).magnitude;
            biSrcLFoot.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcLThigh.name + "/"
                            + srcLCalf.name + "/" + srcLFoot.name;
        }
        srcBoneInfoList.Add(biSrcLFoot);

        biSrcLToe = new BoneInfo();
        if (srcLToe != null)
        {
            biSrcLToe.transform = srcLToe;
            biSrcLToe.length = (srcLToe.position - srcLFoot.position).magnitude;
            biSrcLToe.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcLThigh.name + "/"
                            + srcLCalf.name + "/" + srcLFoot.name + "/" + srcLToe.name;
        }
        srcBoneInfoList.Add(biSrcLToe);

        biSrcLToeNub = new BoneInfo();
        if (srcLToeNub != null)
        {
            biSrcLToeNub.transform = srcLToeNub;
            biSrcLToeNub.length = (srcLToeNub.position - srcLToe.position).magnitude;
            biSrcLToeNub.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcLThigh.name + "/"
                            + srcLCalf.name + "/" + srcLFoot.name + "/" + srcLToe.name + "/" + srcLToeNub.name;
        }
        srcBoneInfoList.Add(biSrcLToeNub);

        // Src RThigh

        biSrcRThigh = new BoneInfo();
        if (srcRThigh != null)
        {
            biSrcRThigh.transform = srcRThigh;
            biSrcRThigh.length = (srcRThigh.position - srcSpine.position).magnitude;
            biSrcRThigh.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcRThigh.name;
        }
        srcBoneInfoList.Add(biSrcRThigh);

        biSrcRCalf = new BoneInfo();
        if (srcRCalf != null)
        {
            biSrcRCalf.transform = srcRCalf;
            biSrcRCalf.length = (srcRCalf.position - srcRThigh.position).magnitude;
            biSrcRCalf.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcRThigh.name + "/"
                            + srcRCalf.name;
        }
        srcBoneInfoList.Add(biSrcRCalf);

        biSrcRFoot = new BoneInfo();
        if (srcRFoot != null)
        {
            biSrcRFoot.transform = srcRFoot;
            biSrcRFoot.length = (srcRFoot.position - srcRCalf.position).magnitude;
            biSrcRFoot.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcRThigh.name + "/"
                            + srcRCalf.name + "/" + srcRFoot.name;
        }
        srcBoneInfoList.Add(biSrcRFoot);

        biSrcRToe = new BoneInfo();
        if (srcRToe != null)
        {
            biSrcRToe.transform = srcRToe;
            biSrcRToe.length = (srcRToe.position - srcRFoot.position).magnitude;
            biSrcRToe.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcRThigh.name + "/"
                            + srcRCalf.name + "/" + srcRFoot.name + "/" + srcRToe.name;
        }
        srcBoneInfoList.Add(biSrcRToe);

        biSrcRToeNub = new BoneInfo();
        if (srcRToeNub != null)
        {
            biSrcRToeNub.transform = srcRToeNub;
            biSrcRToeNub.length = (srcRToeNub.position - srcRToe.position).magnitude;
            biSrcRToeNub.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcRThigh.name + "/"
                            + srcRCalf.name + "/" + srcRFoot.name + "/" + srcRToe.name + "/" + srcRToeNub.name;
        }
        srcBoneInfoList.Add(biSrcRToeNub);

        // Src Spine1

        biSrcSpine1 = new BoneInfo();
        if (srcSpine1 != null)
        {
            biSrcSpine1.transform = srcSpine1;
            biSrcSpine1.length = (srcSpine1.position - srcSpine.position).magnitude;
            biSrcSpine1.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name;
        }
        srcBoneInfoList.Add(biSrcSpine1);

        biSrcNeck = new BoneInfo();
        if (srcNeck != null)
        {
            biSrcNeck.transform = srcNeck;
            biSrcNeck.length = (srcNeck.position - srcSpine1.position).magnitude;
            biSrcNeck.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name;
        }
        srcBoneInfoList.Add(biSrcNeck);

        biSrcHead = new BoneInfo();
        if (srcHead != null)
        {
            biSrcHead.transform = srcHead;
            biSrcHead.length = (srcHead.position - srcNeck.position).magnitude;
            biSrcHead.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcHead.name;
        }
        srcBoneInfoList.Add(biSrcHead);

        biSrcHeadNub = new BoneInfo();
        if (srcHeadNub != null)
        {
            biSrcHeadNub.transform = srcHeadNub;
            biSrcHeadNub.length = (srcHeadNub.position - srcHead.position).magnitude;
            biSrcHeadNub.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcHead.name + "/" + srcHeadNub.name;
        }
        srcBoneInfoList.Add(biSrcHeadNub);

        // Src LClavicle

        biSrcLClavicle = new BoneInfo();
        if (srcLClavicle != null)
        {
            biSrcLClavicle.transform = srcLClavicle;
            biSrcLClavicle.length = (srcLClavicle.position - srcNeck.position).magnitude;
            biSrcLClavicle.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name;
        }
        srcBoneInfoList.Add(biSrcLClavicle);

        biSrcLUpperArm = new BoneInfo();
        if (srcLUpperArm != null)
        {
            biSrcLUpperArm.transform = srcLUpperArm;
            biSrcLUpperArm.length = (srcLUpperArm.position - srcLClavicle.position).magnitude;
            biSrcLUpperArm.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name;
        }
        srcBoneInfoList.Add(biSrcLUpperArm);

        biSrcLForeArm = new BoneInfo();
        if (srcLForeArm != null)
        {
            biSrcLForeArm.transform = srcLForeArm;
            biSrcLForeArm.length = (srcLForeArm.position - srcLUpperArm.position).magnitude;
            biSrcLForeArm.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name;
        }
        srcBoneInfoList.Add(biSrcLForeArm);

        biSrcLHand = new BoneInfo();
        if (srcLHand != null)
        {
            biSrcLHand.transform = srcLHand;
            biSrcLHand.length = (srcLHand.position - srcLForeArm.position).magnitude;
            biSrcLHand.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name + "/"
                           + srcLHand.name;
        }
        srcBoneInfoList.Add(biSrcLHand);

        biSrcLFinger0 = new BoneInfo();
        if (srcLFinger0 != null)
        {
            biSrcLFinger0.transform = srcLFinger0;
            biSrcLFinger0.length = (srcLFinger0.position - srcLHand.position).magnitude;
            biSrcLFinger0.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name + "/"
                           + srcLHand.name + "/" + srcLFinger0.name;
        }
        srcBoneInfoList.Add(biSrcLFinger0);

        biSrcLFinger01 = new BoneInfo();
        if (srcLFinger01 != null)
        {
            biSrcLFinger01.transform = srcLFinger01;
            biSrcLFinger01.length = (srcLFinger01.position - srcLFinger0.position).magnitude;
            biSrcLFinger01.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name + "/"
                           + srcLHand.name + "/" + srcLFinger0.name + "/" + srcLFinger01.name;
        }
        srcBoneInfoList.Add(biSrcLFinger01);

        biSrcLFinger0Nub = new BoneInfo();
        if (srcLFinger0Nub != null)
        {
            biSrcLFinger0Nub.transform = srcLFinger0Nub;
            biSrcLFinger0Nub.length = (srcLFinger0Nub.position - srcLFinger01.position).magnitude;
            biSrcLFinger0Nub.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name + "/"
                           + srcLHand.name + "/" + srcLFinger0.name + "/" + srcLFinger01.name + "/" + srcLFinger0Nub.name;
        }
        srcBoneInfoList.Add(biSrcLFinger0Nub);

        biSrcLFinger1 = new BoneInfo();
        if (srcLFinger1 != null)
        {
            biSrcLFinger1.transform = srcLFinger1;
            biSrcLFinger1.length = (srcLFinger1.position - srcLHand.position).magnitude;
            biSrcLFinger1.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name + "/"
                           + srcLHand.name + "/" + srcLFinger1.name;
        }
        srcBoneInfoList.Add(biSrcLFinger1);

        biSrcLFinger11 = new BoneInfo();
        if (srcLFinger11 != null)
        {
            biSrcLFinger11.transform = srcLFinger11;
            biSrcLFinger11.length = (srcLFinger11.position - srcLFinger1.position).magnitude;
            biSrcLFinger11.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name + "/"
                           + srcLHand.name + "/" + srcLFinger1.name + "/" + srcLFinger11.name;
        }
        srcBoneInfoList.Add(biSrcLFinger11);

        biSrcLFinger1Nub = new BoneInfo();
        if (srcLFinger1Nub != null)
        {
            biSrcLFinger1Nub.transform = srcLFinger1Nub;
            biSrcLFinger1Nub.length = (srcLFinger1Nub.position - srcLFinger11.position).magnitude;
            biSrcLFinger1Nub.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcLClavicle.name + "/" + srcLUpperArm.name + "/" + srcLForeArm.name + "/"
                           + srcLHand.name + "/" + srcLFinger1.name + "/" + srcLFinger11.name + "/" + srcLFinger1Nub.name;
        }
        srcBoneInfoList.Add(biSrcLFinger1Nub);

        // Src RClavicle

        biSrcRClavicle = new BoneInfo();
        if (srcRClavicle != null)
        {
            biSrcRClavicle.transform = srcRClavicle;
            biSrcRClavicle.length = (srcRClavicle.position - srcNeck.position).magnitude;
            biSrcRClavicle.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name;
        }
        srcBoneInfoList.Add(biSrcRClavicle);

        biSrcRUpperArm = new BoneInfo();
        if (srcRUpperArm != null)
        {
            biSrcRUpperArm.transform = srcRUpperArm;
            biSrcRUpperArm.length = (srcRUpperArm.position - srcRClavicle.position).magnitude;
            biSrcRUpperArm.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name;
        }
        srcBoneInfoList.Add(biSrcRUpperArm);

        biSrcRForeArm = new BoneInfo();
        if (srcRForeArm != null)
        {
            biSrcRForeArm.transform = srcRForeArm;
            biSrcRForeArm.length = (srcRForeArm.position - srcRUpperArm.position).magnitude;
            biSrcRForeArm.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name;
        }
        srcBoneInfoList.Add(biSrcRForeArm);

        biSrcRHand = new BoneInfo();
        if (srcRHand != null)
        {
            biSrcRHand.transform = srcRHand;
            biSrcRHand.length = (srcRHand.position - srcRForeArm.position).magnitude;
            biSrcRHand.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name + "/"
                           + srcRHand.name;
        }
        srcBoneInfoList.Add(biSrcRHand);

        biSrcRFinger0 = new BoneInfo();
        if (srcRFinger0 != null)
        {
            biSrcRFinger0.transform = srcRFinger0;
            biSrcRFinger0.length = (srcRFinger0.position - srcRHand.position).magnitude;
            biSrcRFinger0.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name + "/"
                           + srcRHand.name + "/" + srcRFinger0.name;
        }
        srcBoneInfoList.Add(biSrcRFinger0);

        biSrcRFinger01 = new BoneInfo();
        if (srcRFinger01 != null)
        {
            biSrcRFinger01.transform = srcRFinger01;
            biSrcRFinger01.length = (srcRFinger01.position - srcRFinger0.position).magnitude;
            biSrcRFinger01.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name + "/"
                           + srcRHand.name + "/" + srcRFinger0.name + "/" + srcRFinger01.name;
        }
        srcBoneInfoList.Add(biSrcRFinger01);

        biSrcRFinger0Nub = new BoneInfo();
        if (srcRFinger0Nub != null)
        {
            biSrcRFinger0Nub.transform = srcRFinger0Nub;
            biSrcRFinger0Nub.length = (srcRFinger0Nub.position - srcRFinger01.position).magnitude;
            biSrcRFinger0Nub.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name + "/"
                           + srcRHand.name + "/" + srcRFinger0.name + "/" + srcRFinger01.name + "/" + srcRFinger0Nub.name;
        }
        srcBoneInfoList.Add(biSrcRFinger0Nub);

        biSrcRFinger1 = new BoneInfo();
        if (srcRFinger1 != null)
        {
            biSrcRFinger1.transform = srcRFinger1;
            biSrcRFinger1.length = (srcRFinger1.position - srcRHand.position).magnitude;
            biSrcRFinger1.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name + "/"
                           + srcRHand.name + "/" + srcRFinger1.name;
        }
        srcBoneInfoList.Add(biSrcRFinger1);

        biSrcRFinger11 = new BoneInfo();
        if (srcRFinger11 != null)
        {
            biSrcRFinger11.transform = srcRFinger11;
            biSrcRFinger11.length = (srcRFinger11.position - srcRFinger1.position).magnitude;
            biSrcRFinger11.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name + "/"
                           + srcRHand.name + "/" + srcRFinger1.name + "/" + srcRFinger11.name;
        }
        srcBoneInfoList.Add(biSrcRFinger11);

        biSrcRFinger1Nub = new BoneInfo();
        if (srcRFinger1Nub != null)
        {
            biSrcRFinger1Nub.transform = srcRFinger1Nub;
            biSrcRFinger1Nub.length = (srcRFinger1Nub.position - srcRFinger11.position).magnitude;
            biSrcRFinger1Nub.path = srcRoot.name + "/" + srcPelvis.name + "/" + srcSpine.name + "/" + srcSpine1.name + "/"
                           + srcNeck.name + "/" + srcRClavicle.name + "/" + srcRUpperArm.name + "/" + srcRForeArm.name + "/"
                           + srcRHand.name + "/" + srcRFinger1.name + "/" + srcRFinger11.name + "/" + srcRFinger1Nub.name;
        }
        srcBoneInfoList.Add(biSrcRFinger1Nub);

        // ===== Set dst bone info =====

        biDstRoot = new BoneInfo();
        if (dstRoot != null)
        {
            biDstRoot.transform = dstRoot;
            biDstRoot.length = -1.0f; // no parent
            biDstRoot.path = dstRoot.name;
        }
        dstBoneInfoList.Add(biDstRoot);

        biDstPelvis = new BoneInfo();
        if (dstPelvis != null)
        {
            biDstPelvis.transform = dstPelvis;
            biDstPelvis.length = (dstPelvis.position - dstRoot.position).magnitude;
            biDstPelvis.path = dstRoot.name + "/" + dstPelvis.name;
        }
        dstBoneInfoList.Add(biDstPelvis);

        biDstSpine = new BoneInfo();
        if (dstSpine != null)
        {
            biDstSpine.transform = dstSpine;
            biDstSpine.length = (dstSpine.position - dstPelvis.position).magnitude;
            biDstSpine.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name;
        }
        dstBoneInfoList.Add(biDstSpine);

        // Dst LThigh

        biDstLThigh = new BoneInfo();
        if (dstLThigh != null)
        {
            biDstLThigh.transform = dstLThigh;
            biDstLThigh.length = (dstLThigh.position - dstSpine.position).magnitude;
            biDstLThigh.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstLThigh.name;
        }
        dstBoneInfoList.Add(biDstLThigh);

        biDstLCalf = new BoneInfo();
        if (dstLCalf != null)
        {
            biDstLCalf.transform = dstLCalf;
            biDstLCalf.length = (dstLCalf.position - dstLThigh.position).magnitude;
            biDstLCalf.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstLThigh.name + "/"
                            + dstLCalf.name;
        }
        dstBoneInfoList.Add(biDstLCalf);

        biDstLFoot = new BoneInfo();
        if (dstLFoot != null)
        {
            biDstLFoot.transform = dstLFoot;
            biDstLFoot.length = (dstLFoot.position - dstLCalf.position).magnitude;
            biDstLFoot.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstLThigh.name + "/"
                            + dstLCalf.name + "/" + dstLFoot.name;
        }
        dstBoneInfoList.Add(biDstLFoot);

        biDstLToe = new BoneInfo();
        if (dstLToe != null)
        {
            biDstLToe.transform = dstLToe;
            biDstLToe.length = (dstLToe.position - dstLFoot.position).magnitude;
            biDstLToe.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstLThigh.name + "/"
                            + dstLCalf.name + "/" + dstLFoot.name + "/" + dstLToe.name;
        }
        dstBoneInfoList.Add(biDstLToe);

        biDstLToeNub = new BoneInfo();
        if (dstLToeNub != null)
        {
            biDstLToeNub.transform = dstLToeNub;
            biDstLToeNub.length = (dstLToeNub.position - dstLToe.position).magnitude;
            biDstLToeNub.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstLThigh.name + "/"
                            + dstLCalf.name + "/" + dstLFoot.name + "/" + dstLToe.name + "/" + dstLToeNub.name;
        }
        dstBoneInfoList.Add(biDstLToeNub);

        // Dst RThigh

        biDstRThigh = new BoneInfo();
        if (dstRThigh != null)
        {
            biDstRThigh.transform = dstRThigh;
            biDstRThigh.length = (dstRThigh.position - dstSpine.position).magnitude;
            biDstRThigh.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstRThigh.name;
        }
        dstBoneInfoList.Add(biDstRThigh);

        biDstRCalf = new BoneInfo();
        if (dstRCalf != null)
        {
            biDstRCalf.transform = dstRCalf;
            biDstRCalf.length = (dstRCalf.position - dstRThigh.position).magnitude;
            biDstRCalf.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstRThigh.name + "/"
                            + dstRCalf.name;
        }
        dstBoneInfoList.Add(biDstRCalf);

        biDstRFoot = new BoneInfo();
        if (dstRFoot != null)
        {
            biDstRFoot.transform = dstRFoot;
            biDstRFoot.length = (dstRFoot.position - dstRCalf.position).magnitude;
            biDstRFoot.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstRThigh.name + "/"
                            + dstRCalf.name + "/" + dstRFoot.name;
        }
        dstBoneInfoList.Add(biDstRFoot);

        biDstRToe = new BoneInfo();
        if (dstRToe != null)
        {
            biDstRToe.transform = dstRToe;
            biDstRToe.length = (dstRToe.position - dstRFoot.position).magnitude;
            biDstRToe.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstRThigh.name + "/"
                            + dstRCalf.name + "/" + dstRFoot.name + "/" + dstRToe.name;
        }
        dstBoneInfoList.Add(biDstRToe);

        biDstRToeNub = new BoneInfo();
        if (dstRToeNub != null)
        {
            biDstRToeNub.transform = dstRToeNub;
            biDstRToeNub.length = (dstRToeNub.position - dstRToe.position).magnitude;
            biDstRToeNub.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstRThigh.name + "/"
                            + dstRCalf.name + "/" + dstRFoot.name + "/" + dstRToe.name + "/" + dstRToeNub.name;
        }
        dstBoneInfoList.Add(biDstRToeNub);

        // Dst Spine1

        biDstSpine1 = new BoneInfo();
        if (dstSpine1 != null)
        {
            biDstSpine1.transform = dstSpine1;
            biDstSpine1.length = (dstSpine1.position - dstSpine.position).magnitude;
            biDstSpine1.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name;
        }
        dstBoneInfoList.Add(biDstSpine1);

        biDstNeck = new BoneInfo();
        if (dstNeck != null)
        {
            biDstNeck.transform = dstNeck;
            biDstNeck.length = (dstNeck.position - dstSpine1.position).magnitude;
            biDstNeck.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name;
        }
        dstBoneInfoList.Add(biDstNeck);

        biDstHead = new BoneInfo();
        if (dstHead != null)
        {
            biDstHead.transform = dstHead;
            biDstHead.length = (dstHead.position - dstNeck.position).magnitude;
            biDstHead.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstHead.name;
        }
        dstBoneInfoList.Add(biDstHead);

        biDstHeadNub = new BoneInfo();
        if (dstHeadNub != null)
        {
            biDstHeadNub.transform = dstHeadNub;
            biDstHeadNub.length = (dstHeadNub.position - dstHead.position).magnitude;
            biDstHeadNub.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstHead.name + "/" + dstHeadNub.name;
        }
        dstBoneInfoList.Add(biDstHeadNub);

        // Dst LClavicle

        biDstLClavicle = new BoneInfo();
        if (dstLClavicle != null)
        {
            biDstLClavicle.transform = dstLClavicle;
            biDstLClavicle.length = (dstLClavicle.position - dstNeck.position).magnitude;
            biDstLClavicle.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name;
        }
        dstBoneInfoList.Add(biDstLClavicle);

        biDstLUpperArm = new BoneInfo();
        if (dstLUpperArm != null)
        {
            biDstLUpperArm.transform = dstLUpperArm;
            biDstLUpperArm.length = (dstLUpperArm.position - dstLClavicle.position).magnitude;
            biDstLUpperArm.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name;
        }
        dstBoneInfoList.Add(biDstLUpperArm);

        biDstLForeArm = new BoneInfo();
        if (dstLForeArm != null)
        {
            biDstLForeArm.transform = dstLForeArm;
            biDstLForeArm.length = (dstLForeArm.position - dstLUpperArm.position).magnitude;
            biDstLForeArm.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name;
        }
        dstBoneInfoList.Add(biDstLForeArm);

        biDstLHand = new BoneInfo();
        if (dstLHand != null)
        {
            biDstLHand.transform = dstLHand;
            biDstLHand.length = (dstLHand.position - dstLForeArm.position).magnitude;
            biDstLHand.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name + "/"
                           + dstLHand.name;
        }
        dstBoneInfoList.Add(biDstLHand);

        biDstLFinger0 = new BoneInfo();
        if (dstLFinger0 != null)
        {
            biDstLFinger0.transform = dstLFinger0;
            biDstLFinger0.length = (dstLFinger0.position - dstLHand.position).magnitude;
            biDstLFinger0.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name + "/"
                           + dstLHand.name + "/" + dstLFinger0.name;
        }
        dstBoneInfoList.Add(biDstLFinger0);

        biDstLFinger01 = new BoneInfo();
        if (dstLFinger01 != null)
        {
            biDstLFinger01.transform = dstLFinger01;
            biDstLFinger01.length = (dstLFinger01.position - dstLFinger0.position).magnitude;
            biDstLFinger01.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name + "/"
                           + dstLHand.name + "/" + dstLFinger0.name + "/" + dstLFinger01.name;
        }
        dstBoneInfoList.Add(biDstLFinger01);

        biDstLFinger0Nub = new BoneInfo();
        if (dstLFinger0Nub != null)
        {
            biDstLFinger0Nub.transform = dstLFinger0Nub;
            biDstLFinger0Nub.length = (dstLFinger0Nub.position - dstLFinger01.position).magnitude;
            biDstLFinger0Nub.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name + "/"
                           + dstLHand.name + "/" + dstLFinger0.name + "/" + dstLFinger01.name + "/" + dstLFinger0Nub.name;
        }
        dstBoneInfoList.Add(biDstLFinger0Nub);

        biDstLFinger1 = new BoneInfo();
        if (dstLFinger1 != null)
        {
            biDstLFinger1.transform = dstLFinger1;
            biDstLFinger1.length = (dstLFinger1.position - dstLHand.position).magnitude;
            biDstLFinger1.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name + "/"
                           + dstLHand.name + "/" + dstLFinger1.name;
        }
        dstBoneInfoList.Add(biDstLFinger1);

        biDstLFinger11 = new BoneInfo();
        if (dstLFinger11 != null)
        {
            biDstLFinger11.transform = dstLFinger11;
            biDstLFinger11.length = (dstLFinger11.position - dstLFinger1.position).magnitude;
            biDstLFinger11.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name + "/"
                           + dstLHand.name + "/" + dstLFinger1.name + "/" + dstLFinger11.name;
        }
        dstBoneInfoList.Add(biDstLFinger11);

        biDstLFinger1Nub = new BoneInfo();
        if (dstLFinger1Nub != null)
        {
            biDstLFinger1Nub.transform = dstLFinger1Nub;
            biDstLFinger1Nub.length = (dstLFinger1Nub.position - dstLFinger11.position).magnitude;
            biDstLFinger1Nub.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstLClavicle.name + "/" + dstLUpperArm.name + "/" + dstLForeArm.name + "/"
                           + dstLHand.name + "/" + dstLFinger1.name + "/" + dstLFinger11.name + "/" + dstLFinger1Nub.name;
        }
        dstBoneInfoList.Add(biDstLFinger1Nub);

        // Dst RClavicle

        biDstRClavicle = new BoneInfo();
        if (dstRClavicle != null)
        {
            biDstRClavicle.transform = dstRClavicle;
            biDstRClavicle.length = (dstRClavicle.position - dstNeck.position).magnitude;
            biDstRClavicle.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name;
        }
        dstBoneInfoList.Add(biDstRClavicle);

        biDstRUpperArm = new BoneInfo();
        if (dstRUpperArm != null)
        {
            biDstRUpperArm.transform = dstRUpperArm;
            biDstRUpperArm.length = (dstRUpperArm.position - dstRClavicle.position).magnitude;
            biDstRUpperArm.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name;
        }
        dstBoneInfoList.Add(biDstRUpperArm);

        biDstRForeArm = new BoneInfo();
        if (dstRForeArm != null)
        {
            biDstRForeArm.transform = dstRForeArm;
            biDstRForeArm.length = (dstRForeArm.position - dstRUpperArm.position).magnitude;
            biDstRForeArm.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name;
        }
        dstBoneInfoList.Add(biDstRForeArm);

        biDstRHand = new BoneInfo();
        if (dstRHand != null)
        {
            biDstRHand.transform = dstRHand;
            biDstRHand.length = (dstRHand.position - dstRForeArm.position).magnitude;
            biDstRHand.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name + "/"
                           + dstRHand.name;
        }
        dstBoneInfoList.Add(biDstRHand);

        biDstRFinger0 = new BoneInfo();
        if (dstRFinger0 != null)
        {
            biDstRFinger0.transform = dstRFinger0;
            biDstRFinger0.length = (dstRFinger0.position - dstRHand.position).magnitude;
            biDstRFinger0.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name + "/"
                           + dstRHand.name + "/" + dstRFinger0.name;
        }
        dstBoneInfoList.Add(biDstRFinger0);

        biDstRFinger01 = new BoneInfo();
        if (dstRFinger01 != null)
        {
            biDstRFinger01.transform = dstRFinger01;
            biDstRFinger01.length = (dstRFinger01.position - dstRFinger0.position).magnitude;
            biDstRFinger01.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name + "/"
                           + dstRHand.name + "/" + dstRFinger0.name + "/" + dstRFinger01.name;
        }
        dstBoneInfoList.Add(biDstRFinger01);

        biDstRFinger0Nub = new BoneInfo();
        if (dstRFinger0Nub != null)
        {
            biDstRFinger0Nub.transform = dstRFinger0Nub;
            biDstRFinger0Nub.length = (dstRFinger0Nub.position - dstRFinger01.position).magnitude;
            biDstRFinger0Nub.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name + "/"
                           + dstRHand.name + "/" + dstRFinger0.name + "/" + dstRFinger01.name + "/" + dstRFinger0Nub.name;
        }
        dstBoneInfoList.Add(biDstRFinger0Nub);

        biDstRFinger1 = new BoneInfo();
        if (dstRFinger1 != null)
        {
            biDstRFinger1.transform = dstRFinger1;
            biDstRFinger1.length = (dstRFinger1.position - dstRHand.position).magnitude;
            biDstRFinger1.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name + "/"
                           + dstRHand.name + "/" + dstRFinger1.name;
        }
        dstBoneInfoList.Add(biDstRFinger1);

        biDstRFinger11 = new BoneInfo();
        if (dstRFinger11 != null)
        {
            biDstRFinger11.transform = dstRFinger11;
            biDstRFinger11.length = (dstRFinger11.position - dstRFinger1.position).magnitude;
            biDstRFinger11.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name + "/"
                           + dstRHand.name + "/" + dstRFinger1.name + "/" + dstRFinger11.name;
        }
        dstBoneInfoList.Add(biDstRFinger11);

        biDstRFinger1Nub = new BoneInfo();
        if (dstRFinger1Nub != null)
        {
            biDstRFinger1Nub.transform = dstRFinger1Nub;
            biDstRFinger1Nub.length = (dstRFinger1Nub.position - dstRFinger11.position).magnitude;
            biDstRFinger1Nub.path = dstRoot.name + "/" + dstPelvis.name + "/" + dstSpine.name + "/" + dstSpine1.name + "/"
                           + dstNeck.name + "/" + dstRClavicle.name + "/" + dstRUpperArm.name + "/" + dstRForeArm.name + "/"
                           + dstRHand.name + "/" + dstRFinger1.name + "/" + dstRFinger11.name + "/" + dstRFinger1Nub.name;
        }
        dstBoneInfoList.Add(biDstRFinger1Nub);

        if (srcBoneInfoList.Count != dstBoneInfoList.Count)
        {
            Debug.LogError("ERROR: srcBoneInfoList.count is not same as dstBoneInfoList.count!");
        }

        // Duplicate Anime

        // Get selected AnimationClip
        AnimationClip imported = Selection.activeObject as AnimationClip;
        if (imported == null)
        {
            Debug.Log("Selected object is not an AnimationClip");
            return;
        }

        // Find path of copy
        string importedPath = AssetDatabase.GetAssetPath(imported);
        Debug.Log(importedPath);
        string copyPath  = importedPath.Substring(0, importedPath.LastIndexOf("/"));
        copyPath        += "/" + imported.name + duplicatePostfix + ".anim";

        CopyClip(importedPath, copyPath);

        AnimationClip copy = AssetDatabase.LoadAssetAtPath(copyPath, typeof(AnimationClip)) as AnimationClip;
        if (copy == null)
        {
            Debug.Log("No copy found at " + copyPath);
            return;
        }

        // Copy curves from imported to copy
        AnimationClipCurveData[] curveDatas = AnimationUtility.GetAllCurves(imported, true);
        for (int i = 0; i < curveDatas.Length; i++)
        {
            float coef = 1.0f;

            for (int k = 0; k < srcBoneInfoList.Count; k++)
            {
                if (curveDatas[i].path == srcBoneInfoList[k].path)
                {
                    // replace path
                    curveDatas[i].path = dstBoneInfoList[k].path;

                    if (srcBoneInfoList[k].length > 0.001)
                    {
                        coef = dstBoneInfoList[k].length / srcBoneInfoList[k].length;
                    }
                }
            }

            if ( curveDatas[i].propertyName == "m_LocalPosition.x"
              || curveDatas[i].propertyName == "m_LocalPosition.y"
              || curveDatas[i].propertyName == "m_LocalPosition.z")
            {
                AnimationCurve curveTmp = new AnimationCurve();

                for (int k = 0; k < curveDatas[i].curve.length; k++)
                {
                    Keyframe keyTmp = new Keyframe(curveDatas[i].curve[k].time,
                                                   curveDatas[i].curve[k].value * coef * scale, // adjust value
                                                   curveDatas[i].curve[k].inTangent,
                                                   curveDatas[i].curve[k].outTangent);
                    curveTmp.AddKey(keyTmp);
                }

                AnimationUtility.SetEditorCurve(
                    copy,
                    curveDatas[i].path,
                    curveDatas[i].type,
                    curveDatas[i].propertyName,
                    curveTmp // curveDatas[i].curve
                );
            }
            else
            {
                AnimationUtility.SetEditorCurve(
                    copy,
                    curveDatas[i].path,
                    curveDatas[i].type,
                    curveDatas[i].propertyName,
                    curveDatas[i].curve
                );
            }
        }

        Debug.Log("Translating animation into " + copy.name + " is done");
    }
Exemplo n.º 45
0
        /// <summary>
        /// Reset back to time zero.
        /// </summary>
        //public void Rewind()
        //{
        //    Position = 0;
        //}
        /// <summary>
        /// Update the clip position
        /// </summary>
        /// <param name="delta"></param>
        public void Update(GameTime gameTime)
        {
            #region Update current_clip
            current_Position = current_Position + (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (looping && current_Position >= current_clip.Duration)
                current_Position = 0;
            #endregion
             /*#region Update current_clip
             Position = Position + (float)gameTime.ElapsedGameTime.TotalSeconds;
             if (looping && Position >= Duration)
                 Position = 0;
             #endregion  */

            //if not blending, copy current transforms;
            if (next_clip == null)
            {
                #region Copying
                for (int i = 0; i < current_clip.Bones.Count(); i++)
                {
                    blendedBones[i] = new AnimationClip.Bone();
                    blendedBones[i].Name = current_clip.Bones[i].Name;
                    for (int j = 0; j < current_clip.Bones[i].Keyframes.Count(); j++)
                    {
                        blendedBones[i].Keyframes.Add(new AnimationClip.Keyframe());
                        blendedBones[i].Keyframes[j].Rotation = current_clip.Bones[i].Keyframes[j].Rotation;
                        blendedBones[i].Keyframes[j].Translation = current_clip.Bones[i].Keyframes[j].Translation;
                        blendedBones[i].Keyframes[j].Time = current_clip.Bones[i].Keyframes[j].Time;
                    }
                }
                #endregion
                for (int b = 0; b < blendedBones.Length; b++)
                {
                    // Create it
                    played_boneInfos[b] = new BoneInfo(blendedBones[b]);

                    // Assign it to a model bone
                    played_boneInfos[b].SetModel(model);
                }
                return;
            }

            //if we get there, means that we blending WOW!
               // #region Update next_clip
               // next_Position = next_Position + (float)gameTime.ElapsedGameTime.TotalSeconds;
               // if (looping && next_Position >= next_clip.Duration)
               //     next_Position = 0;
               // #endregion

            if (current_Position < current_clip.Duration)
            {

                if (currentblendTime.TotalSeconds > (float)current_clip.Duration) //we try to catch , where are we in current animation
                    currentblendTime = TimeSpan.Zero;
                else
                    currentblendTime += gameTime.ElapsedGameTime;

            }

            float blendAmount = (float)(currentblendTime.TotalSeconds / totalblendTime.TotalSeconds);

               // Console.WriteLine(blendAmount);

            if (blendAmount > 1.0f)
            {
                current_clip = next_clip;
                #region Copying
                for (int i = 0; i < current_clip.Bones.Count(); i++)
                {
                    blendedBones[i] = new AnimationClip.Bone();
                    blendedBones[i].Name = current_clip.Bones[i].Name;
                    for (int j = 0; j < current_clip.Bones[i].Keyframes.Count(); j++)
                    {
                        blendedBones[i].Keyframes.Add(new AnimationClip.Keyframe());
                        blendedBones[i].Keyframes[j].Rotation = current_clip.Bones[i].Keyframes[j].Rotation;
                        blendedBones[i].Keyframes[j].Translation = current_clip.Bones[i].Keyframes[j].Translation;
                        blendedBones[i].Keyframes[j].Time = current_clip.Bones[i].Keyframes[j].Time;
                    }
                }
                #endregion
                next_clip = null;
                for (int b = 0; b < blendedBones.Length; b++)
                {
                    // Create it
                    played_boneInfos[b] = new BoneInfo(blendedBones[b]);
                    // Assign it to a model bone
                    played_boneInfos[b].SetModel(model);
                }
               // Console.WriteLine("AFTER Blend Clip");
                return;

            }

               #region Blending
            Quaternion currentRotation, nextRotation, blendedRotation;
            Vector3 currentTranslation, nextTranslation, blendedTranslation;

            for (int i = 0; i < boneCnt; i++)
            {
                blendedBones[i] = new AnimationClip.Bone();
                blendedBones[i].Name = current_clip.Bones[i].Name;

               // Console.WriteLine(i + " Kość: " + blendedBones[i].Name + " Klatek: " + current_clip.Bones[i].Keyframes.Count());
                if (i == 0 || i == 1)
                {
                }
                else
                {

                    int h = 10;
                    if (current_clip.Bones[i].Keyframes.Count > next_clip.Bones[i].Keyframes.Count)
                        h = next_clip.Bones[i].Keyframes.Count;
                    else
                        h = current_clip.Bones[i].Keyframes.Count;
                    for (int j = 0; j < h; j++)
                    {
                        blendedBones[i].Keyframes.Add(new AnimationClip.Keyframe());

                        currentRotation = current_clip.Bones[i].Keyframes[j].Rotation;
                        currentTranslation = current_clip.Bones[i].Keyframes[j].Translation;
                        nextRotation = next_clip.Bones[i].Keyframes[j].Rotation;
                        nextTranslation = next_clip.Bones[i].Keyframes[j].Translation;

                        //Console.WriteLine("Obecna rotacja: "+currentRotation);
                        //Console.WriteLine("Obecna translacja: " + currentTranslation);
                        //Console.WriteLine("Nastepna rotacja: " + nextRotation);
                        //Console.WriteLine("Nastepna translacja: " + nextTranslation);
                        Quaternion.Slerp(ref currentRotation, ref nextRotation, blendAmount, out blendedRotation);
                        Vector3.Lerp(ref currentTranslation, ref nextTranslation, blendAmount, out blendedTranslation);

                          blendedBones[i].Keyframes[j].Rotation = blendedRotation;
                          blendedBones[i].Keyframes[j].Translation = blendedTranslation;
                          blendedBones[i].Keyframes[j].Time = current_clip.Bones[i].Keyframes[j].Time;

                              // Create it
                              played_boneInfos[i] = new BoneInfo(blendedBones[i]);

                              // Assign it to a model bone
                              played_boneInfos[i].SetModel(model);

                    }
                }
            }
             //   Console.WriteLine(current_clip.Bones[0].Keyframes.Count());
              //  Console.WriteLine(current_clip.Bones[1].Keyframes.Count());
             //   Console.WriteLine(current_clip.Bones[2].Keyframes.Count());

             //   Console.WriteLine(next_clip.Bones[0].Keyframes.Count());
             //   Console.WriteLine(next_clip.Bones[1].Keyframes.Count());
             //   Console.WriteLine(next_clip.Bones[2].Keyframes.Count());

             // System.Threading.Thread.Sleep(100000);

               // Console.WriteLine(blendAmount);
            #endregion
        }
Exemplo n.º 46
0
        private BoneInfo[] played_boneInfos; //tu wrzucac wszystko i tym sterowac caloscia

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor for the animation player. It makes the 
        /// association between a clip and a model and sets up for playing
        /// </summary>
        /// <param name="clip"></param>
        public AnimationPlayer(Dictionary<String, AnimationClip> Clips, AnimatedModel model)
        {
            blendedBones = new AnimationClip.Bone[model.Bones.Count];

            this.Clips = Clips;
            this.model = model;
            current_clip = Clips["Take 001"];

            looping = true;

            // Create the bone information classes
            boneCnt = current_clip.Bones.Count;

            played_boneInfos = new BoneInfo[boneCnt];

            for (int b = 0; b < played_boneInfos.Length; b++)
            {
                // Create it
                played_boneInfos[b] = new BoneInfo(current_clip.Bones[b]);

                // Assign it to a model bone
                played_boneInfos[b].SetModel(model);
            }

            Position = 0;
        }
Exemplo n.º 47
0
        public void Initialize(AnimationPlayer player)
        {
            m_clip = player.Clip;
            m_skinnedEntity = player.m_skinnedEntity;
            m_weight = player.Weight;
            m_timeScale = player.m_timeScale;
            m_frameOption = player.m_frameOption;

            m_boneCount = player.m_boneCount;
            if (m_boneInfos == null || m_boneInfos.Length < m_boneCount)
                m_boneInfos = new BoneInfo[m_boneCount];


            Position = player.Position;

            for (int b = 0; b < m_boneCount; b++)
            {
                if (m_boneInfos[b] == null)
                    m_boneInfos[b] = new BoneInfo();
                // Create it
                m_boneInfos[b].ClipBone = player.m_boneInfos[b].ClipBone;
                m_boneInfos[b].Player = this;
                    
                // Assign it to a model bone
                m_boneInfos[b].SetModel(m_skinnedEntity);
                m_boneInfos[b].CurrentKeyframe = player.m_boneInfos[b].CurrentKeyframe;
                m_boneInfos[b].SetPosition(Position);

                if (MyFakes.ENABLE_BONES_AND_ANIMATIONS_DEBUG)
                {
                    int index;
                    System.Diagnostics.Debug.Assert(m_skinnedEntity.FindBone(m_boneInfos[b].ClipBone.Name, out index) != null, "Can not find clip bone with name: " + m_boneInfos[b].ClipBone.Name + " in model: " + m_skinnedEntity.Name);
                }
            }


            m_initialized = true;
        }
Exemplo n.º 48
0
            /// <summary>
            /// Initializes a new instance of the <see cref="RawDataMetaChunk"/> class.
            /// </summary>
            /// <param name="offset">The offset.</param>
            /// <param name="chunknumber">The chunknumber.</param>
            /// <param name="bb">The bb.</param>
            /// <param name="meta">The meta.</param>
            /// <remarks></remarks>
            public RawDataMetaChunk(int offset, int chunknumber, BoundingBoxContainer bb, ref Meta meta)
            {
                BinaryReader BR = new BinaryReader(meta.MS);
                BR.BaseStream.Position = offset + 4;
                VerticeCount = BR.ReadUInt16();
                FaceCount = BR.ReadUInt16();
                BR.BaseStream.Position = offset + 20;
                type = BR.ReadByte();
                BR.BaseStream.Position = offset + 68;
                HeaderSize = meta.raw.rawChunks[chunknumber].size - BR.ReadInt32() - 4;
                int tempc = BR.ReadInt32();
                int tempr = BR.ReadInt32() - meta.magic - meta.offset;
                RawDataChunkInfo = new RawDataOffsetChunk[tempc];
                for (int x = 0; x < tempc; x++)
                {
                    RawDataChunkInfo[x] = new RawDataOffsetChunk();
                    BR.BaseStream.Position = tempr + (x * 16) + 6;
                    RawDataChunkInfo[x].ChunkSize = BR.ReadUInt16();
                    RawDataChunkInfo[x].Size = BR.ReadInt32();
                    if (RawDataChunkInfo[x].ChunkSize == 0)
                    {
                        RawDataChunkInfo[x].ChunkSize = RawDataChunkInfo[x].Size;
                    }

                    RawDataChunkInfo[x].Offset = BR.ReadInt32();
                    RawDataChunkInfo[x].ChunkCount = RawDataChunkInfo[x].Size / RawDataChunkInfo[x].ChunkSize;
                }

                BR = new BinaryReader(meta.raw.rawChunks[chunknumber].MS);
                SubMeshInfo = new ModelSubMeshInfo[RawDataChunkInfo[0].ChunkCount];
                for (int x = 0; x < RawDataChunkInfo[0].ChunkCount; x++)
                {
                    SubMeshInfo[x] = new ModelSubMeshInfo();
                    BR.BaseStream.Position = HeaderSize + RawDataChunkInfo[0].Offset + (x * 72) + 4;
                    SubMeshInfo[x].ShaderNumber = BR.ReadUInt16();
                    SubMeshInfo[x].IndiceStart = BR.ReadUInt16();
                    SubMeshInfo[x].IndiceCount = BR.ReadUInt16();
                }

                BR.BaseStream.Position = 40;
                IndiceCount = BR.ReadUInt16();

                int indicechunk = 0;
                int verticechunk = 0;
                int uvchunk = 0;

                for (int x = 0; x < RawDataChunkInfo.Length; x++)
                {
                    if (RawDataChunkInfo[x].ChunkSize == 2)
                    {
                        indicechunk = x;
                        verticechunk = x + 2;
                        uvchunk = x + 3;
                        break;
                    }
                }

                int bonemapchunk = 0;
                BR.BaseStream.Position = 108;
                int tempbonemapcount = BR.ReadUInt16();
                if (tempbonemapcount > 0)
                {
                    for (int x = uvchunk + 1; x < RawDataChunkInfo.Length; x++)
                    {
                        if (RawDataChunkInfo[x].ChunkSize == 1)
                        {
                            bonemapchunk = x;
                            break;
                        }
                    }

                    BR.BaseStream.Position = HeaderSize + RawDataChunkInfo[bonemapchunk].Offset;
                    for (int x = 0; x < tempbonemapcount; x++)
                    {
                        BoneMap.Add(BR.ReadByte());
                    }
                }
                else
                {
                    BoneMap.Add(0);
                }

                RawDataChunkInfo[verticechunk].ChunkSize = RawDataChunkInfo[verticechunk].Size / VerticeCount;
                for (int x = 0; x < VerticeCount; x++)
                {
                    Vector3 vec = new Vector3();
                    BR.BaseStream.Position = HeaderSize + RawDataChunkInfo[verticechunk].Offset +
                                             (RawDataChunkInfo[verticechunk].ChunkSize * x);
                    vec.X = DecompressVertice(BR.ReadInt16(), bb.MinX, bb.MaxX);
                    vec.Y = DecompressVertice(BR.ReadInt16(), bb.MinY, bb.MaxY);
                    vec.Z = DecompressVertice(BR.ReadInt16(), bb.MinZ, bb.MaxZ);
                    Vertices.Add(vec);

                    // if (tempbonemapcount == 0) { continue; }

                    switch (RawDataChunkInfo[verticechunk].ChunkSize)
                    {
                        case 6:
                            BoneInfo b = new BoneInfo();
                            b.BoneIndex.Add(0);
                            b.Weight.Add(1.0f);
                            VerticeBones.Add(b);

                            break;
                        case 8:
                            BoneInfo c = new BoneInfo();
                            c.BoneIndex.Add(BR.ReadByte());
                            c.Weight.Add(1.0f);
                            byte tempb = BR.ReadByte();
                            if (tempb == 0)
                            {
                                VerticeBones.Add(c);
                                break;
                            }

                            BoneInfo c2 = new BoneInfo();
                            c2.BoneIndex.Add(tempb);
                            c2.Weight.Add(1.0f);
                            VerticeBones.Add(c2);
                            c.Weight[0] = 1.0f;
                            VerticeBones.Add(c);
                            break;
                        case 12:
                            BoneInfo bbb = new BoneInfo();
                            bbb.BoneIndex.Add(BR.ReadByte());
                            bbb.Weight.Add(0.99f);
                            VerticeBones.Add(bbb);
                            break;
                    }
                }

                RawDataChunkInfo[uvchunk].ChunkSize = 4;
                for (int x = 0; x < VerticeCount; x++)
                {
                    Vector2 tempuv = new Vector2();
                    BR.BaseStream.Position = HeaderSize + RawDataChunkInfo[uvchunk].Offset +
                                             (RawDataChunkInfo[uvchunk].ChunkSize * x);
                    tempuv.X = DecompressVertice(BR.ReadInt16(), bb.MinU, bb.MaxU) % 1;
                    tempuv.Y = DecompressVertice(BR.ReadInt16(), bb.MinV, bb.MaxV) % 1;

                    // if (tempuv.X > 1) { tempuv.X = tempuv.X - 1; }
                    // else
                    if (tempuv.X < 0)
                    {
                        tempuv.X = 1 - tempuv.X;
                    }

                    // if (tempuv.Y > 1) { tempuv.Y = tempuv.Y - 1; }
                    // else
                    if (tempuv.Y < 0)
                    {
                        tempuv.Y = 1 - tempuv.Y;
                    }

                    UVs.Add(tempuv);
                }

                RawDataChunkInfo[uvchunk + 1].ChunkSize = 12;
                for (int x = 0; x < VerticeCount; x++)
                {
                    BR.BaseStream.Position = HeaderSize + RawDataChunkInfo[uvchunk + 1].Offset +
                                             (RawDataChunkInfo[uvchunk + 1].ChunkSize * x);

                    int dword = BR.ReadInt32();

                    Vector3 tempnormal = DecompressNormal(dword);

                    int converto = CompressNormal(tempnormal);
                    Vector3 tempnormal2 = DecompressNormal(converto);
                    Normals.Add(tempnormal);
                }

                BR.BaseStream.Position = HeaderSize + RawDataChunkInfo[indicechunk].Offset;
                this.Indices = new short[IndiceCount];
                for (int x = 0; x < IndiceCount; x++)
                {
                    Indices[x] = (short)BR.ReadUInt16();
                }
            }
Exemplo n.º 49
0
        public void Initialize(AnimationClip clip, MySkinnedEntity skinnedEntity, float weight, float timeScale, MyFrameOption frameOption, string[] explicitBones = null)
        {
            m_clip = clip;
            m_skinnedEntity = skinnedEntity;
            m_weight = weight;
            m_timeScale = timeScale;
            m_frameOption = frameOption;
            
            // Create the bone information classes
            var maxBoneCount = explicitBones == null ? clip.Bones.Count : explicitBones.Length;
            if (m_boneInfos == null || m_boneInfos.Length < maxBoneCount)
                m_boneInfos = new BoneInfo[maxBoneCount];

            int neededBonesCount = 0;

            for (int b = 0; b < maxBoneCount; b++)
            {
                var bone = explicitBones == null ? clip.Bones[b] : FindBone(clip.Bones, explicitBones[b]);
                if (bone == null)
                    continue;

                if (bone.Keyframes.Count == 0) 
                    continue;

                // Create it
                m_boneInfos[neededBonesCount] = new BoneInfo(bone, this);

                // Assign it to a model bone
                m_boneInfos[neededBonesCount].SetModel(skinnedEntity);

                neededBonesCount++;
            }

            m_boneCount = neededBonesCount;

            Position = 0;

            m_initialized = true;
        }
Exemplo n.º 50
0
	void PrepareBones ()
	{
		if (m_root)
		{
			worldRight = m_root.TransformDirection(right);
			worldUp = m_root.TransformDirection(up);
			worldForward = m_root.TransformDirection(forward);
		}
		
		bones = new ArrayList();
		
		m_rootBone = new BoneInfo ();
		m_rootBone.name = "root";
		m_rootBone.anchor = m_root;
		m_rootBone.parent = null;
		m_rootBone.density = 4F;
		bones.Add (m_rootBone);
		
		AddMirroredJoint ("Hips", m_leftHips, m_rightHips, "root", worldRight, worldForward, -90, 90, 50, 10, typeof(CapsuleCollider), 0.25F, 1.5F);
		AddMirroredJoint ("Knee", m_leftKnee, m_rightKnee, "Hips", worldRight, worldUp, -180, 10, 10, 10, typeof(CapsuleCollider), 0.20F, 1.5F);
		
		AddJoint ("Middle Spine", m_spine, "root", worldRight, worldForward, -50, 10, 15, 15, null, 0.8f, 2.5F);
		AddJoint ("Chest", m_chest, "Middle Spine", worldRight, worldForward, -50, 10, 15, 15, null, 0.8f, 2.5F);

		AddMirroredJoint("Shoulder", m_leftShoulder, m_rightShoulder, "Chest", worldUp, worldRight, -10, 10, 5, 5, typeof(CapsuleCollider), 0.25F, 1.0F);
		AddMirroredJoint ("Arm", m_leftArm, m_rightArm, "Shoulder", worldForward, worldUp, -130, 10, 80, 20, typeof(CapsuleCollider), 0.25F, 1.0F);
		AddMirroredJoint ("Elbow", m_leftElbow, m_rightElbow, "Arm", worldUp, worldRight, -180, 10, 15, 20, typeof(CapsuleCollider), 0.15F, 1.0F);

        AddMirroredJoint("Hand", m_leftHand, m_rightHand, "Elbow", worldForward, worldUp, -70, 70, 90, 5, typeof(CapsuleCollider), 0.15F, 1.0F);

		AddJoint ("Neck", m_neck, "Chest", worldRight, worldForward, -1, 1, 1, 1, typeof(CapsuleCollider), 0.5f, 1.0F);
		AddJoint ("Head", m_head, "Neck", worldUp, -worldForward, -30, 30, 25, 25, null, 0.3f, 1.0F);
	}
Exemplo n.º 51
0
	static public void LoadWeapon(int id, BoneInfo boneInfo)
	{
		if (null != boneInfo && null != boneInfo.weaponBone1)
		{
			//Item_Tbl item_tbl = ConfigPool.Instance.GetDataByKey<Item_Tbl>(id);
			GameObject objWeapon = GameObject.Instantiate(Resources.Load("Prefab/Weapon/skeleton_archer_bow")) as GameObject;
			objWeapon.transform.parent = boneInfo.weaponBone1;
			objWeapon.transform.localPosition = Vector3.zero;
			objWeapon.transform.localRotation = new Quaternion();
		}
	}
Exemplo n.º 52
0
        public void Initialize(AnimationClip clip, MyCharacter model, float weight, float timeScale, bool justFirstFrame, string[] explicitBones = null)
        {
            m_clip = clip;
            m_model = model;
            m_weight = weight;
            m_timeScale = timeScale;
            m_justFirstFrame = justFirstFrame;
            
            // Create the bone information classes
            m_boneCount = explicitBones == null ? clip.Bones.Count : explicitBones.Length;
            if (m_boneInfos == null || m_boneInfos.Length < m_boneCount)
                m_boneInfos = new BoneInfo[m_boneCount];

            for (int b = 0; b < m_boneCount; b++)
            {
                // Create it
                m_boneInfos[b] = new BoneInfo(explicitBones == null ? clip.Bones[b] : FindBone(clip.Bones, explicitBones[b]), this);

                // Assign it to a model bone
                m_boneInfos[b].SetModel(model);
            }

            Position = 0;

            m_initialized = true;
        }