Ejemplo n.º 1
0
        public unsafe void ResetBox()
        {
            MDL0VertexNode    vSet = VertexSet;
            SHP0EntryNode     entry;
            SHP0VertexSetNode v;

            if (VertexSet == null || SelectedDestination == null)
            {
                return;
            }
            if ((SelectedAnimation != null) && (CurrentFrame > 0) &&
                ((entry = SelectedAnimation.FindChild(vSet.Name, false) as SHP0EntryNode) != null) &&
                (v = entry.FindChild(SelectedDestination.Name, false) as SHP0VertexSetNode) != null)
            {
                KeyframeEntry e = v.Keyframes.GetKeyframe(CurrentFrame - 1);
                if (e == null)
                {
                    textBox1.Value     = v.Keyframes[CurrentFrame - 1] * 100.0f;
                    textBox1.BackColor = Color.White;
                }
                else
                {
                    textBox1.Value     = e._value * 100.0f;
                    textBox1.BackColor = Color.Yellow;
                }
            }
            else
            {
                textBox1.Value     = 0;
                textBox1.BackColor = Color.White;
            }
            updating        = true;
            trackBar1.Value = ((int)(textBox1.Value * 10.0f)).Clamp(trackBar1.Minimum, trackBar1.Maximum);
            updating        = false;
        }
Ejemplo n.º 2
0
        public unsafe void ResetBox(int index)
        {
            if (index == 2 || index == 4 || index == 5 || index == 8)
            {
                return;
            }

            NumericInputBox     box = _transBoxes[index];
            MDL0MaterialRefNode mr  = TargetTexRef;
            SRT0TextureNode     entry;

            if (TargetTexRef != null)
            {
                if ((SelectedAnimation != null) && (CurrentFrame > 0) && ((entry = SelectedAnimation.FindChild(mr.Parent.Name + "/Texture" + mr.Index, true) as SRT0TextureNode) != null))
                {
                    KeyframeEntry e = entry.Keyframes.GetKeyframe((KeyFrameMode)index + 0x10, CurrentFrame - 1);
                    if (e == null)
                    {
                        box.Value     = entry.Keyframes[KeyFrameMode.ScaleX + index, CurrentFrame - 1];
                        box.BackColor = Color.White;
                    }
                    else
                    {
                        box.Value     = e._value;
                        box.BackColor = Color.Yellow;
                    }
                }
                else
                {
                    FrameState state = mr._bindState;
                    box.Value     = ((float *)&state)[index];
                    box.BackColor = Color.White;
                }
            }
        }
Ejemplo n.º 3
0
        private void UpdateKartReferenceImage()
        {
            KartAnimationSeries refAnim = kartPreviewControl.ReferenceKart.KartAnimations.FirstOrDefault(
                f => (f.KartAnimationType & SelectedAnimation.KartAnimationType) != 0);

            if (refAnim == null)
            {
                kartPreviewControl.OverlayImage = null;
                return;
            }

            int refIndex;

            if (refAnim.IsTurnAnim)
            {
                refIndex = refAnim.GetImageIndexForTurnFrame(SelectedAnimation.GetTurnFrameForImageIndex(SelectedAnimation.OrderedImageNames.IndexOf(SelectedImage.Name)));
            }
            else if (refAnim.IsSpinAnim)
            {
                refIndex = refAnim.GetImageIndexForSpinFrame(SelectedAnimation.GetSpinFrameForImageIndex(SelectedAnimation.OrderedImageNames.IndexOf(SelectedImage.Name)));
            }
            else
            {
                refIndex = refAnim.GetImageIndexForCrashFrame(SelectedAnimation.GetCrashFrameForImageIndex(SelectedAnimation.OrderedImageNames.IndexOf(SelectedImage.Name)));
            }

            kartPreviewControl.OverlayImage = kartPreviewControl.ReferenceKart.KartImages.Images[refAnim.OrderedImageNames[refIndex]].Images[0].Image;
        }
Ejemplo n.º 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if ((SelectedAnimation == null) || (CurrentFrame == 0))
            {
                return;
            }

            SelectedAnimation.DeleteKeyframe(CurrentFrame - 1);
            _mainWindow.SRT0StateChanged(this, null);
        }
Ejemplo n.º 5
0
        private void addCustomAmountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedAnimation == null || type == 0)
            {
                return;
            }

            EditDialog ed = new EditDialog();

            ed.ShowDialog(null, (KeyFrameMode)type, SelectedAnimation.FindChild(TargetTexRef.Name, false) as CHR0EntryNode);
            ResetBox(type - 0x10);
            _mainWindow.UpdateModel();
        }
Ejemplo n.º 6
0
        private void OnPropertyChanged(string propertyName)
        {
            if (propertyName == "SelectedAnimation")
            {
                if (SelectedAnimation != null)
                {
                    SelectedAnimation.RefreshCombinedStates(SelectedState.Self.SelectedElement);
                }
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }

            OnAnyChange(this, propertyName);
        }
