示例#1
0
        //Добавить вращение всех типов объектов
        private void bRotate_Click(object sender, EventArgs e)
        {
            Point axis = new Point();

            if (lboxObj.SelectedIndex == -1)
            {
                foreach (ParamObj item in scene.objs)
                {
                    foreach (Triangle initem in item.polygs)
                    {
                        initem.Reset();
                        initem.Rotate((double)Rotate_x.Value, (double)Rotate_y.Value, (double)Rotate_z.Value, new Point(axis));
                    }
                }
            }
            else
            {
                int      index    = lboxObj.SelectedIndex;
                ParamObj paramObj = scene.objs[index];
                axis = paramObj.Start;
                foreach (Triangle item in paramObj.polygs)
                {
                    item.Reset();
                    item.Rotate((double)Rotate_x.Value, (double)Rotate_y.Value, (double)Rotate_z.Value, new Point(axis));
                }
            }
            ScaleUpDown_ValueChanged(sender, e);
            Redraw();
        }
示例#2
0
 private void ЗагрузитьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFD.ShowDialog() == DialogResult.OK)
     {
         char[]       sep      = { '/', ':' };
         StreamReader stream   = new StreamReader(openFD.FileName, System.Text.Encoding.Default, false);
         ParamObj     paramObj = null;
         string[]     cam_str  = stream.ReadLine().Split(sep);
         string[]     targ_str = stream.ReadLine().Split(sep);
         scene.camera.eye    = new Point(Double.Parse(cam_str[1]), Double.Parse(cam_str[2]), Double.Parse(cam_str[3]));
         scene.camera.target = new Point(Double.Parse(targ_str[1]), Double.Parse(targ_str[2]), Double.Parse(targ_str[3]));
         while (!stream.EndOfStream)
         {
             string service = stream.ReadLine();
             if (service == "[Obj]")
             {
                 if (paramObj != null)
                 {
                     scene.AddObj(paramObj);
                     lboxObj.Items.Add(paramObj);
                 }
                 paramObj = new ParamObj();
                 continue;
             }
             string[] line = service.Split(sep);
             if (line.Length == 13)
             {
                 paramObj.Start     = new Point(double.Parse(line[0]), double.Parse(line[1]), double.Parse(line[2]));
                 paramObj.bar_len   = double.Parse(line[3]);
                 paramObj.bar_diam  = double.Parse(line[4]);
                 paramObj.mag_len   = double.Parse(line[5]);
                 paramObj.box_width = double.Parse(line[6]);
                 paramObj.cev_len   = double.Parse(line[7]);
                 paramObj.targ_ang  = double.Parse(line[8]);
                 paramObj.nas       = int.Parse(line[9]);
                 paramObj.rings     = int.Parse(line[10]);
                 paramObj.sp_ang    = double.Parse(line[11]);
                 paramObj.dist      = double.Parse(line[12]);
             }
             else
             {
                 Triangle polygon = new Triangle(new Point(double.Parse(line[0]), double.Parse(line[1]), double.Parse(line[2])), new Point(double.Parse(line[3]), double.Parse(line[4]), double.Parse(line[5])), new Point(double.Parse(line[6]), double.Parse(line[7]), double.Parse(line[8])), Color.FromArgb(int.Parse(line[9])));
                 paramObj.polygs.Add(polygon);
             }
         }
         scene.AddObj(paramObj);
         lboxObj.Items.Add(paramObj);
         Redraw();
     }
 }
示例#3
0
        private void ScaleUpDown_ValueChanged(object sender, EventArgs e)
        {
            Point axis = new Point();

            if (lboxObj.SelectedIndex == -1)
            {
                scale = (double)ScaleUpDown.Value;
            }
            else
            {
                int      index    = lboxObj.SelectedIndex;
                ParamObj paramObj = (ParamObj)scene.objs[index];
                paramObj.scale = (double)ScaleUpDown.Value;
            }
            Redraw();
        }
