Example #1
0
        public BoxedData GetLocalGeoDataOfExitElements(int wmId, int parentObjectId)
        {
            BoxedData             data       = new BoxedData();
            List <GeoDataElement> resultList = null;
            string msg = "";

            try
            {
                WorldPlaceData worldPlace = GetWorldPlaceByWmId(wmId);
                if (worldPlace == null)
                {
                    throw new Exception("world place not found!");
                }

                PlaceInstance placeInstance = worldPlace.GetPredefinedInstanceByParentObjectId(parentObjectId);
                if (placeInstance == null)
                {
                    throw new Exception("place instance not found!");
                }

                resultList = placeInstance.GetGeoDataOfExitElements();
            }
            catch (Exception exception)
            {
                msg = $"An error occured while getting geo data (exit elements), wm_id [{wmId}] parent obj, ID [{parentObjectId}]: {exception.Message}";
            }

            data.Data = (resultList ?? new List <GeoDataElement>());
            data.Msg  = msg;
            return(data);
        }
Example #2
0
        public BoxedData GetLocalGeoData(int wmId, int parentObjectId, Point3 <int> from, Point3 <int> to)
        {
            BoxedData             data       = new BoxedData();
            List <GeoDataElement> resultList = null;
            string msg = "";

            try
            {
                #region Bounds

                int pointFromX = from.X - DbTerrainObjectDefinitions.MaxCollisionXOfAllObjects;
                int pointFromY = from.Y - DbTerrainObjectDefinitions.MaxCollisionYOfAllObjects;
                int pointFromZ = from.Z - DbTerrainObjectDefinitions.MaxCollisionZOfAllObjects;
                //Console.WriteLine($"mod. point from [{pointFromX}, {pointFromY}, {pointFromZ}]");

                Point3 <int> pointFromTemp = new Point3 <int>
                                             (
                    (pointFromX <= to.X ? pointFromX - 1 : to.X - 1), //NOTE: -1 to prevent rounding error
                    (pointFromY <= to.Y ? pointFromY - 1 : to.Y - 1), //NOTE: -1 to prevent rounding error
                    (pointFromZ <= to.Z ? pointFromZ - 1 : to.Z - 1)  //NOTE: -1 to prevent rounding error
                                             );

                Point3 <int> pointToTemp = new Point3 <int>
                                           (
                    (from.X >= to.X ? from.X + 1 : to.X + 1), //NOTE: +1 to prevent rounding error
                    (from.Y >= to.Y ? from.Y + 1 : to.Y + 1), //NOTE: +1 to prevent rounding error
                    (from.Z >= to.Z ? from.Z + 1 : to.Z + 1)  //NOTE: +1 to prevent rounding error
                                           );

                #endregion

                WorldPlaceData worldPlace = GetWorldPlaceByWmId(wmId);
                if (worldPlace == null)
                {
                    throw new Exception("world place not found!");
                }

                PlaceInstance placeInstance = worldPlace.GetPredefinedInstanceByParentObjectId(parentObjectId);
                if (placeInstance == null)
                {
                    throw new Exception("place instance not found!");
                }

                resultList = placeInstance.GetGeoData(pointFromTemp, pointToTemp);
            }
            catch (Exception exception)
            {
                msg = $"An error occured while getting geo data, wm_id [{wmId}] parent obj, ID [{parentObjectId}]: {exception.Message}";
            }

            data.Data = (resultList ?? new List <GeoDataElement>());
            data.Msg  = msg;
            return(data);
        }