Пример #1
0
        public bool boundingBoxIntersects(boundingBox a, boundingBox b, Vector3 posA, Vector3 posB)
        {
            /*if (a.max.X < b.min.X || a.min.X > b.max.X)
             * {
             *  return false;
             * }
             * if (a.max.Y < b.min.Y || a.min.Y > b.max.Y)
             * {
             *  return false;
             * }
             * if(a.max.Z < b.min.Z || a.min.Z > b.max.Z)
             * {
             *  return false;
             * }*/



            // Exit with no intersection if found separated along an axis
            if (a.max.X + posA.X < b.min.X + posB.X || a.min.X + posA.X > b.max.X + posB.X)
            {
                return(false);
            }
            if (a.max.Y + posA.Y < b.min.Y + posB.Y || a.min.Y + posA.Y > b.max.Y + posB.Y)
            {
                return(false);
            }
            if (a.max.Z + posA.Z < b.min.Z + posB.Z || a.min.Z + posA.Z > b.max.Z + posB.Z)
            {
                return(false);
            }

            // No separating axis found, therefor there is at least one overlapping axis
            return(true);
        }
Пример #2
0
        private void setQueryValues(string q     = "", int c = 30, bool Clustering = false, bool maxModel         = false,
                                    string theme = null, string category = null, string POItype   = null, CRS srs = CRS.WGS84,
                                    int?id       = null, string niscode  = null, boundingBox bbox = null)
        {
            qryValues.Clear();

            if (q != null || q != "")
            {
                qryValues.Add("keyword", q);
            }

            if (Clustering && !maxModel)
            {
                qryValues.Add("Clustering", "true");
            }
            else
            {
                qryValues.Add("Clustering", "false");
            }
            //srs
            qryValues.Add("srsIn", Convert.ToString((int)srs));
            qryValues.Add("srsOut", Convert.ToString((int)srs));
            //string lists
            if (id != null)
            {
                qryValues.Add("id", id.ToString());
            }
            if (niscode != null || niscode != "")
            {
                qryValues.Add("region", niscode);
            }
            if (theme != null || theme != "")
            {
                qryValues.Add("theme", theme);
            }
            if (category != null || category != "")
            {
                qryValues.Add("category", category);
            }
            if (POItype != null || POItype != "")
            {
                qryValues.Add("POItype", POItype);
            }
            qryValues.Add("maxcount", c.ToString());

            if (maxModel)
            {
                qryValues.Add("maxmodel", "true");
            }
            else
            {
                qryValues.Add("maxmodel", "false");
            }

            if (bbox != null)
            {
                qryValues.Add("bbox", bbox.ToBboxString("|", "|"));
            }
        }
Пример #3
0
    void Start()
    {
        Collider2D boundingbox = GetComponent <Collider2D>();
        Vector3    _min        = boundingbox.bounds.min;
        Vector3    _max        = boundingbox.bounds.max;

        _bbox = new boundingBox(_min, _max);
    }
Пример #4
0
 RenderItems.Add(new RenderItem(
                     material,
                     vertexBuffer0,
                     vertexBuffer1,
                     cullFlags,
                     boundingBox,
                     world,
                     DrawCommand.Draw,
                     vertexStart,
                     vertexCount,
                     0, 0, null));
Пример #5
0
        public datacontract.poiMinResponse getMinmodel(string q = null, bool Clustering=false, string theme = null, string category = null, 
            string POItype = null, CRS srs = CRS.WGS84, int? id = null, string niscode = null, boundingBox bbox = null)
        {
            setQueryValues(q, 1024, Clustering, false, theme, category, POItype, srs, id, niscode, bbox );
            client.QueryString = qryValues;

            string json = client.DownloadString(baseUrl);

            datacontract.poiMinResponse poiResponse = JsonConvert.DeserializeObject<datacontract.poiMinResponse>(json);

            client.QueryString.Clear();

            return poiResponse;
        }
