public void OnChange(TimeSpan diff) { bool inverted; if (CheckRequirements(out inverted) == false) { return; } var parameters = new TerrainChangeParameters() { Algorithm = ChangeAlgorithm, Center = EditManager.Instance.MousePosition, InnerRadius = EditManager.Instance.InnerRadius, OuterRadius = EditManager.Instance.OuterRadius, Method = ChangeType, TimeDiff = diff, Shading = ShadingMultiplier, Amount = Amount, Inverted = inverted, AlignModels = AlignModelsToGround }; WorldFrame.Instance.MapManager.OnEditTerrain(parameters); }
public override void OnUpdateModelPositions(TerrainChangeParameters parameters) { var center = new Vector2(parameters.Center.X, parameters.Center.Y); foreach(var inst in DoodadInstances) { if (inst == null || inst.RenderInstance == null) continue; var pos = mDoodadDefs[inst.MddfIndex].Position; var dist = (new Vector2(pos.X, pos.Z) - center).Length(); if (dist > parameters.OuterRadius) continue; if(WorldFrame.Instance.MapManager.GetLandHeight(pos.X, pos.Z, out pos.Y)) { mDoodadDefs[inst.MddfIndex].Position = pos; inst.RenderInstance.UpdatePosition(new Vector3(pos.X, pos.Z, pos.Y)); } } }
public void OnChange(TimeSpan diff) { bool inverted; if (CheckRequirements(out inverted) == false) return; var parameters = new TerrainChangeParameters() { Algorithm = ChangeAlgorithm, Center = EditManager.Instance.MousePosition, InnerRadius = EditManager.Instance.InnerRadius, OuterRadius = EditManager.Instance.OuterRadius, Method = ChangeType, TimeDiff = diff, Shading = ShadingMultiplier, Amount = Amount, Inverted = inverted, AlignModels = AlignModelsToGround }; WorldFrame.Instance.MapManager.OnEditTerrain(parameters); }
public override bool OnChangeTerrain(TerrainChangeParameters parameters) { var changed = false; foreach (var chunk in mChunks) { if (chunk == null) continue; if (chunk.OnTerrainChange(parameters)) changed = true; } if (changed) mWasChanged = true; return changed; }
protected override bool HandleMccvPaint(TerrainChangeParameters parameters) { var amount = (parameters.Amount / 75.0f) * (float)parameters.TimeDiff.TotalSeconds; var changed = false; var destColor = parameters.Shading; if (parameters.Inverted) { destColor.X = 2 - destColor.X; destColor.Y = 2 - destColor.Y; destColor.Z = 2 - destColor.Z; } var radius = parameters.OuterRadius; for (var i = 0; i < 145; ++i) { var p = Vertices[i].Position; var dist = (new Vector2(p.X, p.Y) - new Vector2(parameters.Center.X, parameters.Center.Y)).Length(); if (dist > radius) continue; HasMccv = true; changed = true; var factor = dist / radius; if (dist < parameters.InnerRadius) factor = 1.0f; var curColor = mShadingFloats[i]; var dr = destColor.X - curColor.Z; var dg = destColor.Y - curColor.Y; var db = destColor.Z - curColor.X; var cr = Math.Min(Math.Abs(dr), amount * factor); var cg = Math.Min(Math.Abs(dg), amount * factor); var cb = Math.Min(Math.Abs(db), amount * factor); if (dr < 0) { curColor.Z -= cr; if (curColor.Z < destColor.X) curColor.Z = destColor.X; } else { curColor.Z += cr; if (curColor.Z > destColor.X) curColor.Z = destColor.X; } if (dg < 0) { curColor.Y -= cg; if (curColor.Y < destColor.Y) curColor.Y = destColor.Y; } else { curColor.Y += cg; if (curColor.Y > destColor.Y) curColor.Y = destColor.Y; } if (db < 0) { curColor.X -= cb; if (curColor.X < destColor.Z) curColor.X = destColor.Z; } else { curColor.X += cb; if (curColor.X > destColor.Z) curColor.X = destColor.Z; } mShadingFloats[i] = curColor; curColor.X = Math.Min(Math.Max(curColor.X, 0), 2); curColor.Y = Math.Min(Math.Max(curColor.Y, 0), 2); curColor.Z = Math.Min(Math.Max(curColor.Z, 0), 2); var r = (byte)((curColor.Z / 2.0f) * 255.0f); var g = (byte)((curColor.Y / 2.0f) * 255.0f); var b = (byte)((curColor.X / 2.0f) * 255.0f); var a = (byte)((curColor.W / 2.0f) * 255.0f); var color = (uint)((a << 24) | (r << 16) | (g << 8) | b); Vertices[i].Color = color; } return changed; }
public override bool OnTerrainChange(TerrainChangeParameters parameters) { var changed = base.OnTerrainChange(parameters); if (changed) { MapArea parent; mParent.TryGetTarget(out parent); var omin = BoundingBox.Minimum; var omax = BoundingBox.Maximum; BoundingBox = new BoundingBox(new Vector3(omin.X, omin.Y, mMinHeight), new Vector3(omax.X, omax.Y, mMaxHeight)); if (parent != null) parent.UpdateBoundingBox(BoundingBox); } return changed; }