예제 #1
0
        public void Generate(float startAngle, float angleSpan, float radius, float innerRadius, int segments, float outerdepth, float innerdepth)
        {
            mClosedSmooth = false;
            float maxDepth = Mathf.Max(innerdepth, outerdepth);

            Vector3[] path      = new Vector3[] { new Vector3(0f, radius, 0f), new Vector3(0f, innerRadius, 0f), new Vector3(outerdepth, innerRadius, 0f), new Vector3(innerdepth, radius, 0f) };
            float     midRadius = (innerRadius + radius) * 0.5f;
            Vector3   center    = new Vector3(maxDepth * 0.5f, midRadius);

            for (int j = 0; j < path.Length; j++)
            {
                path[j] -= center;
            }

            mSkipJoints.Clear();
            if (innerRadius <= 0.0001f)
            {
                mSkipJoints.Add(0);
                mSkipJoints.Add(3);
                mSkipJoints.Add(4);
            }

            OfPath(path);

            Vector3[] alongPath = new Vector3[segments + 1];
            float     toAngle   = startAngle + angleSpan;

            if (Mathf.Abs(startAngle - toAngle) < 0.0001f)
            {
                Generator(new Vector3[0], 0f, false);
                return;
            }

            int i = 0;

            mTmpScales.Clear();
            mTmpAngles.Clear();
            //  float dir = Mathf.Sign(angleSpan);
            //    float minSize = Mathf.Max(0f, 1f - JointSize);
            //startAngle = startAngle + dir * JointSize / midRadius;

/*            for (; i<JointSmoothing; i++)
 *          {
 *              float blend = 1f - (i / ((float)JointSmoothing));
 *              float angle = startAngle - ((JointSize / midRadius) * blend)* dir;
 *              alongPath[i] = ChartCommon.FromPolarRadians(angle, midRadius);
 *              mTmpAngles.Add(Quaternion.Euler(-90f, 0f, 0f) * Quaternion.Euler(0f, -angle * Mathf.Rad2Deg, 0f) * Quaternion.Euler(0f, 0f, 90f));
 *              mTmpScales.Add(1f);// Mathf.Lerp(0f,1f , quickBlend(blend )));
 *          }*/

            //  float toJoint = toAngle + dir * (JointSize / midRadius);
            //  int next = JointSmoothing + segments;

            for (i = 0; i <= segments; i++)
            {
                float blend = (i) / ((float)segments);
                float angle = Mathf.Lerp(startAngle, toAngle, blend);
                alongPath[i] = ChartCommon.FromPolarRadians(angle, midRadius);
                mTmpAngles.Add(Quaternion.Euler(-90f, 0f, 0f) * Quaternion.Euler(0f, -angle * Mathf.Rad2Deg, 0f) * Quaternion.Euler(0f, 0f, 90f));
                mTmpScales.Add(1f);
            }

            /*   for (i =0 ; i < JointSmoothing; i++)
             * {
             *     float blend = (i+1) / ((float)JointSmoothing);
             *     float angle = toAngle + ((JointSize / midRadius) * blend) * dir;
             *     alongPath[next+ 1 + i] = ChartCommon.FromPolarRadians(angle, midRadius);
             *     mTmpAngles.Add(Quaternion.Euler(-90f, 0f, 0f) * Quaternion.Euler(0f, -angle * Mathf.Rad2Deg, 0f) * Quaternion.Euler(0f, 0f, 90f));
             *     mTmpScales.Add(Mathf.Lerp(0f,1f, quickBlend(blend) ));
             * }*/

            Generator(alongPath, 0f, false);
        }