예제 #1
0
        private void Toggle()
        {
            listBox1.BeginUpdate();

            int[] indices = new int[listBox1.SelectedIndices.Count];
            listBox1.SelectedIndices.CopyTo(indices, 0);
            foreach (int i in indices)
            {
                bool val = !(bool)listBox1.Items[i];
                listBox1.Items[i] = val;
                _targetNode.SetEntry(i, val);
            }
            foreach (int i in indices)
            {
                listBox1.SelectedIndices.Add(i);
            }

            listBox1.EndUpdate();
        }
예제 #2
0
        public void UpdateVis0(int objectIndex, int drawCallIndex, bool value)
        {
            BRESEntryNode n;

            if ((n = TargetAnimation as BRESEntryNode) == null ||
                _animFrame == 0 ||
                TargetModel == null)
            {
                return;
            }

Start:
            if (_vis0 != null)
            {
                if (objectIndex < 0 || objectIndex >= TargetModel.Objects.Length)
                {
                    return;
                }

                MDL0ObjectNode obj = (MDL0ObjectNode)TargetModel.Objects[objectIndex];

                if (drawCallIndex < 0 || drawCallIndex >= obj._drawCalls.Count)
                {
                    return;
                }

                DrawCall     c    = obj._drawCalls[drawCallIndex];
                MDL0BoneNode bone = c._visBoneNode;

                if (bone == null)
                {
                    return;
                }

                VIS0EntryNode node = null;
                if ((node = (VIS0EntryNode)_vis0.FindChild(bone.Name, true)) == null && bone.BoneIndex != 0 && bone.Name != "EyeYellowM")
                {
                    node      = _vis0.CreateEntry();
                    node.Name = bone.Name;
                    node.MakeConstant(true);
                }

                bool ANIMval = value;

                bool nowAnimated = false, alreadyConstant = false;
Top:
                if (node != null)
                {
                    if (node._entryCount != 0) //Node is animated
                    {
                        bool VIS0val = node.GetEntry((int)_animFrame - 1);

                        if (VIS0val != ANIMval)
                        {
                            node.SetEntry((int)_animFrame - 1, ANIMval);
                        }
                    }
                    else //Node is constant
                    {
                        alreadyConstant = true;

                        bool VIS0val = node._flags.HasFlag(VIS0Flags.Enabled);

                        if (VIS0val != ANIMval)
                        {
                            node.MakeAnimated();
                            nowAnimated = true;
                            goto Top;
                        }
                    }
                }

                //Check if the entry can be made constant.
                //No point if the entry has just been made animated or if the node is already constant.
                if (node != null && !alreadyConstant && !nowAnimated)
                {
                    bool constant = true;
                    for (int i = 0; i < node._entryCount; i++)
                    {
                        if (i == 0)
                        {
                            continue;
                        }

                        if (node.GetEntry(i - 1) != node.GetEntry(i))
                        {
                            constant = false;
                            break;
                        }
                    }
                    if (constant)
                    {
                        node.MakeConstant(node.GetEntry(0));
                    }
                }

                var t = (VIS0EntryNode)KeyframePanel.visEditor.TargetNode;
                if (node != null && t != null && t.Name == node.Name)
                {
                    VIS0Editor.UpdateEntry();
                }
            }
            else
            {
                CreateVIS0();
                if (_vis0 != null)
                {
                    goto Start;
                }
            }
        }
예제 #3
0
        public void UpdateVis0(object sender, EventArgs e)
        {
            BRESEntryNode n;

            if ((n = GetAnimation(TargetAnimType) as BRESEntryNode) == null || CurrentFrame == 0)
            {
                return;
            }

Start:
            if (_vis0 != null)
            {
                int index = listPanel._polyIndex;
                if (index == -1)
                {
                    return;
                }

                MDL0BoneNode bone = ((MDL0ObjectNode)modelListsPanel1.lstObjects.Items[index])._bone;

                VIS0EntryNode node = null;
                if ((node = (VIS0EntryNode)_vis0.FindChild(bone.Name, true)) == null && bone.BoneIndex != 0 && bone.Name != "EyeYellowM")
                {
                    node      = _vis0.CreateEntry();
                    node.Name = bone.Name;
                    node.MakeConstant(true);
                }

                //Item is in the process of being un/checked; it's not un/checked at the given moment.
                //Use opposite of current check state.
                bool ANIMval = !modelListsPanel1.lstObjects.GetItemChecked(index);

                bool nowAnimated = false, alreadyConstant = false;
Top:
                if (node != null)
                {
                    if (node._entryCount != 0) //Node is animated
                    {
                        bool VIS0val = node.GetEntry(CurrentFrame - 1);

                        if (VIS0val != ANIMval)
                        {
                            node.SetEntry(CurrentFrame - 1, ANIMval);
                        }
                    }
                    else //Node is constant
                    {
                        alreadyConstant = true;

                        bool VIS0val = node._flags.HasFlag(VIS0Flags.Enabled);

                        if (VIS0val != ANIMval)
                        {
                            node.MakeAnimated();
                            nowAnimated = true;
                            goto Top;
                        }
                    }
                }

                //Check if the entry can be made constant.
                //No point if the entry has just been made animated or if the node is already constant.
                if (node != null && !alreadyConstant && !nowAnimated)
                {
                    bool constant = true;
                    for (int i = 0; i < node._entryCount; i++)
                    {
                        if (i == 0)
                        {
                            continue;
                        }

                        if (node.GetEntry(i - 1) != node.GetEntry(i))
                        {
                            constant = false;
                            break;
                        }
                    }
                    if (constant)
                    {
                        node.MakeConstant(node.GetEntry(0));
                    }
                }
            }
            else
            {
                CreateVIS0();
                if (_vis0 != null)
                {
                    goto Start;
                }
            }
        }