private unsafe void btnOkay_Click(object sender, EventArgs e) { KeyframeEntry kfe; if (amount.Text != null) { if (comboBox1.SelectedIndex == 0) { for (int x = 0; x < _target.FrameCount; x++) //Loop thru each frame { if ((kfe = _target.GetKeyframe(_type, x)) != null) //Check for a keyframe { kfe._value += Convert.ToSingle(amount.Text); } } } if (comboBox1.SelectedIndex == 1) { for (int x = 0; x < _target.FrameCount; x++) //Loop thru each frame { if ((kfe = _target.GetKeyframe(_type, x)) != null) //Check for a keyframe { kfe._value -= Convert.ToSingle(amount.Text); } } } } DialogResult = DialogResult.OK; Close(); }
private void UpdateTarget() { listKeyframes.BeginUpdate(); listKeyframes.Items.Clear(); if (_target != null) { if (_target.FrameCount > 0) { AnimationFrame a; bool check = false; for (int x = 0; x < _target.FrameCount; x++) //Loop thru each frame { a = _target.GetAnimFrame(x); //Get the frame to check a.Index = x; a.ResetBools(); for (int i = 0x10; i < 0x19; i++) //Loop thru trans, rotate and scale { if (_target.GetKeyframe((KeyFrameMode)i, x) != null) //Check for a keyframe { check = true; //Keyframe found a.SetBools(i); //Make sure the anim frame displays this } } if (check == true) { //Only add the frame if it has a keyframe a.forKeyframeCHR = true; listKeyframes.Items.Add(a); check = false; //Reset the check for the loop } } //foreach (AnimationKeyframe f in _target.Keyframes.Keyframes) // listKeyframes.Items.Add(f); _numFrames = _target.FrameCount; _currentPage = 0; numFrame.Value = 1; numFrame.Maximum = _numFrames; lblFrameCount.Text = String.Format("/ {0}", _numFrames); } else { numFrame.Value = 1; } } listKeyframes.EndUpdate(); RefreshPage(); }
private void UpdateBox(int index) { if (_target.GetKeyframe(index, _currentPage) != null) { _boxes[index].BackColor = Color.Yellow; } else { _boxes[index].BackColor = Color.White; } }
private void toolStripMenuItem3_Click(object sender, EventArgs e) { if (SelectedAnimation == null || type == 0) { return; } KeyframeEntry kfe; CHR0EntryNode _target = SelectedAnimation.FindChild(TargetTexRef.Parent.Name, false) as CHR0EntryNode; for (int x = 0; x < _target.FrameCount; x++) //Loop thru each frame { if ((kfe = _target.GetKeyframe((KeyFrameMode)type, x)) != null) //Check for a keyframe { kfe._value += 180; } } ResetBox(type - 0x10); _mainWindow.UpdateModel(); }
public unsafe void ChangeNode(string _name, ResourceNode parent, Vector3 scale, Vector3 rot, Vector3 trans, MDL0Node _targetModel, MDL0Node model, bool disLoop) { int numFrames; float * v; bool hasKeyframe = false; CHR0EntryNode entry; KeyframeEntry kfe; AnimationFrame anim = new AnimationFrame(); foreach (ResourceNode r in parent.Children) { if (r is CHR0Node) { if (Port.Checked && _targetModel != null && model != null) { ((CHR0Node)r).Port(_targetModel, model); } if (Version.Enabled) { if (Version.SelectedIndex == 0) { ((CHR0Node)r).Version = 4; } else if (Version.SelectedIndex == 1) { ((CHR0Node)r).Version = 5; } } if (disLoop) { ((CHR0Node)r).Loop = false; } _copyNode = r.FindChild(textBox1.Text, false) as CHR0EntryNode; if (r.FindChild(_name, false) == null) { if (_name != null && _name != String.Empty) { CHR0EntryNode c = new CHR0EntryNode(); c._numFrames = (r as CHR0Node).FrameCount; c.Name = _name; if (_copyNode != null) { for (int x = 0; x < _copyNode._numFrames; x++) { for (int i = 0x10; i < 0x19; i++) { if ((kfe = _copyNode.GetKeyframe((KeyFrameMode)i, x)) != null) { c.SetKeyframe((KeyFrameMode)i, x, kfe._value); } } } } r.Children.Add(c); r._changed = true; } } } if (r.Name == _name) { if (r is CHR0EntryNode) { entry = r as CHR0EntryNode; numFrames = entry.FrameCount; if (ReplaceScale.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x10; i < 0x13; i++) { if (entry.GetKeyframe((KeyFrameMode)i, x) != null) { entry.RemoveKeyframe((KeyFrameMode)i, x); } } } entry.SetKeyframeOnlyScale(0, scale); } if (ReplaceRot.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x13; i < 0x16; i++) { if (entry.GetKeyframe((KeyFrameMode)i, x) != null) { entry.RemoveKeyframe((KeyFrameMode)i, x); } } } entry.SetKeyframeOnlyRot(0, rot); } if (ReplaceTrans.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x16; i < 0x19; i++) { if (entry.GetKeyframe((KeyFrameMode)i, x) != null) { entry.RemoveKeyframe((KeyFrameMode)i, x); } } } entry.SetKeyframeOnlyTrans(0, trans); } hasKeyframe = false; if (AddScale.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x10; i < 0x13; i++) { if ((kfe = entry.GetKeyframe((KeyFrameMode)i, x)) != null) { switch (i) { case 0x10: kfe._value += scale._x; break; case 0x11: kfe._value += scale._y; break; case 0x12: kfe._value += scale._z; break; } hasKeyframe = true; } } } if (!hasKeyframe) { anim = entry.GetAnimFrame(0); Vector3 newScale = anim.Scale; scale._x += newScale._x; scale._y += newScale._y; scale._z += newScale._z; entry.SetKeyframeOnlyScale(0, scale); } } hasKeyframe = false; if (AddRot.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x13; i < 0x16; i++) { if ((kfe = entry.GetKeyframe((KeyFrameMode)i, x)) != null) { switch (i) { case 0x13: kfe._value += rot._x; break; case 0x14: kfe._value += rot._y; break; case 0x15: kfe._value += rot._z; break; } hasKeyframe = true; } } } if (!hasKeyframe) { anim = entry.GetAnimFrame(0); Vector3 newRot = anim.Rotation; rot._x += newRot._x; rot._y += newRot._y; rot._z += newRot._z; entry.SetKeyframeOnlyRot(0, rot); } } hasKeyframe = false; if (AddTrans.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x16; i < 0x19; i++) { if ((kfe = entry.GetKeyframe((KeyFrameMode)i, x)) != null) { switch (i) { case 0x16: kfe._value += trans._x; break; case 0x17: kfe._value += trans._y; break; case 0x18: kfe._value += trans._z; break; } hasKeyframe = true; } } } if (!hasKeyframe) { anim = entry.GetAnimFrame(0); Vector3 newTrans = anim.Translation; trans._x += newTrans._x; trans._y += newTrans._y; trans._z += newTrans._z; entry.SetKeyframeOnlyTrans(0, trans); } } hasKeyframe = false; if (SubtractScale.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x10; i < 0x13; i++) { if ((kfe = entry.GetKeyframe((KeyFrameMode)i, x)) != null) { switch (i) { case 0x10: kfe._value -= scale._x; break; case 0x11: kfe._value -= scale._y; break; case 0x12: kfe._value -= scale._z; break; } hasKeyframe = true; } } } if (!hasKeyframe) { anim = entry.GetAnimFrame(0); Vector3 newScale = anim.Scale; scale._x = newScale._x - scale._x; scale._y = newScale._y - scale._y; scale._z = newScale._z - scale._z; entry.SetKeyframeOnlyScale(0, scale); } } hasKeyframe = false; if (SubtractRot.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x13; i < 0x16; i++) { if ((kfe = entry.GetKeyframe((KeyFrameMode)i, x)) != null) { switch (i) { case 0x13: kfe._value -= rot._x; break; case 0x14: kfe._value -= rot._y; break; case 0x15: kfe._value -= rot._z; break; } hasKeyframe = true; } } } if (!hasKeyframe) { anim = entry.GetAnimFrame(0); Vector3 newRot = anim.Rotation; rot._x = newRot._x - rot._x; rot._y = newRot._y - rot._y; rot._z = newRot._z - rot._z; entry.SetKeyframeOnlyRot(0, rot); } } hasKeyframe = false; if (SubtractTrans.Checked) { for (int x = 0; x < numFrames; x++) { for (int i = 0x16; i < 0x19; i++) { if ((kfe = entry.GetKeyframe((KeyFrameMode)i, x)) != null) { switch (i) { case 0x16: kfe._value -= trans._x; break; case 0x17: kfe._value -= trans._y; break; case 0x18: kfe._value -= trans._z; break; } hasKeyframe = true; } } } if (!hasKeyframe) { anim = entry.GetAnimFrame(0); Vector3 newTrans = anim.Translation; trans._x = newTrans._x - trans._x; trans._y = newTrans._y - trans._y; trans._z = newTrans._z - trans._z; entry.SetKeyframeOnlyTrans(0, trans); } } } r._changed = true; } ChangeNode(_name, r, scale, rot, trans, _targetModel, model, disLoop); } }
private void keyframes_Paint(object sender, PaintEventArgs e) { //Nonstop paint? //if (_mainWindow == null) return; KeyframeEntry kfe; CHR0EntryNode entry = null; int cellDims = 0, keyDims = 0; Pen pen = new Pen(Color.LightBlue, 1); if (lstBones.Items.Count > 0) { cellDims = lstBones.PreferredHeight / lstBones.Items.Count; keyDims = cellDims - 2; } int rectX = -(keyDims / 2), rectY = -2; //Keyframes lie on column lines, but in between row lines if (SelectedCHR0 != null && TargetModel != null && lstBones.Items.Count != 0) { bgLayer.Width = SelectedCHR0.FrameCount * cellDims; //For frames e.Graphics.DrawRectangle(pen, 0, 0, bgLayer.Width, 20); //Columns for (int frame = 0; frame < SelectedCHR0.FrameCount; frame++) { } int x = 0, y = 0; //Rows foreach (MDL0BoneNode b in lstBones.Items) { //Get line color if (TargetBone != null && TargetBone.Name == b.Name) { pen.Color = Color.Green; //Selected bone } else if (SelectedCHR0 != null && (entry = SelectedCHR0.FindChild(b.Name, false) as CHR0EntryNode) != null) { if (b._render) { pen.Color = Color.Blue; //Rendered bone has keyframe } else { pen.Color = Color.Red; //Unrendered bone has keyframe } } else { pen.Color = Color.Orange; //Bone doesn't have keyframe regardless } //Draw Line e.Graphics.DrawLine(pen, new Point(0, y), new Point(bgLayer.Width, y)); //Change pen back to black for keyframes pen.Color = Color.Black; int offset = cellDims; e.Graphics.RotateTransform(45); //Mark keyframe spots if (entry != null) { for (int frame = 0; frame < SelectedCHR0.FrameCount; frame++, offset += cellDims, x++) { for (int i = 0x10; i < 0x19; i++) { if ((kfe = entry.GetKeyframe((KeyFrameMode)i, frame)) != null) { e.Graphics.DrawRectangle(pen, x + rectX, y + rectY, keyDims, keyDims); break; //Only one keyframe needs to be marked } } } } e.Graphics.RotateTransform(-45); entry = null; y += cellDims; x = 0; } } }