private void attachpointListBox_MouseDoubleClick(object sender, MouseEventArgs e) { int index = attachpointListBox.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMatches) { BrgAttachpoint att = new BrgAttachpoint(); att.NameId = BrgAttachpoint.GetIdByName((string)attachpointListBox.Items[index]); Maxscript.NewDummy("newDummy", att.GetMaxName(), att.GetMaxTransform(), att.GetMaxPosition(), att.GetMaxBoxSize(), att.GetMaxScale()); } }
private void ExportAttachpoints(string attachDummy, BrgMesh mesh, float time) { time += Maxscript.QueryFloat("animationRange.start.ticks / 4800.0"); //System.Windows.Forms.MessageBox.Show("4"); int numAttachpoints = Maxscript.QueryInteger("{0}.count", attachDummy); //System.Windows.Forms.MessageBox.Show("5 " + numAttachpoints); if (mesh.Header.Flags.HasFlag(BrgMeshFlag.ATTACHPOINTS)) { mesh.Attachpoints = new List<BrgAttachpoint>(); for (int i = 0; i < numAttachpoints; i++) { string aName = Maxscript.QueryString("{0}[{1}].name", attachDummy, i + 1); int nameId; if (!BrgAttachpoint.TryGetIdByName(aName.Substring(6), out nameId)) continue; BrgAttachpoint att = new BrgAttachpoint(); //System.Windows.Forms.MessageBox.Show(aName); //System.Windows.Forms.MessageBox.Show("5.1"); //System.Windows.Forms.MessageBox.Show(mesh.Attachpoints.Count + " " + i); att.NameId = nameId; Maxscript.Command("{0}[{1}].name = \"{2}\"", attachDummy, i + 1, att.GetMaxName()); //System.Windows.Forms.MessageBox.Show("5.2"); Maxscript.SetVarAtTime(time, "{0}Transform", "{0}[{1}].rotation as matrix3", attachDummy, i + 1); Maxscript.SetVarAtTime(time, "{0}Position", "{0}[{1}].position", attachDummy, i + 1); Maxscript.SetVarAtTime(time, "{0}Scale", "{0}[{1}].scale * {0}[{1}].boxsize", attachDummy, i + 1); //System.Windows.Forms.MessageBox.Show("5.3"); Vector3D scale = new Vector3D(Maxscript.QueryFloat("{0}Scale.X", attachDummy), Maxscript.QueryFloat("{0}Scale.Y", attachDummy), Maxscript.QueryFloat("{0}Scale.Z", attachDummy)); Vector3D bBox = scale / 2; //System.Windows.Forms.MessageBox.Show("5.4"); att.XVector.X = -Maxscript.QueryFloat("{0}Transform[1].z", attachDummy); att.XVector.Y = Maxscript.QueryFloat("{0}Transform[3].z", attachDummy); att.XVector.Z = -Maxscript.QueryFloat("{0}Transform[2].z", attachDummy); att.YVector.X = -Maxscript.QueryFloat("{0}Transform[1].y", attachDummy); att.YVector.Y = Maxscript.QueryFloat("{0}Transform[3].y", attachDummy); att.YVector.Z = -Maxscript.QueryFloat("{0}Transform[2].y", attachDummy); att.ZVector.X = -Maxscript.QueryFloat("{0}Transform[1].x", attachDummy); att.ZVector.Y = Maxscript.QueryFloat("{0}Transform[3].x", attachDummy); att.ZVector.Z = -Maxscript.QueryFloat("{0}Transform[2].x", attachDummy); att.Position.X = -Maxscript.QueryFloat("{0}Position.x", attachDummy); att.Position.Z = -Maxscript.QueryFloat("{0}Position.y", attachDummy); att.Position.Y = Maxscript.QueryFloat("{0}Position.z", attachDummy); //System.Windows.Forms.MessageBox.Show("5.5"); att.BoundingBoxMin.X = -bBox.X; att.BoundingBoxMin.Z = -bBox.Y; att.BoundingBoxMin.Y = -bBox.Z; att.BoundingBoxMax.X = bBox.X; att.BoundingBoxMax.Z = bBox.Y; att.BoundingBoxMax.Y = bBox.Z; mesh.Attachpoints.Add(att); } //System.Windows.Forms.MessageBox.Show("# Atpts: " + Attachpoint.Count); } }