示例#4
0
 private void bOK_Click(object sender, EventArgs e)
 {
     if (!edit)
     {
         try
         {
             ParamObj obj = new ParamObj(st, (double)numericUpDown1.Value, (double)numericUpDown2.Value, (double)numericUpDown3.Value, (double)numericUpDown4.Value, (double)numericUpDown5.Value, (double)numericUpDown6.Value, (int)numericUpDown7.Value, (int)numericUpDown8.Value, (double)numericUpDown9.Value, (double)numericUpDown10.Value);
             main.scene.AddObj(obj);
             main.lboxObj.Items.Add(obj);
             main.Redraw();
         }
         catch
         {
             MessageBox.Show("Не удалось создать объект");
         }
         finally
         {
             Close();
         }
     }
     else
     {
         try
         {
             ParamObj obj = new ParamObj(st, (double)numericUpDown1.Value, (double)numericUpDown2.Value, (double)numericUpDown3.Value, (double)numericUpDown4.Value, (double)numericUpDown5.Value, (double)numericUpDown6.Value, (int)numericUpDown7.Value, (int)numericUpDown8.Value, (double)numericUpDown9.Value, (double)numericUpDown10.Value);
             main.scene.objs.Insert(main.lboxObj.SelectedIndex, obj);
             main.scene.objs.RemoveAt(main.lboxObj.SelectedIndex + 1);
             main.lboxObj.Items.Clear();
             foreach (ParamObj item in main.scene.objs)
             {
                 main.lboxObj.Items.Add(item);
             }
             main.lboxObj.SelectedIndex = select;
             main.Redraw();
         }
         catch
         {
             MessageBox.Show("Не удалось создать объект");
         }
         finally
         {
             Close();
         }
     }
 }
示例#5
0
        public void AddObj(Object obj)
        {
            ParamObj paramObj = (ParamObj)obj;

            objs.Add(paramObj);
        }
示例#6
0
        private void bObj_p_Click(object sender, EventArgs e)
        {
            byte axis = 0;

            if (rbObjX.Checked)
            {
                axis = 1;
            }
            if (rbObjY.Checked)
            {
                axis = 2;
            }
            if (rbObjZ.Checked)
            {
                axis = 3;
            }
            switch (axis)
            {
            case 1:
                if (lboxObj.SelectedIndex == -1)
                {
                    foreach (ParamObj item in scene.objs)
                    {
                        item.Start.Moving(15, 0, 0);
                        foreach (Triangle initem in item.polygs)
                        {
                            initem.Moving(15, 0, 0);
                        }
                    }
                }
                else
                {
                    int      index    = lboxObj.SelectedIndex;
                    ParamObj paramObj = scene.objs[index];
                    paramObj.Start.Moving(15, 0, 0);
                    foreach (Triangle item in paramObj.polygs)
                    {
                        item.Moving(15, 0, 0);
                    }
                }
                break;

            case 2:
                if (lboxObj.SelectedIndex == -1)
                {
                    foreach (ParamObj item in scene.objs)
                    {
                        item.Start.Moving(0, 15, 0);
                        foreach (Triangle initem in item.polygs)
                        {
                            initem.Moving(0, 15, 0);
                        }
                    }
                }
                else
                {
                    int      index    = lboxObj.SelectedIndex;
                    ParamObj paramObj = scene.objs[index];
                    paramObj.Start.Moving(0, 15, 0);
                    foreach (Triangle item in paramObj.polygs)
                    {
                        item.Moving(0, 15, 0);
                    }
                }
                break;

            case 3:
                if (lboxObj.SelectedIndex == -1)
                {
                    foreach (ParamObj item in scene.objs)
                    {
                        item.Start.Moving(0, 0, 15);
                        foreach (Triangle initem in item.polygs)
                        {
                            initem.Moving(0, 0, 15);
                        }
                    }
                }
                else
                {
                    int      index    = lboxObj.SelectedIndex;
                    ParamObj paramObj = scene.objs[index];
                    paramObj.Start.Moving(0, 0, 15);
                    foreach (Triangle item in paramObj.polygs)
                    {
                        item.Moving(0, 0, 15);
                    }
                }
                break;

            default:
                break;
            }
            Redraw();
        }