Exemplo n.º 1
0
        private void add_mdl_properties_control(int model_num, string filepath, int model_type, int vertex_def_size)
        {
            Model_Inspector mp = new Model_Inspector();

            mp.Location = new Point(0, model_num * 30);
            mp.filepath = filepath;

            if (model_num % 2 == 0)
            {
                mp.BackColor = System.Drawing.Color.LightGray;
            }

            foreach (Control c in mp.Controls)
            {
                // set smd filename
                if (c.Name == "lab_smd_name")
                {
                    c.Text = Path.GetFileName(filepath);
                }

                // set model part type
                if (c.Name == "cb_mdl_part_type")
                {
                    ComboBox cb = (ComboBox)c;
                    cb.SelectedIndex = model_type;
                }

                // set model part type
                if (c.Name == "cb_vertex_def_size")
                {
                    ComboBox cb = (ComboBox)c;
                    cb.SelectedText = vertex_def_size.ToString();
                }
            }

            // add control
            panel_models.Controls.Add(mp);
        }
Exemplo n.º 2
0
        private void btn_import_Click(object sender, EventArgs e)
        {
            // store each model filepath and other info into list of ModelPart_Import_Settings
            List <ModelPart_Import_Settings> mdlPart_import_settings_List = new List <ModelPart_Import_Settings>();

            // for each model part?
            for (int i = 0; i < mdl_inspector_list.Count; i++)
            {
                Model_Inspector mdl = mdl_inspector_list[i];
                mdlPart_import_settings_List.Add(new ModelPart_Import_Settings(mdl.filepath, mdl.get_mdl_type(), mdl.get_vert_def_size(),
                                                                               Convert.ToSingle(txtb_drawDist_x.Text),
                                                                               Convert.ToSingle(txtb_drawDist_y.Text),
                                                                               Convert.ToSingle(txtb_drawDist_z.Text),
                                                                               Convert.ToSingle(txtb_drawDist_w.Text)));
            }

            mdlPart_import_settings_List.Add(new ModelPart_Import_Settings(main_SMD_filepath, 0, Convert.ToInt32(cb_vertex_def_size.SelectedItem),
                                                                           Convert.ToSingle(txtb_drawDist_x.Text),
                                                                           Convert.ToSingle(txtb_drawDist_y.Text),
                                                                           Convert.ToSingle(txtb_drawDist_z.Text),
                                                                           Convert.ToSingle(txtb_drawDist_w.Text)));

            List <MDLB_Import.MDLB_classes.material> materials = new List <MDLB_Import.MDLB_classes.material>();

            // for each material inspector, create MDLB_builder.material and add to list
            for (int i = 0; i < mat_inspector_list.Count; i++)
            {
                Material_Inspector mi = mat_inspector_list[i];
                Materials.color    c  = mi.get_color();
                int shader_id         = 0;

                #region convert material_id Name to id number

                string[] names  = Enum.GetNames(typeof(Materials.materials));
                int[]    values = (int[])Enum.GetValues(typeof(Materials.materials));

                // find corresponding material name and get shader id
                for (int m = 0; m < names.Length; m++)
                {
                    if (names[m] == mi.cb_material_id.Text)
                    {
                        shader_id = values[m];
                        break;
                    }
                }

                if (mi.cb_material_id.Text.All(char.IsDigit))
                {
                    shader_id = Convert.ToInt32(mi.cb_material_id.Text);
                }

                #endregion

                materials.Add(new MDLB_Import.MDLB_classes.material(new MDLB_Import.MDLB_classes.color(c.B, c.G, c.R, c.A), shader_id, Convert.ToInt32(mi.txtb_unk_id2.Text), Convert.ToSingle(mi.txtb_hb.Text)));
            }

            /*
             * List<MDLB_builder.model_part_triangle_groups> tris_groups = new List<MDLB_builder.model_part_triangle_groups>();
             *
             * for (int i = 0; i < Main.model.Model_Parts_header_List.Count; i++)
             * {
             *  tris_groups.Add(new MDLB_builder.model_part_triangle_groups());
             *
             *
             *  if (Main.model.Model_Parts_header_List[i].triangle_groups_count > 1)
             *  {
             *      tris_groups[i] = new MDLB_builder.model_part_triangle_groups();
             *      for (int t = 0; t < Main.model.Model_Parts_header_List[i].triangle_groups_List.Count; t++)
             *      {
             *          tris_groups[i].tri_groups.Add(Main.model.Model_Parts_header_List[i].triangle_groups_List[t]); //Main.model.Model_Parts_header_List[i].triangle_groups_List[t]
             *      }
             *  }
             * }
             */

            MDLB_builder MDLB_build = new MDLB_builder();
            MDLB_import = MDLB_build.build_MDLB(mdlPart_import_settings_List, materials);

            this.DialogResult = DialogResult.OK;
            // this.Close();
        }