public void CreateVIS0() { if (!(_targetModel is MDL0Node)) { return; } BRRESNode group = null; BRESEntryNode n = null; if ((n = TargetAnimation as BRESEntryNode) != null && (group = n.Parent.Parent as BRRESNode) != null) { _vis0 = group.CreateResource <VIS0Node>(SelectedCHR0.Name); foreach (string s in VIS0Indices.Keys) { VIS0EntryNode node = null; if ((node = (VIS0EntryNode)_vis0.FindChild(s, true)) == null && ((MDL0BoneNode)((ResourceNode)_targetModel).FindChildByType(s, true, ResourceType.MDL0Bone)).BoneIndex != 0 && s != "EyeYellowM") { node = _vis0.CreateEntry(); node.Name = s; node.MakeConstant(true); } } } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { VIS0EntryNode n = visEditor1.TargetNode = listBox1.Items[listBox1.SelectedIndex] as VIS0EntryNode; Constant.Checked = n._flags.HasFlag(VIS0Flags.Constant); eEnabled.Checked = n._flags.HasFlag(VIS0Flags.Enabled); }
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; }
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; }
public void NewBone() { VIS0EntryNode node = ((VIS0Node)_resource).CreateEntry(); BaseWrapper res = this.FindResource(node, false); res.EnsureVisible(); res.TreeView.SelectedNode = res; }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex >= 0 && listBox1.SelectedIndex < listBox1.Items.Count) { TargetVisEntry = listBox1.Items[listBox1.SelectedIndex] as VIS0EntryNode; } //if (_mainWindow.CurrentFrame > 0 && _mainWindow.CurrentFrame < _mainWindow.KeyframePanel.visEditor.listBox1.Items.Count) // _mainWindow.KeyframePanel.visEditor.listBox1.SelectedIndex = _mainWindow.CurrentFrame - 1; }
//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; }
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; } } }