示例#1
0
        //mxd.
        public Vector2D GetHitPosition()
        {
            Vector3D start = General.Map.VisualCamera.Position;
            Vector3D delta = General.Map.VisualCamera.Target - General.Map.VisualCamera.Position;

            delta = delta.GetFixedLength(General.Settings.ViewDistance * 0.98f);
            VisualPickResult target = PickObject(start, start + delta);

            if (target.picked == null)
            {
                return(new Vector2D(float.NaN, float.NaN));
            }

            // Now find where exactly did we hit
            VisualGeometry vg = target.picked as VisualGeometry;

            if (vg != null)
            {
                return(GetIntersection(start, start + delta, vg.BoundingBox[0], new Vector3D(vg.Vertices[0].nx, vg.Vertices[0].ny, vg.Vertices[0].nz)));
            }


            VisualThing vt = target.picked as VisualThing;

            if (vt != null)
            {
                return(GetIntersection(start, start + delta, vt.CenterV3D, D3DDevice.V3D(vt.Center - vt.PositionV3)));
            }

            return(new Vector2D(float.NaN, float.NaN));
        }
示例#2
0
        /// <summary>
        /// mxd. This returns list of selected sectors based on surfaces selected in visual mode
        /// </summary>
        public List <VisualSector> GetSelectedVisualSectors(bool refreshSelection)
        {
            if (refreshSelection || selectedVisualSectors == null)
            {
                selectedVisualSectors = new List <VisualSector>();
                foreach (KeyValuePair <Sector, VisualSector> group in allsectors)
                {
                    foreach (VisualGeometry vg in group.Value.AllGeometry)
                    {
                        if (vg.Selected)
                        {
                            selectedVisualSectors.Add(group.Value);
                            break;
                        }
                    }
                }

                //if nothing is selected - try to get sector from hilighted object
                if (selectedVisualSectors.Count == 0)
                {
                    VisualGeometry vg = GetHilightedSurface();
                    if (vg != null)
                    {
                        selectedVisualSectors.Add(vg.Sector);
                    }
                }
            }
            return(selectedVisualSectors);
        }
示例#3
0
        /// <summary>
        /// mxd. This returns list of surfaces selected in visual mode
        /// </summary>
        public List <VisualGeometry> GetSelectedSurfaces()
        {
            List <VisualGeometry> selectedSurfaces = new List <VisualGeometry>();

            foreach (KeyValuePair <Sector, VisualSector> group in allsectors)
            {
                foreach (VisualGeometry vg in group.Value.AllGeometry)
                {
                    if (vg.Selected)
                    {
                        selectedSurfaces.Add(vg);
                    }
                }
            }

            //if nothing is selected - try to get hilighted surface
            if (selectedSurfaces.Count == 0)
            {
                VisualGeometry vg = GetHilightedSurface();
                if (vg != null)
                {
                    selectedSurfaces.Add(vg);
                }
            }
            return(selectedSurfaces);
        }
示例#4
0
 /// <summary>
 /// This adds geometry for this sector. If the geometry inherits from VisualSidedef then it
 /// will be added to the SidedefGeometry, otherwise it will be added as FixedGeometry.
 /// </summary>
 public void AddGeometry(VisualGeometry geo)
 {
     updategeo = true;
     allgeometry.Add(geo);
     if (geo.Sidedef != null)
     {
         if (!sidedefgeometry.ContainsKey(geo.Sidedef))
         {
             sidedefgeometry[geo.Sidedef] = new List <VisualGeometry>(3);
         }
         sidedefgeometry[geo.Sidedef].Add(geo);
     }
     else
     {
         fixedgeometry.Add(geo);
     }
 }
示例#5
0
        //mxd
        private VisualGeometry GetHilightedSurface()
        {
            Vector3D start = General.Map.VisualCamera.Position;
            Vector3D delta = General.Map.VisualCamera.Target - General.Map.VisualCamera.Position;

            delta = delta.GetFixedLength(General.Settings.ViewDistance * 0.98f);
            VisualPickResult target = PickObject(start, start + delta);

            if (target.picked is VisualGeometry)
            {
                VisualGeometry vg = (VisualGeometry)target.picked;
                if (vg.Sector != null)
                {
                    return(vg);
                }
            }
            return(null);
        }