Helper class to assist you in managing multiple terrain instances that are connected to each other.
Inheritance: DisposableObject, WorkQueue.IRequestHandler, WorkQueue.IResponseHandler
Esempio n. 1
0
		/// <summary>
		/// 
		/// </summary>
		protected override void SetupContent()
		{
			bool blankTerrain = false;

			//editMarker = SceneManager.CreateEntity( "editMarker", "sphere.mesh" );
			//editNode = SceneManager.RootSceneNode.CreateChildSceneNode();
			//editNode.AttachObject( editMarker );
			//editNode.Scale = new Vector3( 0.05f, 0.05f, 0.05f );

			SetupControls();

			CameraManager.TopSpeed = 50;

			DragLook = true;

			MaterialManager.Instance.SetDefaultTextureFiltering( TextureFiltering.Anisotropic );
			MaterialManager.Instance.DefaultAnisotropy = 7;

			SceneManager.SetFog( FogMode.Linear, new ColorEx( 0.07f, 0.07f, 0.08f ), 0, 10000, 25000 );

			Vector3 lightDir = new Vector3( 0.55f, 0.3f, 0.75f );
			lightDir.Normalize();

			Light l = SceneManager.CreateLight( "tsLight" );
			l.Type = LightType.Directional;
			l.Direction = lightDir;
			l.Diffuse = ColorEx.White;
			l.Specular = new ColorEx( 0.4f, 0.4f, 0.4f );

			SceneManager.AmbientLight = new ColorEx( 0.8f, 0.8f, 0.8f );

			terrainGroup = new TerrainGroup( SceneManager, Alignment.Align_X_Z, (ushort)TerrainSize, TerrainWorldSize );
			terrainGroup.SetFilenamConvention( TerrainFilePrefix, TerrainFileSuffix );
			terrainGroup.Origin = Vector3.Zero;
			
			Axiom.Components.Terrain.Terrain terrain = new Components.Terrain.Terrain( SceneManager );
			terrain.Position = terrainPos;
			ImportData data  = ConfigureTerrainDefaults( l );

			for ( long x = TerrainPageMinX; x <= TerrainPageMaxX; x++ )
			{
				for ( long y = TerrainPageMinY; y <= TerrainPageMaxY; y++ )
				{
					DefineTerrain( x, y, false );
				}
			}
			// sync load since we want everything in place when we start
			terrainGroup.LoadAllTerrains( true );

			if ( terrainsImported)
			{
				Axiom.Components.Terrain.Terrain t = terrainGroup.GetTerrain( 0, 0 );
				InitBlendMaps( t );
			}

			//Entity e = SceneManager.CreateEntity( "TudoMesh", "tudorhouse.mesh" );
			//Vector3 entPos = new Vector3( terrainPos.x + 2043, 0, terrainPos.z + 1715 );
			//Quaternion rot = new Quaternion();
			//entPos.y = terrainGroup.GetTerrain(0,0).GetHeightAtWorldPosition( entPos ) + 65.5f + terrainPos.y;
			//rot = Quaternion.FromAngleAxis( Utility.RangeRandom( -180, 180 ), Vector3.UnitY );
			//SceneNode sn = SceneManager.RootSceneNode.CreateChildSceneNode( entPos, rot );
			//sn.Scale = new Vector3( 0.12, 0.12, 0.12 );
			//sn.AttachObject( e );
			//Camera.Position = entPos;
			terrainGroup.FreeTemporaryResources();
			SceneManager.SetSkyDome( true, "Examples/CloudySky", 5, 8 );
			//SceneManager.SetSkyBox( true, "Examples/CloudyNoonSkyBox" , 5000);
		}
