Beispiel #1
0
        private void uploadToLEDBoardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            solution.SaveAll();
            lb_manager      = new LED_Board_Manager();
            lb_manager.Size = new Size(425, 180);

            string ProjectFileName = solution.GetItemPath(solution.GetProject());

            lb_manager.AddFile(ProjectFileName);
            foreach (IDocument item in solution.GetProjectItems(solution.GetProject()))
            {
                Document document = solution.GetItemDocument(item);
                string   path     = document.GetPath();
                lb_manager.AddFile(path);
                if (item.GetType() == typeof(Theme))
                {
                    Theme theme = item as Theme;
                    foreach (LB_Tools_Interface tool in theme.GetTools())
                    {
                        string tool_res;

                        if (tool.GetType() == typeof(LB_Tools_Text))
                        {
                            LB_Tools_Text tool_text = tool as LB_Tools_Text;
                            tool_res = Path.GetDirectoryName(ProjectFileName) + "\\" + "LB_Tools_Text_" + tool_text.Text_Name + ".bma";
                            tool_text.SetLBResourcePath(tool_res);
                            AnimationConverter animationConverter = new AnimationConverter(tool_text.GetBitmap());
                            if (animationConverter.Encode(tool_res, 0, 0, AnimationConverter.ColorOrder.RGB, AnimationConverter.PixelOrder.VS_TR, AnimationConverter.DataType.Default))
                            {
                                lb_manager.AddFile(tool_res);
                            }
                        }
                        else if (tool.GetType() == typeof(LB_Tools_RunningText))
                        {
                            LB_Tools_RunningText tool_rtext = tool as LB_Tools_RunningText;
                            tool_res = Path.GetDirectoryName(ProjectFileName) + "\\" + "LB_Tools_Text_" + tool_rtext.Text_Name + ".bma";
                            CloseTabIfOpened(theme);
                            if (tool_rtext.SaveAsBMA(tool_res))
                            {
                                lb_manager.AddFile(tool_res);
                            }
                        }
                        else
                        {
                            tool_res = tool.GetLBResourcePath();
                            if (tool_res != "")
                            {
                                lb_manager.AddFile(tool_res);
                            }
                        }
                    }
                }
            }


            lb_manager.Show();
        }
Beispiel #2
0
        public override unsafe void Export(string outPath)
        {
            int dataLen = OnCalculateSize(true);

            using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 8, FileOptions.RandomAccess))
            {
                stream.SetLength(dataLen);
                using (FileMap map = FileMap.FromStream(stream))
                    AnimationConverter.EncodeSRT0Keyframes(Keyframes, map.Address, map.Address + _entryLen, _code);
            }
        }
Beispiel #3
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            //_keyframes._evalCode.UseModelScale = _useModelScale;
            //_keyframes._evalCode.UseModelRot = _useModelRotate;
            //_keyframes._evalCode.UseModelTrans = _useModelTranslate;

            //_keyframes._evalCode.ScaleCompApply = _scaleCompApply;
            //_keyframes._evalCode.ScaleCompParent = _scaleCompParent;
            //_keyframes._evalCode.ClassicScaleOff = _classicScaleOff;

            AnimationConverter.EncodeCHR0Keyframes(_keyframes, address, _dataAddr);
        }
