public void VertexChanged(XYInt num) { if (num.X > 0) { if (num.Y > 0) { TileChanged(new XYInt(num.X - 1, num.Y - 1)); } if (num.Y < Terrain.TileSize.Y) { TileChanged(new XYInt(num.X - 1, num.Y)); } } if (num.X < Terrain.TileSize.X) { if (num.Y > 0) { TileChanged(new XYInt(num.X, num.Y - 1)); } if (num.Y < Terrain.TileSize.Y) { TileChanged(num); } } }
public void WaterTriCorrection() { if (Tileset == null) { return; } var X = 0; var Y = 0; var TileNum = new XYInt(); for (Y = 0; Y <= Terrain.TileSize.Y - 1; Y++) { TileNum.Y = Y; for (X = 0; X <= Terrain.TileSize.X - 1; X++) { TileNum.X = X; if (Terrain.Tiles[X, Y].Tri) { if (Terrain.Tiles[X, Y].Texture.TextureNum >= 0) { if (Tileset.Tiles[Terrain.Tiles[X, Y].Texture.TextureNum].DefaultType == Constants.TileTypeNumWater) { Terrain.Tiles[X, Y].Tri = false; SectorGraphicsChanges.TileChanged(TileNum); SectorTerrainUndoChanges.TileChanged(TileNum); } } } } } }
public static bool PosIsWithinTileArea(XYInt worldHorizontal, XYInt startTile, XYInt finishTile) { return(worldHorizontal.X >= startTile.X * Constants.TerrainGridSpacing & worldHorizontal.Y >= startTile.Y * Constants.TerrainGridSpacing & worldHorizontal.X < finishTile.X * Constants.TerrainGridSpacing & worldHorizontal.Y < finishTile.Y * Constants.TerrainGridSpacing); }
public XYInt GetGetFootprintNew(int Rotation) { //get initial footprint XYInt result; switch (Type) { case UnitType.Feature: result = ((FeatureTypeBase)this).Footprint; break; case UnitType.PlayerStructure: result = ((StructureTypeBase)this).Footprint; break; default: //return droid footprint result = new XYInt(1, 1); return(result); } //switch footprint axes if not a droid var Remainder = Convert.ToDouble((Rotation / 90.0D + 0.5D) % 2.0D); if (Remainder < 0.0D) { Remainder += 2.0D; } if (Remainder >= 1.0D) { var X = result.X; result.X = result.Y; result.Y = X; } return(result); }
public Sector(XYInt NewPos) { Units = new ConnectedList <clsUnitSectorConnection, Sector>(this); Pos = NewPos; }
public MapViewControl(frmMain Owner) { owner = Owner; GLSize = new XYInt(0, 0); InitializeComponent(); listSelect = new ContextMenuStrip(); listSelect.ItemClicked += ListSelect_Click; listSelect.Closed += ListSelect_Close; UndoMessageTimer = new Timer(); UndoMessageTimer.Tick += RemoveUndoMessage; OpenGLControl = Program.OpenGL1; pnlDraw.Controls.Add(OpenGLControl); GLInitializeDelayTimer = new Timer(); GLInitializeDelayTimer.Interval = 50; GLInitializeDelayTimer.Tick += GLInitialize; GLInitializeDelayTimer.Enabled = true; tmrDraw = new Timer(); tmrDraw.Tick += tmrDraw_Tick; tmrDraw.Interval = 1; tmrDrawDelay = new Timer(); tmrDrawDelay.Tick += tmrDrawDelay_Tick; tmrDrawDelay.Interval = 30; UndoMessageTimer.Interval = 4000; }
public static XYInt PointGetClosestPosOnLine(XYInt linePointA, XYInt linePointB, XYInt point) { double x1dif = point.X - linePointA.X; double y1dif = point.Y - linePointA.Y; double adifx = linePointB.X - linePointA.X; double adify = linePointB.Y - linePointA.Y; double m = 0; m = adifx * adifx + adify * adify; if (m == 0.0D) { return(linePointA); } double ar = 0; ar = (x1dif * adifx + y1dif * adify) / m; if (ar <= 0.0D) { return(linePointA); } if (ar >= 1.0D) { return(linePointB); } var result = new XYInt(); result.X = linePointA.X + (adifx * ar).ToInt(); result.Y = linePointA.Y + (adify * ar).ToInt(); return(result); }
public clsTerrainUpdate(XYInt TileSize) { Vertices = new clsPointChanges(new XYInt(TileSize.X + 1, TileSize.Y + 1)); Tiles = new clsPointChanges(new XYInt(TileSize.X, TileSize.Y)); SidesH = new clsPointChanges(new XYInt(TileSize.X, TileSize.Y + 1)); SidesV = new clsPointChanges(new XYInt(TileSize.X + 1, TileSize.Y)); }
public FeatureTypeBase() { Footprint = new XYInt(0, 0); FeatureType_ObjectDataLink = new ConnectedListLink <FeatureTypeBase, clsObjectData>(this); Type = UnitType.Feature; }
public void Changed(XYInt Num) { if (!PointIsChanged[Num.X, Num.Y]) { PointIsChanged[Num.X, Num.Y] = true; ChangedPoints.Add(Num); } }
private XYZInt lndPos_From_MapPos(XYInt Horizontal) { return(new XYZInt( Horizontal.X - (map.Terrain.TileSize.X * Constants.TerrainGridSpacing / 2.0D).ToInt(), (map.Terrain.TileSize.Y * Constants.TerrainGridSpacing / 2.0D).ToInt() - Horizontal.Y, map.GetTerrainHeight(Horizontal).ToInt() )); }
public void SideVChanged(XYInt num) { if (num.X > 0) { TileChanged(new XYInt(num.X - 1, num.Y)); } if (num.X < Map.Terrain.TileSize.X) { TileChanged(num); } }
public void SideHChanged(XYInt num) { if (num.Y > 0) { TileChanged(new XYInt(num.X, num.Y - 1)); } if (num.Y < Map.Terrain.TileSize.Y) { TileChanged(num); } }
public void SetPositions(XYInt posA, XYInt posB) { var map = _ParentMapLink.Source; posA.X = MathUtil.ClampInt(posA.X, 0, map.Terrain.TileSize.X * Constants.TerrainGridSpacing - 1); posA.Y = MathUtil.ClampInt(posA.Y, 0, map.Terrain.TileSize.Y * Constants.TerrainGridSpacing - 1); posB.X = MathUtil.ClampInt(posB.X, 0, map.Terrain.TileSize.X * Constants.TerrainGridSpacing - 1); posB.Y = MathUtil.ClampInt(posB.Y, 0, map.Terrain.TileSize.Y * Constants.TerrainGridSpacing - 1); MathUtil.ReorderXY(posA, posB, ref _PosA, ref _PosB); }
private void ToolPerformSideV(XYInt SideNum) { Terrain = Map.Terrain; if (Terrain.SideV[SideNum.X, SideNum.Y].Road != null) { Terrain.SideV[SideNum.X, SideNum.Y].Road = null; Map.AutoTextureChanges.SideVChanged(SideNum); Map.SectorGraphicsChanges.SideVChanged(SideNum); Map.SectorTerrainUndoChanges.SideVChanged(SideNum); } }
public InterfaceOptions() { //set to default CompileName = ""; CompileMultiPlayers = 2.ToStringInvariant(); CompileMultiAuthor = ""; CompileMultiLicense = ""; AutoScrollLimits = true; ScrollMin = new XYInt(0, 0); ScrollMax.X = 0U; ScrollMax.Y = 0U; CampaignGameType = -1; CompileType = CompileType.Unspecified; }
private void SetScrollLimits(ref XYInt Min, ref sXY_uint Max) { Min.X = 0; Min.Y = 0; Max.X = (uint)Map.Terrain.TileSize.X; Max.Y = (uint)Map.Terrain.TileSize.Y; if (!cbxAutoScrollLimits.Checked) { IOUtil.InvariantParse(txtScrollMinX.Text, ref Min.X); IOUtil.InvariantParse(txtScrollMinY.Text, ref Min.Y); IOUtil.InvariantParse(txtScrollMaxX.Text, ref Max.X); IOUtil.InvariantParse(txtScrollMaxY.Text, ref Max.Y); } }
public void SetAllChanged() { var num = new XYInt(0, 0); for (var y = 0; y <= PointIsChanged.GetUpperBound(1); y++) { num.Y = y; for (var x = 0; x <= PointIsChanged.GetUpperBound(0); x++) { num.X = x; Changed(num); } } }
public static sIntersectPos GetLinesIntersectBetween(XYInt a1, XYInt a2, XYInt b1, XYInt b2) { var result = new sIntersectPos(); if ((a1.X == a2.X & a1.Y == a2.Y) || (b1.X == b2.X & b1.Y == b2.Y)) { result.Exists = false; } else { double y1dif = 0; double x1dif = 0; double adifx = 0; double adify = 0; double bdifx = 0; double bdify = 0; double m = 0; double ar = 0; double br = 0; y1dif = b1.Y - a1.Y; x1dif = b1.X - a1.X; adifx = a2.X - a1.X; adify = a2.Y - a1.Y; bdifx = b2.X - b1.X; bdify = b2.Y - b1.Y; m = adifx * bdify - adify * bdifx; if (m == 0.0D) { result.Exists = false; } else { ar = (x1dif * bdify - y1dif * bdifx) / m; br = (x1dif * adify - y1dif * adifx) / m; if (ar <= 0.0D | ar >= 1.0D | br <= 0.0D | br >= 1.0D) { result.Exists = false; } else { result.Pos.X = a1.X + (ar * adifx).ToInt(); result.Pos.Y = a1.Y + (ar * adify).ToInt(); result.Exists = true; } } } return(result); }
public static XYInt GetTileRotatedOffset(TileOrientation tileOrientation, XYInt pos) { var result = new XYInt(); if (tileOrientation.SwitchedAxes) { if (tileOrientation.ResultXFlip) { result.X = Constants.TerrainGridSpacing - pos.Y; } else { result.X = pos.Y; } if (tileOrientation.ResultYFlip) { result.Y = Constants.TerrainGridSpacing - pos.X; } else { result.Y = pos.X; } } else { if (tileOrientation.ResultXFlip) { result.X = Constants.TerrainGridSpacing - pos.X; } else { result.X = pos.X; } if (tileOrientation.ResultYFlip) { result.Y = Constants.TerrainGridSpacing - pos.Y; } else { result.Y = pos.Y; } } return(result); }
public static XYInt GetRotatedPos(TileOrientation orientation, XYInt pos, XYInt limits) { var result = new XYInt(); if (orientation.SwitchedAxes) { if (orientation.ResultXFlip) { result.X = limits.Y - pos.Y; } else { result.X = pos.Y; } if (orientation.ResultYFlip) { result.Y = limits.X - pos.X; } else { result.Y = pos.X; } } else { if (orientation.ResultXFlip) { result.X = limits.X - pos.X; } else { result.X = pos.X; } if (orientation.ResultYFlip) { result.Y = limits.Y - pos.Y; } else { result.Y = pos.Y; } } return(result); }
public void ActionPerform() { var map = Unit.MapLink.Source; var vertexPos = new XYInt(); var x = 0; var y = 0; double total = 0; var footprint = Unit.TypeBase.GetGetFootprintSelected(Unit.Rotation); var start = new XYInt(); var finish = new XYInt(); var samples = 0; map.GetFootprintTileRangeClamped(Unit.Pos.Horizontal, footprint, ref start, ref finish); for (y = start.Y; y <= finish.Y + 1; y++) { vertexPos.Y = y; for (x = start.X; x <= finish.X + 1; x++) { vertexPos.X = x; total += map.Terrain.Vertices[vertexPos.X, vertexPos.Y].Height; samples++; } } if (samples >= 1) { var average = (byte)(MathUtil.ClampInt((total / samples).ToInt(), Byte.MinValue, Byte.MaxValue)); for (y = start.Y; y <= finish.Y + 1; y++) { vertexPos.Y = y; for (x = start.X; x <= finish.X + 1; x++) { vertexPos.X = x; map.Terrain.Vertices[vertexPos.X, vertexPos.Y].Height = average; map.SectorGraphicsChanges.VertexAndNormalsChanged(vertexPos); map.SectorUnitHeightsChanges.VertexChanged(vertexPos); map.SectorTerrainUndoChanges.VertexChanged(vertexPos); } } } }
public clsTerrain(XYInt newSize) { TileSize = newSize; Vertices = new Vertex[TileSize.X + 1, TileSize.Y + 1]; Tiles = new Tile[TileSize.X, TileSize.Y]; SideH = new Side[TileSize.X, TileSize.Y + 1]; SideV = new Side[TileSize.X + 1, TileSize.Y]; var X = 0; var Y = 0; for (Y = 0; Y <= TileSize.Y - 1; Y++) { for (X = 0; X <= TileSize.X - 1; X++) { Tiles[X, Y].Texture.TextureNum = -1; Tiles[X, Y].DownSide = TileUtil.None; } } }
public static void ReorderXY(XYInt a, XYInt b, ref XYInt lesser, ref XYInt greater) { if (a.X <= b.X) { lesser.X = a.X; greater.X = b.X; } else { lesser.X = b.X; greater.X = a.X; } if (a.Y <= b.Y) { lesser.Y = a.Y; greater.Y = b.Y; } else { lesser.Y = b.Y; greater.Y = a.Y; } }
public TextureViewControl(frmMain owner) { this.owner = owner; TextureCount = new XYInt(0, 0); GLSize = new XYInt(0, 0); InitializeComponent(); OpenGLControl = Program.OpenGL2; pnlDraw.Controls.Add(OpenGLControl); GLInitializeDelayTimer = new Timer(); GLInitializeDelayTimer.Interval = 50; GLInitializeDelayTimer.Tick += GLInitialize; GLInitializeDelayTimer.Enabled = true; tmrDraw = new Timer(); tmrDraw.Tick += tmrDraw_Tick; tmrDraw.Interval = 1; tmrDrawDelay = new Timer(); tmrDrawDelay.Tick += tmrDrawDelay_Tick; tmrDrawDelay.Interval = 30; }
public clsPointChanges(XYInt PointSize) { PointIsChanged = new bool[PointSize.X, PointSize.Y]; ChangedPoints.Clear(); }
public override void TileChanged(XYInt num) { var SectorNum = Map.GetTileSectorNum(num); Changed(SectorNum); }
public override void TileChanged(XYInt num) { Changed(num); }
private void PerformAction(clsAction action, sPosNum posNum, XYInt lastValidNum) { var y = 0; if (action.Map == null) { Debugger.Break(); return; } var centre = GetPosNum(posNum); action.Effect = 1.0D; for (y = MathUtil.ClampInt(Tiles.YMin + centre.Y, 0, lastValidNum.Y) - centre.Y; y <= MathUtil.ClampInt(Tiles.YMax + centre.Y, 0, lastValidNum.Y) - centre.Y; y++) { action.PosNum.Y = centre.Y + y; var xNum = y - Tiles.YMin; var x = 0; for (x = MathUtil.ClampInt(Tiles.XMin[xNum] + centre.X, 0, lastValidNum.X) - centre.X; x <= MathUtil.ClampInt(Convert.ToInt32(Tiles.XMax[xNum] + centre.X), 0, lastValidNum.X) - centre.X; x++) { action.PosNum.X = centre.X + x; if (action.UseEffect) { if (Tiles.ResultRadius > 0.0D) { switch (shape) { case ShapeType.Circle: if (alignment) { action.Effect = Convert.ToDouble(1.0D - (new XYDouble(action.PosNum.X, action.PosNum.Y) - new XYDouble(centre.X - 0.5D, centre.Y - 0.5D)).GetMagnitude() / (Tiles.ResultRadius + 0.5D)); } else { action.Effect = Convert.ToDouble(1.0D - (centre - action.PosNum).ToDoubles().GetMagnitude() / (Tiles.ResultRadius + 0.5D)); } break; case ShapeType.Square: if (alignment) { action.Effect = 1.0D - Math.Max(Math.Abs(action.PosNum.X - (centre.X - 0.5D)), Math.Abs(action.PosNum.Y - (centre.Y - 0.5D))) / (Tiles.ResultRadius + 0.5D); } else { action.Effect = 1.0D - Math.Max(Math.Abs(action.PosNum.X - centre.X), Math.Abs(action.PosNum.Y - centre.Y)) / (Tiles.ResultRadius + 0.5D); } break; } } } action.ActionPerform(); } } }
public override void ActionPerform() { if (!Started) { Debugger.Break(); return; } var Unit = default(Unit); var Sector = Map.Sectors[PosNum.X, PosNum.Y]; var DrawUnitLabel = default(bool); var ViewInfo = Map.ViewInfo; var MouseOverTerrain = ViewInfo.GetMouseOverTerrain(); var TextLabel = default(clsTextLabel); var XYZ_dbl = default(XYZDouble); var XYZ_dbl2 = default(XYZDouble); var ScreenPos = new XYInt(); var Connection = default(clsUnitSectorConnection); foreach (var tempLoopVar_Connection in Sector.Units) { Connection = tempLoopVar_Connection; Unit = Connection.Unit; if (!UnitDrawn[Unit.MapLink.ArrayPosition]) { UnitDrawn[Unit.MapLink.ArrayPosition] = true; XYZ_dbl.X = Unit.Pos.Horizontal.X - ViewInfo.ViewPos.X; XYZ_dbl.Y = Unit.Pos.Altitude - ViewInfo.ViewPos.Y; XYZ_dbl.Z = -Unit.Pos.Horizontal.Y - ViewInfo.ViewPos.Z; DrawUnitLabel = false; if (Unit.TypeBase.IsUnknown) { DrawUnitLabel = true; } else { GL.PushMatrix(); GL.Translate(XYZ_dbl.X, XYZ_dbl.Y, Convert.ToDouble(-XYZ_dbl.Z)); Unit.TypeBase.GLDraw(Unit.Rotation); GL.PopMatrix(); if (Unit.TypeBase.Type == UnitType.PlayerDroid) { if (((DroidDesign)Unit.TypeBase).AlwaysDrawTextLabel) { DrawUnitLabel = true; } } if (MouseOverTerrain != null) { if (MouseOverTerrain.Units.Count > 0) { if (MouseOverTerrain.Units[0] == Unit) { DrawUnitLabel = true; } } } } if (DrawUnitLabel && !UnitTextLabels.AtMaxCount()) { Matrix3DMath.VectorRotationByMatrix(ViewInfo.ViewAngleMatrixInverted, XYZ_dbl, ref XYZ_dbl2); if (ViewInfo.PosGetScreenXY(XYZ_dbl2, ref ScreenPos)) { if (ScreenPos.X >= 0 & ScreenPos.X <= ViewInfo.MapViewControl.GLSize.X & ScreenPos.Y >= 0 & ScreenPos.Y <= ViewInfo.MapViewControl.GLSize.Y) { TextLabel = new clsTextLabel(); TextLabel.TextFont = App.UnitLabelFont; TextLabel.SizeY = SettingsManager.Settings.FontSize; TextLabel.Colour.Red = 1.0F; TextLabel.Colour.Green = 1.0F; TextLabel.Colour.Blue = 1.0F; TextLabel.Colour.Alpha = 1.0F; TextLabel.Pos.X = ScreenPos.X + 32; TextLabel.Pos.Y = ScreenPos.Y; TextLabel.Text = Unit.TypeBase.GetDisplayTextCode(); UnitTextLabels.Add(TextLabel); } } } } } }