示例#1
0
        private void add_material_inspector(DataFormats.JSRF.MDLB.material mat = null)
        {
            Material_Inspector mat_inspector = new Material_Inspector();

            mat_inspector.Location = new Point(0, mat_inspector_list.Count * 90);
            Materials.color c = new Materials.color(255, 255, 255, 255);


            // add control
            panel_materials.Controls.Add(mat_inspector);

            // set properties values
            for (int x = 0; x <= panel_materials.Controls.Count - 1; x++)
            {
                Control ct = panel_materials.Controls[x];

                if (ct is Material_Inspector && x == mat_inspector_list.Count)
                {
                    ((Material_Inspector)ct).id = mat_inspector_list.Count;

                    // if no input material is defined, load values from last material inspector
                    if (mat == null)
                    {
                        Material_Inspector mi_last = mat_inspector_list[mat_inspector_list.Count - 1];
                        // set material inspector values taken from last material inspector
                        ((Material_Inspector)ct).set_values(mi_last.get_color(), mi_last.get_shader_type(), mi_last.get_unk_id(), mi_last.get_hb());
                    }
                    else
                    {
                        // set material inspector values from input Material (mat)
                        Materials.color color = new Materials.color(mat.color.R, mat.color.G, mat.color.B, mat.color.A);
                        ((Material_Inspector)ct).set_values(color, mat.shader_id, mat.unk_id2, mat.HB);
                    }


                    mat_inspector_list.Add((Material_Inspector)ct);
                }
            }
        }
示例#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();
        }