/// <summary> /// Apply the terrain height /// </summary> /// <param name="tm">The terrain modifier</param> public void ApplyTerrain(TerrainModifier tm) { OutterInner outterInner = BuildArray(false, tm); for (int i = 0; i < _totalRoads; i++) { int rightRoad = i + 1; if (rightRoad > _totalRoads - 1) { rightRoad -= _totalRoads; } int leftRoad = i - 1; if (leftRoad < 0) { leftRoad += _totalRoads; } RectVector3 r; r = new RectVector3(outterInner.Inner[i].Left, outterInner.Outter[i].Left, outterInner.Inner[i].Right, outterInner.Outter[i].Right); tm.ApplyToTerrain(r, true); r = new RectVector3(outterInner.Outter[i].CurbRightEnd, outterInner.Outter[i].Right, outterInner.Outter[rightRoad].CurbLeftEnd, outterInner.Inner[i].Right); tm.ApplyToTerrain(r, true); r = new RectVector3(outterInner.Outter[i].CurbLeftEnd, outterInner.Outter[i].Left, outterInner.Outter[leftRoad].CurbRightEnd, outterInner.Inner[i].Left); tm.ApplyToTerrain(r, true); r = new RectVector3(_roadNetworkNode.transform.position, _roadNetworkNode.transform.position, outterInner.Inner[i].Left, outterInner.Inner[i].Right); tm.ApplyToTerrain(r, true); } }
/// <summary> /// Modify the terrain for the Junction /// </summary> public void ApplyTerrain(TerrainModifier terrainModifier) { JunctionArray ja = BuildArray(false, terrainModifier); RectVector3 rect; rect = new RectVector3(ja.LeftSide[6], ja.LeftSide[7], ja.RightSide[6], ja.RightSide[7]); terrainModifier.ApplyToTerrain(rect, true); rect = new RectVector3(ja.LeftFarSide[5], ja.LeftFarSide[4], ja.LeftSide[6], ja.LeftSide[5]); terrainModifier.ApplyToTerrain(rect, true); rect = new RectVector3(ja.RightSide[6], ja.RightSide[5], ja.RightFarSide[5], ja.RightFarSide[4]); terrainModifier.ApplyToTerrain(rect, true); rect = new RectVector3(ja.RightSide[6], ja.RightFarSide[5], ja.LeftSide[6], ja.LeftFarSide[5]); terrainModifier.ApplyToTerrain(rect, true); // pavements rect = new RectVector3(ja.LeftSide[1], ja.LeftSide[4], ja.LeftSide[2], ja.LeftSide[3]); terrainModifier.ApplyToTerrain(rect, true); rect = new RectVector3(ja.RightSide[1], ja.RightSide[4], ja.RightSide[2], ja.RightSide[3]); terrainModifier.ApplyToTerrain(rect, true); rect = new RectVector3(ja.LeftFarSide[1], ja.LeftFarSide[2], ja.LeftFarSide[6], ja.LeftFarSide[3]); terrainModifier.ApplyToTerrain(rect, true); rect = new RectVector3(ja.RightFarSide[3], ja.RightFarSide[2], ja.RightFarSide[6], ja.RightFarSide[1]); terrainModifier.ApplyToTerrain(rect, true); rect = new RectVector3(ja.LeftFarSide[6], ja.LeftFarSide[3], ja.RightFarSide[6], ja.RightFarSide[3]); terrainModifier.ApplyToTerrain(rect, true); }
/// <summary> /// Apply the terrain height /// </summary> /// <param name="tm">The terrain modifier</param> public void ApplyTerrain(TerrainModifier tm) { CrossRoadsArray ja = BuildArray(false, tm); RectVector3 r; r = new RectVector3(ja.LeftSide[6], ja.LeftSide[7], ja.RightSide[6], ja.RightSide[7]); tm.ApplyToTerrain(r, true); if (UVDATA.JunctionAcrossUV) { // Main road section Left Vector3 posAMid = (ja.RightFarSide[5] + ja.LeftSide[5]) / 2; Vector3 posBMid = (ja.RightFarSide[6] + ja.LeftSide[6]) / 2; r = new RectVector3(posBMid, posAMid, ja.LeftSide[6], ja.LeftSide[5]); tm.ApplyToTerrain(r, true); r = new RectVector3(ja.RightFarSide[6], ja.RightFarSide[5], posBMid, posAMid); tm.ApplyToTerrain(r, true); } else { r = new RectVector3(ja.RightFarSide[6], ja.RightFarSide[5], ja.LeftSide[6], ja.LeftSide[5]); tm.ApplyToTerrain(r, true); } if (UVDATA.JunctionAcrossUV) { // Road section Right Vector3 posAMid = (ja.RightSide[5] + ja.LeftFarSide[5]) / 2; Vector3 posBMid = (ja.RightSide[6] + ja.LeftFarSide[6]) / 2; r = new RectVector3(ja.RightSide[6], ja.RightSide[5], posBMid, posAMid); tm.ApplyToTerrain(r, true); r = new RectVector3(posBMid, posAMid, ja.LeftFarSide[6], ja.LeftFarSide[5]); tm.ApplyToTerrain(r, true); } else { r = new RectVector3(ja.RightSide[6], ja.RightSide[5], ja.LeftFarSide[6], ja.LeftFarSide[5]); tm.ApplyToTerrain(r, true); } // Road section Middle r = new RectVector3(ja.LeftFarSide[6], ja.LeftFarSide[7], ja.RightFarSide[6], ja.RightFarSide[7]); tm.ApplyToTerrain(r, true); Vector3 posC = (ja.LeftFarSide[6] + ja.RightSide[6]) / 2; Vector3 posD = (ja.RightFarSide[6] + ja.LeftSide[6]) / 2; r = new RectVector3(posC, posD, ja.RightSide[6], ja.LeftSide[6]); tm.ApplyToTerrain(r, true); r = new RectVector3(ja.LeftFarSide[6], ja.RightFarSide[6], posC, posD); tm.ApplyToTerrain(r, true); // pavements r = new RectVector3(ja.LeftSide[1], ja.LeftSide[4], ja.LeftSide[2], ja.LeftSide[3]); tm.ApplyToTerrain(r, true); r = new RectVector3(ja.RightSide[1], ja.RightSide[4], ja.RightSide[2], ja.RightSide[3]); tm.ApplyToTerrain(r, true); r = new RectVector3(ja.LeftFarSide[1], ja.LeftFarSide[4], ja.LeftFarSide[2], ja.LeftFarSide[3]); tm.ApplyToTerrain(r, true); r = new RectVector3(ja.RightFarSide[1], ja.RightFarSide[4], ja.RightFarSide[2], ja.RightFarSide[3]); tm.ApplyToTerrain(r, true); }