コード例 #1
0
        void LateUpdate()
        {
            // Simulate One Step
            float dt = Time.deltaTime;

            SimulateOneStep(1 / 60.0f);

            // Apply to Bone Transform
            for (int i = 0; i < boneParticleList.Count - 1; i++)
            {
                BoneParticle bp         = boneParticleList[i];
                BoneParticle cp         = boneParticleList[i + 1];
                Vector3      animVector = bp.boneTfm.TransformDirection(BoneAxis);
                Quaternion   rotOffset  = Quaternion.FromToRotation(animVector, cp.pos - bp.pos);
                bp.boneTfm.rotation = rotOffset * bp.boneTfm.rotation;
            }
        }
コード例 #2
0
        void Start()
        {
            // Sample from root bone, store into bone particle list
            Debug.Assert(RootBone != null);

            // Add Root Bone
            BoneParticle bp = new BoneParticle(RootBone);

            boneParticleList.Add(bp);

            while (bp.boneTfm.childCount > 0)
            {
                // Add Child Bone to List
                Transform ct             = bp.boneTfm.GetChild(0); // Only Consider the first child
                float     lengthToParent = Vector3.Distance(bp.boneTfm.position, ct.position);

                bp                = new BoneParticle(ct);
                bp.invMass        = 1;
                bp.lengthToParent = lengthToParent;
                boneParticleList.Add(bp);
            }
        }