Ejemplo n.º 7
0
        private void removeAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedAnimation == null || type == 0)
            {
                return;
            }

            SRT0TextureNode _target = SelectedAnimation.FindChild(TargetTexRef.Parent.Name + "/Texture" + TargetTexRef.Index, true) as SRT0TextureNode;

            if (_target != null)
            {
                _target.Keyframes._keyRoots[type & 0xF]  = new KeyframeEntry(-1, type >= 0x10 && type <= 0x12 ? 1 : 0);
                _target.Keyframes._keyCounts[type & 0xF] = 0;
                _target.SignalPropertyChange();
                ResetBox(type - 0x10);
                _mainWindow.UpdateModel();
            }
        }
        private void OnPropertyChanged(string propertyName)
        {
            if (propertyName == nameof(SelectedAnimation))
            {
                if (SelectedAnimation != null)
                {
                    SelectedAnimation.RefreshCombinedStates(SelectedState.Self.SelectedElement);
                }

                RefreshRightClickMenuItems();
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }

            OnAnyChange(this, propertyName);
        }
Ejemplo n.º 9
0
        internal unsafe void PercentChanged(object sender, EventArgs e)
        {
            if (SelectedSource == null || SelectedDestination == null || updating)
            {
                return;
            }

            if ((SelectedAnimation != null) && (CurrentFrame >= 1))
            {
                SHP0EntryNode     entry = SelectedAnimation.FindChild(SelectedSource, false) as SHP0EntryNode;
                SHP0VertexSetNode v;

                if (entry == null)
                {
                    (v = (entry = SelectedAnimation.FindOrCreateEntry(SelectedSource)).Children[0] as SHP0VertexSetNode).Name = SelectedDestination;
                }
                else if ((v = entry.FindChild(SelectedDestination, false) as SHP0VertexSetNode) == null)
                {
                    if (!float.IsNaN(textBox1.Value))
                    {
                        v = entry.FindOrCreateEntry(SelectedDestination);
                        v.SetKeyframe(CurrentFrame - 1, textBox1.Value / 100.0f);
                    }
                }
                else
                if (float.IsNaN(textBox1.Value))
                {
                    v.RemoveKeyframe(CurrentFrame - 1);
                }
                else
                {
                    v.SetKeyframe(CurrentFrame - 1, textBox1.Value / 100.0f);
                }

                if (_mainWindow.InterpolationEditor != null && _mainWindow.InterpolationEditor._targetNode != VertexSetDest)
                {
                    _mainWindow.InterpolationEditor.SetTarget(VertexSetDest);
                }
            }
            ResetBox();
            _mainWindow.KeyframePanel.UpdateKeyframe(CurrentFrame - 1);
            _mainWindow.UpdateModel();
        }
Ejemplo n.º 10
0
        internal unsafe void PercentChanged(object sender, EventArgs e)
        {
            if (VertexSet == null || SelectedDestination == null || updating)
            {
                return;
            }

            MDL0VertexNode vSet = VertexSet;

            if ((SelectedAnimation != null) && (CurrentFrame > 0))
            {
                SHP0EntryNode     entry = SelectedAnimation.FindChild(vSet.Name, false) as SHP0EntryNode;
                SHP0VertexSetNode v;

                if (entry == null)
                {
                    (v = (entry = SelectedAnimation.FindOrCreateEntry(vSet.Name)).Children[0] as SHP0VertexSetNode).Name = SelectedDestination.Name;
                }
                else if ((v = entry.FindChild(SelectedDestination.Name, false) as SHP0VertexSetNode) == null)
                {
                    if (!float.IsNaN(textBox1.Value))
                    {
                        v = entry.FindOrCreateEntry(SelectedDestination.Name);
                        v.SetKeyframe(CurrentFrame - 1, textBox1.Value / 100.0f);
                    }
                }
                else
                if (float.IsNaN(textBox1.Value))
                {
                    v.RemoveKeyframe(CurrentFrame - 1);
                }
                else
                {
                    v.SetKeyframe(CurrentFrame - 1, textBox1.Value / 100.0f);
                }
            }
            //TargetModel.ApplyCHR(SelectedCHR0, CurrentFrame);
            //TargetModel.ApplySHP(SelectedAnimation, CurrentFrame);
            //ResetBox();
            //_mainWindow.modelPanel1.Invalidate();
            _mainWindow.UpdateModel();
        }