Beispiel #4
0
        private void LoadImage()
        {
            if (ImagePath != ImagePathOld && ImagePath != "")
            {
                ImagePathOld = ImagePath;

                FileInfo f_info = new FileInfo(ImagePath);
                switch (f_info.Extension)
                {
                case ".bmp":
                    if (f_info.Extension == ".bmp")
                    {
                        Bitmap tempBitmap = new Bitmap(ImagePath);
                        if (tempBitmap.Height > MaxSize.Height || tempBitmap.Width > MaxSize.Width)
                        {
                            bitmap = new Bitmap(MaxSize.Width, MaxSize.Height);
                            Graphics g = Graphics.FromImage(bitmap);
                            g.DrawImage(tempBitmap, new Rectangle(0, 0, MaxSize.Width, MaxSize.Height));
                            tempBitmap.Dispose();
                        }
                        else
                        {
                            bitmap = new Bitmap(tempBitmap);
                            tempBitmap.Dispose();
                        }
                        animationConverter = new AnimationConverter(bitmap);
                        string bma_path = Path.GetDirectoryName(ImagePath) + "\\" + Path.GetFileNameWithoutExtension(ImagePath) + ".bma";
                        if (animationConverter.Encode(bma_path, 0, 0, AnimationConverter.ColorOrder.RGB, AnimationConverter.PixelOrder.VS_TR, AnimationConverter.DataType.Default))
                        {
                            LbResourcePath = bma_path;
                            LbResourceName = LB_Tools.GetFileName(LbResourcePath);
                        }
                    }
                    break;

                case ".jpg":
                    Stream            imageStreamSource = new FileStream(ImagePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    JpegBitmapDecoder decoder           = new JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                    BitmapSource      bitmapSource      = decoder.Frames[0];
                    bitmap = BitmapFromSource(bitmapSource);
                    break;

                default:

                    break;
                }
            }
        }
Beispiel #5
0
        public bool SaveAsBMA(string path)
        {
            if (path == "")
            {
                return(false);
            }
            bitmap = new Bitmap(1, 8);
            GetBitmap();
            int frames = ActiveFrame.Width;

            ActiveFrameX  = 0.0;
            ActiveFrame.X = 0;
            int x = 0;

            AnimationConverter animationConverter = new AnimationConverter(TextArea.Width, TextArea.Height);

            while (frames > 0)
            {
                GetBitmap();
                if (x != ActiveFrame.X)
                {
                    x = ActiveFrame.X;
                    frames--;
                }
            }
            frames = SpaceWidth + TextSize.Width + 1;
            while (frames > 0)
            {
                animationConverter.AddFrame(GetBitmap());
                if (x != ActiveFrame.X)
                {
                    x = ActiveFrame.X;
                    frames--;
                }
            }
            if (animationConverter.Encode(path, 0, animationConverter.animation.FramesCount - 1, AnimationConverter.ColorOrder.RGB, AnimationConverter.PixelOrder.VS_TR, AnimationConverter.DataType.Default))
            {
                SetLBResourcePath(path);
                return(true);
            }
            return(false);
        }
Beispiel #6
0
        public override unsafe void Export(string outPath)
        {
            StringTable table = new StringTable();

            table.Add(_name);

            int dataLen  = OnCalculateSize(true);
            int totalLen = dataLen + table.GetTotalSize();

            using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 8, FileOptions.RandomAccess))
            {
                stream.SetLength(totalLen);
                using (FileMap map = FileMap.FromStream(stream))
                {
                    AnimationConverter.EncodeKeyframes(Keyframes, map.Address, map.Address + _entryLen);
                    table.WriteTable(map.Address + dataLen);
                    PostProcess(map.Address, table);
                }
            }
        }
Beispiel #7
0
 protected internal override void OnRebuild(VoidPtr address, int length, bool force)
 {
     AnimationConverter.EncodeKeyframes(_keyframes, address, _dataAddr);
 }
