Ejemplo n.º 1
0
        public void Regen()
        {
            MDL0BoneNode b = _resource as MDL0BoneNode;
            MDL0Node     m = b?.Model;

            if (m != null)
            {
                m._linker.RegenerateBoneCache(true);
                OnUpdateProperties(null, null);
                b.SignalPropertyChange();
            }
        }
Ejemplo n.º 2
0
        public void Remap()
        {
            MDL0BoneNode b = _resource as MDL0BoneNode;
            MDL0Node     m = b?.Model;

            if (m != null)
            {
                b._entryIndex = m._linker.BoneCache.Length;
                m._linker.RegenerateBoneCache();
                OnUpdateProperties(null, null);
                b.SignalPropertyChange();
            }
        }
Ejemplo n.º 3
0
        internal unsafe void BoxChanged(object sender, EventArgs e)
        {
            if (_transformObject == null)
            {
                return;
            }

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

            if (_transformObject is MDL0BoneNode)
            {
                MDL0BoneNode bone = _transformObject as MDL0BoneNode;

                if ((_selectedAnim != null) && (_animFrame > 0))
                {
                    //Find bone anim and change transform
                    CHR0EntryNode entry = _selectedAnim.FindChild(bone.Name, false) as CHR0EntryNode;
                    if (entry == null) //Create new bone animation
                    {
                        if (!float.IsNaN(box.Value))
                        {
                            entry       = _selectedAnim.CreateEntry();
                            entry._name = bone.Name;

                            //Set initial values
                            FrameState state = bone._bindState;
                            float *    p     = (float *)&state;
                            for (int i = 0; i < 3; i++)
                            {
                                if (p[i] != 1.0f)
                                {
                                    entry.SetKeyframe(KeyFrameMode.ScaleX + i, 0, p[i]);
                                }
                            }
                            for (int i = 3; i < 9; i++)
                            {
                                if (p[i] != 0.0f)
                                {
                                    entry.SetKeyframe(KeyFrameMode.ScaleX + i, 0, p[i]);
                                }
                            }

                            entry.SetKeyframe(KeyFrameMode.ScaleX + index, _animFrame - 1, box.Value);
                        }
                    }
                    else //Set existing
                    {
                        if (float.IsNaN(box.Value))
                        {
                            entry.RemoveKeyframe(KeyFrameMode.ScaleX + index, _animFrame - 1);
                        }
                        else
                        {
                            entry.SetKeyframe(KeyFrameMode.ScaleX + index, _animFrame - 1, box.Value);
                        }
                    }
                }
                else
                {
                    //Change base transform
                    FrameState state = bone._bindState;
                    float *    p     = (float *)&state;
                    p[index] = float.IsNaN(box.Value) ? (index > 2 ? 0.0f : 1.0f) : box.Value;
                    state.CalcTransforms();
                    bone._bindState = state;
                    bone.RecalcBindState();
                    bone.SignalPropertyChange();
                }

                _targetModel.ApplyCHR(_selectedAnim, _animFrame);
                ResetBox(index);
                if (RenderStateChanged != null)
                {
                    RenderStateChanged(this, null);
                }
            }
        }