Ejemplo n.º 11
0
        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            if (SelectedAnimation == null || type == 0)
            {
                return;
            }

            KeyframeEntry   kfe;
            SRT0TextureNode _target = SelectedAnimation.FindChild(TargetTexRef.Parent.Name + "/Texture" + TargetTexRef.Index, true) as SRT0TextureNode;

            for (int x = 0; x < _target.FrameCount; x++)                        //Loop thru each frame
            {
                if ((kfe = _target.GetKeyframe((KeyFrameMode)type, x)) != null) //Check for a keyframe
                {
                    kfe._value += 90;
                }
            }
            ResetBox(type - 0x10);
            _mainWindow.UpdateModel();
        }
Ejemplo n.º 12
0
        public unsafe void ResetBox()
        {
            MDL0VertexNode    vSet = VertexSet;
            SHP0EntryNode     entry;
            SHP0VertexSetNode v;

            if (VertexSet == null || SelectedDestination == null)
            {
                return;
            }
            if ((SelectedAnimation != null) && (CurrentFrame > 0) &&
                ((entry = SelectedAnimation.FindChild(vSet.Name, false) as SHP0EntryNode) != null) &&
                (v = entry.FindChild(SelectedDestination.Name, false) as SHP0VertexSetNode) != null)
            {
                KeyframeEntry e = v.Keyframes.GetKeyframe(KeyFrameMode.ScaleX, CurrentFrame - 1);
                if (e == null)
                {
                    float val = v.Keyframes[KeyFrameMode.ScaleX, CurrentFrame - 1];
                    textBox1.Value     = (val > 1 ? 1 : val < 0 ? 0 : val) * 100.0f;
                    textBox1.BackColor = Color.White;
                }
                else
                {
                    textBox1.Value     = (e._value > 1 ? 1 : e._value < 0 ? 0 : e._value) * 100.0f;
                    textBox1.BackColor = Color.Yellow;
                }
            }
            else
            {
                textBox1.Value     = 0;
                textBox1.BackColor = Color.White;
            }
            updating        = true;
            trackBar1.Value = (int)(textBox1.Value * 10.0f);
            updating        = false;
        }
Ejemplo n.º 13
0
        private unsafe void button5_Click(object sender, EventArgs e)
        {
            //Set vertices (0), normals (1), and/or colors (2, 3)
            //UVs are not morphed so there's no need to set them

            if (SelectedAnimation == null ||
                SelectedSource == null ||
                TargetModel == null ||
                TargetModel.Objects == null ||
                TargetModel.Objects.Length == 0)
            {
                return;
            }

            SHP0EntryNode entry = SelectedAnimation.FindChild(SelectedSource, false) as SHP0EntryNode;

            if (entry == null)
            {
                return;
            }

            if (MessageBox.Show(this, "Are you sure you want to continue?\nThis will edit the model and make the selected object's vertices, normals and/or colors default to the current morph.", "Are you sure?", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }

            //Set the model to be only the bind pose with the SHP0 applied
            //This is so when the data is unweighted,
            //only the influence of the SHP0 will be set to the model.
            //Otherwise the entire CHR0 pose would be set as well
            float    frame = CurrentFrame;
            SHP0Node shp   = _mainWindow.SelectedSHP0;
            CHR0Node chr   = _mainWindow.SelectedCHR0;

            if (TargetModel != null)
            {
                TargetModel.ApplyCHR(null, 0);
                TargetModel.ApplySHP(shp, frame);
            }

            ResourceNode[] nodes = ((ResourceNode)TargetModel).FindChildrenByName(SelectedSource);
            foreach (ResourceNode n in nodes)
            {
                if (n is MDL0VertexNode)
                {
                    MDL0VertexNode   node = (MDL0VertexNode)n;
                    MDL0ObjectNode[] o    = new MDL0ObjectNode[node._objects.Count];
                    node._objects.CopyTo(o);
                    foreach (MDL0ObjectNode obj in o)
                    {
                        //Set the unweighted positions using the weighted positions
                        //Created using the SHP0
                        obj.Unweight(false);
                        obj.SetEditedAssets(true, true, false, false, false);
                    }
                }
                else if (n is MDL0NormalNode)
                {
                    MDL0NormalNode   node = (MDL0NormalNode)n;
                    MDL0ObjectNode[] o    = new MDL0ObjectNode[node._objects.Count];
                    node._objects.CopyTo(o);
                    foreach (MDL0ObjectNode obj in o)
                    {
                        obj.SetEditedAssets(true, false, true, false, false);
                    }
                }
                else if (n is MDL0ColorNode)
                {
                    MDL0ColorNode    node = (MDL0ColorNode)n;
                    MDL0ObjectNode[] o    = new MDL0ObjectNode[node._objects.Count];
                    node._objects.CopyTo(o);
                    foreach (MDL0ObjectNode obj in o)
                    {
                        obj.SetEditedAssets(true, false, false, true, true);
                    }
                }
            }

            if (TargetModel != null)
            {
                TargetModel.ApplyCHR(chr, frame);
                TargetModel.ApplySHP(shp, frame);
            }
        }
Ejemplo n.º 14
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();
        }