public void NewEntry() { SHP0EntryNode node = ((SHP0Node)_resource).FindOrCreateEntry(_resource.FindName(null)); BaseWrapper res = FindResource(node, false); res.EnsureVisible(); res.TreeView.SelectedNode = res; }
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(); }
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(); }
public void NewEntry() { SHP0EntryNode n = (SHP0EntryNode)_resource; n.CreateEntry(); }
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); } }