Пример #6
0
        //manifestation
        public List<datacontract.gipodResponse> getManifestation( 
                DateTime? startdate = null, DateTime? enddate = null,
                string city = "", string province = "", string owner = "", string eventtype = "",
                CRS CRS = CRS.WGS84, int c = 50, int offset = 0, boundingBox bbox = null )
        {
            setQueryValues(startdate, enddate, city, province, owner, eventtype, CRS, c, offset, bbox);

            client.QueryString = qryValues;

            Uri gipodUri = new Uri("http://gipod.api.agiv.be/ws/v1/manifestation");
            string json = client.DownloadString(gipodUri);

            List<datacontract.gipodResponse> gipodRespons = JsonConvert.DeserializeObject<List<datacontract.gipodResponse>>(json);

            client.QueryString.Clear();
            return gipodRespons;
        }
Пример #7
0
        //manifestation
        public List <datacontract.gipodResponse> getManifestation(
            DateTime?startdate = null, DateTime?enddate = null,
            string city        = "", string province    = "", string owner = "", string eventtype = "",
            CRS CRS            = CRS.WGS84, int c = 50, int offset         = 0, boundingBox bbox  = null)
        {
            setQueryValues(startdate, enddate, city, province, owner, eventtype, CRS, c, offset, bbox);

            client.QueryString = qryValues;

            Uri    gipodUri = new Uri("http://gipod.api.agiv.be/ws/v1/manifestation");
            string json     = client.DownloadString(gipodUri);

            List <datacontract.gipodResponse> gipodRespons = JsonConvert.DeserializeObject <List <datacontract.gipodResponse> >(json);

            client.QueryString.Clear();
            return(gipodRespons);
        }
Пример #8
0
        public List<datacontract.gipodResponse> allWorkassignments(DateTime? startdate = null, DateTime? enddate = null,
                string city = "", string province = "", string owner = "", CRS CRS = CRS.WGS84, boundingBox bbox = null)
        {
            List<datacontract.gipodResponse> allWA = new List<datacontract.gipodResponse>();
            List<datacontract.gipodResponse> WA = getWorkassignment(startdate, enddate, city, province, owner, CRS, 500, 0, bbox);

            allWA.AddRange(WA);

            int counter = 0;

            while (WA.Count == 500)
            {
                counter += 500;
                WA = getWorkassignment(startdate, enddate, city, province, owner, CRS, 500, counter);
                allWA.AddRange(WA);
            }
            return allWA;
        }
Пример #9
0
        public datacontract.poiMinResponse getMinmodel(string q       = null, bool Clustering = false, string theme = null, string category = null,
                                                       string POItype = null, CRS srs         = CRS.WGS84, int?id   = null, string niscode  = null, boundingBox bbox = null)
        {
            setQueryValues(q, 1024, Clustering, false, theme, category, POItype, srs, id, niscode, bbox);
            client.QueryString = qryValues;

            string json = client.DownloadString(baseUrl);

            datacontract.poiMinResponse poiResponse = JsonConvert.DeserializeObject <datacontract.poiMinResponse>(json);

            client.QueryString.Clear();

            return(poiResponse);
        }
Пример #10
0
        private void setQueryValues(string q = "", int c = 30, bool Clustering = false, bool maxModel = false,
             string theme = null, string category = null, string POItype = null, CRS srs = CRS.WGS84, 
             int? id = null, string niscode = null, boundingBox bbox = null)
        {
            qryValues.Clear();

            if (q != null || q != "") qryValues.Add("keyword", q);

            if (Clustering && !maxModel ) qryValues.Add("Clustering", "true");
            else qryValues.Add("Clustering", "false");
            //srs
            qryValues.Add("srsIn", Convert.ToString((int)srs));
            qryValues.Add("srsOut", Convert.ToString((int)srs));
            //string lists
            if (id != null ) qryValues.Add("id", id.ToString());
            if (niscode != null || niscode != "") qryValues.Add("region", niscode);
            if (theme != null || theme != "" ) qryValues.Add("theme", theme);
            if (category != null || category != "" ) qryValues.Add("category", category);
            if (POItype != null || POItype != "" ) qryValues.Add("POItype", POItype);
            qryValues.Add("maxcount", c.ToString());

            if (maxModel)
            {
                qryValues.Add("maxmodel", "true");
            }
            else
            {
                qryValues.Add("maxmodel", "false");
            }

            if (bbox != null) qryValues.Add("bbox", bbox.ToBboxString("|", "|"));
        }
