private TerrainPatch CreatePatch( TerrainMaterial terrainMaterial, HeightMap heightMap, BlendTileData blendTileData, Rectangle patchBounds, GraphicsDevice graphicsDevice, TerrainPatchIndexBufferCache indexBufferCache) { var indexBuffer = indexBufferCache.GetIndexBuffer( patchBounds.Width, patchBounds.Height, out var indices); var vertexBuffer = AddDisposable(CreateVertexBuffer( graphicsDevice, heightMap, patchBounds, indices, out var boundingBox, out var triangles)); return(new TerrainPatch( terrainMaterial, patchBounds, vertexBuffer, indexBuffer, (uint)indices.Length, triangles, boundingBox)); }
private void CreateTextures( ContentManager contentManager, BlendTileData blendTileData, out Texture textureArray, out TextureInfo[] textureDetails) { var graphicsDevice = contentManager.GraphicsDevice; var numTextures = (uint)blendTileData.Textures.Length; var textureInfo = new(uint size, FileSystemEntry entry)[numTextures];
private void CreateTextures( AssetLoadContext loadContext, BlendTileData blendTileData, out Texture textureArray, out TerrainShaderResources.TextureInfo[] textureDetails) { var graphicsDevice = loadContext.GraphicsDevice; var numTextures = (uint)blendTileData.Textures.Length; var textureInfo = new (uint size, FileSystemEntry entry)[numTextures];
private void CreatePatches( GraphicsDevice graphicsDevice, ResourceUploadBatch uploadBatch, Entity terrainEntity, HeightMap heightMap, BlendTileData blendTileData, TerrainEffect terrainEffect, EffectPipelineStateHandle pipelineStateHandle, TerrainPatchIndexBufferCache indexBufferCache) { const int numTilesPerPatch = TerrainComponent.PatchSize - 1; var numPatchesX = heightMap.Width / numTilesPerPatch; if (heightMap.Width % numTilesPerPatch != 0) { numPatchesX += 1; } var numPatchesY = heightMap.Height / numTilesPerPatch; if (heightMap.Height % numTilesPerPatch != 0) { numPatchesY += 1; } for (var y = 0; y < numPatchesY; y++) { for (var x = 0; x < numPatchesX; x++) { var patchX = x * numTilesPerPatch; var patchY = y * numTilesPerPatch; var patchBounds = new Int32Rect { X = patchX, Y = patchY, Width = Math.Min(TerrainComponent.PatchSize, heightMap.Width - patchX), Height = Math.Min(TerrainComponent.PatchSize, heightMap.Height - patchY) }; terrainEntity.Components.Add(CreatePatch( terrainEffect, pipelineStateHandle, heightMap, blendTileData, patchBounds, graphicsDevice, uploadBatch, indexBufferCache)); } } }
private List <TerrainPatch> CreatePatches( GraphicsDevice graphicsDevice, HeightMap heightMap, BlendTileData blendTileData, TerrainMaterial terrainMaterial, TerrainPatchIndexBufferCache indexBufferCache) { const int numTilesPerPatch = Terrain.Terrain.PatchSize - 1; var heightMapWidthMinusOne = heightMap.Width - 1; var numPatchesX = heightMapWidthMinusOne / numTilesPerPatch; if (heightMapWidthMinusOne % numTilesPerPatch != 0) { numPatchesX += 1; } var heightMapHeightMinusOne = heightMap.Height - 1; var numPatchesY = heightMapHeightMinusOne / numTilesPerPatch; if (heightMapHeightMinusOne % numTilesPerPatch != 0) { numPatchesY += 1; } var patches = new List <TerrainPatch>(); for (var y = 0; y < numPatchesY; y++) { for (var x = 0; x < numPatchesX; x++) { var patchX = x * numTilesPerPatch; var patchY = y * numTilesPerPatch; var patchBounds = new Rectangle( patchX, patchY, Math.Min(Terrain.Terrain.PatchSize, heightMap.Width - patchX), Math.Min(Terrain.Terrain.PatchSize, heightMap.Height - patchY)); patches.Add(CreatePatch( terrainMaterial, heightMap, blendTileData, patchBounds, graphicsDevice, indexBufferCache)); } } return(patches); }
public void Create() { this.nameIDs = new Dictionary <string, int>(); this.majorAssets = new Dictionary <string, MajorAsset>(); SubAsset.map = this; Asset.map = this; this.assetList = new AssetList(); this.AddMajorAsset((MajorAsset)this.assetList); this.AddMajorAsset((MajorAsset) new GlobalVersion()); this.heightMap = new HeightMapData(this.mapWidth, this.mapHeight, this.mapBorder); this.AddMajorAsset((MajorAsset)this.heightMap); this.mapWidth = this.heightMap.mapWidth; this.mapHeight = this.heightMap.mapHeight; this.mapBorder = this.heightMap.borderWidth; this.blendTile = new BlendTileData(this.mapWidth, this.mapHeight); this.AddMajorAsset((MajorAsset)this.blendTile); this.worldInfo = new WorldInfo(); this.AddMajorAsset((MajorAsset)this.worldInfo); this.mpPositionList = new MPPositionList(); this.AddMajorAsset((MajorAsset)this.mpPositionList); this.sidesList = new SidesList(); this.AddMajorAsset((MajorAsset)this.sidesList); this.AddMajorAsset((MajorAsset) new LibraryMapLists()); this.AddMajorAsset((MajorAsset) new Teams()); this.AddMajorAsset((MajorAsset) new PlayerScriptsList()); this.AddMajorAsset((MajorAsset) new BuildLists()); this.objectList = new ObjectsList(); this.AddMajorAsset((MajorAsset)this.objectList); /* * this.AddMajorAsset((MajorAsset)new TriggerAreas(this.game)); * this.AddMajorAsset((MajorAsset)new GlobalWaterSettings(this.game)); * this.AddMajorAsset((MajorAsset)new FogSettings(this.game)); * this.AddMajorAsset((MajorAsset)new MissionHotSpots(this.game)); * this.AddMajorAsset((MajorAsset)new MissionObjectives(this.game)); * this.AddMajorAsset((MajorAsset)new StandingWaterAreas(this.game)); * this.AddMajorAsset((MajorAsset)new RiverAreas(this.game)); * this.AddMajorAsset((MajorAsset)new StandingWaveAreas(this.game)); * this.AddMajorAsset((MajorAsset)new GlobalLighting(this.game)); * this.AddMajorAsset((MajorAsset)new PostEffectsChunk(this.game)); * this.AddMajorAsset((MajorAsset)new EnvironmentData(this.game)); * this.AddMajorAsset((MajorAsset)new NamedCameras(this.game)); * this.AddMajorAsset((MajorAsset)new CameraAnimationList(this.game)); * this.AddMajorAsset((MajorAsset)new WaypointsList(this.game)); */ }
public Navigation(BlendTileData tileData, HeightMap heightMap) { var width = tileData.Impassability.GetLength(0); var height = tileData.Impassability.GetLength(1); _graph = new Graph(width, height); for (var x = 0; x < _graph.Width; x++) { for (var y = 0; y < _graph.Height; y++) { var impassable = tileData.Impassability[x, y]; _graph.GetNode(x, y).Passability = impassable ? Passability.Impassable : Passability.Passable; } } _heightMap = heightMap; }
public void Create() { this.nameIDs = new Dictionary<string, int>(); this.majorAssets = new Dictionary<string, MajorAsset>(); SubAsset.map = this; Asset.map = this; this.assetList = new AssetList(); this.AddMajorAsset((MajorAsset)this.assetList); this.AddMajorAsset((MajorAsset)new GlobalVersion()); this.heightMap = new HeightMapData(this.mapWidth, this.mapHeight, this.mapBorder); this.AddMajorAsset((MajorAsset)this.heightMap); this.mapWidth = this.heightMap.mapWidth; this.mapHeight = this.heightMap.mapHeight; this.mapBorder = this.heightMap.borderWidth; this.blendTile = new BlendTileData(this.mapWidth, this.mapHeight); this.AddMajorAsset((MajorAsset)this.blendTile); this.worldInfo = new WorldInfo(); this.AddMajorAsset((MajorAsset)this.worldInfo); this.mpPositionList = new MPPositionList(); this.AddMajorAsset((MajorAsset)this.mpPositionList); this.sidesList = new SidesList(); this.AddMajorAsset((MajorAsset)this.sidesList); this.AddMajorAsset((MajorAsset)new LibraryMapLists()); this.AddMajorAsset((MajorAsset)new Teams()); this.AddMajorAsset((MajorAsset)new PlayerScriptsList()); this.AddMajorAsset((MajorAsset)new BuildLists()); this.objectList = new ObjectsList(); this.AddMajorAsset((MajorAsset)this.objectList); /* this.AddMajorAsset((MajorAsset)new TriggerAreas(this.game)); this.AddMajorAsset((MajorAsset)new GlobalWaterSettings(this.game)); this.AddMajorAsset((MajorAsset)new FogSettings(this.game)); this.AddMajorAsset((MajorAsset)new MissionHotSpots(this.game)); this.AddMajorAsset((MajorAsset)new MissionObjectives(this.game)); this.AddMajorAsset((MajorAsset)new StandingWaterAreas(this.game)); this.AddMajorAsset((MajorAsset)new RiverAreas(this.game)); this.AddMajorAsset((MajorAsset)new StandingWaveAreas(this.game)); this.AddMajorAsset((MajorAsset)new GlobalLighting(this.game)); this.AddMajorAsset((MajorAsset)new PostEffectsChunk(this.game)); this.AddMajorAsset((MajorAsset)new EnvironmentData(this.game)); this.AddMajorAsset((MajorAsset)new NamedCameras(this.game)); this.AddMajorAsset((MajorAsset)new CameraAnimationList(this.game)); this.AddMajorAsset((MajorAsset)new WaypointsList(this.game)); */ }