public void SetNeighbor( Neighbor n, TerrainZoneRenderable t ) { this.mNeighbors[ (int)n ] = t; }
public virtual TerrainZonePage BuildPage( Real[] heightData, Material pMaterial ) { string name; // Create a TerrainZone Page var page = new TerrainZonePage( (ushort)( ( this.mPageSize - 1 )/( this.mTileSize - 1 ) ) ); // Create a node for all tiles to be attached to // Note we sequentially name since page can be attached at different points // so page x/z is not appropriate int pageIndex = this.mTerrainZone.PageCount; name = this.mTerrainZone.Name + "_page["; name += pageIndex + "]_Node"; if ( this.mTerrainZone.mPCZSM.HasSceneNode( name ) ) { page.PageSceneNode = this.mTerrainZone.mPCZSM.GetSceneNode( name ); // set the home zone of the scene node to the terrainzone ( (PCZSceneNode)( page.PageSceneNode ) ).AnchorToHomeZone( this.mTerrainZone ); // EXPERIMENTAL - prevent terrain zone pages from visiting other zones ( (PCZSceneNode)( page.PageSceneNode ) ).AllowToVisit = false; } else { page.PageSceneNode = this.mTerrainZone.TerrainRootNode.CreateChildSceneNode( name ); // set the home zone of the scene node to the terrainzone ( (PCZSceneNode)( page.PageSceneNode ) ).AnchorToHomeZone( this.mTerrainZone ); // EXPERIMENTAL - prevent terrain zone pages from visiting other zones ( (PCZSceneNode)( page.PageSceneNode ) ).AllowToVisit = false; } int q = 0; for ( int j = 0; j < this.mPageSize - 1; j += ( this.mTileSize - 1 ) ) { int p = 0; for ( int i = 0; i < this.mPageSize - 1; i += ( this.mTileSize - 1 ) ) { // Create scene node for the tile and the TerrainZoneRenderable name = this.mTerrainZone.Name + "_tile[" + pageIndex + "][" + p + "," + q + "]_Node"; SceneNode c; if ( this.mTerrainZone.mPCZSM.HasSceneNode( name ) ) { c = this.mTerrainZone.mPCZSM.GetSceneNode( name ); if ( c.Parent != page.PageSceneNode ) { page.PageSceneNode.AddChild( c ); } // set the home zone of the scene node to the terrainzone ( (PCZSceneNode)c ).AnchorToHomeZone( this.mTerrainZone ); // EXPERIMENTAL - prevent terrain zone pages from visiting other zones ( (PCZSceneNode)c ).AllowToVisit = false; } else { c = page.PageSceneNode.CreateChildSceneNode( name ); // set the home zone of the scene node to the terrainzone ( (PCZSceneNode)c ).AnchorToHomeZone( this.mTerrainZone ); // EXPERIMENTAL - prevent terrain zone pages from visiting other zones ( (PCZSceneNode)c ).AllowToVisit = false; } var tile = new TerrainZoneRenderable( name, this.mTerrainZone ); // set queue tile.RenderQueueGroup = this.mTerrainZone.mPCZSM.WorldGeometryRenderQueueId; // Initialise the tile tile.Material = pMaterial; tile.Initialize( i, j, heightData ); // Attach it to the page page.tiles[ p ][ q ] = tile; // Attach it to the node c.AttachObject( tile ); p++; } q++; } pageIndex++; // calculate neighbours for page page.LinkNeighbours(); if ( this.mTerrainZone.Options.lit ) { q = 0; for ( int j = 0; j < this.mPageSize - 1; j += ( this.mTileSize - 1 ) ) { int p = 0; for ( int i = 0; i < this.mPageSize - 1; i += ( this.mTileSize - 1 ) ) { page.tiles[ p ][ q ].CalculateNormals(); p++; } q++; } } return page; }