public void Draw(GraphicsDevice device, Effect effect, Matrix viewMatrix, Matrix projectionMatrix, float terrainWidth, float terrainHeight, VertexPositionTextureWeighted[] verts) { if (isLeaf) { if (tree.CheckVisible(tree.Frustum, this)) { if (tree.CheckVisible(tree.LODFrustum, this)) { device.Indices = NodeIndexBuffer; LOD = 3; } else if (tree.CheckVisible(tree.LOD2Frustum, this)) { device.Indices = LODIndexBuffer; LOD = 2; } else { device.Indices = LOD2IndexBuffer; LOD = 1; } device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verts.Length, 0, (vertIndices.Length)/ 3); } } else { if (tree.CheckVisible(tree.Frustum, this)) // if (isVisible(tree.Frustum)) { topLeft.Draw(device, effect, viewMatrix, projectionMatrix, terrainWidth, terrainHeight, verts); topRight.Draw(device, effect, viewMatrix, projectionMatrix, terrainWidth, terrainHeight, verts); bottomLeft.Draw(device, effect, viewMatrix, projectionMatrix, terrainWidth, terrainHeight, verts); bottomRight.Draw(device, effect, viewMatrix, projectionMatrix, terrainWidth, terrainHeight, verts); } } }
public Quadtree(Texture2D heightMap, Texture2D colorMap, float[,] data, VertexPositionTextureWeighted[] verticesFromGame, Vector3 camPos, BoundingFrustum bounding, GraphicsDevice device) { this.heightMap = heightMap; cameraPosition = camPos; Frustum = bounding; vertices = verticesFromGame; LoadHeightMapPixelData(heightMap); LoadHeightMapTextureData(colorMap); SetupNodes(heightMap, device); }