Exemplo n.º 1
0
        private static int MakeSubUnitsFromBonesRecursive(
            apBone targetBone,
            int startUnitID,
            List <apRetargetSubUnit> bones_All,
            List <apRetargetSubUnit> bones_Root,
            apRetargetSubUnit parentSubUnit
            )
        {
            apRetargetSubUnit newUnit = new apRetargetSubUnit();

            newUnit.SetSubData(startUnitID, null, null, targetBone, parentSubUnit);

            startUnitID++;
            bones_All.Add(newUnit);
            if (parentSubUnit == null)
            {
                bones_Root.Add(newUnit);
            }

            if (targetBone._childBones.Count > 0)
            {
                for (int i = 0; i < targetBone._childBones.Count; i++)
                {
                    startUnitID = MakeSubUnitsFromBonesRecursive(
                        targetBone._childBones[i],
                        startUnitID,
                        bones_All,
                        bones_Root,
                        newUnit
                        );
                }
            }

            return(startUnitID);
        }
Exemplo n.º 2
0
        private static int MakeSubUnitsFromMeshGroupTransformRecursive(
            apMeshGroup rootMeshGroup,
            apTransform_MeshGroup meshGroupTransform,
            int startUnitID,
            List <apRetargetSubUnit> transforms_All,
            List <apRetargetSubUnit> transforms_Root,
            apRetargetSubUnit parentSubUnit
            )
        {
            //MeshGroup Transform을 추가한다.
            apRetargetSubUnit newGroupSubUnit = new apRetargetSubUnit();

            newGroupSubUnit.SetSubData(startUnitID, null, meshGroupTransform, null, parentSubUnit);

            transforms_All.Add(newGroupSubUnit);
            if (parentSubUnit == null)
            {
                transforms_Root.Add(newGroupSubUnit);
            }

            startUnitID++;

            if (meshGroupTransform._meshGroup != null && meshGroupTransform._meshGroup != rootMeshGroup)
            {
                if (meshGroupTransform._meshGroup._childMeshTransforms != null)
                {
                    for (int i = 0; i < meshGroupTransform._meshGroup._childMeshTransforms.Count; i++)
                    {
                        //MeshTransform을 추가한다.
                        apTransform_Mesh meshTransform = meshGroupTransform._meshGroup._childMeshTransforms[i];

                        apRetargetSubUnit newSubUnit = new apRetargetSubUnit();
                        newSubUnit.SetSubData(startUnitID, meshTransform, null, null, newGroupSubUnit);
                        startUnitID++;

                        transforms_All.Add(newSubUnit);
                    }
                }

                //하위에 다른 MeshGroup Transform이 있는 경우
                if (meshGroupTransform._meshGroup._childMeshGroupTransforms != null)
                {
                    //재귀 호출을 한다
                    for (int i = 0; i < meshGroupTransform._meshGroup._childMeshGroupTransforms.Count; i++)
                    {
                        apTransform_MeshGroup childMeshGroup = meshGroupTransform._meshGroup._childMeshGroupTransforms[i];

                        startUnitID = MakeSubUnitsFromMeshGroupTransformRecursive(
                            rootMeshGroup,
                            childMeshGroup,
                            startUnitID,
                            transforms_All,
                            transforms_Root,
                            newGroupSubUnit
                            );
                    }
                }
            }
            return(startUnitID);
        }
