예제 #1
0
        public void AddShape(string ShapeName)
        {
            Scene.Shape shape = null;
            if (ShapeName == "Box")
            {
                shape = new Shapes.Box();
            }
            else if (ShapeName == "IcoSphere")
            {
                shape = new Shapes.IcoSphere(3);
            }
            else if (ShapeName == "Conus")
            {
                shape = new Shapes.Conus();
            }
            else if (ShapeName == "Cylinder")
            {
                shape = new Shapes.Cylinder();
            }
            else if (ShapeName == "Toroid")
            {
                shape = new Shapes.Toroid();
            }
            if (shape != null)
            {
                shape.dx = 0;
                shape.dy = 0;
                shape.dz = 0;

                shape.scale_x = 100;
                shape.scale_y = 100;
                shape.scale_z = 100;

                shape.rotation_x = 0;
                shape.rotation_y = 0;
                shape.rotation_z = 0;

                shape.main_clr = Render.color(255, 255, 255);
                if (scene.selected_gid != -1)
                {
                    scene.groups[scene.selected_gid].shapes.Add(shape);
                    RefreshComboBox();
                    selecter.SelectedIndex = scene.groups[scene.selected_gid].shapes.Count;
                }
            }
        }
예제 #2
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            var lfd = new OpenFileDialog();

            lfd.Filter = "text|*.txt";
            lfd.Title  = "Load an scene";
            lfd.ShowDialog();
            if (lfd.FileName != "")
            {
                scene.groups.Clear();
                using (StreamReader fs = new StreamReader(lfd.FileName))
                {
                    string line;

                    var eye = fs.ReadLine().Split(" ");
                    scene.camera.eye   = new Vector3(float.Parse(eye[0]), float.Parse(eye[1]), float.Parse(eye[2]));
                    scene.camera.fov   = float.Parse(fs.ReadLine());
                    scene.camera.pitch = float.Parse(fs.ReadLine());
                    scene.camera.yaw   = float.Parse(fs.ReadLine());

                    while ((line = fs.ReadLine()) != null)
                    {
                        if (line != "")
                        {
                            if (line == "__group__")
                            {
                                scene.groups.Add(new GroupShapes());
                                scene.groups[scene.groups.Count - 1].name = fs.ReadLine();

                                scene.groups[scene.groups.Count - 1].dx = float.Parse(fs.ReadLine());
                                scene.groups[scene.groups.Count - 1].dy = float.Parse(fs.ReadLine());
                                scene.groups[scene.groups.Count - 1].dz = float.Parse(fs.ReadLine());

                                scene.groups[scene.groups.Count - 1].scale_x = float.Parse(fs.ReadLine());
                                scene.groups[scene.groups.Count - 1].scale_y = float.Parse(fs.ReadLine());
                                scene.groups[scene.groups.Count - 1].scale_z = float.Parse(fs.ReadLine());

                                scene.groups[scene.groups.Count - 1].rotation_x = float.Parse(fs.ReadLine());
                                scene.groups[scene.groups.Count - 1].rotation_y = float.Parse(fs.ReadLine());
                                scene.groups[scene.groups.Count - 1].rotation_z = float.Parse(fs.ReadLine());
                                continue;
                            }
                            Scene.Shape shape = new Scene.Shape();
                            if (line == "Box")
                            {
                                shape = new Shapes.Box();
                            }
                            else if (line == "IcoSphere")
                            {
                                shape = new Shapes.IcoSphere();
                            }
                            else if (line == "Toroid")
                            {
                                shape = new Shapes.Toroid();
                            }
                            else if (line == "Conus")
                            {
                                shape = new Shapes.Conus();
                            }
                            else if (line == "Cylinder")
                            {
                                shape = new Shapes.Cylinder();
                            }

                            shape.dx = float.Parse(fs.ReadLine());
                            shape.dy = float.Parse(fs.ReadLine());
                            shape.dz = float.Parse(fs.ReadLine());

                            shape.scale_x = float.Parse(fs.ReadLine());
                            shape.scale_y = float.Parse(fs.ReadLine());
                            shape.scale_z = float.Parse(fs.ReadLine());

                            shape.rotation_x = float.Parse(fs.ReadLine());
                            shape.rotation_y = float.Parse(fs.ReadLine());
                            shape.rotation_z = float.Parse(fs.ReadLine());

                            var clr = fs.ReadLine().Split(" ");
                            shape.main_clr = Render.color(int.Parse(clr[0]), int.Parse(clr[1]), int.Parse(clr[2]));
                            scene.groups[scene.groups.Count - 1].shapes.Add(shape);
                        }
                    }
                    RefreshComboBox();
                }
            }
        }
예제 #3
0
        private void LoadGroup_Click(object sender, RoutedEventArgs e)
        {
            var lfd = new OpenFileDialog();

            lfd.Filter = "text|*.txt";
            lfd.Title  = "Load an scene";
            lfd.ShowDialog();
            if (lfd.FileName != "")
            {
                scene.groups.Add(new GroupShapes());
                scene.selected_gid = scene.groups.Count - 1;
                using (StreamReader fs = new StreamReader(lfd.FileName))
                {
                    string line;
                    scene.groups[scene.selected_gid].name = fs.ReadLine();

                    while ((line = fs.ReadLine()) != null)
                    {
                        if (line != "")
                        {
                            Scene.Shape shape = new Scene.Shape();
                            if (line == "Box")
                            {
                                shape = new Shapes.Box();
                            }
                            else if (line == "IcoSphere")
                            {
                                shape = new Shapes.IcoSphere();
                            }
                            else if (line == "Toroid")
                            {
                                shape = new Shapes.Toroid();
                            }
                            else if (line == "Conus")
                            {
                                shape = new Shapes.Conus();
                            }
                            else if (line == "Cylinder")
                            {
                                shape = new Shapes.Cylinder();
                            }

                            shape.dx = float.Parse(fs.ReadLine());
                            shape.dy = float.Parse(fs.ReadLine());
                            shape.dz = float.Parse(fs.ReadLine());

                            shape.scale_x = float.Parse(fs.ReadLine());
                            shape.scale_y = float.Parse(fs.ReadLine());
                            shape.scale_z = float.Parse(fs.ReadLine());

                            shape.rotation_x = float.Parse(fs.ReadLine());
                            shape.rotation_y = float.Parse(fs.ReadLine());
                            shape.rotation_z = float.Parse(fs.ReadLine());

                            var clr = fs.ReadLine().Split(" ");
                            shape.main_clr = Render.color(int.Parse(clr[0]), int.Parse(clr[1]), int.Parse(clr[2]));
                            scene.groups[scene.selected_gid].shapes.Add(shape);
                        }
                    }
                }
                RefreshGroupsCB();
                group_selecter.SelectedIndex = scene.groups.Count;
            }
        }