public PatchROAM(LandscapeROAM landscape, Camera cam, int heightX, int heightY, int worldX, int worldY, int patchSize, int mapSize) { this.landscape = landscape; this.cam = cam; this.varianceDepth = 8; this.patchSize = patchSize; this.mapSize = mapSize; // Clear all the relationships m_BaseLeft = new TriTreeNode(); m_BaseRight = new TriTreeNode(); m_BaseLeft.setBaseNeighbor(m_BaseRight); m_BaseRight.setBaseNeighbor(m_BaseLeft); // Store Patch offsets for the world and heightmap. this.worldX = worldX; this.worldY = worldY; // Store pointer to first byte of the height data for this patch. this.heightX = heightX; this.heightY = heightY; // Initialize flags m_VarianceDirty = 1; m_isVisible = 0; m_VarianceLeft = new ushort[1 << (varianceDepth)]; // Left variance tree m_VarianceRight = new ushort[1 << (varianceDepth)]; // Right variance tree Vector3 center = new Vector3(worldX + patchSize / 2, 0.0f, -worldY - patchSize / 2); bs = new BoundingSphere(center, patchSize); }
// --------------------------------------------------------------------- // Reset the patch. // public void reset() { // Assume patch is not visible. m_isVisible = 0; // Reset the important relationships m_BaseLeft.setLeftChild(null); m_BaseLeft.setRightChild(null); m_BaseRight.setLeftChild(null); m_BaseLeft.setLeftChild(null); // Attach the two m_Base triangles together m_BaseLeft.setBaseNeighbor(m_BaseRight); m_BaseRight.setBaseNeighbor(m_BaseLeft); // Clear the other relationships. m_BaseLeft.setRightNeighbor(null); m_BaseLeft.setLeftNeighbor(null); m_BaseRight.setRightNeighbor(null); m_BaseRight.setLeftNeighbor(null); }