Exemplo n.º 3
0
        private static void MakeSubUnits(apMeshGroup targetMeshGroup,
                                         List <apRetargetSubUnit> transforms_All,
                                         List <apRetargetSubUnit> transforms_Root,
                                         List <apRetargetSubUnit> bones_All,
                                         List <apRetargetSubUnit> bones_Root)
        {
            int unitID = 0;


            if (targetMeshGroup._childMeshTransforms != null)
            {
                for (int i = 0; i < targetMeshGroup._childMeshTransforms.Count; i++)
                {
                    apTransform_Mesh meshTransform = targetMeshGroup._childMeshTransforms[i];

                    apRetargetSubUnit newSubUnit = new apRetargetSubUnit();
                    newSubUnit.SetSubData(unitID, meshTransform, null, null, null);
                    unitID++;

                    transforms_All.Add(newSubUnit);
                    transforms_Root.Add(newSubUnit);
                }
            }


            if (targetMeshGroup._childMeshGroupTransforms != null)
            {
                for (int i = 0; i < targetMeshGroup._childMeshGroupTransforms.Count; i++)
                {
                    apTransform_MeshGroup meshGroupTransform = targetMeshGroup._childMeshGroupTransforms[i];

                    //재귀 호출로 ChildMeshGroup의 SubUnit을 만들어주자
                    unitID = MakeSubUnitsFromMeshGroupTransformRecursive(targetMeshGroup, meshGroupTransform,
                                                                         unitID,
                                                                         transforms_All, transforms_Root,
                                                                         null);
                }
            }

            //Sort를 다시 하자
            for (int i = 0; i < transforms_All.Count; i++)
            {
                apRetargetSubUnit subUnit = transforms_All[i];
                int sortIndex             = -1;
                if (subUnit._type == apRetargetSubUnit.TYPE.MeshTransform)
                {
                    sortIndex = targetMeshGroup._renderUnits_All.FindIndex(delegate(apRenderUnit a)
                    {
                        if (a._meshTransform == null)
                        {
                            return(false);
                        }
                        return(a._meshTransform._transformUniqueID == subUnit._uniqueID);
                    });
                }
                else if (subUnit._type == apRetargetSubUnit.TYPE.MeshGroupTransform)
                {
                    sortIndex = targetMeshGroup._renderUnits_All.FindIndex(delegate(apRenderUnit a)
                    {
                        if (a._meshGroupTransform == null)
                        {
                            return(false);
                        }
                        return(a._meshGroupTransform._transformUniqueID == subUnit._uniqueID);
                    });
                }
                subUnit._sortIndex = sortIndex;
            }
            transforms_All.Sort(delegate(apRetargetSubUnit a, apRetargetSubUnit b)
            {
                return(b._sortIndex - a._sortIndex);
            });



            //Bone도 넣자
            //<BONE_EDIT>
            //if(targetMeshGroup._boneList_Root.Count > 0)
            //{
            //	for (int i = 0; i < targetMeshGroup._boneList_Root.Count; i++)
            //	{
            //		unitID = MakeSubUnitsFromBonesRecursive(targetMeshGroup,
            //												targetMeshGroup._boneList_Root[i],
            //												unitID, bones_All, bones_Root, null);
            //	}
            //}

            //>> Bone Set으로 변경
            if (targetMeshGroup._boneListSets.Count > 0)
            {
                apMeshGroup.BoneListSet boneSet = null;
                for (int iSet = 0; iSet < targetMeshGroup._boneListSets.Count; iSet++)
                {
                    boneSet = targetMeshGroup._boneListSets[iSet];
                    for (int iRoot = 0; iRoot < boneSet._bones_Root.Count; iRoot++)
                    {
                        unitID = MakeSubUnitsFromBonesRecursive(
                            boneSet._bones_Root[iRoot],
                            unitID, bones_All, bones_Root, null);
                    }
                }
            }


            //Sort를 다시 하자
            for (int i = 0; i < bones_All.Count; i++)
            {
                apRetargetSubUnit subUnit = bones_All[i];
                //<BONE_EDIT>

                //subUnit._sortIndex = targetMeshGroup._boneList_All.FindIndex(delegate (apBone a)
                //{
                //	return a._uniqueID == subUnit._uniqueID;
                //});

                //>>Bone Set을 이용
                subUnit._sortIndex = -1;

                apMeshGroup.BoneListSet boneSet = null;
                int startIndex = 0;
                for (int iSet = 0; iSet < targetMeshGroup._boneListSets.Count; iSet++)
                {
                    boneSet = targetMeshGroup._boneListSets[iSet];

                    //현재의 Bone List에 있는지 확인
                    int resultIndex = boneSet._bones_All.FindIndex(delegate(apBone a)
                    {
                        return(a._uniqueID == subUnit._uniqueID);
                    });

                    if (resultIndex >= 0 && resultIndex < boneSet._bones_All.Count)
                    {
                        //찾았다.
                        subUnit._sortIndex = startIndex + resultIndex;
                        break;
                    }
                    else
                    {
                        //업다면 기본 인덱스 증가
                        startIndex += boneSet._bones_All.Count;
                    }
                }
            }
            bones_All.Sort(delegate(apRetargetSubUnit a, apRetargetSubUnit b)
            {
                return(a._sortIndex - b._sortIndex);
            });
        }
