public AMT_MODEL? Convert(string path, Import import) { _import = import; //carrega o arquivo var doc = XDocument.Load(path); Namespace = doc.Root.Name.Namespace.NamespaceName; Vector3 upVector = Vector3.UnitY; var colladaNode = doc.Root; #region Pega o vetor UP XElement asset = colladaNode.Element(XName.Get("asset", Namespace)); if (asset != null) { string up = asset.Element(XName.Get("up_axis", Namespace)).Value; if (string.Compare(up, "z_up", true) == 0) upVector = Vector3.UnitZ; else if (string.Compare(up, "x_up", true) == 0) upVector = Vector3.UnitX; } #endregion AMT_MODEL amtModel = ConvertDAEtoAMT(colladaNode); Tools.UniformScale(ref amtModel); Tools.SetYUp(ref amtModel, upVector); Tools.CenterPivot(ref amtModel); return amtModel; }
public bool Export(AMT_MODEL model, string filePath, Import import) { _import = import; using (BinaryWriter bw = new BinaryWriter(File.Open(filePath, FileMode.Create))) { WriteHead(bw, model); WriteVertices(bw, model); WriteFaces(bw, model); WriteMeshes(bw, model); WriteMaterials(bw, model); WriteJoints(bw, model); WriteAnimations(bw, model); bw.Close(); } return true; }
private void btnImport_Click(object sender, EventArgs e) { Import _import = new Import(); _import.PropertyChanged += new PropertyChangedEventHandler(_import_PropertyChanged); try { AMT_MODEL? model = null; IConverter converter = null; string fileType = Path.GetExtension(txtFilePath.Text).ToUpper(); switch (fileType) { case ".DAE": converter = new COLLADAConverter(); model = converter.Convert(txtFilePath.Text, _import); break; } //adiciona as animacoes q estao na interface AddAnimations(ref model); //se fez a conversao entao ele grava o arquivo amt if (model.HasValue) { string fileName = Path.GetFileNameWithoutExtension(txtFilePath.Text); fileName += ".amt"; AMTExport export = new AMTExport(); export.Export(model.Value, txtDestination.Text + "\\" + fileName, _import); MessageBox.Show("Arquivo gerado com sucesso."); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }