public void ReadVIS0() { if (_animFrame == 0 || leftPanel.lstObjects.Items.Count == 0) { return; } leftPanel._vis0Updating = true; if (_vis0 != null) { //if (TargetAnimation != null && _vis0.FrameCount != TargetAnimation.tFrameCount) // UpdateVis0(null, null); foreach (string n in leftPanel.VIS0Indices.Keys) { VIS0EntryNode node = null; List <int> indices = leftPanel.VIS0Indices[n]; for (int i = 0; i < indices.Count; i++) { if ((node = (VIS0EntryNode)_vis0.FindChild(((MDL0ObjectNode)leftPanel.lstObjects.Items[indices[i]])._bone.Name, true)) != null) { if (node._entryCount != 0 && _animFrame > 0) { leftPanel.lstObjects.SetItemChecked(indices[i], node.GetEntry(_animFrame - 1)); } else { leftPanel.lstObjects.SetItemChecked(indices[i], node._flags.HasFlag(VIS0Flags.Enabled)); } } } } } leftPanel._vis0Updating = false; }
//protected override void modelPanel1_MouseUp(object sender, MouseEventArgs e) //{ // base.modelPanel1_MouseUp(sender, e); // if (e.Button == Forms.MouseButtons.Left) // { // } //} public override void ApplyVIS0ToInterface() { //base.ApplyVIS0ToInterface(); //return; if (_animFrame == 0 || leftPanel.lstObjects.Items.Count == 0) { return; } VIS0Updating = true; if (_vis0 != null) { //if (TargetAnimation != null && _vis0.FrameCount != TargetAnimation.tFrameCount) // UpdateVis0(null, null); foreach (string boneName in VIS0Indices.Keys) { MDL0ObjectNode obj; VIS0EntryNode node = null; Dictionary <int, List <int> > objects = VIS0Indices[boneName]; foreach (KeyValuePair <int, List <int> > objKey in objects) { obj = (MDL0ObjectNode)leftPanel.lstObjects.Items[objKey.Key]; foreach (int i in objKey.Value) { node = _vis0.FindChild(obj._drawCalls[i].VisibilityBone, true) as VIS0EntryNode; if (node != null) { bool render = node._entryCount != 0 && _animFrame > 0 ? node.GetEntry(_animFrame - 1) : node._flags.HasFlag(VIS0Flags.Enabled); if (leftPanel.InvokeRequired) { Action <int, int, bool, MDL0ObjectNode> d = new Action <int, int, bool, MDL0ObjectNode>(leftPanel.SetRenderState); Invoke(d, new object[] { objKey.Key, i, render, obj }); } else { leftPanel.SetRenderState(objKey.Key, i, render, obj); } } } } } } VIS0Updating = false; }
private void TargetChanged() { listBox1.BeginUpdate(); listBox1.Items.Clear(); if (_targetNode != null) { for (int i = 0; i < _targetNode._entryCount; i++) { listBox1.Items.Add(_targetNode.GetEntry(i)); } } listBox1.EndUpdate(); }
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; } } }
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; } } }
public void ReadVIS0() { if (CurrentFrame == 0 || modelListsPanel1.lstObjects.Items.Count == 0) { return; } listPanel._vis0Updating = true; if (_vis0 != null) { foreach (string n in listPanel.VIS0Indices.Keys) { VIS0EntryNode node = null; List <int> indices = listPanel.VIS0Indices[n]; for (int i = 0; i < indices.Count; i++) { if ((node = (VIS0EntryNode)_vis0.FindChild(((MDL0ObjectNode)modelListsPanel1.lstObjects.Items[indices[i]])._bone.Name, true)) != null) { if (node._entryCount != 0 && CurrentFrame > 0) { modelListsPanel1.lstObjects.SetItemChecked(indices[i], node.GetEntry(CurrentFrame - 1)); } else { modelListsPanel1.lstObjects.SetItemChecked(indices[i], node._flags.HasFlag(VIS0Flags.Enabled)); } } } } } listPanel._vis0Updating = false; }
public override void ApplyVIS0ToInterface() { if (_animFrame == 0 || modelListsPanel1.lstObjects.Items.Count == 0) { return; } VIS0Updating = true; if (_vis0 != null) { //if (TargetAnimation != null && _vis0.FrameCount != TargetAnimation.tFrameCount) // UpdateVis0(null, null); foreach (string n in VIS0Indices.Keys) { VIS0EntryNode node = null; List <int> indices = VIS0Indices[n]; for (int i = 0; i < indices.Count; i++) { if ((node = (VIS0EntryNode)_vis0.FindChild(((MDL0ObjectNode)modelListsPanel1.lstObjects.Items[indices[i]])._visBoneNode.Name, true)) != null) { if (node._entryCount != 0 && _animFrame > 0) { modelListsPanel1.lstObjects.SetItemChecked(indices[i], node.GetEntry((int)_animFrame - 1)); } else { modelListsPanel1.lstObjects.SetItemChecked(indices[i], node._flags.HasFlag(VIS0Flags.Enabled)); } } } } } VIS0Updating = false; }