Exemplo n.º 4
0
        private static void MakeSubUnits(apMeshGroup targetMeshGroup,
                                         List <apRetargetSubUnit> transforms_All,
                                         List <apRetargetSubUnit> transforms_Root,
                                         List <apRetargetSubUnit> bones_All,
                                         List <apRetargetSubUnit> bones_Root)
        {
            int unitID = 0;


            if (targetMeshGroup._childMeshTransforms != null)
            {
                for (int i = 0; i < targetMeshGroup._childMeshTransforms.Count; i++)
                {
                    apTransform_Mesh meshTransform = targetMeshGroup._childMeshTransforms[i];

                    apRetargetSubUnit newSubUnit = new apRetargetSubUnit();
                    newSubUnit.SetSubData(unitID, meshTransform, null, null, null);
                    unitID++;

                    transforms_All.Add(newSubUnit);
                    transforms_Root.Add(newSubUnit);
                }
            }


            if (targetMeshGroup._childMeshGroupTransforms != null)
            {
                for (int i = 0; i < targetMeshGroup._childMeshGroupTransforms.Count; i++)
                {
                    apTransform_MeshGroup meshGroupTransform = targetMeshGroup._childMeshGroupTransforms[i];

                    //재귀 호출로 ChildMeshGroup의 SubUnit을 만들어주자
                    unitID = MakeSubUnitsFromMeshGroupTransformRecursive(targetMeshGroup, meshGroupTransform,
                                                                         unitID,
                                                                         transforms_All, transforms_Root,
                                                                         null);
                }
            }

            //Sort를 다시 하자
            for (int i = 0; i < transforms_All.Count; i++)
            {
                apRetargetSubUnit subUnit = transforms_All[i];
                int sortIndex             = -1;
                if (subUnit._type == apRetargetSubUnit.TYPE.MeshTransform)
                {
                    sortIndex = targetMeshGroup._renderUnits_All.FindIndex(delegate(apRenderUnit a)
                    {
                        if (a._meshTransform == null)
                        {
                            return(false);
                        }
                        return(a._meshTransform._transformUniqueID == subUnit._uniqueID);
                    });
                }
                else if (subUnit._type == apRetargetSubUnit.TYPE.MeshGroupTransform)
                {
                    sortIndex = targetMeshGroup._renderUnits_All.FindIndex(delegate(apRenderUnit a)
                    {
                        if (a._meshGroupTransform == null)
                        {
                            return(false);
                        }
                        return(a._meshGroupTransform._transformUniqueID == subUnit._uniqueID);
                    });
                }
                subUnit._sortIndex = sortIndex;
            }
            transforms_All.Sort(delegate(apRetargetSubUnit a, apRetargetSubUnit b)
            {
                return(b._sortIndex - a._sortIndex);
            });



            //Bone도 넣자
            if (targetMeshGroup._boneList_Root.Count > 0)
            {
                for (int i = 0; i < targetMeshGroup._boneList_Root.Count; i++)
                {
                    unitID = MakeSubUnitsFromBonesRecursive(targetMeshGroup,
                                                            targetMeshGroup._boneList_Root[i],
                                                            unitID, bones_All, bones_Root, null);
                }
            }

            //Sort를 다시 하자
            for (int i = 0; i < bones_All.Count; i++)
            {
                apRetargetSubUnit subUnit = bones_All[i];
                subUnit._sortIndex = targetMeshGroup._boneList_All.FindIndex(delegate(apBone a)
                {
                    return(a._uniqueID == subUnit._uniqueID);
                });
            }
            bones_All.Sort(delegate(apRetargetSubUnit a, apRetargetSubUnit b)
            {
                return(a._sortIndex - b._sortIndex);
            });
        }