public static KeyframeArray DecodeSHP0Keyframes(SHP0KeyframeEntries *entry, SHP0Node node) { //If the node is null, assume the programmer has created a new entry and accessed //the keyframe collection for the first time before assigning the parent and will //set the frame count later manually. int numFrames = node == null ? 1 : node.FrameCount + (node.Loop ? 1 : 0); KeyframeArray kf = new KeyframeArray(numFrames) { Loop = node.Loop }; if (entry == null) { return(kf); } int fCount = entry->_numEntries; BVec3 *vec = entry->Entries; for (int i = 0; i < fCount; i++, vec++) { kf.SetFrameValue((int)vec->_y, vec->_z, true)._tangent = vec->_x; } return(kf); }
public void NewShp() { SHP0Node node = ((BRRESNode)_resource).CreateResource <SHP0Node>("NewSHP"); node.Version = 3; BaseWrapper res = this.FindResource(node, true); res = res.FindResource(node, false); res.EnsureVisible(); res.TreeView.SelectedNode = res; }
public void ImportShp() { if (Program.OpenFile(FileFilters.SHP0, out string path) > 0) { SHP0Node node = NodeFactory.FromFile(null, path) as SHP0Node; ((BRRESNode)_resource).GetOrCreateFolder <SHP0Node>().AddChild(node); BaseWrapper w = FindResource(node, true); w.EnsureVisible(); w.TreeView.SelectedNode = w; } }
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); } }