public void BuildMesh(PartType partType, AdjacencyMatrix adjMatrix, MeshBuilder meshBuilder, BlockBounds clipBounds) { var slopeBuilder = new SlopedMeshBuilder(meshBuilder); if (partType == PartType.OuterCorner) { BuildMeshCorner(slopeBuilder); } }
public void BuildMesh(PartType partType, AdjacencyMatrix adjMatrix, MeshBuilder meshBuilder, BlockBounds clipBounds) { if (PartType.BlockFront == partType) { meshBuilder.AddTriangleStrip( false, meshBuilder.VertAutoNormal(new Vector3(1, 1, 0), new Vector2(1, 1), true), meshBuilder.VertAutoNormal(new Vector3(1, 0, 0), new Vector2(1, 0), true), meshBuilder.VertAutoNormal(new Vector3(0, 1, 0), new Vector2(0, 1), true), meshBuilder.VertAutoNormal(new Vector3(0, 0, 0), new Vector2(0, 0), true));; } else if (PartType.BlockBack == partType) { meshBuilder.AddTriangleStrip( false, meshBuilder.VertAutoNormal(new Vector3(0, 1, 1), new Vector2(1, 1), true), meshBuilder.VertAutoNormal(new Vector3(0, 0, 1), new Vector2(1, 0), true), meshBuilder.VertAutoNormal(new Vector3(1, 1, 1), new Vector2(0, 1), true), meshBuilder.VertAutoNormal(new Vector3(1, 0, 1), new Vector2(0, 0), true)); } else if (PartType.BlockRight == partType) { meshBuilder.AddTriangleStrip( false, meshBuilder.VertAutoNormal(new Vector3(1, 1, 1), new Vector2(1, 1), true), meshBuilder.VertAutoNormal(new Vector3(1, 0, 1), new Vector2(1, 0), true), meshBuilder.VertAutoNormal(new Vector3(1, 1, 0), new Vector2(0, 1), true), meshBuilder.VertAutoNormal(new Vector3(1, 0, 0), new Vector2(0, 0), true)); } else if (PartType.BlockLeft == partType) { meshBuilder.AddTriangleStrip( false, meshBuilder.VertAutoNormal(new Vector3(0, 1, 0), new Vector2(1, 1), true), meshBuilder.VertAutoNormal(new Vector3(0, 0, 0), new Vector2(1, 0), true), meshBuilder.VertAutoNormal(new Vector3(0, 1, 1), new Vector2(0, 1), true), meshBuilder.VertAutoNormal(new Vector3(0, 0, 1), new Vector2(0, 0), true)); } else if (PartType.BlockTop == partType) { meshBuilder.AddTriangleStrip( false, meshBuilder.VertAutoNormal(new Vector3(1, 1, 1), new Vector2(1, 1), true), meshBuilder.VertAutoNormal(new Vector3(1, 1, 0), new Vector2(1, 0), true), meshBuilder.VertAutoNormal(new Vector3(0, 1, 1), new Vector2(0, 1), true), meshBuilder.VertAutoNormal(new Vector3(0, 1, 0), new Vector2(0, 0), true)); } else if (PartType.BlockBottom == partType) { meshBuilder.AddTriangleStrip( false, meshBuilder.VertAutoNormal(new Vector3(1, 0, 0), new Vector2(1, 1), true), meshBuilder.VertAutoNormal(new Vector3(1, 0, 1), new Vector2(1, 0), true), meshBuilder.VertAutoNormal(new Vector3(0, 0, 0), new Vector2(0, 1), true), meshBuilder.VertAutoNormal(new Vector3(0, 0, 1), new Vector2(0, 0), true)); } }
public bool IsRegionDirty(BlockBounds bounds) { foreach (var block in _updatedBlocks) { if (bounds.Contains(block)) { return(true); } } return(false); }
public void BuildMesh(PartType partType, AdjacencyMatrix adjMatrix, MeshBuilder meshBuilder, BlockBounds clipBounds) { SlopedMeshBuilder slopeBuilder = new SlopedMeshBuilder(meshBuilder); if (PartType.OuterEdgeFront == partType) { slopeBuilder.ConstructSlopedFront(slopeBuilder.GetOuterSlopePoints()); }else if (PartType.OuterEdgeLeft == partType) { Matrix4x4 mat = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(-1, 1, 1)); slopeBuilder.ConstructSlopedSide(false, mat, slopeBuilder.GetOuterSlopePoints()); }else if (PartType.OuterEdgeRight == partType) { Matrix4x4 mat = Matrix4x4.TRS(new Vector3(1, 0, 0), Quaternion.identity, new Vector3(1, 1, 1)); slopeBuilder.ConstructSlopedSide(true, mat, slopeBuilder.GetOuterSlopePoints()); } }
private MeshBlock ToMeshBlock(XmlMeshBlock xmlBlock, SplittedRegion splittedRegion, ref int count) { BlockBounds blockBounds = new BlockBounds(xmlBlock.Position, xmlBlock.Size); return new MeshBlock(xmlBlock.Id, xmlBlock.BlockType, blockBounds, splittedRegion, xmlBlock.Rotation, count += 1); }
public void BeforeNext(Matrix4x4 blockTransform, Vector3 translation, BlockBounds localClipBounds = null) { this.translation = translation; this.transform = blockTransform; this.localClippingBounds = localClipBounds; }
public void RegisterPlugin(Type type, int offset, int length){ plugins[type] = new BlockBounds(offset, length); }
public LevelMap(MiMapManager miMapManager, MiMapLevelConfig config) { MiMapManager = miMapManager; Config = config; Meta = new LevelMeta() { Id = config.LevelId, Name = string.IsNullOrEmpty(config.Label) ? config.LevelId : config.Label, MinZoom = config.MinZoom, MaxZoom = config.MaxZoom, TileSize = new Size(config.TileSize, config.TileSize), Size = new Size(), Bounds = new BlockBounds(new BlockPosition(0, 0), new BlockPosition(0, 0)), LastUpdate = DateTime.MinValue }; BlockBounds = new BlockBounds(new BlockPosition(0, 0), new BlockPosition(0, 0)); TilesDirectory = Path.Combine(MiMapManager.Config.TilesDirectory, config.LevelId); _metaPath = Path.Combine(TilesDirectory, "meta.json"); #if DEBUG if (Directory.Exists(TilesDirectory)) { try { Directory.Delete(TilesDirectory, true); } catch { } } #endif Directory.CreateDirectory(TilesDirectory); _layers = new MapLayer[config.Layers.Length + 1]; var baseLayer = new MapLayer(this, new MiMapLevelLayerConfig() { LayerId = "base", BlendMode = BlendMode.Normal, Default = config.Enabled, Enabled = config.Enabled, Label = config.Label, Renderer = config.Renderer }); baseLayer.OnTileUpdated += (s, e) => OnTileUpdated?.Invoke(s, e); var i = 0; _layers[i] = baseLayer; i++; foreach (var layer in config.Layers) { //Log.InfoFormat("Loading Overlay layer {0} {1}/{2}", layer, i, _layers.Length); var overlayerLayer = new MapLayer(this, layer); overlayerLayer.OnTileUpdated += (s, e) => OnTileUpdated?.Invoke(s, e); _layers[i] = overlayerLayer; i++; } _timer = new Timer(SaveLayers); }
private MeshBlock CreateTestMeshBlock(BlockBounds bounds, String id = "id") { return new MeshBlock(id, null, MeshBlock.TYPE_CUBOID, bounds, new BlockRotation(), 0); }