private void updateAnimStatusLabel() { if (md5anim == null) { trackBarFrame.Enabled = false; lb_animInfo.Text = "No animation loaded."; return; } lb_animInfo.Text = "Frame " + curFrame + " of " + md5anim.getFrameCount() + "."; trackBarFrame.Maximum = md5anim.getFrameCount(); trackBarFrame.Minimum = 0; if (trackBarFrame.Value >= trackBarFrame.Maximum) { trackBarFrame.Value = 0; curFrame = 0; } trackBarFrame.Enabled = true; bones = new BoneOrientations(md5anim.getJointCount()); }
private void refreshTreeView() { treeView1.Nodes.Clear(); if (md5anim == null) { return; } TreeNode root = new TreeNode("MD5Anim"); TreeNode fileName = new TreeNode("FileName"); TreeNode fileNameText = new TreeNode(md5anim.getName()); fileName.Nodes.Add(fileNameText); root.Nodes.Add(fileName); TreeNode commandLine = new TreeNode("commandLine"); TreeNode commandLineText = new TreeNode(md5anim.getCommandLine()); commandLine.Nodes.Add(commandLineText); root.Nodes.Add(commandLine); TreeNode frameRate = new TreeNode("frameRate"); TreeNode frameRateText = new TreeNode(md5anim.getFrameRate().ToString()); frameRate.Nodes.Add(frameRateText); root.Nodes.Add(frameRate); TreeNode numAnimatedComponents = new TreeNode("numAnimatedComponents"); TreeNode numAnimatedComponentsText = new TreeNode(md5anim.getAnimatedComponentsCount().ToString()); numAnimatedComponents.Nodes.Add(numAnimatedComponentsText); root.Nodes.Add(numAnimatedComponents); TreeNode frames = new TreeNode("frames (" + md5anim.getFrameCount() + ")"); for (int i = 0; i < md5anim.getFrameCount(); i++) { TreeNode frame = new TreeNode("frame " + i); TreeNode bounds = new TreeNode("Bounds"); bounds.Nodes.Add(md5anim.getBounds(i).ToString()); frame.Nodes.Add(bounds); TreeNode values = new TreeNode("Values"); for (int j = 0; j < md5anim.getAnimatedComponentsCount(); j++) { values.Nodes.Add(new TreeNode(md5anim.getFrame(i).getValue(j).ToString())); } frame.Nodes.Add(values); frames.Nodes.Add(frame); } root.Nodes.Add(frames); TreeNode joints = new TreeNode("joints (" + md5anim.getJointCount() + ")"); for (int i = 0; i < md5anim.getJointCount(); i++) { MD5AnimJoint j = md5anim.getJoint(i); TreeNode joint = new TreeNode("joint " + i + " " + j.getName()); TreeNode jointName = new TreeNode("name"); TreeNode jointNameValue = new TreeNode(j.getName()); jointName.Nodes.Add(jointNameValue); joint.Nodes.Add(jointName); TreeNode parent = new TreeNode("parent"); TreeNode parentValue = new TreeNode(j.getParentIndex().ToString()); parent.Nodes.Add(parentValue); joint.Nodes.Add(parent); TreeNode jointOrigin = new TreeNode("Ofs"); TreeNode jointOriginValue = new TreeNode(j.getLocalOfs().ToString()); jointOrigin.Nodes.Add(jointOriginValue); joint.Nodes.Add(jointOrigin); TreeNode jointRot = new TreeNode("Rot"); TreeNode jointRotValue = new TreeNode(j.getLocalRot().ToString()); jointRot.Nodes.Add(jointRotValue); joint.Nodes.Add(jointRot); joints.Nodes.Add(joint); } root.Nodes.Add(joints); treeView1.Nodes.Add(root); }
private void mD5ModelAnimationPoseToolStripMenuItem_Click(object sender, EventArgs e) { // first ask user for md5mesh file openFileDialog1.Filter = "Doom3/Quake4 MD5mesh|*.md5mesh|All files (*.*)|*.*"; openFileDialog1.Title = "Open new model."; if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } string md5meshFileName = openFileDialog1.FileName; MD5Model md5 = new MD5Model(); if (md5.loadMD5MeshFile(md5meshFileName)) { return; } if (md5.getMeshCount() == 0) { MessageBox.Show("MD5 model you tried to import has no surfaces.", "MD5 model has 0 surfaces.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // then ask user for md5anim file openFileDialog1.Filter = "Doom3/Quake4 MD5anim|*.md5anim|All files (*.*)|*.*"; openFileDialog1.Title = "Open new anim."; if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } string md5animFileName = openFileDialog1.FileName; #if false // then md5anim file FormImportMD5AnimatedFrame f = new FormImportMD5AnimatedFrame(); f.setOBJViewerForm(this); f.ShowDialog(); #else MD5Anim anim = new MD5Anim(); if (anim.loadMD5AnimFile(md5animFileName)) { return; } if (anim.getFrameCount() == 0) { MessageBox.Show("MD5 model you tried to import has no surfaces.", "MD5 model has 0 surfaces.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } BoneOrientations bones = new BoneOrientations(); bones.allocBones(anim.getJointCount()); anim.buildFrameABSBones(0, bones); md5.buildVertices(bones); importMD5ModelMeshes(md5); #endif }