Пример #11
0
        private void setQueryValues(DateTime? startdate, DateTime? enddate, 
            string city, string province, string owner, string eventtype, CRS sRS, int c, int offset, boundingBox bbox = null)
        {
            //counters
            qryValues.Add("offset", offset.ToString());
            qryValues.Add("limit", c.ToString());
            //string lists
            if (city != "" || city != null) qryValues.Add("city", city);
            if (province != "" || province != null) qryValues.Add("province", province);
            if (owner != "" || owner != null) qryValues.Add("owner", owner);
            if (eventtype != "" || eventtype != null) qryValues.Add("eventtype", eventtype);
            //CRS
            qryValues.Add("CRS", Convert.ToString((int)sRS));

            //Time
            if (startdate != null) qryValues.Add("startdate", startdate.Value.ToString("yyyy-MM-dd"));
            if (enddate != null) qryValues.Add("enddate", enddate.Value.ToString("yyyy-MM-dd"));

            //bbox
            if (bbox != null) qryValues.Add("bbox", bbox.ToBboxString(",", "|") );
        }
Пример #12
0
        private bool InitializeBuffer(SharpDX.Direct3D11.Device device, int ChunkWidth_L, int ChunkWidth_R, int ChunkHeight_L, int ChunkHeight_R, int ChunkDepth_L, int ChunkDepth_R)
        {
            try
            {
                //Set number of vertices in the vertex array.
                VertexCount = 8;
                // Set number of vertices in the index array.
                IndexCount = 36;


                // Create the vertex array and load it with data.
                Vertices = new[]
                {
                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(-1 * _sizeX, -1 * _sizeY, 1 * _sizeZ),
                        color    = _color,
                    },
                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(-1 * _sizeX, 1 * _sizeY, 1 * _sizeZ),
                        color    = _color,
                    },
                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(1 * _sizeX, -1 * _sizeY, 1 * _sizeZ),
                        color    = _color,
                    },
                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(1 * _sizeX, 1 * _sizeY, 1 * _sizeZ),
                        color    = _color,
                    },


                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(-1 * _sizeX, -1 * _sizeY, -1 * _sizeZ),
                        color    = _color,
                    },
                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(-1 * _sizeX, 1 * _sizeY, -1 * _sizeZ),
                        color    = _color,
                    },
                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(1 * _sizeX, -1 * _sizeY, -1 * _sizeZ),
                        color    = _color,
                    },
                    new SC_VR_Touch_Shader.DVertex()
                    {
                        position = new Vector3(1 * _sizeX, 1 * _sizeY, -1 * _sizeZ),
                        color    = _color,
                    },
                };

                // Create Indicies to load into the IndexBuffer.
                indices = new int[]
                {
                    0,  // Bottom left.
                    1,  // Top middle.
                    2,  // Bottom right.
                    3,
                    2,
                    1,

                    1,
                    5,
                    3,
                    7,
                    3,
                    5,

                    2,
                    3,
                    6,
                    7,
                    6,
                    3,

                    6,
                    7,
                    4,
                    5,
                    4,
                    7,

                    4,
                    5,
                    0,
                    1,
                    0,
                    5,

                    4,
                    0,
                    6,
                    2,
                    6,
                    0
                };



                /*lowestX = _vertArray.OrderBy(xx => xx.X).FirstOrDefault();
                 * highestX = _vertArray.OrderBy(xx => xx.X).Last();
                 *
                 * lowestY = _vertArray.OrderBy(yy => yy.X).FirstOrDefault();
                 * highestY = _vertArray.OrderBy(yy => yy.X).Last();
                 *
                 * lowestZ = _vertArray.OrderBy(zz => zz.X).FirstOrDefault();
                 * highestZ = _vertArray.OrderBy(zz => zz.X).Last();
                 */


                //var lowestXTopY = _vertArray.OrderBy(xx => xx.X).ThenBy(xx=>xx.Y).FirstOrDefault();
                //var highestXTopY = _vertArray.OrderBy(xx => xx.X).ThenBy(xx => xx.Y).Last();

                /*
                 *
                 * lowestY = _vertArray.OrderBy(yy => yy.X).FirstOrDefault();
                 * highestY = _vertArray.OrderBy(yy => yy.X).Last();
                 *
                 * lowestZ = _vertArray.OrderBy(zz => zz.X).FirstOrDefault();
                 * highestZ = _vertArray.OrderBy(zz => zz.X).Last();
                 */

                //double minX = Math.Min(Math.Min(lowestX.X, highestX.X), Math.Min(lb.X, rb.X));


                _vertArray = new SharpDX.Vector3[Vertices.Length];

                for (int i = 0; i < Vertices.Length; i++)
                {
                    _vertArray[i] = Vertices[i].position;
                }
                var min = _vertArray.OrderBy(xx => xx.X).ThenBy(xx => xx.Y).ThenBy(xx => xx.Z).FirstOrDefault();
                var max = _vertArray.OrderBy(xx => xx.X).ThenBy(xx => xx.Y).ThenBy(xx => xx.Z).Last();

                float sumX = 0;
                float sumY = 0;
                float sumZ = 0;

                for (int i = 0; i < Vertices.Length; i++)
                {
                    sumX += Vertices[i].position.X;
                    sumY += Vertices[i].position.Y;
                    sumZ += Vertices[i].position.Z;
                }

                sumX /= Vertices.Length;
                sumY /= Vertices.Length;
                sumZ /= Vertices.Length;

                var center = new Vector3(sumX, sumY, sumZ);
                _boundingBox = new boundingBox(center, min, max);



                //_boundingBox.center = center;
                //_boundingBox.min = min;
                //_boundingBox.max = max;

                //_boundingBox = new SharpDX.BoundingBox(min,max);



                //double minX = Math.Min(Math.Min(lt.X, rt.X), Math.Min(lb.X, rb.X));
                //double minY = Math.Min(Math.Min(lt.Y, rt.Y), Math.Min(lb.Y, rb.Y));

                //double maxX = Math.Max(Math.Max(lt.X, rt.X), Math.Max(lb.X, rb.X));
                //double maxY = Math.Max(Math.Max(lt.Y, rt.Y), Math.Max(lb.Y, rb.Y));



                int width  = 4;
                int heigth = 4;
                int depth  = 4;

                InstanceCount = width * heigth * depth;
                DInstanceType[] instances = new DInstanceType[width * heigth * depth];
                _LASTPOSITIONS = new Matrix[width * heigth * depth];

                int counter = 0;


                for (int x = -ChunkWidth_L; x <= ChunkWidth_R; x++)
                {
                    for (int y = -ChunkHeight_L; y <= ChunkHeight_R; y++)
                    {
                        for (int z = -ChunkDepth_L; z <= ChunkDepth_R; z++)
                        {
                            float posX = (x);
                            float posY = (y);
                            float posZ = (z);

                            var xxi = x;
                            var yyi = y;
                            var zzi = z;

                            if (xxi < 0)
                            {
                                xxi *= -1;
                                xxi  = (ChunkWidth_R) + xxi;
                            }
                            if (yyi < 0)
                            {
                                yyi *= -1;
                                yyi  = (ChunkHeight_R) + yyi;
                            }
                            if (zzi < 0)
                            {
                                zzi *= -1;
                                zzi  = (ChunkDepth_R) + zzi;
                            }

                            int _index = xxi + (ChunkWidth_L + ChunkWidth_R + 1) * (yyi + (ChunkHeight_L + ChunkHeight_R + 1) * zzi);


                            instances[counter] = new DInstanceType()
                            {
                                position = new Vector3(x, y, z),
                            };
                            _LASTPOSITIONS[counter]     = Matrix.Identity;
                            _LASTPOSITIONS[counter].M41 = instances[counter].position.X;
                            _LASTPOSITIONS[counter].M42 = instances[counter].position.Y;
                            _LASTPOSITIONS[counter].M43 = instances[counter].position.Z;


                            counter++;
                        }
                    }
                }

                // Create the vertex buffer.
                VertexBuffer = SharpDX.Direct3D11.Buffer.Create(device, BindFlags.VertexBuffer, Vertices);

                // Create the index buffer.
                IndexBuffer = SharpDX.Direct3D11.Buffer.Create(device, BindFlags.IndexBuffer, indices);

                InstanceBuffer = SharpDX.Direct3D11.Buffer.Create(device, BindFlags.VertexBuffer, instances);
                //InstanceBuffer = SharpDX.Direct3D11.Buffer.Create(device, BindFlags.VertexBuffer, instances, Utilities.SizeOf<DInstanceType>() * instances.Length, ResourceUsage.Dynamic, CpuAccessFlags.Write, ResourceOptionFlags.None, 0);

                // Delete arrays now that they are in their respective vertex and index buffers.
                //Vertices = null;
                //indices = null;

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #13
0
        public List <datacontract.gipodResponse> allManifestations(DateTime?startdate = null, DateTime?enddate = null,
                                                                   string city        = "", string province    = "", string owner = "", string eventtype = "", CRS CRS = CRS.WGS84, boundingBox bbox = null)
        {
            List <datacontract.gipodResponse> allWA = new List <datacontract.gipodResponse>();
            List <datacontract.gipodResponse> WA    = getManifestation(startdate, enddate, city, province, owner, eventtype, CRS, 500, 0, bbox);

            allWA.AddRange(WA);

            int counter = 0;

            while (WA.Count == 500)
            {
                counter += 500;
                WA       = getManifestation(startdate, enddate, city, province, owner, eventtype, CRS, 500, counter);
                allWA.AddRange(WA);
            }
            return(allWA);
        }
