Example #1
0
        public bool Close()
        {
            try
            {
                if (!CloseExternal())
                {
                    return(false);
                }

                BrawlBox.Properties.Settings.Default.ViewerSettings     = CollectSettings();
                BrawlBox.Properties.Settings.Default.ScreenCapBgLocText = ScreenCapBgLocText.Text;
                BrawlBox.Properties.Settings.Default.ViewerSettingsSet  = true;
                BrawlBox.Properties.Settings.Default.Save();

                StopAnim();

                if (_viewerForm != null)
                {
                    _viewerForm.Close();
                }
                if (_interpolationForm != null)
                {
                    _interpolationForm.Close();
                }

                if (TargetModel != null)
                {
                    TargetModel.ApplyCHR(null, 0);
                    TargetModel.ApplySRT(null, 0);
                }
                ResetBoneColors();
            }
            catch { }
            return(true);
        }
Example #2
0
        internal unsafe void BoxChanged(object sender, EventArgs e)
        {
            if (TargetTexRef == null || sender == null)
            {
                return;
            }

            NumericInputBox box   = sender as NumericInputBox;
            int             index = (int)box.Tag;

            if (index == 2 || index == 4 || index == 5 || index == 8)
            {
                return;
            }

            MDL0MaterialRefNode mr = TargetTexRef;

            if ((SelectedAnimation != null) && (CurrentFrame > 0))
            {
                SRT0TextureNode entry = SelectedAnimation.FindChild(mr.Parent.Name + "/Texture" + mr.Index, true) as SRT0TextureNode;

                if (entry == null)
                {
                    if (!float.IsNaN(box.Value))
                    {
                        entry = SelectedAnimation.FindOrCreateEntry(mr.Parent.Name, mr.Index);

                        //Set initial values (so they aren't null)
                        FrameState state = mr._bindState; //Get the texture's bindstate
                        float *    p     = (float *)&state;
                        for (int i = 0; i < 3; i++)       //Get the scale
                        {
                            if (p[i] != 1.0f)             //Check for default values
                            {
                                entry.SetKeyframe(KeyFrameMode.ScaleX + i, 0, p[i]);
                            }
                        }
                        for (int i = 3; i < 9; i++) //Get rotation and translation respectively
                        {
                            if (p[i] != 0.0f)       //Check for default values
                            {
                                entry.SetKeyframe(KeyFrameMode.ScaleX + i, 0, p[i]);
                            }
                        }
                        if (p[10] != 0.0f)
                        {
                            entry.SetKeyframe(KeyFrameMode.ScaleX + 10, 0, p[10]);
                        }

                        //Finally, replace with the changed value
                        entry.SetKeyframe(KeyFrameMode.ScaleX + index, CurrentFrame - 1, box.Value);
                    }
                }
                else //Set to existing SRT0 texture
                if (float.IsNaN(box.Value))
                {
                    entry.RemoveKeyframe(KeyFrameMode.ScaleX + index, CurrentFrame - 1);
                }
                else
                {
                    entry.SetKeyframe(KeyFrameMode.ScaleX + index, CurrentFrame - 1, box.Value);
                }
            }
            else
            {
                //Change base transform
                FrameState state = mr._bindState;
                float *    p     = (float *)&state;
                p[index]      = float.IsNaN(box.Value) ? (index > 2 ? 0.0f : 1.0f) : box.Value;
                mr._bindState = state;
                //mr.RecalcBindState();
                mr.SignalPropertyChange();
            }
            TargetModel.ApplySRT(SelectedAnimation, CurrentFrame);
            ResetBox(index);
            _mainWindow.modelPanel1.Invalidate();
        }