private void SetupNewTopNode(TreeNode node) { //Create MSEG and Keyset AquaMotion.KeyData keyData = new AquaMotion.KeyData(); AquaMotion.MSEG newMseg = new AquaMotion.MSEG(); newMseg.nodeDataCount = 1; newMseg.nodeId = currentMotion.motionKeys[node.Index].mseg.nodeId + 1; newMseg.nodeName.SetString("Node " + newMseg.nodeId); int transformType = GetTransformType(node, out int nodeType); if (nodeType == -1) { return; } newMseg.nodeType = nodeType; //Add an empty frame TreeNode keyNode = new TreeNode("Frame 0"); keyNode.Tag = 2; //Add MKEY data keyData.mseg = newMseg; AquaMotion.MKEY newMkey = GenerateMKEY(transformType); keyData.keyData.Add(newMkey); currentMotion.motionKeys.Add(keyData); }
public void animTreeView_Duplicate(object sender, EventArgs e) { TreeNode node = animTreeView.SelectedNode; //Camera motions should only ever have one node if ((int)node.Tag == 0 && currentMotion.moHeader.variant == AquaMotion.cameraAnim) { MessageBox.Show("You cannot have multiple camera nodes!"); return; } //Return if this is a transform category node. There should never be multiple of the same one. Ideally, don't show this option for this category. if ((int)node.Tag == 1) { MessageBox.Show("You can't duplicate transformation categories!"); return; } //Since frames must be whole numbers, prevent more frames than the endframe count from being added if ((int)node.Tag == 2) { currentMotion.motionKeys[node.Parent.Parent.Index].keyData[node.Parent.Index].keyCount += 1; } //Recreate and insert the new node TreeNode newNode = new TreeNode(node.Text); newNode.Tag = node.Tag; //Set the duplicate data switch ((int)node.Tag) { case 0: //Duplicate Transform TreeNodes for (int i = 0; i < node.Nodes.Count; i++) { TreeNode tfmNode = new TreeNode(node.Nodes[i].Text); tfmNode.Tag = node.Nodes[i].Tag; //Duplicate Key Treenodes for (int j = 0; j < node.Nodes.Count; j++) { TreeNode keyNode = new TreeNode(node.Nodes[i].Nodes[j].Text); keyNode.Tag = node.Nodes[i].Nodes[j].Tag; tfmNode.Nodes.Add(keyNode); } newNode.Nodes.Add(tfmNode); } //Set actual data AquaMotion.KeyData oldData = currentMotion.motionKeys[node.Index]; AquaMotion.KeyData keyData = new AquaMotion.KeyData(); keyData.mseg = new AquaMotion.MSEG(); keyData.mseg.nodeName = oldData.mseg.nodeName; keyData.mseg.nodeDataCount = oldData.mseg.nodeDataCount; keyData.mseg.nodeId = oldData.mseg.nodeId; keyData.mseg.nodeType = oldData.mseg.nodeType; //Duplicate keydata for (int i = 0; i < oldData.keyData.Count; i++) { //Duplicate MKEY value data AquaMotion.MKEY oldKey = currentMotion.motionKeys[node.Index].keyData[i]; AquaMotion.MKEY newKey = new AquaMotion.MKEY(); newKey.dataType = oldKey.dataType; newKey.keyCount = oldKey.keyCount; newKey.keyType = oldKey.keyType; newKey.unkInt0 = oldKey.unkInt0; newKey.floatKeys.AddRange(oldKey.floatKeys); newKey.frameTimings.AddRange(oldKey.frameTimings); newKey.intKeys.AddRange(oldKey.intKeys); newKey.vector4Keys.AddRange(oldKey.vector4Keys); keyData.keyData.Add(newKey); } currentMotion.motionKeys.Insert(node.Index, keyData); currentMotion.moHeader.nodeCount++; break; case 2: var keySet = currentMotion.motionKeys[node.Parent.Parent.Index].keyData[node.Parent.Index]; if (keySet.frameTimings.Count == 0) { keySet.frameTimings.Add(0); keySet.frameTimings.Insert(0, 0); } else { keySet.frameTimings.Insert(node.Index, currentMotion.motionKeys[node.Parent.Parent.Index].keyData[node.Parent.Index].frameTimings[node.Index]); } switch (keySet.dataType) { //0x1, 0x2, and 0x3 are Vector4 arrays essentially. 0x1 is seemingly a Vector3 with alignment padding, but could potentially have things. case 0x1: case 0x2: case 0x3: keySet.vector4Keys.Insert(node.Index, currentMotion.motionKeys[node.Parent.Parent.Index].keyData[node.Parent.Index].vector4Keys[node.Index]); break; case 0x5: keySet.intKeys.Insert(node.Index, currentMotion.motionKeys[node.Parent.Parent.Index].keyData[node.Parent.Index].intKeys[node.Index]); break; //0x4 is texture/uv related, 0x6 is Camera related - Array of floats. 0x4 seems to be used for every .aqv frame set interestingly case 0x4: case 0x6: keySet.floatKeys.Insert(node.Index, currentMotion.motionKeys[node.Parent.Parent.Index].keyData[node.Parent.Index].floatKeys[node.Index]); break; default: throw new Exception("Unexpected data type!"); } break; default: throw new Exception("Unexpected node tag!"); } node.Parent.Nodes.Insert(node.Index, newNode); }