Пример #14
0
        private void setQueryValues(DateTime?startdate, DateTime?enddate,
                                    string city, string province, string owner, string eventtype, CRS sRS, int c, int offset, boundingBox bbox = null)
        {
            //counters
            qryValues.Add("offset", offset.ToString());
            qryValues.Add("limit", c.ToString());
            //string lists
            if (city != "" || city != null)
            {
                qryValues.Add("city", city);
            }
            if (province != "" || province != null)
            {
                qryValues.Add("province", province);
            }
            if (owner != "" || owner != null)
            {
                qryValues.Add("owner", owner);
            }
            if (eventtype != "" || eventtype != null)
            {
                qryValues.Add("eventtype", eventtype);
            }
            //CRS
            qryValues.Add("CRS", Convert.ToString((int)sRS));

            //Time
            if (startdate != null)
            {
                qryValues.Add("startdate", startdate.Value.ToString("yyyy-MM-dd"));
            }
            if (enddate != null)
            {
                qryValues.Add("enddate", enddate.Value.ToString("yyyy-MM-dd"));
            }

            //bbox
            if (bbox != null)
            {
                qryValues.Add("bbox", bbox.ToBboxString(",", "|"));
            }
        }
Пример #15
0
    //spawn(top/btm/left/right, displacement coord, time)

    // Use this for initialization
    void Awake()
    {
        boundingBox.current = this;
    }