public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { Vector3[] result = new Vector3[2]; // Vector3 vec1 = UtilScript.CloneVec3(linePos); // Vector3 vec2 = UtilScript.CloneVec3(linePos); float midX = 0; //((topX + bottomX)/2); float midZ = ((topZ + bottomZ) / 2f); // print("+"+topZ); // print(bottomZ); float xPos = linePos.x; float zPos = linePos.z; float hypot = Mathf.Sqrt(Mathf.Pow(xPos - midX, 2) + Mathf.Pow(zPos - midZ, 2)); float hypotAdjusted = hypot * waxLengthMod - counter; // Debug.Log("hypotAdjusted: " + hypotAdjusted); float height = UtilScript.Map(Mathf.Sin(hypotAdjusted), -1, 1, topY, bottomY); float waveHeight = height; //Mathf.Sin(hypotAdjusted) * bottomY;//topY * .75f; result[0] = new Vector3(xPos, waveHeight, zPos); result[1] = new Vector3(xPos, topY, zPos); return(result); }
// Update is called once per frame void Update() { float moveTime = Time.realtimeSinceStartup * speedMod; transform.position = new Vector3( UtilScript.Map(Mathf.PerlinNoise(moveTime, 0), 0, 1, -range, range), transform.position.y, UtilScript.Map(Mathf.PerlinNoise(0, moveTime), 0, 1, -range, range)); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { Vector3[] result = new Vector3[2]; float xPos = linePos.x; float zPos = linePos.z; // Debug.Log("hypotAdjusted: " + hypotAdjusted); float waveHeight = UtilScript.Map(Mathf.PerlinNoise(xPos / waxLengthMod + counter, zPos / waxLengthMod + counter), 0, 1, bottomY, topY); result[0] = new Vector3(xPos, waveHeight, zPos); result[1] = new Vector3(xPos, topY, zPos); if (!ceilingMounted) { result[1] = new Vector3(xPos, bottomY, zPos); } float range = topY - bottomY; float split = range / colors.Length; for (int i = 0; i < colors.Length - 1; i++) { float currentTop = bottomY + i * split * range; if (currentTop < waveHeight) { mat.SetColor("_Color1", colors[i]); mat.SetColor("_Color2", colors[i + 1]); mat.SetFloat("_LerpPer", (waveHeight - currentTop) / split); // mat = colors[colors.Length - i - 1]; } } // if(waveHeight > topY * .1f){ // mat = mat1; // } else if (waveHeight > bottomY * .1f){ // mat = mat2; // } else { // mat = mat3; // } return(result); }
// Update is called once per frame void Update() { float moveTime = Time.realtimeSinceStartup * speedMod; float perlin = Mathf.PerlinNoise(0, moveTime); float zPos = UtilScript.Map(perlin, 0, 1, -frontRanger, frontRanger); float lerpPer = (zPos + frontRanger) / (frontRanger * 2f); float xPos = Mathf.Lerp(frontX, backX, lerpPer); float yPos = perlin - 0.75f; transform.position = new Vector3( UtilScript.Map(Mathf.PerlinNoise(moveTime, 0), 0, 1, -xPos, xPos), yPos, zPos); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { Vector3[] result = new Vector3[2]; result[0] = UtilScript.CloneVec3(linePos); result[1] = UtilScript.CloneVec3(linePos); result[0].y += +10 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 100; result[1].y += -10 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 100; float col = UtilScript.Map(result[0].y, linePos.y - 100, linePos.y + 100, 0, 1); mat.color = new Color(col, 1 - col, 1, 1); return(result); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y = bottomY + 0.725f + Mathf.PerlinNoise(counter + linePos.x * 2, counter + linePos.z * 2) * 0.1f; vec2.y = vec1.y - 0.025f; result.Add(vec1); result.Add(vec2); float col = UtilScript.Map(vec1.y, linePos.y - 1, linePos.y + 1, 0, 1); // Debug.Log(col); mat.color = new Color(0.15f, 0.35f, 0.5f, 1); return(result.ToArray()); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y += 300 + 5 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 50; vec2.y += 300 - 5 + Mathf.Sin(counter + linePos.x / 300f + linePos.z / 300f) * 50; result.Add(vec1); result.Add(vec2); float col = UtilScript.Map(vec1.y, linePos.y - 100, linePos.y + 100, 0, 1); // Debug.Log(col); mat.color = new Color(0.3f, 0.75f, 1, 1); return(result.ToArray()); }
public override Vector3[] GenerateLine(int lineNum, Vector3 linePos, float topX, float bottomX, float topY, float bottomY, float topZ, float bottomZ) { List <Vector3> result = new List <Vector3>(); Vector3 vec1 = UtilScript.CloneVec3(linePos); Vector3 vec2 = UtilScript.CloneVec3(linePos); vec1.y += +0.1f + (Mathf.Sin(counter + linePos.x * 3) + Mathf.Sin(counter - linePos.z * -3)) * 0.11f; vec1.y += -0.1f + (Mathf.Sin(counter + linePos.x * 3) + Mathf.Sin(counter - linePos.z * -3)) * 0.11f; result.Add(vec1); result.Add(vec2); float col = UtilScript.Map(vec1.y, linePos.y - 1, linePos.y + 1, 0, 1); // Debug.Log(col); mat.color = new Color(col, 1 - col, 1, 1); return(result.ToArray()); }