public MapBuffer(WorldMap map, string filename) { LoadRaw(filename); metersPerSample = WorldMap.metersPerTile / numSamples; this.map = map; dirty = false; }
/// <summary> /// This constructor builds an empty buffer /// </summary> /// <param name="size"></param> /// <param name="metersPerSample"></param> public MapBuffer(WorldMap map, int numSamples, int metersPerSample) { this.metersPerSample = metersPerSample; this.numSamples = numSamples; this.map = map; InitBuffer(); dirty = false; }
public MapTile(WorldMap map, CoordXZ tileCoord) { this.map = map; this.tileCoord = tileCoord; zone = null; this.dirty = false; properties = new MapProperties(this); }
/// <summary> /// This constructor is used when creating a new map. All tiles are null, since /// this is a blank world. /// </summary> /// <param name="map">the map</param> /// <param name="sectionCoord">the section coordinate of this object</param> public MapSection(WorldMap map, CoordXZ sectionCoord) { this.sectionCoord = sectionCoord; this.map = map; tileCoord = new CoordXZ(sectionCoord, map.TileSize); dirty = true; dirtyChildren = false; tiles = new MapTile[map.TilesPerSection, map.TilesPerSection]; }
/// <summary> /// Build a buffer from a region of an image, scaling the pixels to the right value range /// </summary> /// <param name="src"></param> /// <param name="metersPerSample"></param> /// <param name="sx"></param> /// <param name="sz"></param> /// <param name="size"></param> public MapBuffer(WorldMap map, Image src, int metersPerSample, int sx, int sz, float srcMinHeight, float srcMaxHeight, int size, float destMinHeight, float destMaxHeight) { Debug.Assert(src.Width >= (sx + size)); Debug.Assert(src.Height >= (sz + size)); Debug.Assert(src.BytesPerPixel == BytesPerSample); this.metersPerSample = metersPerSample; this.numSamples = size; this.map = map; InitBuffer(); CopyFromImageRescale(src, sx, sz, srcMinHeight, srcMaxHeight, size, destMinHeight, destMaxHeight); }
/// <summary> /// Build a buffer from a region of an image /// </summary> /// <param name="src"></param> /// <param name="metersPerSample"></param> /// <param name="sx"></param> /// <param name="sz"></param> /// <param name="size"></param> public MapBuffer(WorldMap map, Image src, int metersPerSample, int sx, int sz, int size) { Debug.Assert(src.Width >= (sx + size)); Debug.Assert(src.Height >= (sz + size)); Debug.Assert(src.BytesPerPixel == BytesPerSample); this.metersPerSample = metersPerSample; this.numSamples = size; this.map = map; InitBuffer(); CopyFromImage(src, sx, sz, size); }
public ValueMapLayer(WorldMap map, string layerName, int metersPerTile, int metersPerSample, float valueBase, float valueRange, uint defaultRawValue, uint maxRaw) : base(map, layerName, metersPerTile, metersPerSample) { Debug.Assert(defaultRawValue <= maxRaw); this.valueBase = valueBase; this.valueRange = valueRange; this.maxRaw = maxRaw; fmaxRaw = (float)maxRaw; // use the property so that defaultValue gets calculated automatically DefaultRawValue = defaultRawValue; }
public static MapLayer MapLayerFactory(WorldMap map, XmlReader r) { for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); if (r.Name == "Type") { LayerParser factory = layerParsers[r.Value]; if (factory != null) { return factory(map, r); } } } return null; }
public ColorMapLayer(WorldMap map, string layerName, int metersPerTile, int metersPerSample, ColorEx defaultColor) : base(map, layerName, metersPerTile, metersPerSample) { this.defaultColor = defaultColor; }
public MapLayer(WorldMap map, string layerName, int metersPerTile, int metersPerSample) { this.map = map; this.layerName = layerName; this.metersPerTile = metersPerTile; this.tileSize = metersPerTile * WorldMap.oneMeter; this.metersPerSample = metersPerSample; this.samplesPerTile = metersPerTile / metersPerSample; tiles = new Dictionary<CoordXZ, MapBuffer>(); properties = new MapProperties(this); }
protected abstract MapBuffer NewBuffer(WorldMap map, int numSamples, int metersPerSample);
protected abstract MapBuffer NewBuffer(WorldMap map, int numSamples, int metersPerSample);
public MapBufferARGB(WorldMap map, int numSamples, int metersPerSample) : base(map, numSamples, metersPerSample) { }
protected override MapBuffer NewBuffer(WorldMap map, int numSamples, int metersPerSample) { return new MapBufferARGB(map, numSamples, metersPerSample); }
public MapBufferARGB(WorldMap map, Image src, int metersPerSample, int sx, int sz, int size) : base(map, src, metersPerSample, sx, sz, size) { }
public MapBufferARGB(WorldMap map, string filename) : base(map, filename) { }
public MapBufferARGB(WorldMap map, int numSamples, int metersPerSample) : base(map, numSamples, metersPerSample) { }
public ValueMapLayer16(WorldMap map, string layerName, int metersPerTile, int metersPerSample, float valueBase, float valueRange, float defaultValue) : base(map, layerName, metersPerTile, metersPerSample, valueBase, valueRange, (uint)((( defaultValue - valueBase ) / valueRange)* ushort.MaxValue), ushort.MaxValue) { }
public MapBufferARGB(WorldMap map, Image src, int metersPerSample, int sx, int sz, int size) : base(map, src, metersPerSample, sx, sz, size) { }
protected static MapLayer ParseLayer(WorldMap map, XmlReader r) { string layerName = null; int metersPerTile = 0; int metersPerSample = 0; float red = 0; float green = 0; float blue = 0; float alpha = 0; // parse attributes for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read switch (r.Name) { case "Type": break; case "Name": layerName = r.Value; break; case "MetersPerTile": metersPerTile = int.Parse(r.Value); break; case "MetersPerSample": metersPerSample = int.Parse(r.Value); break; case "DefaultColorR": red = float.Parse(r.Value); break; case "DefaultColorG": green = float.Parse(r.Value); break; case "DefaultColorB": blue = float.Parse(r.Value); break; case "DefaultColorA": alpha = float.Parse(r.Value); break; } } r.MoveToElement(); //Moves the reader back to the element node. MapLayer layer = new ColorMapLayer(map, layerName, metersPerTile, metersPerSample, new ColorEx(alpha, red, green, blue)); if (!r.IsEmptyElement) { // now parse the sub-elements while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "Property": layer.Properties.ParseProperty(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } } return layer; }
public void LoadMap() { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Load Map"; dlg.DefaultExt = "mwm"; dlg.Filter = "Multiverse World Map files (*.mwm)|*.mwm|All files (*.*)|*.*"; dlg.RestoreDirectory = true; if (dlg.ShowDialog() == DialogResult.OK) { worldMap = new WorldMap(dlg.FileName); currentViewLayer = worldMap.GetLayer("heightfield"); gridOffset = worldMap.MinTile; imageGrid.WidthCells = worldMap.MaxTile.x - worldMap.MinTile.x + 1; imageGrid.HeightCells = worldMap.MaxTile.z - worldMap.MinTile.z + 1; imageGrid.Enabled = true; InitTreeView(); } } }
public MapBuffer32(WorldMap map, Image src, int metersPerSample, int sx, int sz, float srcMinHeight, float srcMaxHeight, int size, float destMinHeight, float destMaxHeight) : base(map, src, metersPerSample, sx, sz, srcMinHeight, srcMaxHeight, size, destMinHeight, destMaxHeight) { }
public MapBuffer32(WorldMap map, Image src, int metersPerSample, int sx, int sz, float srcMinHeight, float srcMaxHeight, int size, float destMinHeight, float destMaxHeight) : base(map, src, metersPerSample, sx, sz, srcMinHeight, srcMaxHeight, size, destMinHeight, destMaxHeight) { }
public MapBufferARGB(WorldMap map, string filename) : base(map, filename) { }
public MapSection(WorldMap map, CoordXZ sectionCoord, string worldPath) : this(map, sectionCoord) { FromXml(worldPath); }
protected override MapBuffer NewBuffer(WorldMap map, int numSamples, int metersPerSample) { return(new MapBufferARGB(map, numSamples, metersPerSample)); }
public ColorMapLayer(WorldMap map, string layerName, int metersPerTile, int metersPerSample, ColorEx defaultColor) : base(map, layerName, metersPerTile, metersPerSample) { this.defaultColor = defaultColor; }
private void newMapToolStripMenuItem_Click(object sender, EventArgs e) { using (NewMapDialog dlg = new NewMapDialog()) { DialogResult result; result = dlg.ShowDialog(); if (result != DialogResult.OK) { return; } int tw = (dlg.MapWidth + WorldMap.tileSize - 1) / WorldMap.tileSize; int th = (dlg.MapHeight + WorldMap.tileSize - 1) / WorldMap.tileSize; imageGrid.WidthCells = tw; imageGrid.HeightCells = th; imageGrid.Enabled = true; int tx, tz; if ((tw <= WorldMap.tilesPerSection) && (th <= WorldMap.tilesPerSection)) { // if the world fits in a single section, then center it in section 0,0 tx = (WorldMap.tilesPerSection - tw) / 2; tz = (WorldMap.tilesPerSection - th) / 2; } else { // if the world doesn't fit in a single section, then center on the origin tx = -tw / 2; tz = -th / 2; } CoordXZ minTile = new CoordXZ(tx, tz, WorldMap.tileSize); CoordXZ maxTile = new CoordXZ(tx + tw - 1, tz + th - 1, WorldMap.tileSize); worldMap = new WorldMap(dlg.MapName, minTile, maxTile, dlg.MinTerrainHeight, dlg.MaxTerrainHeight, dlg.DefaultTerrainHeight); currentViewLayer = worldMap.GetLayer("heightfield"); gridOffset = minTile; InitTreeView(); } }
protected static MapLayer ParseLayer(WorldMap map, XmlReader r) { string layerName = null; int metersPerTile = 0; int metersPerSample = 0; float red = 0; float green = 0; float blue = 0; float alpha = 0; // parse attributes for (int i = 0; i < r.AttributeCount; i++) { r.MoveToAttribute(i); // set the field in this object based on the element we just read switch (r.Name) { case "Type": break; case "Name": layerName = r.Value; break; case "MetersPerTile": metersPerTile = int.Parse(r.Value); break; case "MetersPerSample": metersPerSample = int.Parse(r.Value); break; case "DefaultColorR": red = float.Parse(r.Value); break; case "DefaultColorG": green = float.Parse(r.Value); break; case "DefaultColorB": blue = float.Parse(r.Value); break; case "DefaultColorA": alpha = float.Parse(r.Value); break; } } r.MoveToElement(); //Moves the reader back to the element node. MapLayer layer = new ColorMapLayer(map, layerName, metersPerTile, metersPerSample, new ColorEx(alpha, red, green, blue)); if (!r.IsEmptyElement) { // now parse the sub-elements while (r.Read()) { // look for the start of an element if (r.NodeType == XmlNodeType.Element) { // parse that element // save the name of the element string elementName = r.Name; switch (elementName) { case "Property": layer.Properties.ParseProperty(r); break; } } else if (r.NodeType == XmlNodeType.EndElement) { break; } } } return(layer); }