Exemple #1
0
            public void AddPosWeightPair(PosWeightPair srcPosWeightPair, float weight)
            {
                WeightPairData srcWeightPairData    = null;
                WeightPairData targetWeightPairData = null;

                for (int i = 0; i < srcPosWeightPair._weightPairs.Count; i++)
                {
                    srcWeightPairData = srcPosWeightPair._weightPairs[i];
                    if (srcWeightPairData._bone == null)
                    {
                        continue;
                    }

                    //동일한 Bone의 기록이 있다면 Weight 더하기
                    //없다면 새로운 기록 만들기
                    targetWeightPairData = null;
                    targetWeightPairData = _weightPairs.Find(delegate(WeightPairData a)
                    {
                        return(a._bone == srcWeightPairData._bone);
                    });

                    if (targetWeightPairData != null)
                    {
                        //동일한 Bone에 대한 기록이 있다면 Weight 더하기
                        targetWeightPairData._weight += srcWeightPairData._weight * weight;
                    }
                    else
                    {
                        //새로운 기록 만들기
                        targetWeightPairData = new WeightPairData(srcWeightPairData._bone, srcWeightPairData._weight * weight);
                        _weightPairs.Add(targetWeightPairData);
                    }
                }
            }
Exemple #2
0
            //Lerp가 0이면 A에 100%
            public void Lerp(PosWeightPair srcPosA, PosWeightPair srcPosB, float lerp)
            {
                _posWorld = srcPosA._posWorld * (1.0f - lerp) + srcPosB._posWorld * lerp;

                float weightA = (1.0f - lerp);
                float weightB = lerp;

                _weightPairs.Clear();

                //A와 B의 PairData를 weight를 이용하여 대입한다.
                WeightPairData srcData = null;
                WeightPairData dstData = null;

                //일단 A부터
                for (int i = 0; i < srcPosA._weightPairs.Count; i++)
                {
                    srcData = srcPosA._weightPairs[i];

                    //Bone이 있는지 확인
                    dstData = _weightPairs.Find(delegate(WeightPairData a)
                    {
                        return(a._bone == srcData._bone);
                    });

                    if (dstData != null)
                    {
                        dstData._weight += srcData._weight * weightA;
                    }
                    else
                    {
                        dstData = new WeightPairData(srcData._bone, srcData._weight * weightA);
                        _weightPairs.Add(dstData);
                    }
                }

                //B도 적용
                for (int i = 0; i < srcPosB._weightPairs.Count; i++)
                {
                    srcData = srcPosB._weightPairs[i];

                    //Bone이 있는지 확인
                    dstData = _weightPairs.Find(delegate(WeightPairData a)
                    {
                        return(a._bone == srcData._bone);
                    });

                    if (dstData != null)
                    {
                        dstData._weight += srcData._weight * weightB;
                    }
                    else
                    {
                        dstData = new WeightPairData(srcData._bone, srcData._weight * weightB);
                        _weightPairs.Add(dstData);
                    }
                }

                //마지막으로 Normalize
                Normalize();
            }
Exemple #3
0
            //저장된 값을 대상 ModVertRig에 복사한다.
            public void PasteToModVertRig(apMeshGroup keyMeshGroup, apModifiedVertexRig targetModVertRig)
            {
                if (targetModVertRig == null)
                {
                    return;
                }


                targetModVertRig._weightPairs.Clear();

                for (int iSrcPair = 0; iSrcPair < _weightPairs.Count; iSrcPair++)
                {
                    WeightPairData srcPair = _weightPairs[iSrcPair];
                    apModifiedVertexRig.WeightPair dstPair = new apModifiedVertexRig.WeightPair(srcPair._bone);
                    dstPair._meshGroup   = keyMeshGroup;
                    dstPair._meshGroupID = keyMeshGroup._uniqueID;
                    dstPair._weight      = srcPair._weight;

                    targetModVertRig._weightPairs.Add(dstPair);
                }
            }