/// <summary> /// Create the main section of the road. EG the road /// </summary> /// <param name="rA">Start of road</param> /// <param name="rB">End of the road</param> /// <param name="texturePercent">The percentage of texture to use</param> /// <returns>The flip flag</returns> private bool AddMainRoadSection(RoadCrossSection rA, RoadCrossSection rB, List <int> triangles, float texturePercent) { bool flip = false; // TODO: ADD subdivde here: Debug.Log("_subDivide = "+ _subDivide); _roadObject.MeshUVs.Add(new Vector2(UVDATA.StraightStart, UVDATA.CurbRightLipInner)); _roadObject.MeshUVs.Add(new Vector2(UVDATA.StraightStart, UVDATA.CurbLeftLipInner)); _roadObject.MeshUVs.Add(new Vector2(UVDATA.StraightLength * texturePercent, UVDATA.CurbRightLipInner)); _roadObject.MeshUVs.Add(new Vector2(UVDATA.StraightLength * texturePercent, UVDATA.CurbLeftLipInner)); _roadObject.MeshVertices.Add(rA.Left); _roadObject.MeshVertices.Add(rA.Right); _roadObject.MeshVertices.Add(rB.Left); _roadObject.MeshVertices.Add(rB.Right); int v = _roadObject.MeshVertices.Count - 4; // now we can work out if we need to flip the normals Vector3 nA = MathsHelper.NormalTri( _roadObject.MeshVertices[v], _roadObject.MeshVertices[v + 1], _roadObject.MeshVertices[v + 2]); nA.Normalize(); Vector3 nB = MathsHelper.NormalTri( _roadObject.MeshVertices[v + 3], _roadObject.MeshVertices[v + 2], _roadObject.MeshVertices[v + 1]); nB.Normalize(); if (nA.y < 0 && nB.y < 0) { flip = true; } AddTriangles(flip, triangles); return(flip); }