示例#1
0
        private void GenerateVertex(int l, Quaternion q, float u, int r)
        {
            float normalizedLoopIndex = CustomMethod.Interpolate(0f, 1f, 0, loopAmount - 1, l);
            float normalizedRingIndex = CustomMethod.Interpolate(0f, 1f, 0, RingAmountMultipliedByCircle() - 1, r);

            float currDepth  = Mathf.LerpUnclamped(0, ClampedOuterLoopDepth(), loopPositionRemap.Evaluate(normalizedLoopIndex));
            float addedDepth = Mathf.LerpUnclamped(0, maxLoopDepth, loopDepthPositionRemap.Evaluate(normalizedLoopIndex));

            float indexWidth = Mathf.InverseLerp(0, ClampedOuterLoopDepth(), currDepth);

            float widthMultiplier = Mathf.Lerp(1, widthRemap.Evaluate(normalizedRingIndex), widthRemapInfluence);
            float currentWidth    = Mathf.LerpUnclamped(minRadius, Mathf.LerpUnclamped(minRadius, maxRadius, widthMultiplier), loopHeightPositionRemap.Evaluate(indexWidth));

            float currentTwist = Mathf.LerpUnclamped(0, twist, normalizedLoopIndex);

            Quaternion twistRot = Quaternion.AngleAxis(currentTwist, Vector3.back);

            Vector3 newVert = (q * twistRot) * (Vector3.up * currentWidth) + new Vector3(0, 0, currDepth + depthByU * u + addedDepth);

            float   maxOffset    = 0.5f;
            float   randomOffset = Random.Range(-maxOffset, maxOffset);
            Vector3 debugOffset  = new Vector3(0, 0, randomOffset);

            AddVertex(newVert);

            if (!invertUAndV)
            {
                uv.Add(new Vector2(u, normalizedLoopIndex));
            }

            else
            {
                uv.Add(new Vector2(normalizedLoopIndex, u));
            }
        }
示例#2
0
        public void UpdateColors(int width, int height)
        {
            colors = new List <Color>();
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    float normalizedX = CustomMethod.Interpolate(0f, 1f, 0f, width - 1, x);
                    float normalizedY = CustomMethod.Interpolate(1f, 0f, 0f, height - 1, y);

                    if (gradientTop != null && gradientBottom != null)
                    {
                        Color colX = gradientTop.Evaluate(normalizedX);
                        Color colY = gradientBottom.Evaluate(normalizedX);

                        Color mixed = Color.Lerp(colX, colY, normalizedY);
                        if (twoDimensional)
                        {
                            colors.Add(mixed);
                        }
                        else
                        {
                            colors.Add(colX);
                        }
                    }
                }
            }
        }
示例#3
0
        private void AddMainVertices()
        {
            float angle = 360f / (RingAmountMultipliedByCircle() - 1);
            float mul   = arc / 360f;

            for (int l = 0; l < loopAmount; l++)
            {
                for (int r = 0; r < RingAmountMultipliedByCircle(); r++)
                {
                    float      curveRemapEvaluate = CustomMethod.Interpolate(0f, 1f, 0f, RingAmountMultipliedByCircle() - 1, r);
                    float      curveValue         = ringPositionRemap.Evaluate(curveRemapEvaluate);
                    float      u = CustomMethod.Interpolate(0, 1f, 0, RingAmountMultipliedByCircle() - 1, r);
                    Quaternion q = Quaternion.AngleAxis(spiralAmount * angle * (curveValue * (RingAmountMultipliedByCircle() - 1)) * mul, Vector3.back);
                    GenerateVertex(l, q, u, r);
                }
            }
        }