Esempio n. 1
0
        /// <summary>
        /// transform the aabb we just drew to X/Y space
        /// create and transform solid back to this viewport space
        /// </summary>
        /// <param name="transform"></param>
        public void CreateSolid(Matrix4 transform)
        {
            if (!RubberBand.Bounds.HasVolume3D)
            {
                return;
            }

            // Transform rubberband to allow creation of correct orientated solid
            AABB    creationBounds = (AABB)RubberBand.Bounds.Clone();
            Vector3 min            = creationBounds.Min.TransformL(transform);
            Vector3 max            = creationBounds.Max.TransformL(transform);

            creationBounds.Reset();
            creationBounds.Grow(min);
            creationBounds.Grow(max);

            // create solid
            Solid solid = solidFactory.CreateMapObject(currentSolidCreatorIdentifier, creationBounds);

            // transform the solid and recreate the bounds with every transformed vertex
            transform.Invert();
            for (int i = 0; i < solid.VertexPositions.Count; i++)
            {
                solid.VertexPositions[i] = solid.VertexPositions[i].TransformL(transform);
            }

            solid.RegenerateBounds();
            solid.CalculateNormals();

            // add to scene and selection
            SceneDocument.AddMapObject(solid);
            solid.Selected = true;
            Selection.Clear();
            Selection.Add(solid);

            // set solid properties
            if (TextureCollection.SelectedTexture.HasValue)
            {
                ApplySelectedTexture(TextureCollection.SelectedTexture.Value);
            }

            // calculate texture coordinates
            solid.Faces.ForEach(solid.AlignTextureAxisToWorldForFace);
            solid.Faces.ForEach(f => solid.CalculateTextureCoordinatesForFace(f, true));
        }
Esempio n. 2
0
        private void UngroupMapObject()
        {
            if (!Selection.Empty)
            {
                List <MapObjectGroup> groups = new List <MapObjectGroup>();
                CustomOperation       collectGroupsOperation = new CustomOperation
                {
                    OnMapObjectGroup = group =>
                    {
                        if (!group.IsTransient)
                        {
                            return;
                        }

                        groups.Add(group);
                    }
                };

                // collect all top level groups
                Selection.MapObjectList.ForEach(m => m.PerformOperation(collectGroupsOperation));

                // remove groups that have been ungrouped
                groups.ForEach(group =>
                {
                    group.Selected = false;
                    Selection.Remove(group);
                    SceneDocument.RemoveMapObject(group);

                    group.MapObjectList.ForEach(mapObject =>
                    {
                        mapObject.Selected = true;
                        Selection.Add(mapObject);
                        SceneDocument.AddMapObject(mapObject);
                    });
                });

                groups.Clear();
                UpdateGroupToolbar();
            }
        }
Esempio n. 3
0
        private void GroupMapObject()
        {
            if (!Selection.Empty && Selection.MapObjectList.Count > 1)
            {
                // remove the map objects from the document
                foreach (MapObject mapObject in Selection)
                {
                    SceneDocument.RemoveMapObject(mapObject);
                }

                // clone and clear the selected map objects
                MapObject newMapObjectGroup = (MapObject)Selection.Clone();
                Selection.Clear();

                // add map object group with map objects in it to the document and selection map object
                SceneDocument.AddMapObject(newMapObjectGroup);
                Selection.Add(newMapObjectGroup);

                UpdateGroupToolbar();

                RenderViewports();
            }
        }
Esempio n. 4
0
        public void PasteMapObject()
        {
            if (!CopyBoard.Empty)
            {
                List <MapObject> clonedMapObjects = new List <MapObject>();
                foreach (MapObject mapObject in CopyBoard)
                {
                    clonedMapObjects.Add((MapObject)mapObject.Clone());
                }

                Selection.Clear();
                foreach (MapObject mapObject in clonedMapObjects)
                {
                    SceneDocument.AddMapObject(mapObject);
                    Selection.Add(mapObject);
                }

                CopyBoard.Clear();
                UpdateCutCopyPasteToolbar();

                RenderViewports();
            }
        }