public void CopySelection(Scene scene)
        {
            Scene tmpScene = scene.SceneFromSelection(out copiedElemCenter);

            copyBuffer = new PreparedElement("copy_buffer", "", tmpScene);
        }
        private void contextSave(object sender, System.EventArgs e)
        {
            if (currScene.selTriangles.Count > 0)
            {
                Scene scene = currScene.SceneFromSelection(out trash);
                System.Drawing.Image sceneImg = renderer.GetSceneImage(scene);
                PreparedElement elem = new PreparedElement("", "", scene);
                bool replace = false;

                Modeler.DialogBoxes.NameDialog newName = new NameDialog();
                bool res = (bool)newName.Show("Podaj nazwę obiektu", "");
                if (!res)
                    return;
                elem.Name = newName.Result;

                while (_elementsGallery.GetNames().Contains(elem.Name, StringComparer.OrdinalIgnoreCase) && !replace)
                {
                    Modeler.DialogBoxes.NameDialog dialog = new NameDialog();
                    dialog.Owner = this;

                    bool result = (bool)dialog.Show(elementMessage, elem.Name);
                    string name = dialog.Result;
                    if (!result)
                        return;
                    if (elem.Name == name)
                        replace = true;
                    elem.Name = name;
                    dialog.Close();
                }

                if (replace)
                {
                    int idx = _elementsGallery.GetNameIdx(elem.Name);
                    _elementsGallery.RemoveAt(idx);
                    _elementsGallery.SaveObjectToGallery(elem, sceneImg);
                    _elementsGallery.Insert(idx, elem);
                }
                else
                {

                    _elementsGallery.SaveObjectToGallery(elem, sceneImg);
                    _elementsGallery.Add(elem);
                }
            }
        }
 public CopyPaste()
 {
     copyBuffer = new PreparedElement("copy_buffer", "", new Scene());
 }
示例#4
0
        public void AddPreparedElement(PreparedElement element, Vector3 translation)
        {
            modified = true;
            uint pCount = (uint)points.Count;

            for (int i = 0; i < element.Scene.points.Count; i++)
            {
                points.Add(new Vector3D(
                               element.Scene.points[i].x + translation.X, element.Scene.points[i].y + translation.Y, element.Scene.points[i].z + translation.Z));
            }

            uint tCount = (uint)triangles.Count;

            for (int i = 0; i < element.Scene.triangles.Count; i++)
            {
                triangles.Add(new Modeler.Data.Scene.Triangle(
                                  element.Scene.triangles[i].p1 + pCount, element.Scene.triangles[i].p2 + pCount,
                                  element.Scene.triangles[i].p3 + pCount));
            }
            int lCount = lights.Count;

            foreach (Light_ light in element.Scene.lights)
            {
                lights.Add(new Light_(light));
                lights[lights.Count - 1].position += translation;
            }
            for (int i = 0; i < element.Scene.parts.Count; i++)
            {
                Part part = new Part(new List <int>());
                for (int j = 0; j < element.Scene.parts[i].triangles.Count; j++)
                {
                    part.triangles.Add(element.Scene.parts[i].triangles[j] + (int)tCount);
                }
                parts.Add(part);
                materialAssign.Add(element.Scene.materialAssign[i]);
            }

            Hierarchy newHierarchy = new Hierarchy();

            newHierarchy.objects = new List <HierarchyObject>();
            foreach (HierarchyObject ho in element.Scene.hierarchy.objects)
            {
                if (ho is HierarchyLight)
                {
                    newHierarchy.objects.Add(new HierarchyLight((HierarchyLight)ho));
                }
                else if (ho is HierarchyMesh)
                {
                    newHierarchy.objects.Add(new HierarchyMesh((HierarchyMesh)ho));
                }
                else if (ho is HierarchyNode)
                {
                    newHierarchy.objects.Add(new HierarchyNode((HierarchyNode)ho));
                }
            }

            RebuildAddedHierarchy(newHierarchy.objects, (int)tCount, lCount);

            hierarchy.objects.AddRange(newHierarchy.objects);

            foreach (Material_ material in element.Scene.materials)
            {
                if (!ContainsMaterialName(material.name))
                {
                    materials.Add(new Material_(material));
                }
            }
            hierarchyChange = true;
        }
 public void CopySelection(Scene scene)
 {
     Scene tmpScene = scene.SceneFromSelection(out copiedElemCenter);
     copyBuffer = new PreparedElement("copy_buffer", "", tmpScene);
 }
 public CopyPaste()
 {
     copyBuffer = new PreparedElement("copy_buffer", "", new Scene());
 }
示例#7
0
        public void AddPreparedElement(PreparedElement element, Vector3 translation)
        {
            modified = true;
            uint pCount = (uint)points.Count;
            for (int i = 0; i < element.Scene.points.Count; i++)
                points.Add(new Vector3D(
                    element.Scene.points[i].x + translation.X, element.Scene.points[i].y + translation.Y, element.Scene.points[i].z + translation.Z));

            uint tCount = (uint)triangles.Count;
            for (int i = 0; i < element.Scene.triangles.Count; i++)
            {
                triangles.Add(new Modeler.Data.Scene.Triangle(
                                  element.Scene.triangles[i].p1 + pCount, element.Scene.triangles[i].p2 + pCount,
                                  element.Scene.triangles[i].p3 + pCount));
            }
            int lCount = lights.Count;
            foreach (Light_ light in element.Scene.lights)
            {
                lights.Add(new Light_(light));
                lights[lights.Count - 1].position += translation;
            }
            for (int i = 0; i < element.Scene.parts.Count; i++)
            {
                Part part = new Part(new List<int>());
                for (int j = 0; j < element.Scene.parts[i].triangles.Count; j++)
                {
                    part.triangles.Add(element.Scene.parts[i].triangles[j] + (int) tCount);
                }
                parts.Add(part);
                materialAssign.Add(element.Scene.materialAssign[i]);
            }

            Hierarchy newHierarchy = new Hierarchy();
            newHierarchy.objects = new List<HierarchyObject>();
            foreach (HierarchyObject ho in element.Scene.hierarchy.objects)
            {
                if (ho is HierarchyLight)
                {
                    newHierarchy.objects.Add(new HierarchyLight((HierarchyLight)ho));
                }
                else if (ho is HierarchyMesh)
                {
                    newHierarchy.objects.Add(new HierarchyMesh((HierarchyMesh)ho));
                }
                else if (ho is HierarchyNode)
                {
                    newHierarchy.objects.Add(new HierarchyNode((HierarchyNode)ho));
                }
            }

            RebuildAddedHierarchy(newHierarchy.objects, (int)tCount, lCount);

            hierarchy.objects.AddRange(newHierarchy.objects);

            foreach (Material_ material in element.Scene.materials)
            {
                if (!ContainsMaterialName(material.name))
                {
                    materials.Add(new Material_(material));
                }
            }
            hierarchyChange = true;
        }