public List<IGridRegisterable> GetObjectsInMyZone(IGridRegisterable obj)
        {
            List<Vector3> registeredZones = new List<Vector3>();
            List<IGridRegisterable> objList = new List<IGridRegisterable>();

            if (objectRegisteredZones.ContainsKey(obj))
                registeredZones = objectRegisteredZones[obj];

            if (registeredZones.Count > 0)
            {
                for (int z = 0; z < registeredZones.Count; z++)
                {
                    for (int o = 0; o < gridObjects[registeredZones[z]].Count; o++)
                    {
                        if (gridObjects[registeredZones[z]][o] != obj && /*!objList.Exists(delegate(IGridRegisterable igr) { return igr == obj; }) &&*/ !objList.Contains(gridObjects[registeredZones[z]][o]))
                            objList.Add(gridObjects[registeredZones[z]][o]);
                    }
                }
            }
            return objList;
        }
        private void RegisterObject(IGridRegisterable obj)
        {
            bool oob = false;
            List<Vector3> registeredZones = new List<Vector3>();
            List<Vector3> gridRefs = new List<Vector3>();
            List<IGridRegisterable> objList = new List<IGridRegisterable>();

            for (int b = 0;obj.Bounds != null && b < obj.Bounds.Count; b++)
            {
                if (masterbb.Intersects(obj.Bounds[b]))
                {
                    oob = true;
                    break;
                }
            }
            // Not in the grid anymore :(
            if (!oob)
            {
                // Clean up my registrations.
                registeredZones = objectRegisteredZones[obj];

                for (int u = 0; u < registeredZones.Count; u++)
                {
                    objList = gridObjects[registeredZones[u]];
                    objList.Remove(obj);
                    gridObjects[registeredZones[u]] = objList;

                    registeredZones.Remove(registeredZones[u]);
                }
                return;
            }



            if (objectRegisteredZones.ContainsKey(obj))
                registeredZones = objectRegisteredZones[obj];

            gridRefs = GetGridRef(obj);



            // If not then find my initial place in the grid..
            // Unregister from the grid where we are no longer present.
            for (int u = 0; u < registeredZones.Count; u++)
            {
                if (!gridRefs.Contains(registeredZones[u]))
                {
                    objList = gridObjects[registeredZones[u]];
                    objList.Remove(obj);
                    gridObjects[registeredZones[u]] = objList;

                    registeredZones.Remove(registeredZones[u]);
                }
            }

            // Register with these grid ref.
            for (int r = 0; r < gridRefs.Count; r++)
            {
                if (!registeredZones.Contains(gridRefs[r]))
                {
                    objList = gridObjects[gridRefs[r]];
                    objList.Add(obj);
                    gridObjects[gridRefs[r]] = objList;
                    registeredZones.Add(gridRefs[r]);
                }
            }
            objectRegisteredZones[obj] = registeredZones;
        }
        public List<Vector3> GetGridRef(IGridRegisterable obj)
        {
            List<Vector3> gridRefs = new List<Vector3>();

            int xs = int.MaxValue, ys = int.MaxValue, zs = int.MaxValue;
            int xf = (int)gridDimensions.X, yf = (int)gridDimensions.Y, zf = (int)gridDimensions.Z;
            xf = 0; yf = 0; zf = 0;

            if (obj is ICameraService)
            { }
            else
            {
                // Comvert to Grid position.
                for (int b = 0; b < obj.Bounds.Count; b++)
                {
                    // Am I in the GGR?
                    if (masterbb.Intersects(obj.Bounds[b]))
                    {
                        // Now what box do we first intersect?
                        Vector3 nearestMin = (obj.Bounds[b].Min - min) / elWidth;
                        Vector3 nearestMax = (obj.Bounds[b].Max + max) / elWidth;

                        xs = (int)MathHelper.Clamp(MathHelper.Min(xs, nearestMin.X), 0, gridDimensions.X - 1);
                        ys = (int)MathHelper.Clamp(MathHelper.Min(ys, nearestMin.Y), 0, gridDimensions.Y - 1);
                        zs = (int)MathHelper.Clamp(MathHelper.Min(zs, nearestMin.Z), 0, gridDimensions.Z - 1);

                        xf = (int)MathHelper.Clamp(MathHelper.Max(xf, nearestMax.X), 0, gridDimensions.X - 1);
                        yf = (int)MathHelper.Clamp(MathHelper.Max(yf, nearestMax.Y), 0, gridDimensions.Y - 1);
                        zf = (int)MathHelper.Clamp(MathHelper.Max(zf, nearestMax.Z), 0, gridDimensions.Z - 1);
                    }
                }
            }

            bool outLoop = false;
            for (int x = xs; x <= xf && !outLoop; x++)
            {
                for (int y = ys; y <= yf && !outLoop; y++)
                {
                    for (int z = zs; z <= zf && !outLoop; z++)
                    {
                        Vector3 checkRef = new Vector3(x, y, z);

                        if (obj is ICameraService)
                        {
                            if (theGrid[checkRef].Intersects(((ICameraService)obj).Frustum))
                                gridRefs.Add(checkRef);
                        }
                        else
                        {
                            for (int b = 0; b < obj.Bounds.Count; b++)
                            {
                                if (theGrid[checkRef].Intersects(obj.Bounds[b]))
                                {
                                    gridRefs.Add(checkRef);
                                    // Do do later
                                    //if (obj is ITerrain || obj is IVolumetric || obj is IPlatform3D)
                                    //    outLoop = false;
                                    //else
                                    //outLoop = true;
                                }
                            }
                        }
                    }
                }
            }

            return gridRefs;
        }
        public void AddObject(IGridRegisterable obj)
        {
            bool added = false;

            for (int o = 0; o < listObjects.Count; o++)
            {
                if (listObjects[o] == null)
                {
                    listObjects[o] = obj;
                    added = true;
                    break;
                }
            }
            if (!added)
                listObjects.Add(obj);
            objectRegisteredZones.Add(obj, new List<Vector3>());
            RegisterObject(obj);
        }