public void Subdivide() { //Sub divide the current node’s bounding box into 4 equal boxes float childSize = Size / 2; OctTree TTL = new OctTree( childSize, new Vector3(Position.X - childSize / 2, Position.Y + childSize / 2, Position.Z - childSize / 2), MaxObjects); OctTree TTR = new OctTree( childSize, new Vector3(Position.X + childSize / 2, Position.Y + childSize / 2, Position.Z - childSize / 2), MaxObjects); OctTree TBL = new OctTree( childSize, new Vector3(Position.X + childSize / 2, Position.Y + childSize / 2, Position.Z + childSize / 2), MaxObjects); OctTree TBR = new OctTree( childSize, new Vector3(Position.X + childSize / 2, Position.Y - childSize / 2, Position.Z + childSize / 2), MaxObjects); OctTree BBL = new OctTree( childSize, new Vector3(Position.X - childSize / 2, Position.Y - childSize / 2, Position.Z + childSize / 2), MaxObjects); OctTree BBR = new OctTree( childSize, new Vector3(Position.X + childSize / 2, Position.Y - childSize / 2, Position.Z + childSize / 2), MaxObjects); OctTree BTL = new OctTree( childSize, new Vector3(Position.X - childSize / 2, Position.Y + childSize / 2, Position.Z - childSize / 2), MaxObjects); OctTree BTR = new OctTree( childSize, new Vector3(Position.X - childSize / 2, Position.Y - childSize / 2, Position.Z - childSize / 2), MaxObjects); Nodes.Add(TTL); Nodes.Add(TTR); Nodes.Add(BBL); Nodes.Add(BBR); Nodes.Add(BTL); Nodes.Add(BTR); Nodes.Add(TBL); Nodes.Add(TBR); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { GameUtilities.Content = Content; GameUtilities.GraphicsDevice = GraphicsDevice; debug.Initialize(); shapeDrawer.Initialize(); mainCamera = new Camera("cam", new Vector3(0, 5, 20), new Vector3(0, 0, -1)); mainCamera.Initialize(); //quadTree = new QuadTree(100, Vector2.Zero, 5); octTree = new OctTree(100, Vector3.Zero, 5); occQuery = new OcclusionQuery(GraphicsDevice); // TODO: Add your initialization logic here base.Initialize(); }