Esempio n. 2
0
		protected override void SetupContent()
		{
			var blankTerrain = false;

			this.editMarker = SceneManager.CreateEntity( "editMarker", "sphere.mesh" );
			this.editNode = SceneManager.RootSceneNode.CreateChildSceneNode();
			this.editNode.AttachObject( this.editMarker );
			this.editNode.Scale = new Vector3( 0.05f, 0.05f, 0.05f );

			_setupControls();

			CameraManager.TopSpeed = 50;

			DragLook = true;

			MaterialManager.Instance.SetDefaultTextureFiltering( TextureFiltering.Anisotropic );
			MaterialManager.Instance.DefaultAnisotropy = 7;

			SceneManager.SetFog( FogMode.Linear, new ColorEx( 0.07f, 0.07f, 0.08f ), 0, 10000, 25000 );

			var lightDir = new Vector3( 0.55f, 0.3f, 0.75f );
			lightDir.Normalize();

			var l = SceneManager.CreateLight( "tsLight" );
			l.Type = LightType.Directional;
			l.Direction = lightDir;
			l.Diffuse = ColorEx.White;
			l.Specular = new ColorEx( 0.4f, 0.4f, 0.4f );

			SceneManager.AmbientLight = new ColorEx( 0.2f, 0.2f, 0.2f );

			this.terrainGroup = new TerrainGroup( SceneManager, Alignment.Align_X_Z, (ushort)TerrainSize, TerrainWorldSize );
			this.terrainGroup.SetFilenameConvention( TerrainFilePrefix, TerrainFileSuffix );
			this.terrainGroup.Origin = this.terrainPos;

			_configureTerrainDefaults( l );
#if PAGING
	// Paging setup
            pageManager = new PageManager();
            // Since we're not loading any pages from .page files, we need a way just 
            // to say we've loaded them without them actually being loaded
            pageManager.PageProvider = dummyPageProvider;
            pageManager.AddCamera( Camera );
            terrainPaging = new TerrainPaging( pageManager );
            PagedWorld world = pageManager.CreateWorld();
            terrainPaging.CreateWorldSection( world, terrainGroup, 2000, 3000,
                TerrainPageMinX, TerrainPageMinY,
                TerrainPageMaxX, TerrainPageMaxY );
#else
			for ( long x = TerrainPageMinX; x <= TerrainPageMaxX; ++x )
			{
				for ( long y = TerrainPageMinY; y <= TerrainPageMaxY; ++y )
				{
					_defineTerrain( x, y, blankTerrain );
				}
			}
			// sync load since we want everything in place when we start
			this.terrainGroup.LoadAllTerrains( true );
#endif

			if ( this.terrainsImported )
			{
				foreach ( var ts in this.terrainGroup.TerrainSlots )
				{
					_initBlendMaps( ts.Instance );
				}
			}

			this.terrainGroup.FreeTemporaryResources();

			var e = SceneManager.CreateEntity( "TudoMesh", "tudorhouse.mesh" );
			var entPos = new Vector3( this.terrainPos.x + 2043, 0, this.terrainPos.z + 1715 );
			var rot = new Quaternion();
			entPos.y = this.terrainGroup.GetHeightAtWorldPosition( entPos ) + 65.5 + this.terrainPos.y;
			rot = Quaternion.FromAngleAxis( Utility.RangeRandom( -180, 180 ), Vector3.UnitY );
			var sn = SceneManager.RootSceneNode.CreateChildSceneNode( entPos, rot );
			sn.Scale = new Vector3( 0.12, 0.12, 0.12 );
			sn.AttachObject( e );
			this.houseList.Add( e );

			e = SceneManager.CreateEntity( "TudoMesh1", "tudorhouse.mesh" );
			entPos = new Vector3( this.terrainPos.x + 1850, 0, this.terrainPos.z + 1478 );
			entPos.y = this.terrainGroup.GetHeightAtWorldPosition( entPos ) + 65.5 + this.terrainPos.y;
			rot = Quaternion.FromAngleAxis( Utility.RangeRandom( -180, 180 ), Vector3.UnitY );
			sn = SceneManager.RootSceneNode.CreateChildSceneNode( entPos, rot );
			sn.Scale = new Vector3( 0.12, 0.12, 0.12 );
			sn.AttachObject( e );
			this.houseList.Add( e );

			e = SceneManager.CreateEntity( "TudoMesh2", "tudorhouse.mesh" );
			entPos = new Vector3( this.terrainPos.x + 1970, 0, this.terrainPos.z + 2180 );
			entPos.y = this.terrainGroup.GetHeightAtWorldPosition( entPos ) + 65.5 + this.terrainPos.y;
			rot = Quaternion.FromAngleAxis( Utility.RangeRandom( -180, 180 ), Vector3.UnitY );
			sn = SceneManager.RootSceneNode.CreateChildSceneNode( entPos, rot );
			sn.Scale = new Vector3( 0.12, 0.12, 0.12 );
			sn.AttachObject( e );
			this.houseList.Add( e );

			//SceneManager.SetSkyDome( true, "Examples/CloudyNoonSkyBox", 5000, 8 );
			SceneManager.SetSkyDome( true, "Examples/CloudySky", 5000, 8 );
		}
		public virtual void Initialize( TerrainGroup grp )
		{
			if ( this.terrainGroup == grp )
			{
				return;
			}

			if ( this.terrainGroup != null )
			{
				this.terrainGroup.Dispose();
			}

			this.terrainGroup = grp;
			SyncSettings();

			// Unload all existing terrain pages, because we want the paging system
			// to be in charge of this
			this.terrainGroup.RemoveAllTerrains();
		}
		protected override void LoadSubtypeData( StreamSerializer ser )
		{
			// we load the TerrainGroup information from here
			if ( this.terrainGroup == null )
			{
				this.terrainGroup = new TerrainGroup( SceneManager );
			}

			this.terrainGroup.LoadGroupDefinition( ref ser );

			// params that are in the Grid2DStrategyData will have already been loaded
			// as part of the main load() routine
			SyncSettings();
		}
Esempio n. 5
0
		public TerrainPagedWorldSection CreateWorldSection( PagedWorld world, TerrainGroup terrainGroup, Real loadRadius,
		                                                    Real holdRadius,
#if NET_40
            int minX = -10, int minY = -10, int maxX = 10, int maxY = 10, string sectionName = "" )