private void SetValue(IReadOnlyList <IRippleData> source, RippleOptions dest) { if (source[0] == null) { dest.Clear(); FinalRippleCount = 0; return; } FinalRippleCount = 0; for (int i = 0; i < source.Count; i++) { IRippleData rippleInfo = source[i]; if (rippleInfo == null) { dest.Clear(i); } else { FinalRippleCount++; dest.SetTexture(rippleInfo.Texture, i); dest.Rect[i] = rippleInfo.Rect; dest.Position[i] = new Vector4(rippleInfo.Position.x, rippleInfo.Position.y, rippleInfo.Position.z, rippleInfo.Radian); dest.HeightScale[i] = rippleInfo.HeightScale; } } }
public RippleSystem(IRippleFilter rippleFilter) { observers = new List <IRippleData>(); FinalRipples = new IRippleData[RippleOptions.RippleCount]; FinalRippleOptions = new RippleOptions(); RippleFilter = rippleFilter; }
public static float GetRippleHeight(this RippleOptions data, Texture2D rippleTex, Vector3 worldPos, int index) { Vector2 uv = GetWorldRippleUV(new Vector2(worldPos.x, worldPos.z), new Vector2(data.Position[index].x, data.Position[index].z), data.Position[index].w, data.Rect[index]); if (UVClamp(uv)) { Color color = GetColorNormal(rippleTex, uv.x, uv.y); Vector4 heightScale = data.HeightScale[index]; float height = GetRippleHeight(color, heightScale); return(height); } return(0); }
public static float GetRippleHeight(Vector3 worldPos) { RippleOptions rippleOptions = RippleSystem.Current.FinalRippleOptions; float height = 0; for (int i = 0; i < RippleOptions.RippleCount; i++) { Texture tex = rippleOptions.GetTexture(i); if (tex != null) { Texture2D rippleTex = (Texture2D)tex; height += GetRippleHeight(rippleOptions, rippleTex, worldPos, i); } } return(height); }