コード例 #1
0
        private void SplitFBX(string fileName)
        {
            Cursor = Cursors.WaitCursor;

            if (!File.Exists(fileName))
            {
                AddMessageLine("File not found: " + fileName);
                Cursor = Cursors.Arrow;
                return;
            }

            ParseFBX fbx = new ParseFBX(this);
            fbx.LoadAsText(fileName);

            LoadModel(true, fileName, rotateX, rotateY, rotateZ);

            fbx.SaveIndividualFBXtakes();

            Cursor = Cursors.Arrow;
        }
コード例 #2
0
 private void ProcessTypeTwo(string rotateXdeg, string rotateYdeg, string rotateZdeg)
 {
     ParseFBX fbx = new ParseFBX(form);
     // Just get the file names and paths
     fbx.ExtractFileNames(fileFullPathToModel);
     // Load the model as a model
     form.LoadModel(true, fileFullPathToModel, rotateXdeg, rotateYdeg, rotateZdeg);
     if (form.IsAnimatedModel())
     {
         // Animation files (FBX) must already exist
         // Now we can load each in turn to get the keyframe data
         ExportTakesToKeyframes(2, fbx, rotateXdeg, rotateYdeg, rotateZdeg);
     }
 }
コード例 #3
0
        private void ExportTakesToKeyframes(int formatType, ParseFBX fbx, string rotateXdeg, string rotateYdeg, string rotateZdeg)
        {
            string rigType = "unknown";
            List<string> headFilter = new List<string>();
            List<string> armsFilter = new List<string>();
            List<Poses> clipPoses = new List<Poses>();

            // == Extract list of clips

            // For extractng the data
            string[] items;
            // Starting on the fourth line following the file name and the rotation
            for (int s = 3; s < source.Count; s++)
            {
                items = ParseData.SplitItemByDivision(source[s]);
                switch (items[0].ToLowerInvariant())
                {
                    case GlobalSettings.itemRigType:
                        if (items.Length > 1)
                        {
                            rigType = items[1].ToLowerInvariant();
                        }
                        break;
                    case GlobalSettings.itemHeadBones:
                        if (items.Length > 1)
                        {
                            for (int b = 1; b < items.Length; b++)
                            {
                                headFilter.Add(items[b]);
                            }
                        }
                        break;
                    case GlobalSettings.itemArmsBones:
                        if (items.Length > 1)
                        {
                            for (int b = 1; b < items.Length; b++)
                            {
                                armsFilter.Add(items[b]);
                            }
                        }
                        break;
                    case GlobalSettings.itemHeadTake:
                        if (items.Length > 2)
                        {
                            Poses pose = new Poses();
                            pose.poseType = GlobalSettings.itemHeadTake;
                            pose.takeName = items[1];
                            pose.poseName = items[2];
                            pose.centreFrame = 0;
                            if (items.Length > 3)
                            {
                                pose.centreFrame = ParseData.FloatFromString(items[3]);
                            }
                            clipPoses.Add(pose);
                        }
                        break;
                    case GlobalSettings.itemArmsTake:
                        if (items.Length > 2)
                        {
                            Poses pose = new Poses();
                            pose.poseType = GlobalSettings.itemArmsTake;
                            pose.takeName = items[1];
                            pose.poseName = items[2];
                            pose.centreFrame = 0;
                            if (items.Length > 3)
                            {
                                pose.centreFrame = ParseData.FloatFromString(items[3]);
                            }
                            clipPoses.Add(pose);
                        }
                        break;
                    case GlobalSettings.itemClipTake:
                        if (items.Length > 2)
                        {
                            Poses pose = new Poses();
                            pose.poseType = GlobalSettings.itemClipTake;
                            pose.takeName = items[1];
                            pose.poseName = items[2];
                            pose.centreFrame = 0;
                            clipPoses.Add(pose);
                        }
                        break;
                    case GlobalSettings.itemMergeClips:
                        if (items.Length > 3)
                        {
                            string upperfile = fbx.GetFullPath(items[1]);
                            string lowerfile = fbx.GetFullPath(items[2]);
                            string mergefile = fbx.GetKeyframeFileName(rigType, items[3], GlobalSettings.itemClipTake);
                            MergeAnimationsFromFiles(
                                upperfile, lowerfile, mergefile,
                                rotateXdeg, rotateYdeg, rotateZdeg,
                                headFilter, armsFilter);
                        }
                        break;
                }
            }

            // == Export each clip
            for (int c = 0; c < clipPoses.Count; c++)
            {
                // Get the filename to load each take from
                string fileName = "";
                if (formatType == 1)
                {
                    // In type 1 only the animation (action, take) name is included in the config file
                    fileName = fbx.GetTakeFileName(clipPoses[c].takeName);
                }
                else if (formatType == 2)
                {
                    // In type 2 the file including extension that contains the
                    // animation is included in the config file
                    fileName = fbx.GetFullPath(clipPoses[c].takeName);
                }
                else
                {
                    // Error but we should never get this far anyway
                    return;
                }
                if (File.Exists(fileName))
                {
                    // Add each animation in to the form
                    form.LoadAnimationTakes(fileName, rotateXdeg, rotateYdeg, rotateZdeg);
                    // The animation loaded must have been selected as the current animation for this to work
                    List<string> exportData;
                    if (clipPoses[c].poseType == GlobalSettings.itemHeadTake)
                    {
                        exportData = GetSaveClipData(form.GetCurrentClip(), false, form.GetBoneMap(), clipPoses[c].takeName, headFilter, clipPoses[c].centreFrame);
                    }
                    else if (clipPoses[c].poseType == GlobalSettings.itemArmsTake)
                    {
                        exportData = GetSaveClipData(form.GetCurrentClip(), false, form.GetBoneMap(), clipPoses[c].takeName, armsFilter, clipPoses[c].centreFrame);
                    }
                    else
                    {
                        exportData = GetSaveClipData(form.GetCurrentClip(), true, form.GetBoneMap(), clipPoses[c].takeName, null, 0);
                    }

                    if (exportData == null || exportData.Count < 1)
                    {
                        // Nothing to save go to the next one
                        continue;
                    }
                    // Save the file
                    fileName = fbx.GetKeyframeFileName(rigType, clipPoses[c].poseName, clipPoses[c].poseType);
                    form.AddMessageLine("Saving: " + fileName);
                    File.WriteAllLines(fileName, exportData);
                }
                else
                {
                    form.AddMessageLine("Animation does not exist: " + fileName);
                }
            }
        }
コード例 #4
0
 private void ProcessTypeOne(string rotateXdeg, string rotateYdeg, string rotateZdeg)
 {
     ParseFBX fbx = new ParseFBX(form);
     // Load the model text for splitting to separate files
     fbx.LoadAsText(fileFullPathToModel);
     // Load the model as a model
     form.LoadModel(true, fileFullPathToModel, rotateXdeg, rotateYdeg, rotateZdeg);
     if (form.IsAnimatedModel())
     {
         // Must save the takes to individual files and
         // the file names must be consistent
         fbx.SaveIndividualFBXtakes();
         // Now we can load each in turn to get the keyframe data
         ExportTakesToKeyframes(1, fbx, rotateXdeg, rotateYdeg, rotateZdeg);
     }
 }