private void btnImportAnimation_Click(object sender, EventArgs e)
        {
            if (m_BMD == null || m_BCA == null)
            {
                MessageBox.Show("Please select a valid model (BMD) and animation (BCA) to replace.");
                return;
            }
            if (txtInputAnimation.Text == null || txtInputAnimation.Text.Equals(""))
            {
                MessageBox.Show("Please select an animation file or model to import.");
                return;
            }

            float scale;

            if (!Helper.TryParseFloat(txtScale.Text, out scale))
            {
                MessageBox.Show("Please enter a valid Scale value as a decimal value, eg. 1.234");
                return;
            }

            string animationFormat = txtInputAnimation.Text.Substring(txtInputAnimation.Text.Length - 3).ToLowerInvariant();

            bool wasRunning = m_Running;

            StopTimer();

            try
            {
                ModelBase loadedModel = null;
                switch (animationFormat)
                {
                case "dae":
                {
                    if (txtInputModel.Text != null && !txtInputModel.Text.Equals(""))
                    {
                        loadedModel = BMDImporter.LoadModel(txtInputAnimation.Text, scale);
                        m_BMD       = BMDImporter.CallBMDWriter(ref m_BMD.m_File, loadedModel,
                                                                BMDImporter.BMDExtraImportOptions.DEFAULT, true);
                    }
                    // >>> TODO <<<
                    // Below line in necessary to an obscure bug with NARC files, if you have two file from the same
                    // NARC open and modify and save the first, when you then go to save the second, it won't have
                    // picked up the changes from the first file and when saved will write the original first file and
                    // the modified second file.
                    NitroFile animationFile = Program.m_ROM.GetFileFromName(m_BCA.m_FileName);
                    m_BCA = BMDImporter.ConvertAnimatedDAEToBCA(ref animationFile, txtInputAnimation.Text, m_BCAImportationOptions, true);
                }
                break;

                case "ica":
                {
                    if (txtInputModel.Text != null && !txtInputModel.Text.Equals(""))
                    {
                        loadedModel = BMDImporter.LoadModel(txtInputModel.Text, scale);
                        m_BMD       = BMDImporter.CallBMDWriter(ref m_BMD.m_File, loadedModel,
                                                                BMDImporter.BMDExtraImportOptions.DEFAULT, true);
                    }
                    NitroFile animationFile = Program.m_ROM.GetFileFromName(m_BCA.m_FileName);
                    m_BCA = BMDImporter.ConvertICAToBCA(ref animationFile, txtInputAnimation.Text, loadedModel,
                                                        scale, BMDImporter.BMDExtraImportOptions.DEFAULT, m_BCAImportationOptions, true);
                }
                break;
                }

                m_AnimationFrameNumber  = 0;
                m_AnimationNumFrames    = m_BCA.m_NumFrames;
                txtCurrentFrameNum.Text = "" + m_AnimationFrameNumber;
                txtNumFrames.Text       = "" + (m_BCA.m_NumFrames - 1);

                PrerenderModel();

                if (wasRunning)
                {
                    StartTimer();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred: \n" + ex.Message + "\n\n" + ex.StackTrace);
                m_BMD = new BMD(Program.m_ROM.GetFileFromName(m_BMD.m_FileName));
                m_BCA = new BCA(Program.m_ROM.GetFileFromName(m_BCA.m_FileName));
            }
        }
Пример #2
0
 private void btnSaveChanges_Click(object sender, EventArgs e)
 {
     m_Model.m_ModelChunks[0].m_MatGroups[0].m_Alpha = 12;
     BMDImporter.CallBMDWriter(ref m_ModelFile, new BMDLoader(m_ModelName, m_Model).LoadModel(), BMDImporter.BMDExtraImportOptions.DEFAULT).m_File.SaveChanges();
 }