/// <summary> /// Creates geometry for river water surface with different start and end Y. /// </summary> void TriangulateRiverQuad(Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, float y1, float y2, float v, bool reversed, Vector3 indices) { v1.y = v2.y = y1; v3.y = v4.y = y2; Rivers.AddQuad(v1, v2, v3, v4); // Add UVs according to river orientation (used in water flow effect in river shader) if (reversed) { Rivers.AddQuadUV(1f, 0f, 0.8f - v, 0.6f - v); } else { Rivers.AddQuadUV(0f, 1f, v, v + 0.2f); } Rivers.AddQuadCellData(indices, weights1, weights2); }
private void TriangulateRiverQuad( Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, float y1, float y2, float v, bool reversed, Vector3 indices) { v1.y = v2.y = y1; v3.y = v4.y = y2; Rivers.AddQuad(v1, v2, v3, v4); if (reversed) { Rivers.AddQuadUV(1f, 0f, 0.8f - v, 0.6f - v); } else { Rivers.AddQuadUV(0f, 1f, v, v + 0.2f); // left to right, bottom to top. } Rivers.AddQuadCellData(indices, weights1, weights2); }
private void TriangulateWaterfallInWater( Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, float y1, float y2, float waterY, Vector3 indices) { v1.y = v2.y = y1; v3.y = v4.y = y2; v1 = HexMetrics.Perturb(v1); v2 = HexMetrics.Perturb(v2); v3 = HexMetrics.Perturb(v3); v4 = HexMetrics.Perturb(v4); var t = (waterY - y2) / (y1 - y2); v3 = Vector3.Lerp(v3, v1, t); v4 = Vector3.Lerp(v4, v2, t); Rivers.AddQuadUnperterbed(v1, v2, v3, v4); Rivers.AddQuadUV(0f, 1f, 0.8f, 1f); Rivers.AddQuadCellData(indices, weights1, weights2); }
/// <summary> /// Create geometry for a river than flows in a waterfall unto the water surface, /// parameter orientation is aligned with river, looking downstream, left & right start vertex, /// left and right end vertex, cell start height, cell end height and water (where waterfall ends) height. /// </summary> void TriangulateWaterfallInWater(Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, float y1, float y2, float waterY, Vector3 indices) { v1.y = v2.y = y1; v3.y = v4.y = y2; // Perturn vertices before interpolating // If we didnt do this and did it afterwards when creating the quad then we would loose // the results we will calculate with our interpolation bellow v1 = HexMetrics.Perturb(v1); v2 = HexMetrics.Perturb(v2); v3 = HexMetrics.Perturb(v3); v4 = HexMetrics.Perturb(v4); float t = (waterY - y2) / (y1 - y2); // calculate interpolator v3 = Vector3.Lerp(v3, v1, t); v4 = Vector3.Lerp(v4, v2, t); // Create unperturbed quad, we already perturbed the vertices Rivers.AddQuadUnperturbed(v1, v2, v3, v4); Rivers.AddQuadUV(0f, 1f, 0.8f, 1f); Rivers.AddQuadCellData(indices, weights1, weights2); }