Beispiel #8
0
 protected override int OnCalculateSize(bool force)
 {
     //Keyframes.Clean();
     _dataLen = AnimationConverter.CalculateSize(Keyframes, out _entryLen);
     return(_dataLen + _entryLen);
 }
        //********************************************************************************
        // Private Methods
        //********************************************************************************

        private void OnGUI()
        {
            bool hasAnActiveError = false;

            if (h1Style == null)
            {
                h1Style           = new GUIStyle(GUI.skin.label);
                h1Style.alignment = TextAnchor.MiddleCenter;
                h1Style.fontStyle = FontStyle.Bold;
                h1Style.fontSize  = 14;
            }

            GUILayout.Space(5);

            GUILayout.Label("Animation Converter", h1Style);

            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label("V" + AnimationConverter.GetVersion());
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(8);

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Reset Configuration"))
                {
                    if (EditorUtility.DisplayDialog("Animation Converter - Reset Configuration", "Do you really want to reset the current configuration?\r\n\r\nAll changes will be lost!", "Yes", "No"))
                    {
                        configuration = new AnimationConverter.Configuration();
                        clipsToConvertList.Clear();
                    }
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Manual"))
                {
                    AnimationConverter.BrowseManual();
                }
                if (GUILayout.Button("Support"))
                {
                    AnimationConverter.BrowseSupport();
                }
            }
            GUILayout.EndHorizontal();

            if (configuration.Prefabs == null)
            {
                configuration.Prefabs = new AnimationConverter.PrefabPair[1];
            }

            GUILayout.Space(4);

            DrawLine(1000, 2, 0, 0, Color.black);

            GUILayout.Space(10);

            AnimationConverter.AnimationType inputAnimationType = AnimationConverter.AnimationType.Legacy;
            bool inputAnimationTypeValid         = false;
            bool multipleDifferentAnimationTypes = false;

            // ---------------------
            // Input
            // ---------------------
            clipsToConvertFoldout = EditorGUILayout.Foldout(clipsToConvertFoldout, "Input");
            if (clipsToConvertFoldout)
            {
                EditorGUI.indentLevel++;

                int  indexToDelete = -1;
                bool anyClipNull   = false;
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);
                    inputScrollView = EditorGUILayout.BeginScrollView(inputScrollView, GUI.skin.box, GUILayout.Height(150));
                    {
                        for (int index = 0; index < clipsToConvertList.Count; index++)
                        {
                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.BeginVertical(GUILayout.Width(20));
                                {
                                    if (GUILayout.Button("-"))
                                    {
                                        indexToDelete = index;
                                    }
                                }
                                GUILayout.EndVertical();

                                AnimationClip clip = clipsToConvertList[index];
                                if (clip != null)
                                {
                                    AnimationConverter.AnimationType animType = AnimationConverter.GetAnimationType(clip);
                                    if (!inputAnimationTypeValid)
                                    {
                                        inputAnimationType      = animType;
                                        inputAnimationTypeValid = true;
                                    }
                                    else
                                    {
                                        if (animType != inputAnimationType)
                                        {
                                            multipleDifferentAnimationTypes = true;
                                        }
                                    }

                                    GUILayout.Label(animType.ToString(), GUILayout.Width(70));
                                }
                                else
                                {
                                    GUILayout.Label("", GUILayout.Width(70));

                                    anyClipNull = true;
                                }

                                clipsToConvertList[index] = (AnimationClip)EditorGUILayout.ObjectField(clip, typeof(AnimationClip), false);
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                }
                GUILayout.EndHorizontal();

                if (indexToDelete >= 0)
                {
                    clipsToConvertList.RemoveAt(indexToDelete);
                }

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);
                    GUILayout.BeginHorizontal(GUI.skin.box, GUILayout.Height(40));
                    {
                        GUILayout.FlexibleSpace();
                        GUILayout.BeginVertical();
                        {
                            GUILayout.FlexibleSpace();
                            GUILayout.Label("Drag & Drop Animation Clips Here");
                            GUILayout.FlexibleSpace();
                        }
                        GUILayout.EndVertical();
                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();

                    Rect     lastRect       = GUILayoutUtility.GetLastRect();
                    Object[] droppedObjects = DragAndDropReceiver(lastRect, new System.Type[] { typeof(AnimationClip), typeof(GameObject) }, true);
                    if (droppedObjects != null)
                    {
                        foreach (Object droppedObj in droppedObjects)
                        {
                            AnimationClip animationClip = droppedObj as AnimationClip;

                            if (animationClip != null)
                            {
                                clipsToConvertList.Add(animationClip);
                            }
                            else
                            {
                                string assetPath = AssetDatabase.GetAssetPath(droppedObj);

                                Object[] allAssets = AssetDatabase.LoadAllAssetsAtPath(assetPath);

                                foreach (Object asset in allAssets)
                                {
                                    animationClip = asset as AnimationClip;
                                    if ((animationClip != null) && !animationClip.name.StartsWith("__preview__"))
                                    {
                                        clipsToConvertList.Add(animationClip);
                                    }
                                }
                            }
                        }
                    }
                }
                GUILayout.EndHorizontal();

                if (anyClipNull)
                {
                    EditorGUILayout.HelpBox("Entries with no clip assigned need to be removed.", MessageType.Error);

                    hasAnActiveError = true;
                }

                List <string> clipsWithDuplicateNames = GetClipsWithDuplicateNames(clipsToConvertList);
                if (clipsWithDuplicateNames.Count > 0)
                {
                    string helpText = "The following clip names are not unique:";
                    foreach (string clipName in clipsWithDuplicateNames)
                    {
                        helpText += string.Format("\r\n\"{0}\"", clipName);
                    }
                    EditorGUILayout.HelpBox(helpText, MessageType.Error);

                    hasAnActiveError = true;
                }

                if (multipleDifferentAnimationTypes)
                {
                    EditorGUILayout.HelpBox("All clips need to be of the same animation type.", MessageType.Error);

                    hasAnActiveError = true;
                }

                EditorGUI.indentLevel--;
            }

            // ---------------------
            // Output
            // ---------------------
            GUILayout.Space(10);
            convertToFoldout = EditorGUILayout.Foldout(convertToFoldout, "Output");
            if (convertToFoldout)
            {
                EditorGUI.indentLevel++;
                float originalLabelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 125;

                configuration.DestinationAnimationType = (AnimationConverter.AnimationType)EditorGUILayout.EnumPopup(animationTypeContent, configuration.DestinationAnimationType);

                if (inputAnimationTypeValid && (configuration.DestinationAnimationType == inputAnimationType))
                {
                    EditorGUILayout.HelpBox("The output anmiation type must be different then the input animation type.", MessageType.Error);

                    hasAnActiveError = true;
                }

                GUILayout.BeginHorizontal();
                {
                    configuration.OutputDirectory = EditorGUILayout.TextField(outputDirectoryContent, configuration.OutputDirectory);

                    GUILayout.BeginVertical(GUILayout.Width(40));
                    {
                        if (GUILayout.Button("..."))
                        {
                            configuration.OutputDirectory = BrowseDirectory("Open Folder", configuration.OutputDirectory);
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                if (!AssetDatabase.IsValidFolder(configuration.OutputDirectory))
                {
                    EditorGUILayout.HelpBox("Invalid output directory. The directory needs to be a child of the \"Assets\" folder.", MessageType.Error);

                    hasAnActiveError = true;
                }

                EditorGUIUtility.labelWidth = originalLabelWidth;
                EditorGUI.indentLevel--;
            }

            // ---------------------
            // Settings
            // ---------------------

            GUILayout.Space(10);
            settingsFoldout = EditorGUILayout.Foldout(settingsFoldout, "Settings");
            if (settingsFoldout)
            {
                EditorGUI.indentLevel++;

                if (inputAnimationTypeValid)
                {
                    float originalLabelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 170;

                    bool anySettingsShow = false;
                    if ((inputAnimationType == AnimationConverter.AnimationType.Humanoid) ||
                        (configuration.DestinationAnimationType == AnimationConverter.AnimationType.Humanoid))
                    {
                        configuration.KeyReduction = (AnimationConverter.KeyReductionMode)EditorGUILayout.EnumPopup(keyReductionContent, configuration.KeyReduction);
                        if (configuration.KeyReduction == AnimationConverter.KeyReductionMode.Lossy)
                        {
                            configuration.KeyReductionPositionError = EditorGUILayout.FloatField(positionErrorContent, configuration.KeyReductionPositionError);
                            configuration.KeyReductionRotationError = EditorGUILayout.FloatField(rotationErrorContent, configuration.KeyReductionRotationError);
                            configuration.KeyReductionScaleError    = EditorGUILayout.FloatField(scaleErrorContent, configuration.KeyReductionScaleError);
                        }

                        anySettingsShow = true;
                    }

                    if (configuration.DestinationAnimationType == AnimationConverter.AnimationType.Humanoid)
                    {
                        configuration.HumanoidKeepExtraGenericBones = EditorGUILayout.Toggle(keepExtraBonesContent, configuration.HumanoidKeepExtraGenericBones);

                        anySettingsShow = true;
                    }
                    else if (inputAnimationType == AnimationConverter.AnimationType.Humanoid)
                    {
                        configuration.SampleHumanoidHandIK = EditorGUILayout.Toggle(humanoidHandIkContent, configuration.SampleHumanoidHandIK);
                        configuration.SampleHumanoidFootIK = EditorGUILayout.Toggle(humanoidFootIkContent, configuration.SampleHumanoidFootIK);

                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(20);
                            GUILayout.Label(constrainRootPositionContent, GUILayout.Width(150));
                            configuration.ConstrainRootMotionPosition.ConstrainX = GUILayout.Toggle(configuration.ConstrainRootMotionPosition.ConstrainX, "X");
                            configuration.ConstrainRootMotionPosition.ConstrainY = GUILayout.Toggle(configuration.ConstrainRootMotionPosition.ConstrainY, "Y");
                            configuration.ConstrainRootMotionPosition.ConstrainZ = GUILayout.Toggle(configuration.ConstrainRootMotionPosition.ConstrainZ, "Z");
                            GUILayout.FlexibleSpace();
                        }
                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(20);
                            GUILayout.Label(constrainRootRotationContent, GUILayout.Width(150));
                            configuration.ConstrainRootMotionRotation.ConstrainX = GUILayout.Toggle(configuration.ConstrainRootMotionRotation.ConstrainX, "X");
                            configuration.ConstrainRootMotionRotation.ConstrainY = GUILayout.Toggle(configuration.ConstrainRootMotionRotation.ConstrainY, "Y");
                            configuration.ConstrainRootMotionRotation.ConstrainZ = GUILayout.Toggle(configuration.ConstrainRootMotionRotation.ConstrainZ, "Z");
                            GUILayout.FlexibleSpace();
                        }
                        GUILayout.EndHorizontal();

                        anySettingsShow = true;
                    }

                    EditorGUIUtility.labelWidth = originalLabelWidth;

                    if (!anySettingsShow)
                    {
                        EditorGUILayout.LabelField("No settings require");
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Please assign the input clip(s) first.", MessageType.Warning);
                }
                EditorGUI.indentLevel--;
            }

            // ---------------------
            // Prefabs
            // ---------------------
            GUILayout.Space(10);
            gameObjectsFoldout = EditorGUILayout.Foldout(gameObjectsFoldout, "Prefabs");
            if (gameObjectsFoldout)
            {
                EditorGUI.indentLevel++;
                string helpText = string.Format("The model related to the animation clips needs to be assigned once using the animation type of the source clips and once using the destination animation type.\r\n\r\n1) Duplicate the original model in Unity's Project Window.\r\n\r\n2) Change the animation type of the duplicated model to the desired animation type and click on Apply.\r\n\r\n3) Drag & Drop the duplicated model to the appropriate field:", configuration.DestinationAnimationType);
                EditorGUILayout.HelpBox(helpText, MessageType.Info);
                EditorGUI.indentLevel--;

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);

                    int removePrefabIndex = -1;
                    if (configuration.Prefabs.Length > 1)
                    {
                        GUILayout.BeginVertical(GUILayout.Width(20));
                        {
                            GUILayout.Space(38);
                            for (int prefabIndex = 1; prefabIndex < configuration.Prefabs.Length; prefabIndex++)
                            {
                                if (GUILayout.Button("-", GUILayout.Height(15)))
                                {
                                    removePrefabIndex = prefabIndex;
                                }
                            }
                        }
                        GUILayout.EndVertical();
                    }

                    GUILayout.BeginVertical();
                    {
                        if (inputAnimationTypeValid)
                        {
                            inputPrefabContent.text = string.Format("Input ({0})", inputAnimationType);
                        }
                        else
                        {
                            inputPrefabContent.text = "Input";
                        }
                        GUILayout.Label(inputPrefabContent);

                        for (int prefabIndex = 0; prefabIndex < configuration.Prefabs.Length; prefabIndex++)
                        {
                            AnimationConverter.PrefabPair prefabPair = configuration.Prefabs[prefabIndex];

                            prefabPair.SourcePrefab = (GameObject)EditorGUILayout.ObjectField("", prefabPair.SourcePrefab, typeof(GameObject), false, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true));

                            if (inputAnimationTypeValid && (prefabPair.SourcePrefab != null))
                            {
                                string errorMessage;
                                AnimationConverter.AnimationType sourceAnimationType = DetermineAnimationType(prefabPair.SourcePrefab, out errorMessage);

                                if (!string.IsNullOrEmpty(errorMessage))
                                {
                                    EditorGUILayout.HelpBox(errorMessage, MessageType.Error);
                                    hasAnActiveError = true;
                                }
                                else if (sourceAnimationType != inputAnimationType)
                                {
                                    EditorGUILayout.HelpBox(string.Format("The prefab's animation type is {0} but should be {1}", sourceAnimationType, inputAnimationType), MessageType.Error);
                                    hasAnActiveError = true;
                                }
                            }

                            configuration.Prefabs[prefabIndex] = prefabPair;
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical();
                    {
                        outputPrefabContent.text = string.Format("Output ({0})", configuration.DestinationAnimationType);
                        GUILayout.Label(outputPrefabContent);

                        for (int prefabIndex = 0; prefabIndex < configuration.Prefabs.Length; prefabIndex++)
                        {
                            AnimationConverter.PrefabPair prefabPair = configuration.Prefabs[prefabIndex];

                            prefabPair.DestinationPrefab = (GameObject)EditorGUILayout.ObjectField("", prefabPair.DestinationPrefab, typeof(GameObject), false, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true));

                            if (prefabPair.DestinationPrefab != null)
                            {
                                string errorMessage;
                                AnimationConverter.AnimationType animationType = DetermineAnimationType(prefabPair.DestinationPrefab, out errorMessage);

                                if (!string.IsNullOrEmpty(errorMessage))
                                {
                                    EditorGUILayout.HelpBox(errorMessage, MessageType.Error);
                                    hasAnActiveError = true;
                                }
                                else if (animationType != configuration.DestinationAnimationType)
                                {
                                    EditorGUILayout.HelpBox(string.Format("The prefab's animation type is {0} but should be {1}", animationType, configuration.DestinationAnimationType), MessageType.Error);
                                    hasAnActiveError = true;
                                }
                            }

                            configuration.Prefabs[prefabIndex] = prefabPair;
                        }
                    }
                    GUILayout.EndVertical();

                    if (removePrefabIndex >= 0)
                    {
                        List <AnimationConverter.PrefabPair> prefabsList = configuration.Prefabs.ToList();
                        prefabsList.RemoveAt(removePrefabIndex);
                        configuration.Prefabs = prefabsList.ToArray();
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);

                    if (GUILayout.Button("Add Row"))
                    {
                        System.Array.Resize(ref configuration.Prefabs, configuration.Prefabs.Length + 1);
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            // ---------------------
            // Convert Button
            // ---------------------

            if (GUILayout.Button("Convert", GUILayout.Height(30)))
            {
                if (clipsToConvertList.Count <= 0)
                {
                    EditorUtility.DisplayDialog("Animation Converter - Couldn't start Conversion", "No clips to convert.", "OK");
                }
                else if (hasAnActiveError)
                {
                    EditorUtility.DisplayDialog("Animation Converter - Couldn't start Conversion", "Please fix all errors first.", "OK");
                }
                else if ((configuration.Prefabs[0].SourcePrefab == null) ||
                         (configuration.Prefabs[0].DestinationPrefab == null))
                {
                    EditorUtility.DisplayDialog("Animation Converter - Couldn't start Conversion", "Please assign the correct prefabs first.", "OK");
                }
                else
                {
                    string errorMessage             = "This action would overwrite the following input clips:";
                    bool   wouldOverwriteInputClips = false;
                    foreach (AnimationClip clip in clipsToConvertList)
                    {
                        string path = AssetDatabase.GetAssetPath(clip);

                        if (System.IO.Path.GetDirectoryName(path) == configuration.OutputDirectory)
                        {
                            errorMessage            += string.Format("\r\n\"{0}.anim\"", clip.name);
                            wouldOverwriteInputClips = true;
                        }
                    }

                    if (wouldOverwriteInputClips)
                    {
                        errorMessage += "\r\n\r\nPlease choose a different output directory.";
                        EditorUtility.DisplayDialog("Animation Converter - Couldn't start Conversion", errorMessage, "OK");
                    }
                    else
                    {
                        try
                        {
                            string logMessages;
                            AnimationConverter.Convert(clipsToConvertList.ToArray(), configuration, out logMessages);

                            AnimationConverterLogWindow.ShowDialog(logMessages);
                        }
                        catch (System.Exception ex)
                        {
                            Debug.LogException(ex);

                            EditorUtility.DisplayDialog("Animation Converter - An Error Occured", ex.Message + "\r\n\r\nA detailed error message is printed to the console.", "OK");
                        }
                    }
                }
            }
        }
 public override int OnCalculateSize(bool force)
 {
     _dataLen = AnimationConverter.CalculateCHR0Size(Keyframes, out _entryLen, out _code);
     return(_dataLen + _entryLen);
 }
Beispiel #11
0
 public override void OnRebuild(VoidPtr address, int length, bool force)
 {
     AnimationConverter.EncodeSRT0Keyframes(_keyframes, address, _dataAddr, _code);
 }
Beispiel #12
0
        /// <summary>
        /// Initialize Variables
        /// </summary>
        private void Initialize()
        {
           bones = new Collection<Bone>();
           joints = new Collection<Joint>();
           content = new Model3DGroup();
           if (animationConverter == null)
                animationConverter = new AnimationConverter();
            if (skeletonConverter == null)
                skeletonConverter = new SkeletonConverter();
            if (modelConverter == null)
                modelConverter = new ModelConverter();
            if (skeletonLiveConverter == null)
                skeletonLiveConverter = new SkeletonLiveConverter();

            PropertyChanged += CurrentModel3D_PropertyChanged;
        }
Beispiel #13
0
        /// <summary>
        /// Initialize Variables
        /// </summary>
        private void Initialize(string fullPath)
        {
            string PINOCCHIO_BINARY_PATH = System.IO.Path.Combine(System.IO.Path.Combine(Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).ToString()).ToString()).ToString()).ToString(), "AttachWeights"), "AttachWeightsWin.exe");
            Reinitialize(fullPath);

            if (animationConverter == null)
                animationConverter = new AnimationConverter();
            if (skeletonConverter == null)
                skeletonConverter = new SkeletonConverter();
            if (modelConverter == null)
                modelConverter = new ModelConverter();
            if (skeletonLiveConverter == null)
                skeletonLiveConverter = new SkeletonLiveConverter();

            PropertyChanged += CurrentModel3D_PropertyChanged;
        }
Beispiel #14
0
 public override Object Convert(IExportContainer container)
 {
     return(AnimationConverter.Convert(container, this));
 }
Beispiel #15
0
 public LB_Tools_Animation()
 {
     animationConverter = new AnimationConverter();
 }
Beispiel #16
0
 public override int OnCalculateSize(bool force)
 {
     _dataLength = AnimationConverter.CalculateSRT0Size(Keyframes, out _entryLength, out _code);
     return(_dataLength + _entryLength);
 }